SA-MP Forums Archive
GetPlayerMid - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: GetPlayerMid (/showthread.php?tid=662778)



GetPlayerMid - Kevinas100 - 11.01.2019

PHP код:
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 код:
    GetPlayerName(targetnamesizeof(name));
    new 
tname GetPlayerMid(name); 



Re: GetPlayerMid - NoteND - 11.01.2019

Change

new tname = GetPlayerMid(name);

to

new tname = GetPlayeridMid(name);


Re: GetPlayerMid - Kevinas100 - 11.01.2019

Quote:
Originally Posted by NoteND
Посмотреть сообщение
Change

new tname = GetPlayerMid(name);

to

new tname = GetPlayeridMid(name);
omg I'm so stupid, thanks haha


Re: GetPlayerMid - NoteND - 11.01.2019

Quote:
Originally Posted by Kevinas100
Посмотреть сообщение
omg I'm so stupid, thanks haha
happens to the best


Re: GetPlayerMid - Pottus - 11.01.2019

Код:
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.


Re: GetPlayerMid - Kevinas100 - 11.01.2019

Quote:
Originally Posted by ******
Посмотреть сообщение
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


Re: GetPlayerMid - codExpert - 11.01.2019

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




Re: GetPlayerMid - codExpert - 12.01.2019

fixed