Multi Theft Auto: Wiki:Exports.global:giveMoney: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "role play")
 
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
role play
== exports.global:giveMoney ==
The function gives the player money in RolePlay
==Syntax==
<syntaxhighlight lang="lua">
bool exports.global:giveMoney ( theElement, amount )
</syntaxhighlight>
{{OOP||player:giveMoney|.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== 
<section show="true" name="Example 1 - Server" class="server">
This example gives a player money when using "givemoney" command.
<syntaxhighlight lang="lua">
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"
</syntaxhighlight>
</section>
<section show="true" name="Example 2 - Client" class="client">
This example gives a player money when using "givemoney" command.
<syntaxhighlight lang="lua">
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"
</syntaxhighlight>
</section>

Latest revision as of 04:44, 28 February 2021

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"