Personal tools

Lua/Events/Client/InputPoll

From JC2-MP Documentation

< Lua
Jump to: navigation, search
Name    InputPoll
Arguments (in table)    None
Return option    None


Description

This event is the only place you should use the Input:SetValue function. It is called every frame.

Examples

Force the handbrake on while in any vehicle

Foo = function(args)
	Input:SetValue(Action.Handbrake, 1.0)
end
 
Events:Subscribe("InputPoll", Foo)

Simulate broken car steering

Foo = function(args)
	if Input:GetValue(Action.TurnRight) == 0 and Input:GetValue(Action.TurnLeft) == 0 then
		local value = os.clock() + (math.random() - 0.5)
		if value % 1 > 0.5 then
			Input:SetValue(Action.TurnRight, 1)
		else
			Input:SetValue(Action.TurnLeft, 1)
		end
	end
end
 
Events:Subscribe("InputPoll", Foo)