CMoveData.GetMaxSpeed

From GMod Wiki

Revision as of 22:00, 2 March 2010 by Crazy Quebecer (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Function
Syntax MoveData:GetMaxSpeed( )
Description:
Returns the speed of the player
Returns: Number
In Object: CMoveData
Realm: NewerShared.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=CMoveData.GetMaxSpeed]CMoveData.GetMaxSpeed [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]



Examples

DescriptionThis example changes the frequency of step sounds depending of the type of ground.
Used onNewerShared.png
Code
function GM:PlayerStepSoundTime( ply, iType, bWalking )
 
	local fStepTime = 350
	local fMaxSpeed = ply:GetMaxSpeed()
 
	if ( iType == STEPSOUNDTIME_NORMAL || iType == STEPSOUNDTIME_WATER_FOOT ) then
 
		if ( fMaxSpeed <= 100 ) then 
			fStepTime = 400
		elseif ( fMaxSpeed <= 300 ) then 
			fStepTime = 350
		else 
			fStepTime = 250 
		end
 
	elseif ( iType == STEPSOUNDTIME_ON_LADDER ) then
 
		fStepTime = 450 
 
	elseif ( iType == STEPSOUNDTIME_WATER_KNEE ) then
 
		fStepTime = 600 
 
	end
 
	// Step slower if crouching
	if ( ply:Crouching() ) then
		fStepTime = fStepTime + 50
	end
 
	return fStepTime
 
end
OutputN/A
Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox