Garry's Mod

Garry's Mod

Original Counter Strike: Source Playermodels
HATE™ 19 Aug, 2024 @ 6:28pm
Allow to Override Holdtype Based on Weapon/Swep
Some hold types don't look right and etc.

Please add a way to override thirdperson animations for certain sweps/weapons.

Here's some code ChatGPT generated. I have no idea how to actually hook it and since I don't pay for it, I wasn't able to get a complete LUA.


-- Function to override animations for specific weapons local function OverrideWeaponAnimations(pl) local weapon = pl:GetActiveWeapon() -- Check if the weapon is valid if not weapon:IsValid() then return end -- Override animations for specific weapons local weaponClass = weapon:GetClass() if weaponClass == "weapon_physgun" then -- Override with AWP animations OverrideAWPAnimations(pl) elseif weaponClass == "weapon_pistol" then -- Example: Override with custom animations for a pistol (replace with actual sequences) OverridePistolAnimations(pl) elseif weaponClass == "weapon_smg1" then -- Example: Override with custom animations for an SMG (replace with actual sequences) OverrideSMGAnimations(pl) end end -- Helper function to apply AWP animations local function OverrideAWPAnimations(pl) if pl:Crouching() then if pl:GetVelocity():Length2D() > 10 then pl:SetSequence(pl:LookupSequence("crouch_walk_upper_awp")) else pl:SetSequence(pl:LookupSequence("crouch_idle_upper_awp")) end else if pl:GetVelocity():Length2D() > 10 then if pl:KeyDown(IN_WALK) then pl:SetSequence(pl:LookupSequence("walk_upper_awp")) else pl:SetSequence(pl:LookupSequence("run_upper_awp")) end else pl:SetSequence(pl:LookupSequence("idle_upper_awp")) end end end -- Helper function for Pistol animations (example) local function OverridePistolAnimations(pl) if pl:Crouching() then pl:SetSequence(pl:LookupSequence("crouch_idle_upper_pistol")) -- Replace with actual sequence else pl:SetSequence(pl:LookupSequence("idle_upper_pistol")) -- Replace with actual sequence end end -- Helper function for SMG animations (example) local function OverrideSMGAnimations(pl) if pl:Crouching() then pl:SetSequence(pl:LookupSequence("crouch_idle_upper_smg")) -- Replace with actual sequence else pl:SetSequence(pl:LookupSequence("idle_upper_smg")) -- Replace with actual sequence end end -- Hook into CalcMainActivity to override animations hook.Add("CalcMainActivity", "OverrideSpecificWeaponAnimations", function(pl, vel) OverrideWeaponAnimations(pl) -- Default activity handling (can be customized further if needed) return pl:SelectWeightedSequence(ACT_HL2MP_IDLE), pl:SelectWeightedSequence(ACT_HL2MP_IDLE) end)
< >
Showing 1-3 of 3 comments
Jenny/Siobhan  [developer] 19 Aug, 2024 @ 7:27pm 
ai generated code? bleh
however i could use it in the near future
Jenny/Siobhan  [developer] 19 Aug, 2024 @ 7:27pm 
thanks for your suggestion
HATE™ 21 Aug, 2024 @ 2:46pm 
Edit (2024-09-02):

Turns out the script wasn't watching for current weapon in both shooting and reload events. Though this was a pretty obvious mistake I corrected it. Feel free to paste as you'd like. Optionally credit if you feel like it.

https://pastebin.com/raw/JZSyLMwS

Looking forward to any future improvements this gets. Would be nice if the snapping would get fixed or be reduced and any performance issues with PAC also get addressed if there are any.
Last edited by HATE™; 2 Sep, 2024 @ 7:46pm
< >
Showing 1-3 of 3 comments
Per page: 1530 50