25.10.2013, 20:35
pawn Код:
CMD:getid(playerid, params[])
{
new id[24], count = 0, dstring[500], string[50];
if(sscanf(params, "s[24]", id)) return SendClientMessage(playerid, 0xFF0000FF, "Usage: /getid [name/id]"); // this can be used with name and ID, check sscanf usage
for(new i = 0; i < MAX_PLAYERS; i ++)
{
if(IsPlayerConnected(i))
{
new name[MAX_PLAYER_NAME];
GetPlayerName(i, name, sizeof(name));
if(strfind(id, name, true) != -1)
{
format(string, sizeof(string), "%s (ID: %i)\n", name, i);
strcat(dstring, string);
count ++;
}
}
}
if(count == 0) return ShowPlayerDialog(playerid, 2500, DIALOG_STYLE_MSGBOX, "No players found!", "Unfortunately, we couldn't find any players with the specification you gave us.", "OK", "");
new dialogtitle[50];
format(dialogtitle, sizeof(dialogtitle), "%i players were found", count);
ShowPlayerDialog(playerid, 2534, DIALOG_STYLE_LIST, dialogtitle, dstring, "Done", "");
return 1;
}