I made a weapon base and a weapon using my own base but Gmod says there is no name or classname and it doesn't work! I made a train gun that worked then I wanted to make it a base so I could make different weapons and this is what I ended up with. PLZ Help!
[B]weapon_household_base/shared.lua[/B]
[CODE]
SWEP.PrintName = ""
SWEP.Author = "BeastKiller"
SWEP.Base = ""
SWEP.HoldType = "physgun"
SWEP.ViewModel = "models/weapons/v_superphyscannon.mdl"
SWEP.WorldModel = "models/weapons/w_physics.mdl"
SWEP.Spawnable = "false"
SWEP.Category = "BeastKiller's HouseHold Weapons"
SWEP.AdminOnly = "true"
SWEP.Purpose = "Kill your enemies with random items!!!"
SWEP.Instructions = "Primary Fire: Throw items. Secondary Fire: Throw alternate items (if available)."
SWEP.Weight = 1
SWEP.Slot = 1
SWEP.SlotPos = 88
SWEP.Primary.ClipSize = -1
SWEP.Primary.DefaultClip = -1
SWEP.Primary.Ammo = ""
SWEP.Secondary.ClipSize = 10
SWEP.Secondary.DefaultClip = 10
SWEP.Secondary.Ammo = ""
SWEP.Primary.Automatic = false
SWEP.Secondary.Automatic = false
SWEP.DrawAmmo = true
SWEP.DrawCrosshair = true
SWEP.DrawWeaponInfoBox = true
SWEP.BounceWeaponIcon = true
function SWEP:Initialize()
self:Precache()
self:SetHoldType( "physgun" )
end
function SWEP:PrimaryAttack()
end
function SWEP:SecondaryAttack()
end
function SWEP:Throw( prop, sound )
local trainent = ents.Create( "prop_physics" )
if (!self:CanPrimaryAttack()) then return end
if (!IsValid( trainent )) then return end
trainent:SetModel( prop )
trainent:SetPos( self.Owner:EyePos() + (self.Owner:GetAimVector() * 16) )
trainent:SetAngles( self.Owner:EyeAngles() )
trainent:Ignite( 10000000000000000000000000 )
trainent:Spawn()
local phys = trainent:GetPhysicsObject()
if ( !IsValid(phys) ) then ent:Remove() return end
local velocity = self.Owner:GetAimVector()
velocity = velocity * 100000000000000000000000000000000000001
velocity = velocity + ( VectorRand() * 10 )
phys:ApplyForceCenter( velocity )
self:EmitSound( sound )
self.Owner:SetAnimation( 7 )
self:SendWeaponAnim( 404 )
end
function SWEP:CanPrimaryAttack()
if ( self:Clip1() <= 0 ) then
self:SetNextPrimaryFire( CurTime() + 0.2 )
self:Reload()
return false
else
return true
end
end
function SWEP.Reload()
end
function SWEP:Clip1()
return self.Owner:GetAmmoCount( self.Weapon:GetPrimaryAmmoType() )
end
function SWEP:Precache()
util.PrecacheSound("weapons/airstrike_fire_03.wav")
end
[/CODE]
[B]weapon_special_household_traingun/shared.lua[/B]
[CODE]
SWEP.ClassName = "weapon_special_household_traingun"
SWEP.PrintName = "Train Gun"
SWEP.Spawnable = true
SWEP.Base = "weapon_household_base"
function SWEP:PrimaryAttack()
self:Throw("models/props_trainstation/train001.mdl", Sound("weapons/airstrike_fire_03.wav"))
end
function SWEP:SecondaryAttack()
self:Throw("models/props_trainstation/train003.mdl", Sound("weapons/airstrike_fire_03.wav"))
end
[/CODE]
The Class of a weapon is the file name... Why have a variable for it?
I got rid of the class names and problem still persists.
Then post a lua error
You're going to have a generic error when you don't set the SWEP.Base to weapon_base...
weapon_base is sort of a general template that has the necessary functions to work; you can overwrite them all and have no trouble but you'll continue having the error without Base set to something.
Sorry, you need to Log In to post a reply to this thread.