Action only works at ID 0.
# support-forum
i
Hi guys, good afternoon! All right with you? I'm doing a transfer action between nearby players, however, this only works when transferred to the connected ID 0. if(dialogid == 613) { new str[140], p2; if(response) { if(listitem == 0) { if(GetDistanceBetweenPlayers(playerid, p2) < 10) { format(str, sizeof(str), "{00FF7F}[MONEY]{FFFFFF} How much do you want to transfer to %s?", NameP(p2)); ShowPlayerDialog(playerid, 630, DIALOG_STYLE_INPUT, "MONEY", str, "Enviar", "Cancelar"); } else { } } } Could someone help me please?
f
Is it supposed to magically assign a value to
p2
? You declare it, but never assign anything to it.
g
declaring a int by default is 0, so 'GetDistanceBetweenPlayers(playerid, p2) ' will be like (ID, 0) u need to assign the another playerid to p2
as vince said >You declare it, but never assign anything to it.
i
I understand, I was in doubt why the use is in Dialog. In commands I use the sscanf function, but I didn't see how to define it in a Dialog.
Copy code
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
     if((newkeys == KEY_CTRL_BACK))
     {
           format(str, sizeof(str), "Money: \t\t {00FF7F}$%i{FFFFFF}", backMoney(playerid));
           ShowPlayerDialog(playerid, 613, DIALOG_STYLE_LIST, "Bag", str, "Send", "End");
     }
}
OnDialogResponse...
Copy code
if(dialogid == 613)
{
      new str[140], p2;

      if(response)
       {
            if(listitem == 0)
            {
                if(GetDistanceBetweenPlayers(playerid, p2) < 10)
                {
                    format(str, sizeof(str), "{00FF7F}[MONEY]{FFFFFF} How much do you want to transfer to %s?", NameP(p2));
                 ShowPlayerDialog(playerid, 630, DIALOG_STYLE_INPUT, "MONEY", str, "Enviar", "Cancelar");
                }
                else
                {
                }
            }
}
If I try to use a loop to identify nearby players, it returns my own ID. As if I had to define that my ID would not count in this loop. For example:
Copy code
for(new i; i < MAX_PLAYERS; i++) 
{
     if(GetDistanceBetweenPlayers(playerid, i) < 10)
     {
          format(str, sizeof(str), "{00FF7F}[MONEY]{FFFFFF} How much do you want to transfer to %s?", NameP(i));
          ShowPlayerDialog(playerid, 630, DIALOG_STYLE_INPUT, "Send Money", str, "Send", "End");
     }
}
g
dont use a loop
maybe u can use a global variable to set it in the command using sscanf
idk if u want to just set it to a unique player or everyone in the radius of it
i
The problem is that the use is made in a hotkey, if it were in command, I could use sscanf and then define the variable in a global one, for example:
Copy code
new playerTrade[MAX_PLAYERS];

new IDplayer;
if(sscanf(params, "i", IDplayer)) return SCM(playerid, -1,"{FF4500}Use: /command [id].");
playerTrade[IDplayer] = playerid;
And so use playerTrade[playerid] to characterize who used the command. The problem is that the OnDialogResponse callback doesn't have params[], and I don't know how I can work around it..
g
you could loop through nearby players and then make the player select them via a listitem in the dialog. Then you maybe can do what you want