Garry's Mod

Garry's Mod

TTT M60
15 Comments
Dorito 22 Oct, 2016 @ 9:05pm 
Can I Use This Outside Of TTT?
*Sam 11 Jul, 2015 @ 4:56pm 
Here you are, this is exactly as I'm using it on my server and I don't get any lua script errors.
http://pastebin.com/YiYaUWm1
There are a couple other changes in there too, just a heads up.
FrostyIce  [author] 11 Jul, 2015 @ 3:05am 
I'll have to look more in depth into your code when I have time. So far, when I put your changes in, the game has a draw error. If you want to just put the entire shared.lua file up on pastebin, it'll alleviate any errors that you may have when pasting. But, as of right now, I get the following when running it.

[ERROR] addons/m60/lua/weapons/weapon_ttt_m60/shared.lua:220: attempt to call method 'SetRenderOrigin' (a nil value)
1. DrawWorldModel - addons/m60/lua/weapons/weapon_ttt_m60/shared.lua:220
2. unknown - addons/m60/lua/weapons/weapon_ttt_m60/shared.lua:180

Thanks for the attempt, anyways. Glad to see someone take an interest in it.
*Sam 10 Jul, 2015 @ 5:27pm 
And in the SWEP:DrawWorldModel code, change the if not IsValid(self.owner) part to:

if not IsValid( self.Owner ) then
self:SetRenderOrigin(self.Pos)
self:SetRenderAngles(self.Ang)
self:DrawModel( )
return
end

and the if not hand part to:
if not hand then
self:SetRenderOrigin(self.Pos)
self:SetRenderAngles(self.Ang)
self:DrawModel( )
return
end
*Sam 10 Jul, 2015 @ 5:25pm 
After experimenting a bit more, I think I found a better fix that should eliminate the problem all together. It seems as though for some reason the game will sometimes not draw the weapon immediately after drop, so you have to force it to draw. The CalcAbsolutePosition code keeps track of where the weapon ACTUALLY is in the world.
You may want to check and confirm that this code is working though, I may have missed something when copying it into here:

SWEP.Pos = nil
SWEP.Ang = nil

function SWEP:CalcAbsolutePosition(pos, ang)
self.Pos = pos
self.Ang = ang
return
end

SWEP.Offset = {
Pos = {
Up = 0,
Right = 1,
Forward = -3,
},
Ang = {
Up = 0,
Right = 0,
Forward = 0,
}
}

function SWEP:Think()
self:DrawWorldModel( )
end

function SWEP:RenderOverride()
self:DrawWorldModel()
end

function SWEP:OnDrop()
self.Owner = nil
end
FrostyIce  [author] 10 Jul, 2015 @ 3:26pm 
Alright, the gma has been updated. Thanks for the help. If you don't mind, I gave you credit in the change notes for the new code.
*Sam 9 Jul, 2015 @ 9:09pm 
So I was having a play around with this and I think I partially solved the problem with the world model being drawn stationary in the air after drop.

Inside the SWEP:DrawWorldModel() code, remove the first clause:

if not IsValid( self.Owner ) then return end

and replace it with:

if not IsValid( self.Owner ) then
self:SetRenderOrigin(self:GetNetworkOrigin())
self:SetRenderAngles(self:GetNetworkAngles())
self:DrawModel( )
return
end

This KIND OF fixes the problem, the gun will sometimes still be invisible initially but will become visible in the correct location after a time.
FrostyIce  [author] 28 Apr, 2015 @ 12:54pm 
LMG/HMG is just an abbreviated way of saying Light Machine Gun/Heavy Machine Gun, which is what the M60 is.
DH1806 28 Apr, 2015 @ 5:04am 
Well I'll do it if you tell me what LMGs/HMGs is :D
FrostyIce  [author] 27 Apr, 2015 @ 2:09pm 
It usually occurs with the LMGs/HMGs, if you look at any of them, they will most likely occur. If you know of one that doesn't have this issue, link it, and I'll see how they calculate the dropped weapon's physics.
DH1806 27 Apr, 2015 @ 1:46pm 
Well thats a bit strange because I dont know any other weapon who has this mistake...but thanks for the reply.
FrostyIce  [author] 27 Apr, 2015 @ 1:03pm 
Unfortunately, with the current hooks given to me, I can't fix that issue. I've tried, and the weapon physics become messed up when dropped. The bug is due to moving the model the player holds to the correct position so that it isn't in their body. However, the weapon is actually still there and can be picked up, it just doesn't graphically appear in the proper place. I apologize for the bug but I cannot fix it. Feel free to take the addon and fix it, if you can.
DH1806 27 Apr, 2015 @ 5:08am 
It's pretty nice, but if someone with the weapn dies or i think also if he throws it away the weapon stays flying in the air (but can't be taken). Could you fix that? :)
Rhythm 10 Apr, 2015 @ 4:55pm 
Looks nice. Is nice.
FrostyIce  [author] 5 Apr, 2015 @ 11:45pm 
Got tired of the M249 sucking, went looking for a better replacement. Found an M60. No regrets.

Stay Frosty.