givePlayerMoney | Multi Theft Auto: Wiki Skip to content

givePlayerMoney

Client-side
Server-side
Shared

Manual Review Required

Please finish this page using the corresponding Old Wiki article. Go to Contribution guidelines for more information.


This function adds money to a player's current money amount. To set absolute values, setPlayerMoney can be used.

Note

Using this function client side (not recommended) will not change a players money server side.

Note

As of MTA SA version 1.5.9, despite the documentation claiming that amount should be a positive integer, this function does work with negative values or zero. In that case the function does still add the number to the game money value, in the negative case resulting in a decreased value.

OOP Syntax Help! I don't understand this!

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

Syntax

bool givePlayerMoney ( int amount )
Required Arguments
  • amount: a positive integer number specifying the amount of money to give to the player.

Returns

  • bool: value

Returns true if the money was added, or false if invalid parameters were passed.

Code Examples

server

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

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

See Also