SA-MP Forums Archive
TakePlayerMoney - 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)
+--- Thread: TakePlayerMoney (/showthread.php?tid=617336)



TakePlayerMoney - Maheerali - 19.09.2016

When i was new I have many difficulties regarding how to take money from player. So this is its stock. So that new players will do this easily.

PHP код:
stock TakePlayerMoney(player,amount)
{
    new 
cash;
    new 
togive;
    
cash GetPlayerMoney(player);
    
togive cash-amount;
    
ResetPlayerMoney(player);
    
GivePlayerMoney(playertogive);
}
//add this to your  gamemode
//Example
public OnPlayerDeath(playerid,killerid,reason)
{
       
TakePlayerMoney(playerid,200);




Re: TakePlayerMoney - oMa37 - 19.09.2016

Why don't just use GivePlayerMoney(playerid, -Amount); ?


Re: TakePlayerMoney - SickAttack - 19.09.2016

pawn Код:
stock TakePlayerMoney(playerid, amount)
{
    return GivePlayerMoney(playerid, -amount);
}
If you don't want it to go below 0:
pawn Код:
stock TakePlayerMoney(playerid, amount)
{
    return (((GetPlayerMoney(playerid) - amount) < 0) ? (ResetPlayerMoney(playerid)) : (GivePlayerMoney(playerid, -amount)));
}