Squirrel/Server/Events/Player/onPlayerCashChange
From Liberty Unleashed Wiki
(Difference between revisions)
(New page: __NOTOC__ This is called when a player's money amount is changed == Syntax == <code>function onPlayerCashChange( player, oldCash, newCash )</code> == Parameters == * '''player''' - The...) |
|||
Line 1: | Line 1: | ||
− | + | {{Squirrel/Title|onPlayerCashChange}} | |
− | This is called when a player's money amount is changed | + | This is called when a player's money amount is changed. |
== Syntax == | == Syntax == | ||
− | <code>function onPlayerCashChange( player, oldCash, newCash )</code> | + | <code>function onPlayerCashChange( Player player, int oldCash, int newCash )</code> |
− | == | + | === Arguments === |
* '''player''' - The player pointer | * '''player''' - The player pointer | ||
* '''oldCash''' - Amount of cash prior to the detected change | * '''oldCash''' - Amount of cash prior to the detected change | ||
* '''newCash''' - Amount of cash after the detected change | * '''newCash''' - Amount of cash after the detected change | ||
+ | |||
+ | === Returns === | ||
+ | |||
+ | This event does not handle return values. | ||
== Example == | == Example == | ||
− | This example will message a player | + | This example will message a player when they have more than $1,000,000. |
<code lang="squirrel"> | <code lang="squirrel"> | ||
function onPlayerCashChange( player, oldCash, newCash ) | function onPlayerCashChange( player, oldCash, newCash ) | ||
{ | { | ||
− | if ( oldCash | + | if ( oldCash > newCash && newCash > 1000000 ) MessagePlayer( "You're now a millionaire!", player ); |
+ | |||
+ | return 1; | ||
} | } | ||
</code> | </code> | ||
Line 25: | Line 31: | ||
=== Notes === | === Notes === | ||
− | The function [[Squirrel/Server/Functions/Messages/MessagePlayer|MessagePlayer]] was used | + | The function [[Squirrel/Server/Functions/Messages/MessagePlayer|MessagePlayer]] was used in this example. More info about it can be found in the corresponding page. |
== Related Events == | == Related Events == | ||
{{Squirrel/Server/Events/Player}} | {{Squirrel/Server/Events/Player}} |
Latest revision as of 18:42, 22 December 2010
This is called when a player's money amount is changed.
[edit] Syntax
function onPlayerCashChange( Player player, int oldCash, int newCash )
[edit] Arguments
- player - The player pointer
- oldCash - Amount of cash prior to the detected change
- newCash - Amount of cash after the detected change
[edit] Returns
This event does not handle return values.
[edit] Example
This example will message a player when they have more than $1,000,000.
function onPlayerCashChange( player, oldCash, newCash ) { if ( oldCash > newCash && newCash > 1000000 ) MessagePlayer( "You're now a millionaire!", player ); return 1; }
[edit] Notes
The function MessagePlayer was used in this example. More info about it can be found in the corresponding page.
[edit] Related Events
- onPlayerAction
- onPlayerArmourChange
- onPlayerCashChange
- onPlayerChat
- onPlayerCommand
- onPlayerConnect
- onPlayerDeath
- onPlayerFall
- onPlayerHealthChange
- onPlayerIslandChange
- onPlayerJoin
- onPlayerKeyStateChange
- onPlayerKill
- onPlayerPart
- onPlayerScoreChange
- onPlayerSkinChange
- onPlayerSpawn
- onPlayerUpdate
- onPlayerTeamChange
- onPlayerUseDetonator
- onPlayerVirtualWorldChange
- onPlayerWeaponChange