TakePlayerMoney: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
m (global -> server)
mNo edit summary
Line 29: Line 29:
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.
<section name="Server" class="server" show="true">
<section name="Server" class="server" show="true">
This takes a specified amount of money from your wallet.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function takeCash ( thePlayer, command, amount )    -- when the takecash command is called
function takeCash ( thePlayer, command, amount )    -- when the takecash command is called

Revision as of 18:04, 18 February 2012

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 )

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 )

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

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

Click to collapse [-]
Server

This takes a specified amount of money from your wallet.

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