TakePlayerMoney
#1

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

Reply
#2

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)