getid dialog -
gotwarzone - 25.10.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.
Re: getid dialog -
DanishHaq - 25.10.2013
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;
}
Re: getid dialog -
gotwarzone - 25.10.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?
Re: getid dialog -
gotwarzone - 28.10.2013
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.
|
Re: getid dialog -
-Prodigy- - 28.10.2013
pawn Код:
new gDialogPos[MAX_PLAYERS] = {-1, ...};
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[512];//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%s (ID: %i)\n", fstr, playersname, i);
//SendClientMessage(playerid, 0xFFFF00FF, fstr);
gDialogPos[Count] = i;
Count++;
//continue;
}
}
}
if(Count == 0) SendClientMessage(playerid, 0xFF0000FF, "There were no matches found.");
else
{
new str[128];
format(str, sizeof(str), "There was a total of %i potential matches found.", Count);
SendClientMessage(playerid, 0x00FF00FF, str);
ShowPlayerDialog(playerid, YOUR_DIALOG_ID, DIALOG_STYLE_LIST, "Players", fstr, "Goto", "Close");
}
return 1;
}
//On Dialog Response
switch(dialogid)
{
case YOUR_DIALOG_ID:
{
if(response)
{
new pID = gDialogPos[listitem], Float: pos[3];
GetPlayerPos(pID, pos[0], pos[1], pos[2]);
SetPlayerPos(playerid, pos[0], pos[1], pos[2]);
}
}
}
Try that.
Edit: Check the new code to be able to teleport to that player
Re: getid dialog -
kbalor - 28.10.2013
Quote:
Originally Posted by -Prodigy-
pawn Код:
new gDialogPos[MAX_PLAYERS] = {-1, ...};
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[512];//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%s (ID: %i)\n", fstr, playersname, i); //SendClientMessage(playerid, 0xFFFF00FF, fstr);
gDialogPos[Count] = i;
Count++; //continue; } } }
if(Count == 0) SendClientMessage(playerid, 0xFF0000FF, "There were no matches found."); else { new str[128]; format(str, sizeof(str), "There was a total of %i potential matches found.", Count); SendClientMessage(playerid, 0x00FF00FF, str);
ShowPlayerDialog(playerid, YOUR_DIALOG_ID, DIALOG_STYLE_LIST, "Players", fstr, "Goto", "Close"); } return 1; }
//On Dialog Response switch(dialogid) { case YOUR_DIALOG_ID: { if(response) { new pID = gDialogPos[listitem], Float: pos[3]; GetPlayerPos(pID, pos[0], pos[1], pos[2]); SetPlayerPos(playerid, pos[0], pos[1], pos[2]); } } }
Try that.
Edit: Check the new code to be able to teleport to that player
|
Omggg man its working! But I don't why I do need to type the whole name? Is it possible to show dialog list even I type the first 3 letters of the player name or the part of name?
AW: Re: getid dialog -
Nero_3D - 28.10.2013
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(inputtext[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));
}
}
}
Re: AW: Re: getid dialog -
gotwarzone - 28.10.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?
AW: Re: AW: Re: getid dialog -
Nero_3D - 28.10.2013
Quote:
Originally Posted by gotwarzone
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?
|
It already should find all targets, the line should look like (also fixed in post above)
pawn Код:
giveplayerid = strval(inputtext[strfind(inputtext, "ID:", false) + 3])
Also dont quote huge blocks of code :S
Re: AW: Re: getid dialog -
-Prodigy- - 28.10.2013
Quote:
Originally Posted by Nero_3D
|
Nice! Never knew the string was stored in the inputtext