OnPlayerWeaponSwitch

From Multi Theft Auto: Wiki
Revision as of 14:34, 2 December 2006 by Talidan (talk | contribs)
Jump to navigation Jump to search

This event is triggered when a player switches weapons.

Syntax

void onPlayerWeaponSwitch ( int previousWeaponID, int currentWeaponID )

Variables

  • previousWeaponID: An integer representing the weapon that was switched from
  • currentWeaponID: An integer representing the weapon that was switched to

Example

This example disables use of the minigun

--add an event handler for onPlayerWeaponSwitch
addEventHandler ( "onPlayerWeaponSwitch", getRootElement(), "weaponSwitchDisableMinigun" )
function weaponSwitchDisableMinigun ( previousWeaponID, currentWeaponID ) --when a player switches his weapon
if currentWeaponID == 38 then --if the weapon ID is minigun
     toggleControl ( source, "fire", false ) --disable the fire button
else --otherwise
     toggleControl ( source, "fire", true )  --enable it
end

See Also