GivePlayerMoney: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
mNo edit summary |
||
Line 23: | Line 23: | ||
==Example== | ==Example== | ||
<section show="true" name="Example 1 - Client and Server" class="server"> | |||
This example gives a player money when using "givecash" command. | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function consoleGiveCash ( thePlayer, command, amount ) --when the givecash command is called | function consoleGiveCash ( thePlayer, command, amount ) --when the givecash command is called | ||
Line 30: | Line 31: | ||
addCommandHandler ( "givecash", consoleGiveCash ) --add a handler function for the command "givecash" | addCommandHandler ( "givecash", consoleGiveCash ) --add a handler function for the command "givecash" | ||
</syntaxhighlight> | </syntaxhighlight> | ||
</section> | |||
<section show="true" name="Example 2 - Server" class="server"> | |||
This example gives a player one thousand dollars, as a reward for killing another player. | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function rewardOnWasted ( ammo, killer, killerweapon, bodypart ) | function rewardOnWasted ( ammo, killer, killerweapon, bodypart ) | ||
Line 41: | Line 44: | ||
addEventHandler ( "onPlayerWasted", getRootElement(), rewardOnWasted ) --attach the rewardOnWasted function to the relevant event. | addEventHandler ( "onPlayerWasted", getRootElement(), rewardOnWasted ) --attach the rewardOnWasted function to the relevant event. | ||
</syntaxhighlight> | </syntaxhighlight> | ||
</section> | |||
==See Also== | ==See Also== | ||
{{Player functions}} | {{Player functions}} |
Revision as of 23:34, 14 November 2011
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 )
Required Arguments
- thePlayer: the player to whom you are giving the money.
- amount: a positive integer number specifying the amount of money to give to the player.
Click to collapse [-]
Clientbool givePlayerMoney ( int amount )
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.
See Also
- getPlayerTeam
- getPlayerBlurLevel
- setPlayerBlurLevel
- getPlayerSerial
- forcePlayerMap
- getPlayerScriptDebugLevel
- getPlayerFromName
- getPlayerMoney
- getPlayerName
- getPlayerNametagColor
- getPlayerNametagText
- getPlayerPing
- getPlayerWantedLevel
- givePlayerMoney
- isPlayerMapForced
- isPlayerNametagShowing
- setPlayerHudComponentVisible
- setPlayerMoney
- setPlayerNametagColor
- setPlayerNametagShowing
- setPlayerNametagText
- takePlayerMoney
- countPlayersInTeam
- getPlayersInTeam
- isVoiceEnabled
- setControlState
- getControlState