GivePlayerMoney
From Multi Theft Auto: Wiki
This function adds money to a player's current money amount. To set absolute values, setPlayerMoney can be used.
Note: Using this function client side (not recommended) will not change a players money server side. |
Syntax
Click to collapse [-]
Serverbool givePlayerMoney ( player thePlayer, int amount )
OOP Syntax Help! I don't understand this!
- Method: player:giveMoney(...)
- Variable: .money
Required Arguments
- thePlayer: the player you are giving the money to.
- amount: a positive integer number specifying the amount of money to give to the player.
Click to collapse [-]
Clientbool givePlayerMoney ( int amount )
OOP Syntax Help! I don't understand this!
- Method: Player.giveMoney(...)
Required Arguments
- amount: a positive integer number specifying the amount of money to give to the player.
Returns
Returns true if the money was added, or false if invalid parameters were passed.
Example
Click to collapse [-]
Example 1 - Client and ServerThis example gives a player money when using "givecash" command.
function consoleGiveCash ( thePlayer, command, amount ) --when the givecash command is called givePlayerMoney ( thePlayer, amount ) --give the player money according to the amount end addCommandHandler ( "givecash", consoleGiveCash ) --add a handler function for the command "givecash"
Click to collapse [-]
Example 2 - ServerThis example gives a player one thousand dollars, as a reward for killing another player.
function rewardOnWasted ( ammo, killer, killerweapon, bodypart ) --if there is a killer, and that killer is not the same person as whoever died if ( killer ) and ( killer ~= source ) then givePlayerMoney ( killer, 1000 ) --reward the killer with 1000 cash. end end addEventHandler ( "onPlayerWasted", getRootElement(), rewardOnWasted ) --attach the rewardOnWasted function to the relevant event.
Click to collapse [-]
Example 3 - ServerThis example Creates money Money (dollar symbol) pickup and gives 30,000 dollars on Pick up hit.
local money = createPickup (1896.4000244141, -1950.9000244141, 13, 3, 1274, 10000 ) function pickupUse ( player ) givePlayerMoney ( player, 30000 ) end addEventHandler ( "onPickupUse", money, pickupUse )
See Also
- forcePlayerMap
- getAlivePlayers
- getDeadPlayers
- getPlayerACInfo
- getPlayerAnnounceValue
- getPlayerBlurLevel
- getPlayerCount
- getPlayerFromName
- getPlayerIdleTime
- getPlayerIP
- getPlayerMoney
- getPlayerName
- getPlayerNametagColor
- getPlayerNametagText
- getPlayerPing
FROM VERSION 1.5.7 r19626 ONWARDS
- getPlayerSerial
- getPlayerTeam
- getPlayerVersion
- getPlayerWantedLevel
- getRandomPlayer
- givePlayerMoney
- isPlayerMapForced
- isPlayerMuted
- isPlayerNametagShowing
- isVoiceEnabled
- redirectPlayer
- resendPlayerACInfo
- resendPlayerModInfo
- setPlayerAnnounceValue
- setPlayerBlurLevel
- setPlayerHudComponentVisible
- setPlayerMoney
- setPlayerMuted
- setPlayerName
- setPlayerNametagColor
- setPlayerNametagShowing
- setPlayerNametagText
FROM VERSION 1.5.7 r19626 ONWARDS