SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 11/01/2019, 03:27 PM   #1
Kevinas100
Little Clucker
 
Join Date: Oct 2015
Posts: 27
Reputation: 7
Default GetPlayerMid

PHP Code:
stock GetPlayeridMid(name[]) //Boylett
{
    for (new 
0MAX_PLAYERSi++)
    {
        if (
IsPlayerConnected(i))
        {
            new 
gPlayerName[MAX_PLAYER_NAME];
            
GetPlayerName(igPlayerNameMAX_PLAYER_NAME);
            if(
strfind(gPlayerNamenametrue) != -1)
            {
                return 
i;
            }
       }
    }
    return 
INVALID_PLAYER_ID;

gives error undefined symbol GetPlayerMid, what gives?
PHP Code:
    GetPlayerName(targetnamesizeof(name));
    new 
tname GetPlayerMid(name); 
Kevinas100 is offline   Reply With Quote
Old 11/01/2019, 03:28 PM   #2
NoteND
Big Clucker
 
Join Date: May 2016
Posts: 93
Reputation: 0
Default Re: GetPlayerMid

Change

new tname = GetPlayerMid(name);

to

new tname = GetPlayeridMid(name);
NoteND is online now   Reply With Quote
Old 11/01/2019, 03:31 PM   #3
Kevinas100
Little Clucker
 
Join Date: Oct 2015
Posts: 27
Reputation: 7
Default Re: GetPlayerMid

Quote:
Originally Posted by NoteND View Post
Change

new tname = GetPlayerMid(name);

to

new tname = GetPlayeridMid(name);
omg I'm so stupid, thanks haha
Kevinas100 is offline   Reply With Quote
Old 11/01/2019, 03:43 PM   #4
NoteND
Big Clucker
 
Join Date: May 2016
Posts: 93
Reputation: 0
Default Re: GetPlayerMid

Quote:
Originally Posted by Kevinas100 View Post
omg I'm so stupid, thanks haha
happens to the best
NoteND is online now   Reply With Quote
Old 11/01/2019, 05:13 PM   #5
Pottus
Godfather
 
Pottus's Avatar
 
Join Date: Jun 2012
Posts: 5,248
Reputation: 1258
Default Re: GetPlayerMid

Code:
stock GetPlayeridMid(name[]) //Boylett 
{ 
    for (new i = 0; i < MAX_PLAYERS; i++) 
    { 
        if (IsPlayerConnected(i)) 
        { 
            new gPlayerName[MAX_PLAYER_NAME]; 
            GetPlayerName(i, gPlayerName, MAX_PLAYER_NAME); 
            if(strfind(gPlayerName, name, true) != -1) 
            { 
                return i; 
            } 
       } 
    } 
    return INVALID_PLAYER_ID; 
}
What a horrible function you are using here!

You can't use this with any reliability heck there isn't even any sanity checks at all to validate your input data.
Pottus is online now   Reply With Quote
Old 11/01/2019, 07:06 PM   #6
Y_Less
Beta Tester
 
Y_Less's Avatar
 
Join Date: Jun 2008
Location: 629 - git.io/Y
Posts: 15,518
Reputation: 3207
Default Re: GetPlayerMid

What are you trying to do? This can return so many false positives, and I've not seen anyone trying to get an ID from a name like this since sscanf came out 10 years ago...
Y_Less is online now   Reply With Quote
Old 11/01/2019, 07:23 PM   #7
Kevinas100
Little Clucker
 
Join Date: Oct 2015
Posts: 27
Reputation: 7
Default Re: GetPlayerMid

Quote:
Originally Posted by Y_Less View Post
What are you trying to do? This can return so many false positives, and I've not seen anyone trying to get an ID from a name like this since sscanf came out 10 years ago...
get half of a players name
Kevinas100 is offline   Reply With Quote
Old 11/01/2019, 07:53 PM   #8
codExpert
Little Clucker
 
Join Date: Jan 2019
Posts: 22
Reputation: 17
Default Re: GetPlayerMid

PHP Code:
uidFromName(userName[]){
    new 
userID;
    
sscanf(userName,"u",userID)
    return 
userID;


Last edited by codExpert; 12/01/2019 at 11:23 AM.
codExpert is online now   Reply With Quote
Old 11/01/2019, 08:21 PM   #9
Y_Less
Beta Tester
 
Y_Less's Avatar
 
Join Date: Jun 2008
Location: 629 - git.io/Y
Posts: 15,518
Reputation: 3207
Default Re: GetPlayerMid

That is not what that code does.
Y_Less is online now   Reply With Quote
Old 12/01/2019, 11:23 AM   #10
codExpert
Little Clucker
 
Join Date: Jan 2019
Posts: 22
Reputation: 17
Default Re: GetPlayerMid

fixed
codExpert is online now   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT. The time now is 09:12 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.