You know, I want to use it so it works like this:
[CODE]...
tracedata.start = pl:EyePos() + (pl:GetUp() * 38) + (pl:GetForward() * 1)
tracedata.endpos = pl:EyePos()+ (pl:GetUp() * 50) + (pl:GetForward() * 64)
tracedata.filter = pl
if trace.Hit then
crouch -- but not toggle(use RunConsoleCommand), because, I want it so when the trace doesnt hit you can crouch and stand.
end
...[/CODE]
Thanks and sorry for my bad english
I don't know of a way to force them crouch other than the console commands. I would approach it like this:
[lua]
--Determine if they are already crouching, and if it's because we forced them to
local IsCrouching = ply:Crouching()
local WasForced = ply.ForcedCrouching or false
if not IsCrouching then
--We aren't crouching yet, so do the trace and see if we need to crouch
-- todo: trace goes here
if trace.Hit then
--Force them to crouch
ply:ConCommand("+crouch")
ply.ForcedCrouching = true
end
else
--We are already crouching, check if it was forced?
if WasForced then
--Check if we can stand up yet
--todo: trace goes here
if not trace.Hit then
--Force them to stand up, and reset our 'forced status'
ply:ConCommand("-crouch")
ply.ForcedCrouching = false
end
end
end[/lua]
[QUOTE=wh1t3rabbit;44219414]I don't know of a way to force them crouch other than the console commands. I would approach it like this:
[lua]
--Determine if they are already crouching, and if it's because we forced them to
local IsCrouching = ply:Crouching()
local WasForced = ply.ForcedCrouching or false
if not IsCrouching then
--We aren't crouching yet, so do the trace and see if we need to crouch
-- todo: trace goes here
if trace.Hit then
--Force them to crouch
ply:ConCommand("+crouch")
ply.ForcedCrouching = true
end
else
--We are already crouching, check if it was forced?
if WasForced then
--Check if we can stand up yet
--todo: trace goes here
if not trace.Hit then
--Force them to stand up, and reset our 'forced status'
ply:ConCommand("-crouch")
ply.ForcedCrouching = false
end
end
end[/lua][/QUOTE]
Well I tried to do something like that.
It works wierdly. You see, I used "RunConsoleCommand("+duck") and it worked fine when it forces the player to crouch, but, when you try to make the player stand up, it just doesnt work. The command doesnt wants to work. (I'm talking about RunConsoleCommand("-duck"))
Force it in CreateMove
[lua]function GM:CreateMove(cmd)
if bit.band(cmd:GetButtons(), IN_DUCK) == 0 then
cmd:SetButtons(cmd:GetButtons() + IN_DUCK)
end
end[/lua]
[QUOTE=JetBoom;44222813]Force it in CreateMove
[lua]function GM:CreateMove(cmd)
if bit.band(cmd:GetButtons(), IN_DUCK) == 0 then
cmd:SetButtons(cmd:GetButtons() + IN_DUCK)
end
end[/lua][/QUOTE]
why do people use bit.band when you can easily check it by doing cmd:KeyDown
also you should use bit.band with cmd:SetButtons because that's the proper way
[QUOTE=MeepDarknessM;44223643]why do people use bit.band when you can easily check it by doing cmd:KeyDown
also you should use bit.band with cmd:SetButtons because that's the proper way[/QUOTE]
Might as well do this if you really want to nitpick.
[lua]function GM:CreateMove(cmd)
cmd:SetButtons(bit.bor(cmd:GetButtons(), IN_DUCK))
end[/lua]
[QUOTE=JetBoom;44222813]Force it in CreateMove
[lua]function GM:CreateMove(cmd)
if bit.band(cmd:GetButtons(), IN_DUCK) == 0 then
cmd:SetButtons(cmd:GetButtons() + IN_DUCK)
end
end[/lua][/QUOTE]
How can I use this with the trace that I wrote down?
-snip-
Sorry, you need to Log In to post a reply to this thread.