Squirrel/Server/Events/Player/onPlayerWeaponChange

From Liberty Unleashed Wiki
(Difference between revisions)
Jump to: navigation, search
(Example)
Line 4: Line 4:
 
== Syntax ==
 
== Syntax ==
  
<code>function onPlayerWeaponChange( player, oldWeapon, newWeapon )</code>
+
<code>function onPlayerWeaponChange( player, oldWeapon, newWeapon, iAmoo )</code>
  
 
=== Arguments ===
 
=== Arguments ===
Line 11: Line 11:
 
* '''oldWeapon''' - ID of the weapon the player was wielding before the detected change
 
* '''oldWeapon''' - ID of the weapon the player was wielding before the detected change
 
* '''newWeapon''' - ID of the weapon after the change
 
* '''newWeapon''' - ID of the weapon after the change
 +
* '''iAmmo''' - Ammo of the weapon
  
 
=== Returns ===
 
=== Returns ===

Revision as of 13:35, 17 February 2015

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

This is called when a player switches their weapon.

Syntax

  1. function onPlayerWeaponChange( player, oldWeapon, newWeapon, iAmoo )

Arguments

  • player - The player pointer
  • oldWeapon - ID of the weapon the player was wielding before the detected change
  • newWeapon - ID of the weapon after the change
  • iAmmo - Ammo of the weapon

Returns

This event does not handle return values.

Example

This example will reset the player's weapons if they switch to grenades.

  1.  
  2. function onPlayerWeaponChange( player, oldwep, newwep, ammo )
  3. {
  4. if ( newwep == WEP_GRENADE )
  5. {
  6. MessagePlayer( "Grenades are not allowed!", player );
  7. player.ClearWeapons();
  8. }
  9. return 1;
  10. }
  11.  

Notes

The functions MessagePlayer and Player.ClearWeapons were used in this example. More info about them can be found in the corresponding pages.

Related Events

Personal tools
Namespaces

Variants
Actions
Navigation
scripting
Toolbox