Squirrel/Server/Events/Player/onPlayerWeaponChange
From Liberty Unleashed Wiki
(Difference between revisions)
(→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
This is called when a player switches their weapon.
Syntax
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.
function onPlayerWeaponChange( player, oldwep, newwep, ammo ) { if ( newwep == WEP_GRENADE ) { MessagePlayer( "Grenades are not allowed!", player ); player.ClearWeapons(); } return 1; }
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
- onPlayerAction
- onPlayerArmourChange
- onPlayerCashChange
- onPlayerChat
- onPlayerCommand
- onPlayerConnect
- onPlayerDeath
- onPlayerFall
- onPlayerHealthChange
- onPlayerIslandChange
- onPlayerJoin
- onPlayerKeyStateChange
- onPlayerKill
- onPlayerPart
- onPlayerScoreChange
- onPlayerSkinChange
- onPlayerSpawn
- onPlayerUpdate
- onPlayerTeamChange
- onPlayerUseDetonator
- onPlayerVirtualWorldChange
- onPlayerWeaponChange