SWEP Holdtype Fix

[release]
I made this hacky and probbably buggy fix for most SWEPs being held as pistols, i got tired of everything clogging up with theads about this problem.

This should work in multiplayer, but i havent tested it in multiplayer yet

Bugs:[ul]When you deploy the weapon it goes pistol holdtype then back to what it should be, no idea why this happens[/ul]

Download:
http://www.garrysmod.org/img/?t=dll&id=98822
[/release]

:siren: WARNING: This is very hacky, feel free to post better ways of doing it :siren:

You don’t need to do hackish things like this to fix the issue, as it has been stated in about 10 topics already, there are two things you need to do to fix the glitch as it was stated by AzuiSleet about 3-4 updates ago.

You must move HoldType out of SERVER/CLIENT specific blocks and allow it to be used on both the client and server, and if you override a SWEPS Initialize function, you need to remove SERVER/CLIENT guards around SetWeaponHoldType and allow it to also be called on both the client and server.

For example:
[lua]function SWEP:Initialize()
if SERVER then
self:SetWeaponHoldType(“melee”)
end
end[/lua]

Would become:
[lua]function SWEP:Initialize()
self:SetWeaponHoldType(“melee”)
end[/lua]

And the SWEP.HoldType just needs to be moved out of the blocks like that as well.

I do know that, though its very annoying having to go though all like 100 weapons in a pack fixing this, this is for those who dont know how to fix and for those packs that have way too much stuff for someone to fix

Have you actually tried doing that to about 1000 different lua scripts? Its boring and risky, one wrong line or space and you could potentially ruin the sweps. I personally prefer this “hacky” method :smiley:

Thank you! Now my knives wont go “Pistol” again!

Awsome!

Where the heck do I install this?

What would be more useful is a script that applies the fix to the lua files directly. :smile:

Noticed it dosent work for everyone on every SWEP, but it seems to work for some

I don’t get it… xþ

Its for fixing the holdtypes of older weapons after an update

Also this got on front page on garrysmod.org

Although some of the logic for this is messy, specifically the method and member value names; the methodology for implementing this fix is absolutely right.

Nice work, Tobba, I was considering writing a fix just like this.

Then I remembered I don’t write GMod addons anymore.

Whatever I did it became a stupid infinite loop so it became kinda messy fixing that.

Thanks Andrew

Yes, I know I’m bumping a super old thread.

I may just have old sweps but I’ve never seen commands like that even though I KNOW there supposed to be there, my swep holdtype block contains this:

if (SERVER) then
AddCSLuaFile(“shared.lua”)
SWEP.HoldType = “ar2”

I’m pretty sure these commands where supposed to be changed because of the recent update, but their not, this is in shared Lua by the way.