SA-MP Forums Archive
Help with money limits - 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 money limits (/showthread.php?tid=210425)



Help with money limits - Jacob_T_Harden - 13.01.2011

Hello, Iam a semi-New scripter.. Ive searched for a long time on a tutorial for this.. But I have an entire weapon shop on my script iam working on.. But I want to to make it where you cannot buy weapons if you dont have enough money.. As of know, I cant find help on that.. So I decided to make a topic.. Here is what I have for a deagle.
Код:
if (strcmp("/buygun deagle", cmdtext, true)==0){
	SendClientMessage(playerid, COLOR_WHITE, "You have bought a Deagle for 1000 dollars!");
	GivePlayerWeapon(playerid, 24, 40);
	GivePlayerMoney(playerid, -1000);
	return 1;
	}
How can I make it where if you dont have 1000 dollars you cannot buy this weapon etc..
Thanks


Re: Help with money limits - cessil - 13.01.2011

pawn Код:
if(GetPlayerMoney(playerid) < 1000) return SendClientMessage(playerid,COLOR_WHITE, "You do not have 1000 dollars!");



Re: Help with money limits - JamesC - 13.01.2011

pawn Код:
if( GetPlayerMoney( playerid ) >= 1000 )
{
    // Can buy
}
else
{
    // Does not have enough money.
}



Re: Help with money limits - Jacob_T_Harden - 13.01.2011

James like this?

Код:
       if (strcmp("/buygun deagle", cmdtext, true)==0){
             if( GetPlayerMoney( playerid ) >= 1000 )
	{
             SendClientMessage(playerid, COLOR_WHITE, "You have bought a Deagle for 1000 dollars!");
	GivePlayerWeapon(playerid, 24, 40);
	GivePlayerMoney(playerid, -1000);
	}
	else
	{
	SendClientMessage(playerid, COLOR_YELLOW, "You dont have enough money!");
	}
	return 1;
	}



Re: Help with money limits - California - 13.01.2011

Quote:
Originally Posted by Jacob_T_Harden
Посмотреть сообщение
James like this?

Код:
       if (strcmp("/buygun deagle", cmdtext, true)==0){
             if( GetPlayerMoney( playerid ) >= 1000 )
	{
             SendClientMessage(playerid, COLOR_WHITE, "You have bought a Deagle for 1000 dollars!");
	GivePlayerWeapon(playerid, 24, 40);
	GivePlayerMoney(playerid, -1000);
	}
	else
	{
	SendClientMessage(playerid, COLOR_YELLOW, "You dont have enough money!");
	}
	return 1;
	}
Yes, like that, also, indent your code, more readable. ^^

Код:
    if (strcmp("/buygun deagle", cmdtext, true)==0)
    {
        if( GetPlayerMoney( playerid ) >= 1000 )
	{
             SendClientMessage(playerid, COLOR_WHITE, "You have bought a Deagle for 1000 dollars!");
	     GivePlayerWeapon(playerid, 24, 40);
	     GivePlayerMoney(playerid, -1000);
	}
	else
	{
	    SendClientMessage(playerid, COLOR_YELLOW, "You dont have enough money!");
	}
	return 1;
    }



Re: Help with money limits - California - 13.01.2011

Accidentally double posted, please ignore/delete this post.


Re: Help with money limits - Jacob_T_Harden - 13.01.2011

Thank you guys very very much!
California.. I use your houseing system on one of my RP servers.. Anyways, Could you maybe tell me how to make a command 1 time use only? Such as this for example (Just made this.. Not in my script) How would I make it 1 time use only?
Код:
     if (strcmp("/starter", cmdtext, true==0) 
      {
          SendClientMessage(playerid, COLOR_YELLOW, "Here is your starter money!");
          GivePlayerMoney(playerid, 10000);
    return 1;
  {



Re: Help with money limits - coole210 - 13.01.2011

Make a saved variable like
Код:
new StarterMoneyGiven[MAX_PLAYERS];
at the top of the script
and then save/load it
then set the variable to 0 (or false) when they type /starter
or you can just give players starter money when they register :\