Multi Theft Auto: Wiki:Exports.global:giveMoney

From Multi Theft Auto: Wiki
Revision as of 04:42, 28 February 2021 by Oldmr3b (talk | contribs)
Jump to navigation Jump to search

exports.global:giveMoney

The function gives the player money in RolePlay

Syntax

bool exports.global:giveMoney ( theElement, amount )

OOP Syntax Help! I don't understand this!

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


Required Arguments

  • thePlayer: the player you are giving the money to..
  • 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 - Server

This example gives a player money when using "givemoney" command.

function givePlayerMoney ( thePlayer, command, amount ) --when the givecash command is called
	exports.global:giveMoney ( thePlayer, amount ) --give the player money according to the amount
end
addCommandHandler ( "givemoney", givePlayerMoney) --add a handler function for the command "givecash"
Click to collapse [-]
Example 2 - Client

This example gives a player money when using "givemoney" command.

function givePlayerMoney ( command, amount ) --when the givecash command is called
	exports.global:giveMoney ( localPlayer, amount ) --give the player money according to the amount
end
addCommandHandler ( "givemoney", givePlayerMoney) --add a handler function for the command "givecash"