25.10.2013, 20:25
Код:
CMD:getid(playerid, params[]) { new name[24]; if(sscanf(params, "s[24]", name)) return SendClientMessage(playerid, 0xFF0000FF, "Usage: /getid [name/id]"); new Count = 0; new fstr[150]; for(new i = 0; i < MAX_PLAYERS; i++) //foreach would be the better option... { if(IsPlayerConnected(i)) { new playersname[24]; GetPlayerName(i, playersname, 24); if(strfind(name, playersname, true) != -1) { format(fstr, sizeof(fstr), "%s (ID: %i)", playersname, i); SendClientMessage(playerid, 0xFFFF00FF, fstr); Count++; continue; } } } if(Count == 0) return SendClientMessage(playerid, 0xFF0000FF, "There were no matches found."); format(fstr, sizeof(fstr), "There was a total of %i potential matches found.", Count); SendClientMessage(playerid, 0x00FF00FF, fstr); return 1; }
It will be like this for example.
If I do "/getid Jor" after I enter it should show in dialog list box with the list of names of Jor like
Jorge (4)
Jorosh (1)
Jorja (6)
Jorlol(34)
Then when I click any name in the dialog list box it should teleport me to that player position that I have chosen.