Help with money limits
#1

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

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

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

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

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

Accidentally double posted, please ignore/delete this post.
Reply
#7

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;
  {
Reply
#8

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 :\
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)