SA-MP Forums Archive
Get Player ID from name - 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: Get Player ID from name (/showthread.php?tid=458168)



Get Player ID from name - ScRipTeRi - 15.08.2013

FIXED


Re: Get Player ID from name - sKgaL - 15.08.2013

PHP код:
new name[MAX_PLAYER_NAME], targetid=-1// String who will store players name, targetid who will store the targetid.
for(new i=0,j=GetMaxPlayers();i<j;i++) // Loop players
if(IsPlayerConnected(i)) // If playerid connected
{
    
GetPlayerName(inamesizeof(name)); // Get ID's name
    
if(!strcmp(name,"Target_Name"// Checks if the Id's name is what we wanted.
    
{
        
targetid i// Defines targerid
        
break; //No need to contuine the loop.
    
}
}
if(
targetid==-1)return Player Not Found // If player not found, returns MSG for exmple. 



Re: Get Player ID from name - ScRipTeRi - 15.08.2013

i make it with my self but anyway thanks


Re : Get Player ID from name - Garwan50 - 15.08.2013

You can also use the function ReturnUser(string)