24.05.2014, 13:44
Try something like this:
ReturnUser( 14698 ) should return the player name of the user with the "unknown number" 14698. Also, if there's no player online with the ID 14698, it will return 0, so check for that:
pawn Код:
new UnknownID[MAX_PLAYERS];
public OnPlayerConnect(playerid)
{
UnknownID[playerid] = 14698;
//or random numbers:
UnknownID[playerid] = random(50000);
}
public OnPlayerText(playerid, text[])
{
new str[144];
format(str, sizeof (str), "Inconnu_%d: %s", UnknownID[playerid], text);
SendPlayerMessageToAll(playerid, str);
return 0;
}
ReturnUser(id)
{
new pid=-1, name[24];
for(new i; i < MAX_PLAYERS; i++)
{
if(UnknownID[i] == id)
{
pid = i;
break;
}
}
if(pid=-1) return 0;
GetPlayerName(pid, name, sizeof name);
return name;
}
pawn Код:
if(!ReturnUser(14698)) return SendClientMessage(playerid, -1, "There's no player online with that number.");