OnClientPlayerWeaponSwitch: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
No edit summary
Line 1: Line 1:
[[Category:Incomplete Event]]
__NOTOC__
{{Client event}}
This event is triggered whenever a player switches his weapon.


__NOTOC__
==Parameters==
This event is blahblah and is used for blahblah.
 
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
void onClientPlayerWeaponSwitch ( int previous, int current )
int previousWeapon, int currentWeapon
</syntaxhighlight>  
</syntaxhighlight>  
*'''previousWeapon''': An integer representing the previous weapon the player had before he switched.
*'''currentWeapon''': An integer representing the new weapon the player has.
==Source==
The [[event system#Event source|source]] of this event is the [[player]] who changed his weapon


==Example==  
==Example==  
This example does...
This example disables the use of aiming for the minigun.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
--This line does...
function disableMinigunOnSwitch ( prevID, newID )
blabhalbalhb --abababa
if newID == 38 then --if the switched weapon is the minigun
--This line does this...
toggleControl ( "aim_weapon", false ) --disable the aim button
mooo
else --if it isnt the minigun
toggleControl ( "aim_weapon", true ) --renable the aim button
end
end
addEventHandler ( "onClientPlayerWeaponSwitch", getRootElement(), disableMinigunOnSwitch )
</syntaxhighlight>
</syntaxhighlight>
==See Also==
{{Event_functions}}

Revision as of 13:30, 22 October 2007

This event is triggered whenever a player switches his weapon.

Parameters

int previousWeapon, int currentWeapon
  • previousWeapon: An integer representing the previous weapon the player had before he switched.
  • currentWeapon: An integer representing the new weapon 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 ( prevID, newID )
	if newID == 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