• Floating Weapons When Dropped
    9 replies, posted
So this is what happens, when I drop a weapon on the server it physically drops, but when someone else on the server drops it, it just floats in mid air. This is the code from one of my weapons: [LUA] AddCSLuaFile() SWEP.HoldType = "ar2" if CLIENT then SWEP.PrintName = "Dragunov" SWEP.Slot = 2 SWEP.Icon = "vgui/ttt/icon_scout" end SWEP.Base = "weapon_tttbase" SWEP.Spawnable = true SWEP.Kind = WEAPON_HEAVY SWEP.Primary.Delay = 0.1 SWEP.Primary.Recoil = 1.2 SWEP.Primary.Automatic = false SWEP.Primary.Ammo = "357" SWEP.Primary.Damage = 70 SWEP.Primary.Cone = 0.003 SWEP.Primary.ClipSize = 10 SWEP.Primary.ClipMax = 60 SWEP.Primary.DefaultClip = 10 SWEP.HeadshotMultiplier = 3 SWEP.AutoSpawnable = true SWEP.AmmoEnt = "item_ammo_357_ttt" SWEP.UseHands = true SWEP.ViewModelFlip = false SWEP.ViewModelFOV = 70 SWEP.ViewModel = Model("models/RazorSWEP/weapons/v_snip_dragu.mdl") SWEP.WorldModel = Model("models/RazorSWEP/weapons/w_snip_dragu.mdl") SWEP.Primary.Sound = Sound("RazorSWEP/drag/g3sg1-1.wav") SWEP.DeploySpeed = 2 SWEP.Secondary.Sound = Sound("Default.Zoom") SWEP.IronSightsPos = Vector(-11.961, -20, 1.679) SWEP.IronSightsAng = Vector(0, 0, 0) function SWEP:SetZoom(state) if CLIENT then return elseif IsValid(self.Owner) and self.Owner:IsPlayer() then if state then self.Owner:SetFOV(20, 0.3) else self.Owner:SetFOV(0, 0.2) end end end -- Add some zoom to ironsights for this gun function SWEP:SecondaryAttack() if not self.IronSightsPos then return end if self:GetNextSecondaryFire() > CurTime() then return end local bIronsights = not self:GetIronsights() self:SetIronsights( bIronsights ) if SERVER then self:SetZoom(bIronsights) else self:EmitSound(self.Secondary.Sound) end self:SetNextSecondaryFire( CurTime() + 0.3) end function SWEP:PreDrop() self:SetZoom(false) self:SetIronsights(false) return self.BaseClass.PreDrop(self) end local Time = CurTime() function SWEP:Reload() if ( self:Clip1() == self.Primary.ClipSize or self.Owner:GetAmmoCount( self.Primary.Ammo ) <= 0 ) then return end self:DefaultReload( ACT_VM_RELOAD ) self:SetIronsights( false ) self:SetZoom( false ) end function SWEP:Holster() self:SetIronsights(false) self:SetZoom(false) return true end if CLIENT then local scope = surface.GetTextureID("sprites/scope") function SWEP:DrawHUD() if self:GetIronsights() then surface.SetDrawColor( 0, 0, 0, 255 ) local x = ScrW() / 2.0 local y = ScrH() / 2.0 local scope_size = ScrH() -- crosshair local gap = 80 local length = scope_size surface.DrawLine( x - length, y, x - gap, y ) surface.DrawLine( x + length, y, x + gap, y ) surface.DrawLine( x, y - length, x, y - gap ) surface.DrawLine( x, y + length, x, y + gap ) gap = 0 length = 50 surface.DrawLine( x - length, y, x - gap, y ) surface.DrawLine( x + length, y, x + gap, y ) surface.DrawLine( x, y - length, x, y - gap ) surface.DrawLine( x, y + length, x, y + gap ) -- cover edges local sh = scope_size / 2 local w = (x - sh) + 2 surface.DrawRect(0, 0, w, scope_size) surface.DrawRect(x + sh - 2, 0, w, scope_size) surface.SetDrawColor(255, 0, 0, 255) surface.DrawLine(x, y, x + 1, y + 1) -- scope surface.SetTexture(scope) surface.SetDrawColor(255, 255, 255, 255) surface.DrawTexturedRectRotated(x, y, scope_size, scope_size, 0) else return self.BaseClass.DrawHUD(self) end end function SWEP:AdjustMouseSensitivity() return (self:GetIronsights() and 0.2) or nil end end --Crotch Gun Fix SWEP.Offset = { Pos = { Up = 0, Right = 1, Forward = -3, }, Ang = { Up = 0, Right = 0, Forward = 0, } } function SWEP:DrawWorldModel( ) local hand, offset, rotate if not IsValid( self.Owner ) then self:DrawModel( ) return end if not self.Hand then self.Hand = self.Owner:LookupAttachment( "anim_attachment_rh" ) end hand = self.Owner:GetAttachment( self.Hand ) if not hand then self:DrawModel( ) return end offset = hand.Ang:Right( ) * self.Offset.Pos.Right + hand.Ang:Forward( ) * self.Offset.Pos.Forward + hand.Ang:Up( ) * self.Offset.Pos.Up hand.Ang:RotateAroundAxis( hand.Ang:Right( ), self.Offset.Ang.Right ) hand.Ang:RotateAroundAxis( hand.Ang:Forward( ), self.Offset.Ang.Forward ) hand.Ang:RotateAroundAxis( hand.Ang:Up( ), self.Offset.Ang.Up ) self:SetRenderOrigin( hand.Pos + offset ) self:SetRenderAngles( hand.Ang ) self:DrawModel( ) end [/LUA]
Is this for TTT or DarkRP? And is CS:GO and sandbox mounted/installed correctly?
This is for TTT, and I do believe CS:S is mounted.
The world model may not have a collision mesh/box. If you spawned the "w_snip_dragu.mdl" from the spawn menu, does it also just float?
nope, it doesn't float. But another thing is the weapon floats where the person that dropped it, like the position that they were holding the weapon.
Well "floating weapons when dropped" is misleading
I can give you a picture of the problem. I shot someone holding the gun and this happened, it also happens when someone drops it, and also when some carry it with a magneto stick. [IMG]http://i.imgur.com/0fnQY8B.jpg[/IMG] [editline]1st September 2014[/editline] Could it be the crotch fix code I have in my gun lua? [LUA] --Crotch Gun Fix SWEP.Offset = { Pos = { Up = 0, Right = 1, Forward = -3, }, Ang = { Up = 0, Right = 0, Forward = 0, } } function SWEP:DrawWorldModel( ) local hand, offset, rotate if not IsValid( self.Owner ) then self:DrawModel( ) return end if not self.Hand then self.Hand = self.Owner:LookupAttachment( "anim_attachment_rh" ) end hand = self.Owner:GetAttachment( self.Hand ) if not hand then self:DrawModel( ) return end offset = hand.Ang:Right( ) * self.Offset.Pos.Right + hand.Ang:Forward( ) * self.Offset.Pos.Forward + hand.Ang:Up( ) * self.Offset.Pos.Up hand.Ang:RotateAroundAxis( hand.Ang:Right( ), self.Offset.Ang.Right ) hand.Ang:RotateAroundAxis( hand.Ang:Forward( ), self.Offset.Ang.Forward ) hand.Ang:RotateAroundAxis( hand.Ang:Up( ), self.Offset.Ang.Up ) self:SetRenderOrigin( hand.Pos + offset ) self:SetRenderAngles( hand.Ang ) self:DrawModel( ) end [/LUA] [editline]1st September 2014[/editline] What if I used function SWEP:OnDrop() and made it return to the world model?
Weapons that don't have any physics are basic weapons that're missing the model on the server.
w_snip_dragu.mdl is missing
Don't models needs a .phy file with them for physics? Does that model have one?
Sorry, you need to Log In to post a reply to this thread.