19.06.2013, 21:13
I made this one for you, enjoy! I did not try to compile this btw.
pawn Код:
stock GetPlayerIDFromName(input[])
{
/*
-1 = NO INPUT
-2 = NO PLAYER FOUND
-3 = MULTIPLE PLAYERS FOUND
*/
if(strlen(input) == 0) return -1;
new name[MAX_PLAYER_NAME+1], savedplayerid, matches;
for(new playerid = 0; playerid < MAX_PLAYERS; playerid++)
{
if(!IsPlayerConnected(playerid)) continue;
GetPlayerName(playerid,name,sizeof(name));
if(strfind(name,input,true) != -1)
{
matches++;
savedplayerid = playerid;
}
}
if(matches == 0) return -2;
else if(matches > 1) return -3;
return savedplayerid;
}