on money
#1

Hi, so, if a man anxious to buy, and if it is not enough money can not buy.
Reply
#2

pawn Код:
if(GetPlayerCash(playerid) =< /*Whatever the item costs*/)
{
  //Player cant afford
}
else
{
  //Player can afford
}
Is that what you mean?
Reply
#3

It is GetPlayerMoney,not GetPlayerCash,so here it is if you want to use to more things in your script
pawn Код:
new playermoney = GetPlayerMoney(playerid); // now you can use it where you want in your script,you don`t must always write GetPlayerMoney blah blah

if(playermoney =< /* price you want */)
{
    //effect (Player can`t afford)
}
else
{
    //effect (Player can afford)
}
Reply
#4

Quote:
Originally Posted by °Luka°
It is GetPlayerMoney,not GetPlayerCash,so here it is if you want to use to more things in your script
pawn Код:
new playermoney = GetPlayerMoney(playerid); // now you can use it where you want in your script,you don`t must always write GetPlayerMoney blah blah

if(playermoney =< /* price you want */)
{
    //effect (Player can`t afford)
}
else
{
    //effect (Player can afford)
}
if playermoney is = or < he can't afford, why he can't afford if his money is [b]same[b] as price?


pawn Код:
if(GetPlayerMoney(playerid) >= PRICE)
{
    // put your code (can afford)
}
else
{
    // put your code (can't afford)
}
Reply
#5

Quote:
Originally Posted by Don Correlli
Quote:
Originally Posted by °Luka°
It is GetPlayerMoney,not GetPlayerCash,so here it is if you want to use to more things in your script
pawn Код:
new playermoney = GetPlayerMoney(playerid); // now you can use it where you want in your script,you don`t must always write GetPlayerMoney blah blah

if(playermoney =< /* price you want */)
{
    //effect (Player can`t afford)
}
else
{
    //effect (Player can afford)
}
if playermoney is = or < he can't afford, why he can't afford if his money is [b]same[b] as price?


pawn Код:
if(GetPlayerMoney(playerid) >= PRICE)
{
    // put your code (can afford)
}
else
{
    / put your code (can't afford)
}
You make same code lol! But you are using first if playermoney is same or higher than a player cash
Reply
#6

Код:
case 0:
			{
				new playermoney = GetPlayerMoney(playerid); // now you can use it where you want in your script,you don`t must always write GetPlayerMoney blah blah

				if(playermoney =< GivePlayerWeapon(playerid,25,1000);
				{
          GivePlayerWeapon(playerid,25,1000);
				}
				else
				{
				 SendClientMessage(playerid,COLOR_LIME,"You don't money");
				}

      }
Reply
#7

You can`t have if(playermoney =< GivePlayerWeapon....change GivePlayerWeapon with price
Reply
#8

Quote:
Originally Posted by °Luka°
You make same code lol! But you are using first if playermoney is same or higher than a player cash
Check again, it's not same. You used =< which should be <= in your case. That means You can't buy that thing if you even have same amount of cash as the PRICE is defined. You should just use <.
Reply
#9

Example (ingame):

I have 200$ and some object cost 200$ and I can buy it,and i have now 0$!

You saying:

I have 200$ and some object cost 200$ and I can`t buy it,because i need 201$
Reply
#10

You don't know what <= means do you? It means if your money is lower or same as that you can't buy it, that's what you did in your code. You used =< which should really be <= to check player's money. That check would check if player's money is lower or same as PRICE.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)