Give player money
#1

Hello.
I am using this weapon dialog : http://pastebin.com/MWFC9Qd4
I want to make something like this:

If player has $100 and wants to buy a knife for $500 he cant beacuse he doesnt have enough money.
How do you make it?
Reply
#2

here:

Код:
if(GetPlayerMoney(playerid) < 500)
{
  SendClientMessage(playerid, COLOR, "You dont have enough money");
}
add it to all weapon
and change the COLOR to the color you want
and change 500 to the price you want
piece of cake
Reply
#3

Well each weapon has other price..

@EDIT

For example my sniper gun :

Код:
if(listitem == 13)
			{
        GivePlayerWeapon(playerid,34, 20);
        GivePlayerMoney(playerid, -9000);
        if(GetPlayerMoney(playerid) < 9000)
        {
        SendClientMessage(playerid, COLOR_NARANCS, "You dont have enough money");
        }
      	 new name[256];
				new string[256];
				GetPlayerName(playerid, name, sizeof(name));
				format(string, sizeof(string), "[INFO] %s got a Sniper Rifle.", name);
				SendClientMessageToAll(COLOR_NARANCS, string);
				TogglePlayerControllable(playerid,1);
 			}
But still if i have $3500 i can buy it and my money goes on -$XXXX
Reply
#4

Quote:
Originally Posted by XxerykxX
Well each weapon has other price..

@EDIT

For example my sniper gun :

Код:
if(listitem == 13)
			{
        GivePlayerWeapon(playerid,34, 20);
        GivePlayerMoney(playerid, -9000);
        if(GetPlayerMoney(playerid) < 9000)
        {
        SendClientMessage(playerid, COLOR_NARANCS, "You dont have enough money");
        }
      	 new name[256];
				new string[256];
				GetPlayerName(playerid, name, sizeof(name));
				format(string, sizeof(string), "[INFO] %s got a Sniper Rifle.", name);
				SendClientMessageToAll(COLOR_NARANCS, string);
				TogglePlayerControllable(playerid,1);
 			}
But still if i have $3500 i can buy it and my money goes on -$XXXX
it should be like that:

Код:
if(listitem == 13)
			{
		    if(GetPlayerMoney(playerid) >= 9000)
		    {
        GivePlayerWeapon(playerid,34, 20);
        GivePlayerMoney(playerid, GetPlayerMoney(playerid) - 9000);
        }
        if(GetPlayerMoney(playerid) < 9000)
        {
        SendClientMessage(playerid, COLOR_NARANCS, "You dont have enough money");
        }
      	 new name[256];
				new string[256];
				GetPlayerName(playerid, name, sizeof(name));
				format(string, sizeof(string), "[INFO] %s got a Sniper Rifle.", name);
				SendClientMessageToAll(COLOR_NARANCS, string);
				TogglePlayerControllable(playerid,1);
 			}
Reply
#5

Well works thanks but another problem it adds over 200,000+ when you buy it
How to fix it? meyby cause of my gamemode?
my gamemode : http://pastebin.com/0z0utwEJ
my weapon shop : http://pastebin.com/fVrCvqWY
Reply
#6

Adds over 200,000..?? $?
Reply
#7

Try like this.
Btw: At the GivePlayerMoney only do it like this GivePlayerMoney(playerid, - 9000);
change -9000 with what ammount of money you want to be taken from the player

Код:
if(listitem == 13)
		{
		if(GetPlayerMoney(playerid) >= 9000)
		{
          GivePlayerWeapon(playerid,34, 20);
          GivePlayerMoney(playerid, - 9000);
        }
        else if(GetPlayerMoney(playerid) < 9000)
        {
          SendClientMessage(playerid, COLOR_NARANCS, "You dont have enough money");
        }
      	 new name[256];
				new string[256];
				GetPlayerName(playerid, name, sizeof(name));
				format(string, sizeof(string), "[INFO] %s got a Sniper Rifle.", name);
				SendClientMessageToAll(COLOR_NARANCS, string);
				TogglePlayerControllable(playerid,1);
 		}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)