GivePlayerMoney: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
Line 3: Line 3:


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


===Required Arguments===  
===Required Arguments===  
*'''Player:''' Tells the function to give money to a player
*'''thePlayer:''' The [[player]] to whom you are giving the money.
*'''Money:''' A whole integer specifying the amount of money to give to the player
*'''amount:''' An 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==   
==Example==   
This example gives a player money when he types "givecash" in console
This example gives a player money when he types "givecash" in console.
<syntaxhighlight lang="lua">addCommandHandler ( "givecash", "giveCash" ) --add the command "givecash"
<syntaxhighlight lang="lua">
function giveCash ( player, command, amount ) --when the givecash command is called
addCommandHandler ( "givecash", "giveCash" ) --add a handler function for the command "givecash"
givePlayerMoney ( player, amount ) --gives the player money according to the amount
function giveCash ( thePlayer, command, amount ) --when the givecash command is called
end</syntaxhighlight>
givePlayerMoney ( thePlayer, amount ) --give the player money according to the amount
end
</syntaxhighlight>


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

Revision as of 14:42, 25 April 2007

Adds money to the player's current money amount.

Syntax

bool givePlayerMoney ( player thePlayer, int amount )

Required Arguments

  • thePlayer: The player to whom you are giving the money.
  • amount: An 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

This example gives a player money when he types "givecash" in console.

addCommandHandler ( "givecash", "giveCash" ) --add a handler function for the command "givecash"
function giveCash ( thePlayer, command, amount ) --when the givecash command is called
	givePlayerMoney ( thePlayer, amount ) --give the player money according to the amount
end

See Also