SA-MP Forums Archive
Need some help. - 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: Need some help. (/showthread.php?tid=313344)



Need some help. - nogh445 - 25.01.2012

Alright well I've just converted my script from commands like /ak, /deagle, /spas...etc. to dialog.
so now you /shop and it pulls up a dialog with the prices and the gun name...
I would like to know how to make it to where if you do not have the money to buy the gun it will not let you.
Right now if you /shop and you have no money it will let you buy it but it will put you into negative money.


Re: Need some help. - iggy1 - 25.01.2012

pawn Код:
if(GetPlayerMoney(playerid) >= YOUR_GUN_PRICE_HERE)
{
    //player can afford the gun
}
else
{
    //player can't afford the gun
}



Re: Need some help. - nogh445 - 25.01.2012

Where would I place this? Under the Case 1:, Case 2:, Case 3: and so on...?


Re: Need some help. - iggy1 - 25.01.2012

Put it where you give them the gun preferably, give the gun inside the 'if' block. If you give the gun inside a case put it there.

pawn Код:
case 0:
{
    if(GetPlayerMoney(playerid) >= YOUR_GUN_PRICE_HERE)
    {
        //player can afford the gun so give the gun here and reduce money
    }
    else
    {
        //player can't afford the gun send a message
    }
}



Re: Need some help. - nogh445 - 25.01.2012

That worked. Thank you very much.