WEAPON/TranslateActivity

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
(Created page with "{{Hook |Name=TranslateActivity |Parent=WEAPON |Description= |Realm= }}")
 
m (Added actual enum to description)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
{{Hook
 
{{Hook
|Name=TranslateActivity
+
|Description=Translate a player's Activity into a weapon's activity, depending on how you want the player to be holding the weapon.
|Parent=WEAPON
+
 
|Description=
+
For example, ACT_MP_RUN becomes ACT_HL2MP_RUN_PISTOL.
|Realm=
+
|Realm=Shared
 +
|Predicted=No
 +
}}
 +
{{Arg
 +
|type=number
 +
|name=act
 +
|desc=The activity to translate
 +
}}
 +
{{Ret
 +
|type=number
 +
|desc=The translated activity
 +
}}
 +
{{Example
 +
|Description=Default action
 +
|Code=function SWEP:TranslateActivity( act )
 +
 
 +
if ( self.Owner:IsNPC() ) then
 +
if ( self.ActivityTranslateAI[ act ] ) then
 +
return self.ActivityTranslateAI[ act ]
 +
end
 +
return -1
 +
end
 +
 
 +
if ( self.ActivityTranslate[ act ] != nil ) then
 +
return self.ActivityTranslate[ act ]
 +
end
 +
 
 +
return -1
 +
 
 +
end
 
}}
 
}}

Latest revision as of 06:03, 14 April 2017

 WEAPON:TranslateActivity( )

Contents

Description

Translate a player's Activity into a weapon's activity, depending on how you want the player to be holding the weapon.

For example, ACT_MP_RUN becomes ACT_HL2MP_RUN_PISTOL.

Arguments

number act

The activity to translate

Returns

number

The translated activity

Examples

Example

Default action

function SWEP:TranslateActivity( act )

	if ( self.Owner:IsNPC() ) then
		if ( self.ActivityTranslateAI[ act ] ) then
			return self.ActivityTranslateAI[ act ]
		end
		return -1
	end

	if ( self.ActivityTranslate[ act ] != nil ) then
		return self.ActivityTranslate[ act ]
	end

	return -1

end


Personal tools
Navigation