Posts: 512
Threads: 121
Joined: Sep 2013
Код:
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;
}
Hi I would to ask if you someone know how to make a dialog getid.
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.
Posts: 512
Threads: 121
Joined: Sep 2013
Quote:
Originally Posted by DanishHaq
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; }
|
Hi dan it was nice seeing you. Thank you. Im gald you are trying to help me again.
Is it possible to show it by DIALOG_STYLE_LIST?
Posts: 512
Threads: 121
Joined: Sep 2013
28.10.2013, 16:54
(
Последний раз редактировалось gotwarzone; 28.10.2013 в 16:55.
Причина: Hi I would to ask if you someone know how to make a dialog getid. It will be like this for example. If I do "
)
Hi someone can help me with this? Thanks alot!
Quote:
Hi I would to ask if you someone know how to make a dialog getid.
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...
BUT in Dialog LIST BOX
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.
|
Posts: 512
Threads: 121
Joined: Sep 2013
Quote:
Originally Posted by Nero_3D
Just a little rewritten
pawn Код:
CMD:getid(playerid, params[]) { if(isnull(params)) { return SendClientMessage(playerid, 0xFF0000FF, "Usage: /getid [name/id]"); } new i = -1, tmp[512], name[MAX_PLAYER_NAME] ; while(++i < MAX_PLAYERS) { if(GetPlayerName(i, name, sizeof name) && (strfind(name, params, true) != -1)) { format(tmp, sizeof tmp, "%s\n%s (ID: %i)", tmp, name, i); } } if(tmp[0] == EOS) { return SendClientMessage(playerid, 0xFF0000FF, "There were no matches found."); } return ShowPlayerDialog(playerid, YOUR_DIALOG_ID, DIALOG_STYLE_LIST, "Players", tmp[1], "Goto", "Close"); }
pawn Код:
//OnDialogResponse case YOUR_DIALOG_ID: { if(response) { new Float: X, Float: Y, Float: Z, giveplayerid = strval(strfind(inputtext, "ID:", false) + 3) ; if(GetPlayerPos(giveplayerid, X, Y, Z)) { // player could have left meanwhile SetPlayerPos(playerid, X, Y, Z);
SetPlayerInterior(playerid, GetPlayerInterior(giveplayerid)); SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(giveplayerid)); } } }
|
Thanks man. Really great job! I see that it also targets the player interior and virtual world.
Anyway I got this warning
Код:
(5938) : error 035: argument type mismatch (argument 1)
this line
Код:
giveplayerid = strval(strfind(inputtext, "ID:", false) + 4);
And may I ask if you also fix when targeting a player part of name it should show the list of those who has this part of name?