Why does this not work?
#1

pawn Код:
new Wallet[MAX_PLAYERS][24],Wallet2[MAX_PLAYERS][24],Wallet3[MAX_PLAYERS][24]
pawn Код:
new format1[256];
if(PlayerInfo[playerid][pAdmin]==0)
{
    format(Wallet[playerid],24,"Wallet1");
    format(Wallet3[playerid],24,"Wallet3");
}
if(PlayerInfo[playerid][pAdmin]==1)
{
    format(Wallet[playerid],24,"Wallet1");
    format(Wallet2[playerid],24,"Wallet2");
    format(Wallet3[playerid],24,"Wallet3");
}
format(format1,256,"%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n",Wallet[playerid],Wallet2[playerid],Wallet3[playerid]);
ShowPlayerDialog(playerid, DIALOG_P, DIALOG_STYLE_LIST,"Inventory:",format1,"Use","Close");
pawn Код:
case DIALOG_P:
{
     if(response)
     {
           if(!strcmp(inputtext, Wallet[playerid], true))
          {
               SendClientMessage(playerid,COLOR_WHITE2,"You Picked Wallet1");
          }
          if(!strcmp(inputtext, Wallet2[playerid], true))
         {
               SendClientMessage(playerid,COLOR_WHITE2,"You Picked Wallet2");
         }
         if(!strcmp(inputtext, Wallet3[playerid], true))
        {
               SendClientMessage(playerid,COLOR_WHITE2,"You Picked  Wallet3");
        }
     }
It works with admin = 1. Which wallet you pick, correct message you get.
If you are admin = 0. If you pick Wallet you get Wallet and Wallet2 message
If you pick Wallet3 you get wallet2 and wallet3 message. Any ideas?
Reply
#2

Try this:

pawn Код:
case DIALOG_P:
{
    if(response)
    {
        if(!strcmp(inputtext, Wallet[playerid], true))
        {
            SendClientMessage(playerid,COLOR_WHITE2,"You Picked Wallet1");
        }
        else if(!strcmp(inputtext, Wallet2[playerid], true))
        {
             SendClientMessage(playerid,COLOR_WHITE2,"You Picked Wallet2");
        }
        else if(!strcmp(inputtext, Wallet3[playerid], true))
        {
            SendClientMessage(playerid,COLOR_WHITE2,"You Picked  Wallet3");
        }
    }
Reply
#3

I would assign IDs instead of setting strings for each identifiable item.
Reply
#4

How can I do that? Since every player will have different list so i cant listitem 0++.

I tried this and now there is just one message but Wallet1 gives Wallet1 message, Wallet3 gives Wallet2 message.
Reply
#5

Quote:
Originally Posted by JohnTravis
Посмотреть сообщение
How can I do that? Since every player will have different list so i cant listitem 0++.

I tried this and now there is just one message but Wallet1 gives Wallet1 message, Wallet3 gives Wallet2 message.
It's an issue with strcmp. Since the Wallet2 variable is empty for non-admins, strcmp will assume that the strings match. Try this:

pawn Код:
case DIALOG_P:
{
    if(response)
    {
        if(!strcmp(inputtext, Wallet[playerid], true) && strlen(inputtext) == strlen(Wallet[playerid]))
        {
            SendClientMessage(playerid,COLOR_WHITE2,"You Picked Wallet1");
        }
        else if(!strcmp(inputtext, Wallet2[playerid], true) && strlen(inputtext) == strlen(Wallet2[playerid]))
        {
             SendClientMessage(playerid,COLOR_WHITE2,"You Picked Wallet2");
        }
        else if(!strcmp(inputtext, Wallet3[playerid], true) && strlen(inputtext) == strlen(Wallet3[playerid]))
        {
            SendClientMessage(playerid,COLOR_WHITE2,"You Picked  Wallet3");
        }
    }
Reply
#6

Can you explain what you want to do?
Reply
#7

Thank you very much, it works Rep++ to both of you. You have no idea how long I was trying to get this working for.
Reply
#8

First of all you try to show a list dialog, which won't return any proper string at "inputtext" at all. You have to get the list item ID (row) from the variable "listitem" from any list dialogs.

Second thing is you are doing like setting a string for each player each type of "wallet", wtf?
Why not just like wallet type 1 is like wallet type ID 0, wallet type 2 like wallet ID 1, etc.
Even, if you are in need of sub data (for example you have those wallets, and those have different kind of attributes), so you can create some kind of one more list, to store the sub attribute values. I hope you know what I am trying to explain to you.
Reply
#9

Quote:
Originally Posted by BigETI
Посмотреть сообщение
First of all you try to show a list dialog, which won't return any proper string at "inputtext" at all. You have to get the list item ID (row) from the variable "listitem" from any list dialogs
Actually, if the dialog is not an input dialog, the chosen item from the list will be stored in inputtext. It's clearly stated in the SA-MP scripting wiki and I'm using it for many scripts.

https://sampwiki.blast.hk/wiki/OnDialogResponse

Quote:
Originally Posted by wiki
inputtext[] The text entered into the input box by the player or the selected list item text.
Reply
#10

All good but I've got one problem. You can click on the Disguise (Crips) and it changes stuff for you and it becomes green since pUbrany becoms=1. And then when you click on the green one there is no response from the dialog, any idea why?

pawn Код:
if(PlayerInfo[playerid][pGang]==1)
{
     if(PlayerInfo[playerid][pUbrany]==0) { format(UbranieG[playerid],48,"Disguise (Crips)");
     if(PlayerInfo[playerid][pUbrany]==1) { format(UbranieG[playerid],48,"{00CC00}Disguise (Crips)");
}
format(format1[playerid],256,"%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n",Wallet[playerid],UbranieG[playerid]);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)