Wanted List Dialog
#1

Hi, how do I know which is the player that I selected in dialog.

Код:
	if(strcmp(cmd, "/wanted2", true) == 0)
{
    new count, namestr[MAX_PLAYER_NAME];//64 is too much since the max length of a name is like ~20
    for(new i; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(PlayerData[i][pWantedLevel]!=0)
            {
                count++;
                GetPlayerName(i,namestr,MAX_PLAYER_NAME);
                if(!strlen(string))
                {
                    format(string,sizeof(string),"%s level: %d",namestr,PlayerData[i][pWantedLevel]);
                }
                else
                {
                    format(string,sizeof(string),"\n%s level: %d",namestr,PlayerData[i][pWantedLevel]);
                }
            }
        }
    }
    ShowPlayerDialog(playerid,500, DIALOG_STYLE_LIST, "Wanted List.",string,"Ok", "Cancel");
    if(count == 0)return SendClientMessage(playerid,0xFFFFFFFF,"There are no wanted Players");
    return 1;
}

Код:
		  				  if(dialogid == 500)
		        {
      		    if(!response)
            {
                return 1;
            }
              if(PlayerData[PlayerSelectedInDialog][pWantedLevel] > 0)
              {
       		 			   new Float:x, Float:y, Float:z;
			             GetPlayerPos(PlayerSelectedInDialog, x, y, z);
			             SetPlayerCheckpoint(playerid, x,y,z, 3.0);
			             return 1;
               }
		       }
Reply
#2

Up...
Reply
#3

Код:
ShowPlayerDialog(playerid,500, DIALOG_STYLE_LIST, "Wanted List.",string,"Ok", "Cancel");
Reply
#4

Quote:
Originally Posted by SmoW
Посмотреть сообщение
Код:
ShowPlayerDialog(playerid,500, DIALOG_STYLE_LIST, "Wanted List.",string,"Ok", "Cancel");
But how do I know which is the player whom I selected?
Reply
#5

https://sampwiki.blast.hk/wiki/OnDialogResponse
inputtext[] The text entered into the input box by the player or the selected list item text.

That means if line 3 "w3b Level: 10", listitem will be 2, and inputtext will be that <<

You should know what to do with the rest of it ..
Reply
#6

Quote:
Originally Posted by PrO.GameR
Посмотреть сообщение
https://sampwiki.blast.hk/wiki/OnDialogResponse
inputtext[] The text entered into the input box by the player or the selected list item text.

That means if line 3 "w3b Level: 10", listitem will be 2, and inputtext will be that <<

You should know what to do with the rest of it ..
I know I can do by inputtext, but I saw a server that select and put checkpoint on the suspect, without having to write in dialogue inputtext suspect ID (Sorry my englesh..)
Reply
#7

pawn Код:
if(strcmp(cmd, "/wanted2", true) == 0)
{
    string[0] = EOS; // clearing string array
    new namestr[MAX_PLAYER_NAME];//64 is too much since the max length of a name is like ~20
    for(new i, g = GetMaxPlayers(); i < g; i++)
        if(IsPlayerConnected(i))
        {
            if(PlayerData[i][pWantedLevel] != 0)
            {
                GetPlayerName(i,namestr,MAX_PLAYER_NAME);
                format(string,sizeof(string),"\n%s%s level: %d",string,namestr,PlayerData[i][pWantedLevel]);
            }
        }

    if(!string[0]) SendClientMessage(playerid,0xFFFFFFFF,"There are no wanted Players");
    else ShowPlayerDialog(playerid,500, DIALOG_STYLE_LIST, "Wanted List.",string,"Ok", "Cancel");

    return 1;
}

if(dialogid == 500)
{
    if(!response) return 1;

    new pos = strfind(inputtext," ",true);
    if(pos != -1)
    {
        inputtext[pos] = EOS;
        new giveplayerid;
        //giveplayerid = GetPlayerIdFromName(inputtext); you need add/find this function if there is no sscanf in your gamemode
        sscanf(inputtext,"u",giveplayerid);
        if(giveplayerid != INVALID_PLAYER_ID)
        {
            if(PlayerData[giveplayerid][pWantedLevel] > 0)
            {
                new Float:x, Float:y, Float:z;
                GetPlayerPos(giveplayerid, x, y, z);
                SetPlayerCheckpoint(playerid, x, y, z, 3.0);
            }
        }
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)