Disappearing Bodies While Holding Custom SWEP (GMOD TTT)

Hello everyone. I run a TTT server and have been for many months now. I understand that there are weapons that can be downloaded and installed for TTT purposes, and there are weapons that are sandbox weapons. Well, I downloaded and tried installing a custom SWEP (http://steamcommunity.com/sharedfiles/filedetails/?id=268011198&searchtext=intervention) that was for sandbox only, and I’m trying to get it to work. I installed the base needed as well the actual weapon, then manually added all the materials, etc. To get to the point, the weapon shows up, sounds work fine and everything, however, when someone holding the weapon dies, their body disappears. I’ve searched up and down forums and google and I’ve still not been able to find anything. If anyone has a quick fix, please help. Thank you so much!

Copy the rifle’s code and just replace the model and sound paths.


// Variables that are used on both client and server
SWEP.Category				= "Nikolai's Sweps"
SWEP.Author				= "Nikolai MacPootislavski"
SWEP.Contact				= "Nikolai MacPootislavski"
SWEP.Purpose				= "Create Destruction"
SWEP.Instructions			= "Use your index finger to shoot and your middle finger to aim."
SWEP.MuzzleAttachment			= "1" 	-- Should be "1" for CSS models or "muzzle" for hl2 models
SWEP.ShellEjectAttachment		= "2" 	-- Should be "2" for CSS models or "1" for hl2 models
SWEP.DrawCrosshair			= false

if CLIENT then
   SWEP.PrintName          = "Intervention"
   SWEP.Slot               = 2
   SWEP.Icon = "VGUI/ttt/icon_scout"
end
SWEP.Kind = WEAPON_HEAVY
SWEP.WeaponID = AMMO_RIFLE

SWEP.ViewModelFOV			= 80
SWEP.ViewModelFlip			= true
SWEP.ViewModel				= "models/weapons/v_snip_m200i.mdl"
SWEP.WorldModel				= "models/weapons/w_interventionhbs.mdl"
SWEP.Base 				= "gdcw_nikbase_rifleman"
SWEP.Spawnable				= false
SWEP.AdminSpawnable			= true

SWEP.Primary.Sound			= Sound("weapons/m200/trigger.wav")
SWEP.Primary.Round			= ("gdcwa_m200_round")
SWEP.Primary.Damage = 85
SWEP.HeadshotMultiplier = 4
SWEP.Primary.RPM			= 41						// This is in Rounds Per Minute
SWEP.Primary.ClipSize			= 5						// Size of a clip
SWEP.Primary.DefaultClip		= 73
SWEP.Primary.ConeSpray			= 0.002					// Hip fire accuracy
SWEP.Primary.ConeIncrement		= .7					// Rate of innacuracy
SWEP.Primary.ConeMax			= 3.0					// Maximum Innacuracy
SWEP.Primary.ConeDecrement		= 1.1					// Rate of accuracy
SWEP.Primary.KickUp			= 1					// Maximum up recoil (rise)
SWEP.Primary.KickDown			= 0					// Maximum down recoil (skeet)
SWEP.Primary.KickHorizontal		= 0.1					// Maximum up recoil (stock)
SWEP.Primary.Automatic			= false						// Automatic/Semi Auto
SWEP.Primary.Ammo			= "357"

SWEP.Secondary.ClipSize			= 0						// Size of a clip
SWEP.Secondary.DefaultClip		= 0						// Default number of bullets in a clip
SWEP.Secondary.Automatic		= false						// Automatic/Semi Auto
SWEP.Secondary.Ammo			= ""
SWEP.Secondary.ScopeZoom		= 4	
SWEP.Secondary.UseParabolic		= true						// How much you 'zoom' in. Less is more! 	

SWEP.data 				= {}						// The starting firemode
SWEP.data.ironsights			= 1
SWEP.ScopeScale 			= .6

SWEP.SightsPos = Vector(5, -8, 0.1)
SWEP.SightsAng = Vector(0, -3, 0)
SWEP.RunSightsPos = Vector(0, 0, 0)
SWEP.RunSightsAng = Vector(-5.299, -20.017, -5.953)

SWEP.Offset = {
Pos = {
Up = -2.1,
Right = 1.0,
Forward = -3.0,
},
Ang = {
Up = 0,
Right = 1.5,
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 )

local IRONSIGHT_TIME = 0.09

self:DrawModel( )
end

What do you mean by replace the sound and models paths?

–edit–
This is the init.lua file:


AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )

include('shared.lua')

SWEP.Weight				= 30		// Decides whether we should switch from/to this
SWEP.AutoSwitchTo			= true		// Auto switch to if we pick it up
SWEP.AutoSwitchFrom			= true		// Auto switch from if you pick up a better weapon

function SWEP:Initialize()
	self:SetWeaponHoldType("ar2")
end

function SWEP:OnRemove()
end





Change the SWEP.Base = “weapon_tttbase”

That didn’t work.

Unless that swep does anything special, instead of trying to get another base to work with TTT, do as YourStalker suggested and use TTT’s ordinary rifle as a template

Here’s the file:

Basically, what you’d want to do is go to line 35 and 36 and then replace that ordinary css model with the one that swep pack comes with. Do the same thing with the sound on line 38 and that should be all you need

I may have figured out the problem already, there is no SWEP.HoldType. I will take a minute to try and fix it, but thanks for the help! The result when I changed the SWEP’s base to the weapon_tttbase was that i wasn’t able to drop it, nor able to scope in. When I died, I still disappeared along with the gun.

[editline]9th June 2014[/editline]

Well, that didn’t work. I’m going to try and add the default things in the weapon_tttbase to the base of the actual gun.

I did just read in the weapon_tttbase that all TTT weapons need to have weapon_tttbase…

[editline]9th June 2014[/editline]

After messing around with it for a while, I’ve gotten it to drop, the body not to disappear, but now I can’t figure out how to add the scope to it. Here is the code.


// Variables that are used on both client and server
SWEP.Category           = "TTT"
SWEP.Author				= "Nikolai MacPootislavski"
SWEP.Contact				= "Nikolai MacPootislavski"
SWEP.Purpose				= "Create Destruction"
SWEP.Instructions			= "Use your index finger to shoot and your middle finger to aim."
SWEP.MuzzleAttachment			= "1" 	-- Should be "1" for CSS models or "muzzle" for hl2 models
SWEP.ShellEjectAttachment		= "2" 	-- Should be "2" for CSS models or "1" for hl2 models
SWEP.DrawCrosshair			= false

if CLIENT then
   SWEP.PrintName          = "Intervention"
   SWEP.Slot               = 2
   SWEP.Icon = "VGUI/ttt/icon_scout"
end
SWEP.Kind = WEAPON_HEAVY
SWEP.WeaponID = AMMO_RIFLE
SWEP.AllowDrop = true
SWEP.IsSilent = false

SWEP.ViewModelFOV			= 80
SWEP.ViewModelFlip			= true
SWEP.ViewModel				= "models/weapons/v_snip_m200i.mdl"
SWEP.WorldModel				= "models/weapons/w_interventionhbs.mdl"
SWEP.Base 				= "weapon_tttbase"
SWEP.Spawnable				= false
SWEP.AdminSpawnable			= true
SWEP.HoldType               = "ar2"
SWEP.UseHands			= true

SWEP.Primary.Sound			= Sound("weapons/m200/trigger.wav")
SWEP.Primary.Round			= ("gdcwa_m200_round")
SWEP.Primary.Damage = 85
SWEP.HeadshotMultiplier = 4
SWEP.Primary.RPM			= 41						// This is in Rounds Per Minute
SWEP.Primary.ClipSize			= 5						// Size of a clip
SWEP.Primary.DefaultClip		= 73
SWEP.Primary.ConeSpray			= 0.002					// Hip fire accuracy
SWEP.Primary.ConeIncrement		= .7					// Rate of innacuracy
SWEP.Primary.ConeMax			= 3.0					// Maximum Innacuracy
SWEP.Primary.ConeDecrement		= 1.1					// Rate of accuracy
SWEP.Primary.KickUp			= 1					// Maximum up recoil (rise)
SWEP.Primary.KickDown			= 0					// Maximum down recoil (skeet)
SWEP.Primary.KickHorizontal		= 0.1					// Maximum up recoil (stock)
SWEP.Primary.Automatic			= false						// Automatic/Semi Auto
SWEP.Primary.Ammo			= "357"
SWEP.AmmoEnt = "item_ammo_357_ttt"	
SWEP.Primary.Delay          = 1.1

SWEP.Secondary.Sound = Sound("Default.Zoom")
SWEP.Secondary.ClipSize	 = -1	 // Size of a clip
SWEP.Secondary.DefaultClip	= -1	 // Default number of bullets in a clip
SWEP.Secondary.Automatic	= false	 // Automatic/Semi Auto
SWEP.Secondary.Ammo	 = "none"

SWEP.SightsPos = Vector(5, -8, 0.1)
SWEP.SightsAng = Vector(0, -3, 0)
SWEP.RunSightsPos = Vector(0, 0, 0)
SWEP.RunSightsAng = Vector(-5.299, -20.017, -5.953)

SWEP.Offset = {
Pos = {
Up = -2.1,
Right = 1.0,
Forward = -3.0,
},
Ang = {
Up = 0,
Right = 1.5,
Forward = 0,
}
}

Zoom = 0

function SWEP:SecondaryAttack()
if(Zoom == 0) then

    if(SERVER) then
        self.Owner:SetFOV( 45, 0 )
    end    

    Zoom = 1

else if(Zoom == 1) then

    if(SERVER) then
        self.Owner:SetFOV( 25, 0 )
    end    

    Zoom = 2

else

    if(SERVER) then
        self.Owner:SetFOV( 0, 0 )
    end        

    Zoom = 0

end
end

self.Owner:SetFOV( 0, 0 )
ScopeLevel = 0

return true
end

function SWEP:SetZoom(state)
    if CLIENT then
       return
    else
       if state then
          self.Owner:SetFOV(20, 0.3)
       else
          self.Owner:SetFOV(0, 0.2)
       end
    end
end
 
function SWEP:GetZoom()
    if CLIENT then
       return
    else
        return state
        end
end
 
-- Add some zoom to ironsights for this gun
function SWEP:SecondaryAttack()
    if not self.IronSightsPos then return end
    if self.Weapon:GetNextSecondaryFire() > CurTime() then return end
   
    bIronsights = not self:GetIronsights()
   
    self:SetIronsights( bIronsights )
   
    if SERVER then
        self:SetZoom(bIronsights)
     else
        self:EmitSound(self.Secondary.Sound)
    end
   
    self.Weapon:SetNextSecondaryFire( CurTime() + 0.3)
end

function SWEP:PreDrop()
    self:SetZoom(false)
    self:SetIronsights(false)
 
    return self.BaseClass.PreDrop(self)
end
 
function SWEP:Reload()
    self.Weapon:DefaultReload( ACT_VM_RELOAD );
    self:SetIronsights( false )
    self:SetZoom(false)
end
 
function SWEP:Deploy()
   self.Weapon:SetNextPrimaryFire( CurTime() + 2 )
   self:SetIronsights(false)
 
   return true
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

If you did this you wouldn’t have that issue.

Btw congrats on moderator Niandra, seems like they finally came to their senses and got more mods.

[editline]9th June 2014[/editline]

Add this to your gun, copied straight from the stock rifle
[lua]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

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
[/lua]