19.10.2015, 15:29
Just made this for my script:
It returns the ID of the player who has the specified name, or INVALID_PLAYER_ID if player isn't found. The given name must match 100%.
Take this one too:
Returns the name of the player with the specified ID, if us is set to true it'll remove the underscores.
PHP Code:
GetPlayerID(givenname[])
{
new name[MAX_PLAYER_NAME];
for(new x = 0, t = GetPlayerPoolSize(); x <= t; x++)
{
if(IsPlayerConnected(x))
{
GetPlayerName(x, name, MAX_PLAYER_NAME);
if(!strcmp(givenname, name, false)) return x;
}
}
return INVALID_PLAYER_ID;
}
Take this one too:
PHP Code:
GetName(playerid, bool:us=false)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
if(us)
{
for(new i = 0; i < MAX_PLAYER_NAME; i++)
{
if(name[i] == '_') name[i] = ' ';
}
}
return name;
}