Squirrel/Server/Events/Player/onPlayerCashChange

From Liberty Unleashed Wiki
(Difference between revisions)
Jump to: navigation, search
(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:
__NOTOC__
+
{{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>
  
== Parameters ==
+
=== 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 if their amount of money increases
+
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 < newCash ) MessagePlayer( "Your cash amount just increased", player );
+
     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 in in this example. More info about it can be found in the corresponding page.
+
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

Home   |   Squirrel Scripting   |   Server Functions   |   Server Events   |   Client Functions   |   Client Events

This is called when a player's money amount is changed.

[edit] Syntax

  1. 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.

  1.  
  2. function onPlayerCashChange( player, oldCash, newCash )
  3. {
  4. if ( oldCash > newCash && newCash > 1000000 ) MessagePlayer( "You're now a millionaire!", player );
  5. return 1;
  6. }
  7.  

[edit] Notes

The function MessagePlayer was used in this example. More info about it can be found in the corresponding page.

[edit] Related Events

Personal tools
Namespaces

Variants
Actions
Navigation
scripting
Toolbox