GivePlayerMoney: Difference between revisions
		
		
		
		
		
		Jump to navigation
		Jump to search
		
				
		
		
	
No edit summary  | 
				No edit summary  | 
				||
| Line 13: | Line 13: | ||
<syntaxhighlight lang="lua">addEventHandler ( "onPlayerConsole", root, "onConsole" )  | <syntaxhighlight lang="lua">addEventHandler ( "onPlayerConsole", root, "onConsole" )  | ||
function onConsole ( message )  | function onConsole ( message )  | ||
	if gettok(message, 1, 32) == "!givecash" then --when the player types !givecash  | 	if gettok(message, 1, 32) == "!givecash" then --when the player types !givecash on console  | ||
		givePlayerMoney ( source, 100 )  --add $100 to player's money  | 		givePlayerMoney ( source, 100 )  --add $100 to player's money  | ||
	end  | 	end  | ||
end</syntaxhighlight>  | end</syntaxhighlight>  | ||
Revision as of 08:54, 18 May 2006
Adds money to the player's current money amount.
Syntax
givePlayerMoney ( player, money )
Required Arguments
- Player: Tells the function to give money to a player
 - Money: A whole integer specifying the amount of money to give to the player
 
Example
Note: Player is not defined in this function, so I used source to point to the player. You can read about using source on the LUA Tips and Tricks page
addEventHandler ( "onPlayerConsole", root, "onConsole" ) function onConsole ( message ) if gettok(message, 1, 32) == "!givecash" then --when the player types !givecash on console givePlayerMoney ( source, 100 ) --add $100 to player's money end end