15.05.2014, 15:08
Probably this will help:
Have fun
pawn Код:
CMD:getid(playerid, params[])
{
new string[128], name[25];
if(sscanf(params, "s[25]", name))
{
format(string, sizeof (string), "[USAGE]: /getid (name).");
SendClientMessage(playerid, 0xFF0000FF, string);
return 1;
}
if(!IsPlayerConnected(GetPlayerIDFromName(name)))
{
format(string, sizeof (string), "[ERROR]: The player entered is unknown.");
SendClientMessage(playerid, 0xFF0000FF, string);
return 1;
}
format(string, sizeof (string), "%s's player id is %d.", PlayerName(GetPlayerIDFromName(name)), GetPlayerIDFromName(name));
SendClientMessage(playerid, 0xFFFFFFFF, string);
return 1;
}
stock GetPlayerIDFromName(playername[])
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
new playername2[MAX_PLAYER_NAME];
GetPlayerName(i, playername2, sizeof(playername2));
if(strcmp(playername2, playername, true, strlen(playername)) == 0)
{
return i;
}
}
}
return INVALID_PLAYER_ID;
}
stock PlayerName(playerid)
{
new pname[25];
GetPlayerName(playerid, pname, sizeof(pname));
return pname;
}