TakePlayerMoney: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Updated to command handlers from onConsole)
No edit summary
Line 1: Line 1:
__NOTOC__  
__NOTOC__  
Subtracts money from the player's current money amount.
This function substracts money from a [[player]]'s current money amount.


==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">takePlayerMoney ( player, money )</syntaxhighlight>  
<syntaxhighlight lang="lua">bool takePlayerMoney ( player thePlayer, int amount )</syntaxhighlight>  


===Required Arguments===  
===Required Arguments===  
*'''Player:''' Tells the function to give money to a player
*'''thePlayer:''' the [[player]] you are taking the money from.
*'''Money:''' A whole integer specifying the amount of money to give to the player
*'''amount:''' an integer number specifying the amount of money to take from the player.
 
===Returns===
Returns ''true'' if the money was taken, or ''false'' if invalid parameters were passed.


==Example==   
==Example==   
This example takes a player money when he types "takecash" in console
This example takes money from a player when he types "takecash" in console.
<syntaxhighlight lang="lua">addCommandHandler ( "takecash", "takeCash" ) --add the command "takecash"
<syntaxhighlight lang="lua">
function takeCash ( player, command, amount ) --when the takecash command is called
addCommandHandler ( "takecash", "takeCash" ) --add a handler function for the command "takecash"
takePlayerMoney ( player, amount ) --take the player's money according to the amount
function takeCash ( thePlayer, command, amount ) --when the takecash command is called
end</syntaxhighlight>
takePlayerMoney ( thePlayer, amount ) --take the amount of money from the player
end
</syntaxhighlight>


==See Also==
==See Also==
{{Player functions}}
{{Player functions}}

Revision as of 15:00, 25 April 2007

This function substracts money from a player's current money amount.

Syntax

bool takePlayerMoney ( player thePlayer, int amount )

Required Arguments

  • thePlayer: the player you are taking the money from.
  • amount: an integer number specifying the amount of money to take from the player.

Returns

Returns true if the money was taken, or false if invalid parameters were passed.

Example

This example takes money from a player when he types "takecash" in console.

addCommandHandler ( "takecash", "takeCash" ) --add a handler function for the command "takecash"
function takeCash ( thePlayer, command, amount ) --when the takecash command is called
	takePlayerMoney ( thePlayer, amount ) --take the amount of money from the player
end

See Also