SA-MP Forums Archive
on money - 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: on money (/showthread.php?tid=80771)



on money - Sin- - 06.06.2009

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


Re: on money - [HiC]TheKiller - 06.06.2009

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


Re: on money - Luka P. - 06.06.2009

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)
}



Re: on money - Correlli - 06.06.2009

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)
}



Re: on money - Luka P. - 06.06.2009

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


Re: on money - Sin- - 06.06.2009

Код:
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");
				}

      }



Re: on money - Luka P. - 06.06.2009

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


Re: on money - Correlli - 06.06.2009

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 <.


Re: on money - Luka P. - 06.06.2009

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$


Re: on money - Correlli - 06.06.2009

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.