SA-MP Forums Archive
Help with dialog. - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Help with dialog. (/showthread.php?tid=218617)



Help with dialog. - SchurmanCQC - 30.01.2011

I have:
pawn Код:
if (strcmp("/store", cmdtext, true, 10) == 0) {
        ShowPlayerDialog(playerid,2055,DIALOG_STYLE_LIST,"Store Menu","Full Armour ($300)\r\nFull Health ($300)","Buy","Cancel");
        return 1;
    }
Could anyone give me the proper OnDialogResponse for this command? Thanks.


Re: Help with dialog. - Mike Garber - 30.01.2011

pawn Код:
if(dialogid==2055)
{
    if(response)
    {
        if(listitem==0) // Full armour
        {
            SetPlayerArmour(playerid,100);
            GivePlayerMoney(playerid,-300);
        }
        if(listitem==1) // Full Health
        {
            SetPlayerHealth(playerid,100);
            GivePlayerMoney(playerid,-300);
        }
        return 1;
    }

}



Re: Help with dialog. - SchurmanCQC - 30.01.2011

Quote:
Originally Posted by Mike Garber
Посмотреть сообщение
pawn Код:
if(dialogid==2055)
{
    if(response)
    {
        if(listitem==0) // Full armour
        {
            SetPlayerArmour(playerid,100);
            GivePlayerMoney(playerid,-300);
        }
        if(listitem==1) // Full Health
        {
            SetPlayerHealth(playerid,100);
            GivePlayerMoney(playerid,-300);
        }
        return 1;
    }

}
This is wrong, it'll take 300 dollars away even if you have $0, causing it to to go -$300. If you could tell me how to put in a "You don't have enough money for this," I'd be happy.

Thanks.


Re: Help with dialog. - MMiz - 30.01.2011

Код:
if(dialogid==2055)
{
      if(response)
     {
            if(listitem==0) // Full armour
            { 
                if(GetPlayerMoney(playerid) < 300) return SendClientMessage(playerid, 0xFFFFFF, "You don't have enough Cash!");
                SetPlayerArmour(playerid,100);
                GivePlayerMoney(playerid,-300);
            }
            if(listitem==1) // Full Health
            {
                if(GetPlayerMoney(playerid) < 300) return SendClientMessage(playerid, 0xFFFFFF, "You don't have enough Cash!");
                SetPlayerHealth(playerid,100);
                GivePlayerMoney(playerid,-300);
            }
            return 1;
     }

}
Fixed