SA-MP Forums Archive
dialog fail - 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: dialog fail (/showthread.php?tid=308585)



dialog fail - Tanush123 - 04.01.2012

Well actually i wanted to make if they enter a player ID that is connected it will work but when i enter some random things, it just works. I want to make if they type someone ID that is connected, it will work
pawn Код:
if(dialogid == 15)
    {
        if(response)
        {
                if(!IsPlayerConnected(bankerID))
                {
                    ShowPlayerDialog(playerid,12,DIALOG_STYLE_LIST,"Bank","Withdraw\nDeposit\nBalance\nTransfer","Open","Close");
                    SendClientMessage(playerid,red,"ERROR: That ID is not connected");
                }
                else
                {
                    ShowPlayerDialog(playerid,16,DIALOG_STYLE_INPUT,"Transfer","Enter the amount you want to give your cash to","Send","Back");
                }
        }
        if(!response)
        {
            ShowPlayerDialog(playerid,12,DIALOG_STYLE_LIST,"Bank","Withdraw\nDeposit\nBalance\nTransfer","Open","Close");
        }
        return 1;
    }



Re: dialog fail - Norck - 04.01.2012

Check this out:
pawn Код:
if(dialogid == 15)
    {
        if(response)
        {
                if(!IsPlayerConnected(strval(inputtext)))
                {
                    ShowPlayerDialog(playerid,12,DIALOG_STYLE_LIST,"Bank","Withdraw\nDeposit\nBalance\nTransfer","Open","Close");
                    SendClientMessage(playerid,red,"ERROR: That ID is not connected");
                }
                else
                {
                    ShowPlayerDialog(playerid,16,DIALOG_STYLE_INPUT,"Transfer","Enter the amount you want to give your cash to","Send","Back");
                }
        }
        else
        {
            ShowPlayerDialog(playerid,12,DIALOG_STYLE_LIST,"Bank","Withdraw\nDeposit\nBalance\nTransfer","Open","Close");
        }
        return 1;
    }



Re: dialog fail - Tanush123 - 05.01.2012

ok i got a problem, when i enter some random letters it just leads me to "how much you want to donate to that person". how i fix it


Re: dialog fail - Norck - 05.01.2012

You should add this function in your script:
pawn Код:
stock IsNumeric(const str[])
{
    new l = strlen(str);
        if(l == 0)
            return 0;
    for(new i; i < l; i++)
       {
            if (str[i] < '0' || str[i] > '9')
                return 0;
        }
    return 1;
}
And modify your code, so it will looks like:
pawn Код:
if(dialogid == 15)
    {
        if(response)
        {
                if(!IsNumeric(inputtext) || !IsPlayerConnected(strval(inputtext)))
                {
                    ShowPlayerDialog(playerid,12,DIALOG_STYLE_LIST,"Bank","Withdraw\nDeposit\nBalance\nTransfer","Open","Close");
                    SendClientMessage(playerid,red,"ERROR: That ID is not connected");
                }
                else
                {
                    ShowPlayerDialog(playerid,16,DIALOG_STYLE_INPUT,"Transfer","Enter the amount you want to give your cash to","Send","Back");
                }
        }
        else
        {
            ShowPlayerDialog(playerid,12,DIALOG_STYLE_LIST,"Bank","Withdraw\nDeposit\nBalance\nTransfer","Open","Close");
        }
        return 1;
    }



Re: dialog fail - Vince - 05.01.2012

You could also use sscanf;
pawn Код:
new targetid;
                if(sscanf(inputtext, "r", targetid)) { /* return syntax error message */ }
                if(targetid == INVALID_PLAYER_ID)
                {
                    ShowPlayerDialog(playerid,12,DIALOG_STYLE_LIST,"Bank","Withdraw\nDeposit\nBalance\nTransfer","Open","Close");
                    SendClientMessage(playerid,red,"ERROR: That ID is not connected");
                }
                else
                {
                    ShowPlayerDialog(playerid,16,DIALOG_STYLE_INPUT,"Transfer","Enter the amount you want to give your cash to","Send","Back");
                }



Re: dialog fail - Tanush123 - 05.01.2012

well thank you, for that when someone enters a id that is connected it leads me to this dialog
pawn Код:
if(dialogid == 16)
    {
        if(response)
        {
            if(strval(inputtext)>0)
            {
                if(PlayerData[playerid][Bank] < strval(inputtext)) return SendClientMessage(playerid,red,"ERROR: You don't have that much money in your bank account");
                GetPlayerName(playerid,Nam,sizeof(Nam));
                PlayerData[bankerID][Bank] += strval(inputtext);
                PlayerData[playerid][Bank] -= strval(inputtext);
                format(str,sizeof(str),"You have transfer %d from your money to the other person account",strval(inputtext));
                SendClientMessage(playerid,Niceyellow,str);
                format(str,sizeof(str),"%s has transfered %s from his/her bank account to your bank account",Nam,strval(inputtext));
                SendClientMessage(bankerID,Niceyellow,str);
                ShowPlayerDialog(playerid,12,DIALOG_STYLE_LIST,"Bank","Withdraw\nDeposit\nBalance\nTransfer","Open","Close");
            }
            else return SendClientMessage(playerid,red,"ERROR: You cannot give negative numbers to others");
        }
        if(!response)
        {
            ShowPlayerDialog(playerid,12,DIALOG_STYLE_LIST,"Bank","Withdraw\nDeposit\nBalance\nTransfer","Open","Close");
        }
        return 1;
    }
why does the ID always becomes 0 when i send cash?