Newbie SWEPs Not Working (TTT)

Hey FP,

I have a few SWEPs that won’t spawn, get thousands of LUA error, etc.

I’m trying to get them to work on my TTT (Trouble in Terrorist Town) server.
Here are some of them:

**THE HOMECOMING

**This weapon has a Crossbow model, and sounds. Once primary fire is activated, ten seconds count down to an explosion at where you are aiming when the timer’s up. It won’t spawn with cheats or the Traitor buy menu. What am I doing wrong?



if SERVER then
   AddCSLuaFile( "shared.lua" )
   
end
SWEP.HoldType = "crossbow"
   SWEP.ViewModelFlip = true
if CLIENT then
SWEP.PrintName = "HomeComing"
SWEP.Author = "Evil"
SWEP.Slot = 6
SWEP.SlotPos = 1
SWEP.EquipMenuData = {
   type = "Weapon",
   desc = "On hit starts timer to explode where
you are looking.

Slow to fire."
};    
end
SWEP.Base               = "weapon_tttbase"
SWEP.Spawnable = true
SWEP.AdminSpawnable = true
SWEP.Icon = "vgui/ttt/icon_hc"
SWEP.NoSights = false
SWEP.IronSightsPos      = Vector( 5, -15, -2 )
SWEP.IronSightsAng      = Vector( 2.6, 1.37, 3.5 )
if SERVER then
   resource.AddFile("VGUI/ttt/icon_hc.vmt")
end
SWEP.Primary.Delay          = 8
SWEP.Primary.Recoil         = 35
SWEP.Primary.Automatic = false
SWEP.Primary.Damage = 350
SWEP.Primary.Cone = 0.025
SWEP.Primary.ClipSize = 2
SWEP.Primary.ClipMax = 2 -- keep mirrored to ammo
SWEP.Primary.DefaultClip = 2
SWEP.AutoSpawnable      = false
SWEP.ViewModel          = "models/weapons/v_crossbow.mdl"
SWEP.WorldModel         = "models/weapons/w_crossbow.mdl"
SWEP.CanBuy = {ROLE_TRAITOR} -- only traitors can buy
SWEP.LimitedStock = true -- only buyable once
SWEP.Kind = WEAPON_EQUIP
SWEP.WeaponID = AMMO_RIFLE
SWEP.Primary.Sound            = Sound( "Weapon_crossbow.Single" )
function SWEP:PrimaryAttack() // when primary attack happens
 
    local eyetrace = self.Owner:GetEyeTrace();
    // this gets where you are looking. The SWep is making an explosion where you are LOOKING, right?
 
    timer.Simple ( 10, ExplodeFunc )
end
function ExplodeFunc()
    local explode = ents.Create( "env_explosion" ) //creates the explosion
    explode:SetPos( eyetrace.HitPos ) //this creates the explosion where you were looking
    explode:SetOwner( self.Owner ) // this sets you as the person who made the explosion
    explode:Spawn() //this actually spawns the explosion
    explode:SetKeyValue( "iMagnitude", "220" ) //the magnitude
    explode:Fire( "Explode", 0, 0 )
    explode:EmitSound( "c4.explode", 400, 400 ) //the sound for the explosion, and how far away it can be heard
ExplodeFunc()


FAMAS

This weapon is basically the FAMAS. It’s in game as a semi-auto weapon right now, but I’d like it to shoot in 3 shot burst fire. Add to this?


if SERVER then

   AddCSLuaFile( "shared.lua" )
   
end

SWEP.HoldType = "ar2"

if CLIENT then

SWEP.PrintName = "FAMAS"
SWEP.Author = "Evil"
SWEP.Slot = 6
SWEP.SlotPos = 1
SWEP.EquipMenuData = {
   type = "Weapon",
   desc = "Semi-automatic. 9MM ammo."
};    
end


   SWEP.ViewModelFlip = false

SWEP.Base               = "weapon_tttbase"
SWEP.Spawnable = true
SWEP.AdminSpawnable = true

SWEP.Kind = WEAPON_EQUIP
SWEP.AmmoEnt = "item_ammo_pistol_ttt"
SWEP.Icon = "vgui/ttt/icon_famas"
SWEP.CanBuy = { ROLE_DETECTIVE }
SWEP.NoSights = true

if SERVER then
   resource.AddFile("VGUI/ttt/icon_famas.vmt")
end

SWEP.Primary.Delay          = 0.14
SWEP.Primary.Recoil         = 0.5
SWEP.Primary.Automatic = false
SWEP.Primary.Ammo = "pistol"
SWEP.Primary.Damage = 23
SWEP.Primary.Cone = 0.025
SWEP.Primary.ClipSize = 10
SWEP.Primary.ClipMax = 30-- keep mirrored to ammo
SWEP.Primary.DefaultClip = 20
SWEP.AutoSpawnable      = true
SWEP.ViewModel          = "models/weapons/v_rif_famas.mdl"
SWEP.WorldModel         = "models/weapons/w_rif_famas.mdl"

SWEP.Primary.Sound            = Sound( "Weapon_FAMAS.Single" )

Thanks in advance!

**Don’t just read, reply please! :downs:
**

The latter should really be in requests

Basically everything you didn’t copy paste. Take my advice and start out smaller:wink:

:lol: Good idea…

Learning the basics might seem pointless now, but once you do learn them, you’ll see how much easier everything else gets:smile: