dialog fail
#1

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;
    }
Reply
#2

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;
    }
Reply
#3

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
Reply
#4

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;
    }
Reply
#5

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");
                }
Reply
#6

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?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)