SA-MP Forums Archive
Help with dialog input - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Help with dialog input (/showthread.php?tid=325175)



Help with dialog input [+rep] - Smyle - 12.03.2012

Hi there, i have a dialog which asks to introduce the card PIN. The PIN is used to withdraw money. But when i type the right PIN, it says that the PIN is incorrect.

OnDialogResponse:

pawn Код:
}
        if (dialogid == DIALOG_PIN)
        {
            if(inputtext[0] == PlayerInfo[playerid][pPIN])
            {
                PinOk[playerid] = 1;
            }
            else
            {
                SendClientMessage(playerid, 0xFF0000FF, "PIN Incorect, mai incearca !");
            }

       
        }
/withdraw command:

pawn Код:
if(strcmp(cmd, "/withdraw", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(PlayerInfo[playerid][pCard] == 1)
            {
           
                if(PlayerInfo[playerid][pLocal] != 103)
                {
                   SendClientMessage(playerid, COLOR_GREY, "   You are not at the Bank !");
                   return 1;
               }
               if(PlayerInfo[playerid][pConnectTime] < 1)
               {
                    SendClientMessage(playerid, COLOR_GREY, "   You must have at least 4 playing hours !");
                    return 1;
                }
                tmp= strtok(cmdtext, idx);
                if(!strlen(tmp))
                {
                    SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /withdraw [amount]");
                    format(string, sizeof(string), "  You Have $%d in your account.", PlayerInfo[playerid][pAccount]);
                    SendClientMessage(playerid, COLOR_GRAD3, string);
                    return 1;
                }
                new cashdeposit = strval(tmp);
                if(!strlen(tmp))
                {
                    SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /withdraw [amount]");
                    format(string, sizeof(string), "  You Have $%d in your account.", PlayerInfo[playerid][pAccount]);
                    SendClientMessage(playerid, COLOR_GRAD3, string);
                    return 1;
                }
                if (cashdeposit > PlayerInfo[playerid][pAccount] || cashdeposit < 1)
                {
                    SendClientMessage(playerid, COLOR_GRAD2, "   You dont have that much !");
                    return 1;
                }
                ShowPlayerDialog(playerid,DIALOG_PIN,DIALOG_STYLE_INPUT,"WITHDRAW","Va rugam introduceti\nPIN'ul: ","ENTER","");
                if(PinOk[playerid] == 1)
                {
                    ConsumingMoney[playerid] = 1;
                    GivePlayerCash(playerid,cashdeposit);
                    PlayerInfo[playerid][pAccount]=PlayerInfo[playerid][pAccount]-cashdeposit;
                    format(string, sizeof(string), "  You Have Withdrawn $%d from your account Total: $%d ", cashdeposit,PlayerInfo[playerid][pAccount]);
                    SendClientMessage(playerid, COLOR_YELLOW, string);
                    return 1;
                }
            }
            else
            {
                SendClientMessage(playerid, COLOR_GRAD1, "Nu ai MasterCard !");
                return 1;
            }
           
        return 1;
        }
    }
Thanks !!


Re: Help with dialog input - Smyle - 12.03.2012

up, +rep if u help


Re: Help with dialog input - Bogdan1992 - 12.03.2012

Try this. That PIN is only with numbers?
Код:
if (dialogid == DIALOG_PIN)
        {
            new PIN ;
            PIN = strval(inputtext);
            if(PIN == PlayerInfo[playerid][pPIN])
            {
                PinOk[playerid] = 1;
            }
            else
            {
                SendClientMessage(playerid, 0xFF0000FF, "PIN Incorect, mai incearca !");
            }

        
        }



Re: Help with dialog input - Smyle - 12.03.2012

Yeah, it works now but when I type /withdraw it shows me the dialog, i type the PIN and nothing happens. After that, i type /withdraw and the command works.


Re: Help with dialog input - Bogdan1992 - 12.03.2012

Код:
if (dialogid == DIALOG_PIN)
        {
            new PIN ;
            PIN = strval(inputtext);
            if(PIN == PlayerInfo[playerid][pPIN])
            {
                PinOk[playerid] = 1;
                if(PinOk[playerid] == 1)
                {
                    ConsumingMoney[playerid] = 1;
                    GivePlayerCash(playerid,cashdeposit);
                    PlayerInfo[playerid][pAccount]=PlayerInfo[playerid][pAccount]-cashdeposit;
                    format(string, sizeof(string), "  You Have Withdrawn $%d from your account Total: $%d ", cashdeposit,PlayerInfo[playerid][pAccount]);
                    SendClientMessage(playerid, COLOR_YELLOW, string);
                    return 1;
                }
            }
            else
            {
                SendClientMessage(playerid, 0xFF0000FF, "PIN Incorect, mai incearca !");
            }

        
        }


if(strcmp(cmd, "/withdraw", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(PlayerInfo[playerid][pCard] == 1)
            {
            
                if(PlayerInfo[playerid][pLocal] != 103)
                {
                   SendClientMessage(playerid, COLOR_GREY, "   You are not at the Bank !");
                   return 1;
               }
               if(PlayerInfo[playerid][pConnectTime] < 1)
               {
                    SendClientMessage(playerid, COLOR_GREY, "   You must have at least 4 playing hours !");
                    return 1;
                }
                tmp= strtok(cmdtext, idx);
                if(!strlen(tmp))
                {
                    SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /withdraw [amount]");
                    format(string, sizeof(string), "  You Have $%d in your account.", PlayerInfo[playerid][pAccount]);
                    SendClientMessage(playerid, COLOR_GRAD3, string);
                    return 1;
                }
                new cashdeposit = strval(tmp);
                if(!strlen(tmp))
                {
                    SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /withdraw [amount]");
                    format(string, sizeof(string), "  You Have $%d in your account.", PlayerInfo[playerid][pAccount]);
                    SendClientMessage(playerid, COLOR_GRAD3, string);
                    return 1;
                }
                if (cashdeposit > PlayerInfo[playerid][pAccount] || cashdeposit < 1)
                {
                    SendClientMessage(playerid, COLOR_GRAD2, "   You dont have that much !");
                    return 1;
                }
                ShowPlayerDialog(playerid,DIALOG_PIN,DIALOG_STYLE_INPUT,"WITHDRAW","Va rugam introduceti\nPIN'ul: ","ENTER","");
            }
            else
            {
                SendClientMessage(playerid, COLOR_GRAD1, "Nu ai MasterCard !");
                return 1;
            }
            
        return 1;
        }
    }



Re: Help with dialog input - Smyle - 12.03.2012

pawn Код:
C:\Users\SMYLE\Desktop\Server\gamemodes\mqq.pwn(15540) : error 017: undefined symbol "cashdeposit"
C:\Users\SMYLE\Desktop\Server\gamemodes\mqq.pwn(15541) : error 017: undefined symbol "cashdeposit"
C:\Users\SMYLE\Desktop\Server\gamemodes\mqq.pwn(15542) : error 017: undefined symbol "cashdeposit"
It gives me 3 errors...


Re: Help with dialog input - Bogdan1992 - 12.03.2012

Код:
if (dialogid == DIALOG_PIN)
        {
            new PIN ;
            PIN = strval(inputtext);
            if(PIN == PlayerInfo[playerid][pPIN])
            {
                PinOk[playerid] = 1;
                new cashdeposit;
                if(PinOk[playerid] == 1)
                {
                    ConsumingMoney[playerid] = 1;
                    GivePlayerCash(playerid,cashdeposit);
                    PlayerInfo[playerid][pAccount]=PlayerInfo[playerid][pAccount]-cashdeposit;
                    format(string, sizeof(string), "  You Have Withdrawn $%d from your account Total: $%d ", cashdeposit,PlayerInfo[playerid][pAccount]);
                    SendClientMessage(playerid, COLOR_YELLOW, string);
                    return 1;
                }
            }
            else
            {
                SendClientMessage(playerid, 0xFF0000FF, "PIN Incorect, mai incearca !");
            }

        
        }