TakePlayerMoney: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
m (fix oop syntax 2)
 
(10 intermediate revisions by 7 users not shown)
Line 2: Line 2:
{{Server client function}}
{{Server client function}}
This function subtracts money from a [[player]]'s current money amount.
This function subtracts money from a [[player]]'s current money amount.
{{Note|Using this function client side (not recommended) will not change a players money server side.}}


==Syntax==  
==Syntax==  
Line 8: Line 9:
bool takePlayerMoney ( player thePlayer, int amount )
bool takePlayerMoney ( player thePlayer, int amount )
</syntaxhighlight>  
</syntaxhighlight>  
 
{{OOP||[[player]]:takeMoney|money|}}
====Required Arguments====  
====Required Arguments====  
*'''thePlayer:''' the [[player]] you are taking the money from.
*'''thePlayer:''' the [[player]] you are taking the money from.
Line 17: Line 18:
bool takePlayerMoney ( int amount )
bool takePlayerMoney ( int amount )
</syntaxhighlight>
</syntaxhighlight>
 
{{OOP||[[Player]].takeMoney}}
====Required Arguments====  
====Required Arguments====  
*'''amount:''' an integer number specifying the amount of money to take from the player.
*'''amount:''' an integer number specifying the amount of money to take from the player.
Line 26: Line 27:


==Example==   
==Example==   
<section name="Server" class="server" show="true">
This example takes money from a player when he types "takecash ''number''" in the console.
This example takes money from a player when he types "takecash ''number''" in the console.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
Line 33: Line 35:
addCommandHandler ( "takecash", takeCash )          -- add a handler function for the command "takecash"
addCommandHandler ( "takecash", takeCash )          -- add a handler function for the command "takecash"
</syntaxhighlight>
</syntaxhighlight>
</section>


==See Also==
==See Also==
{{Player functions}}
{{Player functions}}
[[ru:takePlayerMoney]]

Latest revision as of 04:28, 29 December 2014

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

[[{{{image}}}|link=|]] Note: Using this function client side (not recommended) will not change a players money server side.

Syntax

Click to collapse [-]
Server
bool takePlayerMoney ( player thePlayer, int amount )

OOP Syntax Help! I don't understand this!

Method: player:takeMoney(...)
Variable: .money


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.
Click to collapse [-]
Client
bool takePlayerMoney ( int amount )

OOP Syntax Help! I don't understand this!

Method: Player.takeMoney(...)


Required Arguments

  • 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

Click to collapse [-]
Server

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

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

See Also