• Disable ducking in air / code snipet
    9 replies, posted
I need a code snipet, that disables ducking in air, I just can't do it myself. I am trying around since a week and can't get it to work properly. I just managed to disable ducking at all ;)
If the player isn't on the ground in a Move hook, remove the FL_DUCKING flag. Don't know when exactly Move is ran in the C++ movement code hierarchy, so you may have to remove the IN_DUCK key if it doesn't work.
I tried both already, I used the player hooks, the gamemode hooks and couldn't get it to work properly. Just screwing up crouching completly as I said.
Try the other movement hooks, like SetupMove and CreateMove.
I tried also. I don't know what I am doing wrong. I just added to GM:Move() [lua]if pl:GetState() == KNOCKEDDOWN then pl:RemoveFlags(FL_DUCKING) pl:RemoveFlags(FL_ANIMDUCKING) end[/lua] Which returns in the player never being able to duck again, but the duck viewoffst still goes down.
[code]local CMoveData = FindMetaTable( "CMoveData" ) function CMoveData:RemoveKeys( keys ) -- Using bitwise operations to clear the key bits. local newbuttons = bit.band( self:GetButtons(), bit.bnot( keys ) ) self:SetButtons( newbuttons ) end hook.Add( "SetupMove", "Disable Crouching", function( ply, mvd, cmd ) if mvd:KeyDown( IN_DUCK ) and !ply:IsFlagSet( FL_ONGROUND ) then mvd:RemoveKeys( IN_DUCK ) end end )[/code]
Wouldn't that remove it permanently? This topic is sooo confusing. :P
[QUOTE=mcNuggets1;52090689]Wouldn't that remove it permanently? This topic is sooo confusing. :P[/QUOTE] That would in fact do it permanently (When you're in the air you won't be able to duck) You could define the function that disables Ducking and Add/Remove the hook appropriately when your terms are met If you're new to GLua/coding in general and have no idea what I just said you might want to take a look at [URL="https://facepunch.com/showthread.php?t=1557600"]this[/URL]
[QUOTE=JasonMan34;52090699]That would in fact do it permanently (When you're in the air you won't be able to duck) You could define the function that disables Ducking and Add/Remove the hook appropriately when your terms are met If you're new to GLua/coding in general and have no idea what I just said you might want to take a look at [URL="https://facepunch.com/showthread.php?t=1557600"]this[/URL][/QUOTE] No I am not new, just new to this specific topic. I never played around with move-hooks.
[QUOTE=mcNuggets1;52090689]Wouldn't that remove it permanently?[/QUOTE] It'd only disable it if they're in the air.
Sorry, you need to Log In to post a reply to this thread.