Squirrel/Server/Events/Player/onPlayerWeaponChange

From Liberty Unleashed Wiki
(Difference between revisions)
Jump to: navigation, search
 
Line 4: Line 4:
 
== Syntax ==
 
== Syntax ==
  
<code>function onPlayerWeaponChange( player, oldWeapon, newWeapon, iAmoo )</code>
+
<code>function onPlayerWeaponChange( player, oldWeapon, newWeapon, iAmmo )</code>
  
 
=== Arguments ===
 
=== Arguments ===

Latest revision as of 13:37, 17 February 2015

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

This is called when a player switches their weapon.

[edit] Syntax

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

[edit] 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

[edit] Returns

This event does not handle return values.

[edit] 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.  

[edit] Notes

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

[edit] Related Events

Personal tools
Namespaces

Variants
Actions
Navigation
scripting
Toolbox