Dialog
#1

Hello,

I have a question for you all. How could I possible do something like this:

If a player types /bank, then it shows "Withdraw\nDeposit\nTransfer", then I did this:

pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++)
{
    if(IsPlayerConnected(i))
    {
        format(string, sizeof(string), "%s%s\n", string, GetName);
    }
}
ShowPlayerDialog(playerid, DIALOG_TRANSFER, DIALOG_STYLE_LIST, "Transfer", string, "Transfer", "");
How could it grab the ID from the dialog?

EG: If there was this:

player1
player2
player3
player10

If playerid's 4, 5, 6, 7, 8 and 9 aren't connected, and I wanted player10, which was id 10, how could I grab the ID?

Because it would usually be:

pawn Код:
case 0:
case 1:
case 2:
for the ID's, but that won't work in this case. Thanks!
Reply
#2

pawn Код:
format(string, sizeof(string), "%s%s(%d)\n", string, GetName,playerid);
this is to get playerid..

To get dialog id try to use switch(dialogid) somehow
Reply
#3

Edit: Wrong.
Reply
#4

Quote:
Originally Posted by Lajko1
Посмотреть сообщение
pawn Код:
format(string, sizeof(string), "%s%s(%d)\n", string, GetName,playerid);
this is to get playerid..

To get dialog id try to use switch(dialogid) somehow
You're not reading it right.

I know how to get the dialog ID, I don't need to display the playerid.

For instance, I press "player10", but there's only 4 people online, id 0, id 1, id 2, id, 10 - It will display all the players on the dialog, but it will think that it's playerid 4, due to it being listitem 4, is there a way to not do that?

Quote:
Originally Posted by iGetty
Посмотреть сообщение
Edit: Wrong.
Hmm?
Reply
#5

The easiest way is to store the ID in a global bar for each listitem slot. Something like below should do the work:

pawn Код:
// at the top
new gPlayerList[MAX_PLAYERS];

// when you use this:
new slot;

for(new i = 0; i < MAX_PLAYERS; i++)
{
    if(IsPlayerConnected(i))
    {
        format(string, sizeof(string), "%s%s\n", string, GetName);

        gPlayerList[slot] = i;
        slot ++;
    }
}

ShowPlayerDialog(playerid, DIALOG_TRANSFER, DIALOG_STYLE_LIST, "Transfer", string, "Transfer", "");

// on dialog resp
case DIALOG_TRANSFER:
{
    new pid = gPlayerList[listitem];
   
    SendClientMessage(pid, -1, "Transfer success!");
}
Reply
#6

I'll try that, thanks for the reply!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)