OnPlayerWeaponSwitch: Difference between revisions
Jump to navigation
Jump to search
m (See Also for server events) |
LeetWoovie (talk | contribs) m (It only had 1 end.) |
||
Line 18: | Line 18: | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function weaponSwitchDisableMinigun ( previousWeaponID, currentWeaponID ) --when a player switches his weapon | function weaponSwitchDisableMinigun ( previousWeaponID, currentWeaponID ) --when a player switches his weapon | ||
if currentWeaponID == 38 then --if the weapon ID is minigun | if currentWeaponID == 38 then --if the weapon ID is minigun | ||
toggleControl ( source, "fire", false ) --disable the fire button | |||
else --otherwise | else --otherwise | ||
toggleControl ( source, "fire", true ) --enable it | |||
end | |||
end | end | ||
--add an event handler for onPlayerWeaponSwitch | --add an event handler for onPlayerWeaponSwitch |
Revision as of 06:36, 25 August 2009
This event is triggered when a player switches weapons.
Parameters
int previousWeaponID, int currentWeaponID
- previousWeaponID: An integer representing the weapon that was switched from
- currentWeaponID: An integer representing the weapon that was switched to
Source
The source of this event is the player that switched his weapon.
Example
This example disables use of the minigun upon switch. It should be noted that this can be done more efficiently clientside.
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 end --add an event handler for onPlayerWeaponSwitch addEventHandler ( "onPlayerWeaponSwitch", getRootElement(), weaponSwitchDisableMinigun )
See Also
Player events
- onPlayerACInfo
- onPlayerBan
- onPlayerChangeNick
- onPlayerChat
- onPlayerClick
- onPlayerCommand
- onPlayerConnect
- onPlayerContact
- onPlayerDamage
- onPlayerJoin
- onPlayerLogin
- onPlayerLogout
- onPlayerMarkerHit
- onPlayerMarkerLeave
- onPlayerModInfo
- onPlayerMute
- onPlayerNetworkStatus
- onPlayerPickupHit
- onPlayerPickupLeave
- onPlayerPickupUse
- onPlayerPrivateMessage
- onPlayerQuit
- onPlayerScreenShot
- onPlayerSpawn
- onPlayerStealthKill
- onPlayerTarget
- onPlayerUnmute
- onPlayerVehicleEnter
- onPlayerVehicleExit
- onPlayerVoiceStart
- onPlayerVoiceStop
- onPlayerWasted
- onPlayerWeaponFire
- onPlayerWeaponSwitch
Event functions
- addEvent
- addEventHandler
- cancelEvent
- cancelLatentEvent
- getEventHandlers
- getLatentEventHandles
- getLatentEventStatus
- removeEventHandler
- triggerEvent
- wasEventCancelled