OnClientPlayerWeaponSwitch: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
m (See Also for client player events)
(Clientside uses slots not weapons.)
Line 5: Line 5:
==Parameters==
==Parameters==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
int previousWeapon, int currentWeapon
int previousWeaponSlot, int currentWeaponSlot
</syntaxhighlight>  
</syntaxhighlight>  


*'''previousWeapon''': An integer representing the previous weapon the player had before he switched.
*'''previousWeaponSlot''': An integer representing the previous weapon slot the player had before he switched.
*'''currentWeapon''': An integer representing the new weapon the player has.
*'''currentWeaponSlot''': An integer representing the new weapon slot the player has.


==Source==
==Source==
Line 17: Line 17:
This example disables the use of aiming for the minigun.
This example disables the use of aiming for the minigun.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function disableMinigunOnSwitch ( prevID, newID )
function disableMinigunOnSwitch ( prevSlot, newSlot )
if newID == 38 then --if the switched weapon is the minigun
if getPlayerWeapon(getLocalPlayer(),newSlot) == 38 then --if the switched weapon is the minigun
toggleControl ( "aim_weapon", false ) --disable the aim button
toggleControl ( "aim_weapon", false ) --disable the aim button
else --if it isnt the minigun
else --if it isnt the minigun

Revision as of 03:42, 2 February 2008

This event is triggered whenever a player switches his weapon.

Parameters

int previousWeaponSlot, int currentWeaponSlot
  • previousWeaponSlot: An integer representing the previous weapon slot the player had before he switched.
  • currentWeaponSlot: An integer representing the new weapon slot the player has.

Source

The source of this event is the player who changed his weapon

Example

This example disables the use of aiming for the minigun.

function disableMinigunOnSwitch ( prevSlot, newSlot )
	if getPlayerWeapon(getLocalPlayer(),newSlot) == 38 then --if the switched weapon is the minigun
		toggleControl ( "aim_weapon", false ) --disable the aim button
	else --if it isnt the minigun
		toggleControl ( "aim_weapon", true ) --renable the aim button
	end
end
addEventHandler ( "onClientPlayerWeaponSwitch", getRootElement(), disableMinigunOnSwitch )

See Also

Client player events


Client event functions