Dialog list as 24/7 when press cancel takes money
#1

I have my Dialog list working exept for one thing when i press cancel it still takes the money away from you.

This is the actual dialog box:
Код:
if(pickupid == noob247)
{
ShowPlayerDialog(playerid, DIALOG_NOOB247, DIALOG_STYLE_LIST, "24/7 Shopping Cart", "Test1($10)\nTest2($20)\nTest3($30)", "Purchase","Cancel");
}
This is the code behind the dialog:
Код:
case DIALOG_NOOB247:
        {
        switch(listitem)
        {
        case 0:
        {
        if(GetPlayerMoney(playerid) < 10) return SendClientMessage(playerid, COLOUR_YELLOW, "You cant afford this item.");
        GivePlayerMoney(playerid, -10);
        }
        case 1:
        {
        if(GetPlayerMoney(playerid) < 20) return SendClientMessage(playerid, COLOUR_YELLOW, "You cant afford this item.");
        GivePlayerMoney(playerid, -20);
        }
        case 2:
        {
        if(GetPlayerMoney(playerid) < 30) return SendClientMessage(playerid, COLOUR_YELLOW, "You cant afford this item.");
        GivePlayerMoney(playerid, -30);
        }
        case 3:
        {
		return SendClientMessage(playerid, COLOUR_YELLOW, "You cant afford this item.");
        }
        }
Reply
#2

pawn Код:
case DIALOG_NOOB247:
    {
        if(response)
        {
            switch(listitem)
            {
                case 0:
                {
                    if(GetPlayerMoney(playerid) < 10) return SendClientMessage(playerid, COLOUR_YELLOW, "You cant afford this item.");
                    GivePlayerMoney(playerid, -10);
                }
                case 1:
                {
                    if(GetPlayerMoney(playerid) < 20) return SendClientMessage(playerid, COLOUR_YELLOW, "You cant afford this item.");
                    GivePlayerMoney(playerid, -20);
                }
                case 2:
                {
                    if(GetPlayerMoney(playerid) < 30) return SendClientMessage(playerid, COLOUR_YELLOW, "You cant afford this item.");
                    GivePlayerMoney(playerid, -30);
                }
                case 3:
                {
                    return SendClientMessage(playerid, COLOUR_YELLOW, "You cant afford this item.");
                }
            }
        }
    }
Reply
#3

Код:
if(response==1)
0 would be your Cancel Button if I'm not mistaken
(So this would only execute if the player has use response 1 (Purchase Button)

But the reason its taking away money & purchasing the item regardless is because the list item is selected when players hit the cancel button, the response check will help determine which button the player has pressed...
Reply
#4

that worked thanks allot pal =). Respecpa

Regards Matt
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)