onPlayerWeaponChange

From Liberty Unleashed Wiki
Jump to: navigation, search
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, iAmmo )

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