I'm making a SWEP, but it dosn't show up in the weapon tab.
Why not?
The Lua code:
[CODE]if ( SERVER ) then
AddCSLuaFile( "shared.lua" )
SWEP.HoldType = "pistol"
end
if ( CLIENT ) then
SWEP.PrintName = "G18"
SWEP.Author = "NinjaCat"
SWEP.Purpose = "Shoot stuff"
SWEP.Instructions = "Ever hold a gun on gmod? Use it like that one."
SWEP.Slot = 3
SWEP.SlotPos = 1
SWEP.IconLetter = "e"
killicon.AddFont( "weapon_pistol", "CSKillIcons", SWEP.IconLetter, Color( 255, 80, 0, 255 ) )
end
SWEP.DrawCrosshair = true
SWEP.DrawAmmo = true
SWEP.Spawnable = true
SWEP.AdminSpawnable = true
SWEP.ViewModel = "models/weapons/v_pist_glock18.mdl"
SWEP.WorldModel = "models/weapons/w_pist_glock18.mdl"
SWEP.Weight = 5
SWEP.AutoSwitchTo = false
SWEP.AutoSwitchFrom = false
SWEP.Primary.Recoil = 5
SWEP.Primary.Damage = 21
SWEP.Primary.NumShots = 1
SWEP.Primary.Cone = 0
SWEP.Primary.ClipSize = 20
SWEP.Primary.Delay = 2
SWEP.Primary.DefaultClip = 1
SWEP.Primary.Automatic = true
SWEP.Primary.Ammo = "smg1"
function SWEP:Initialize()
local sound = Sound("sound/clong-2.mp3")
ent:EmitSound( sound )
util.PrecacheSound("Weapon_pist_glock18.Single")
end
function SWEP:PrimaryAttack()
if ( !self:CanPrimaryAttack() ) then return end
self.Weapon:EmitSound(Sound("Weapon_pist_glock18.Single"))
self:ShootBullet( 100, 1, 0 )
self:TakePrimaryAmmo( 1 )
self.Owner:ViewPunch( Angle( -1, 0, 0 ) )
self.Weapon:SetNextPrimaryFire( CurTime() + 0.1 )if (SERVER) then
local owner=self.Owner
if self.Owner.SENT then
owner=self.Owner.SENT.Entity
end
end
[/CODE]
I bet it's something simple. :o
Launch the game, and look in the console. There should be some lua errors if it's installed right. Put those here, if you can't figure it out yourself.
I think you have either an extra 'end' or you're missing one.
You are missing an end at the very bottom.
Ah, thanks, I'll test it out. :P
Edit:
Well, It worked, but Allways an error comes up, or it dosn't show up in the list.
I tryed alot, but I can't get it to work.
I belive it was something around line 51, The emit sound thing.
[code]if ( SERVER ) then
AddCSLuaFile( "shared.lua" )
SWEP.HoldType = "pistol"
end
if ( CLIENT ) then
SWEP.PrintName = "G18"
SWEP.Author = "NinjaCat"
SWEP.Purpose = "Shoot stuff"
SWEP.Instructions = "Ever hold a gun on gmod? Use it like that one."
SWEP.Slot = 3
SWEP.SlotPos = 1
SWEP.IconLetter = "e"
killicon.AddFont( "weapon_pistol", "CSKillIcons", SWEP.IconLetter, Color( 255, 80, 0, 255 ) )
end
SWEP.DrawCrosshair = true
SWEP.DrawAmmo = true
SWEP.Spawnable = true
SWEP.AdminSpawnable = true
SWEP.ViewModel = "models/weapons/v_pist_glock18.mdl"
SWEP.WorldModel = "models/weapons/w_pist_glock18.mdl"
SWEP.Weight = 5
SWEP.AutoSwitchTo = false
SWEP.AutoSwitchFrom = false
SWEP.Primary.Recoil = 5
SWEP.Primary.Damage = 21
SWEP.Primary.NumShots = 1
SWEP.Primary.Cone = 0
SWEP.Primary.ClipSize = 20
SWEP.Primary.Delay = 2
SWEP.Primary.DefaultClip = 1
SWEP.Primary.Automatic = true
SWEP.Primary.Ammo = "smg1"
function SWEP:Initialize()
local sound = Sound("sound/clong-2.mp3")
!self.weapon:EmitSound( sound )
util.PrecacheSound("Weapon_pist_glock18.Single")
end
function SWEP:SecondaryAttack()
end
function SWEP:PrimaryAttack()
if ( !self:CanPrimaryAttack() ) then return end
self.Weapon:EmitSound(Sound("Weapon_pist_glock18.Single"))
self:ShootBullet( 100, 1, 0 )
self:TakePrimaryAmmo( 1 )
self.Owner:ViewPunch( Angle( -1, 0, 0 ) )
self.Weapon:SetNextPrimaryFire( CurTime() + 0.1 )if (SERVER) then
local owner=self.Owner
if self.Owner.SENT then
owner=self.Owner.SENT.Entity
end
end
end
[/code]
Bump 4 answear and probly a ban.
If it was an error then post the error or we can't help.
[noparse]Also, use [lua] and [/lua] tags for lua code, not [code][/code] tags.[/noparse]
well using Sound() starts in the sound directory so you do not need sound/
Also this part seems unneeded and I suspect it might cause an error
[code]
if (SERVER) then
local owner=self.Owner
if self.Owner.SENT then
owner=self.Owner.SENT.Entity
end
end
[/code]
Because I dont think self.Owner.SENT even exists.
Error: weapons/glock_18/shared.lua:51: unexpected symbol near 'not'
Currect code
[lua]if ( SERVER ) then
AddCSLuaFile( "shared.lua" )
SWEP.HoldType = "pistol"
end
if ( CLIENT ) then
SWEP.PrintName = "G18"
SWEP.Author = "NinjaCat"
SWEP.Purpose = "Shoot stuff"
SWEP.Instructions = "Ever hold a gun on gmod? Use it like that one."
SWEP.Slot = 3
SWEP.SlotPos = 1
SWEP.IconLetter = "e"
killicon.AddFont( "weapon_pistol", "CSKillIcons", SWEP.IconLetter, Color( 255, 80, 0, 255 ) )
end
SWEP.DrawCrosshair = true
SWEP.DrawAmmo = true
SWEP.Spawnable = true
SWEP.AdminSpawnable = true
SWEP.ViewModel = "models/weapons/v_pist_glock18.mdl"
SWEP.WorldModel = "models/weapons/w_pist_glock18.mdl"
SWEP.Weight = 5
SWEP.AutoSwitchTo = false
SWEP.AutoSwitchFrom = false
SWEP.Primary.Recoil = 5
SWEP.Primary.Damage = 21
SWEP.Primary.NumShots = 1
SWEP.Primary.Cone = 0
SWEP.Primary.ClipSize = 20
SWEP.Primary.Delay = 2
SWEP.Primary.DefaultClip = 1
SWEP.Primary.Automatic = true
SWEP.Primary.Ammo = "smg1"
function SWEP:Initialize()
local sound = Sound("sound/clong-2.mp3")
!self.weapon:EmitSound( sound )
util.PrecacheSound("Weapon_pist_glock18.Single")
end
function SWEP:SecondaryAttack()
end
function SWEP:PrimaryAttack()
if ( !self:CanPrimaryAttack() ) then return end
self.Weapon:EmitSound(Sound("Weapon_pist_glock18.Single"))
self:ShootBullet( 100, 1, 0 )
self:TakePrimaryAmmo( 1 )
self.Owner:ViewPunch( Angle( -1, 0, 0 ) )
self.Weapon:SetNextPrimaryFire( CurTime() + 0.1 )if (SERVER) then
end
end
[/lua]
You forgot an if an a then.
[code]
if !self.weapon:EmitSound( sound ) then
util.PrecacheSound("Weapon_pist_glock18.Single")
end
[/code]
Thanks, I'll see if it helps!
It helped alot!
It works and stuff, onlyt problem is there is no sound effects...
Due to the fact I'm a noob I have no idea why, And no errors.
[lua]if ( SERVER ) then
AddCSLuaFile( "shared.lua" )
SWEP.HoldType = "pistol"
end
if ( CLIENT ) then
SWEP.PrintName = "G18"
SWEP.Author = "NinjaCat"
SWEP.Purpose = "Shoot stuff"
SWEP.Instructions = "Ever hold a gun on gmod? Use it like that one."
SWEP.Slot = 3
SWEP.SlotPos = 1
SWEP.IconLetter = "e"
killicon.AddFont( "weapon_pistol", "CSKillIcons", SWEP.IconLetter, Color( 255, 80, 0, 255 ) )
end
SWEP.DrawCrosshair = true
SWEP.DrawAmmo = true
SWEP.Spawnable = true
SWEP.AdminSpawnable = true
SWEP.ViewModel = "models/weapons/v_pist_glock18.mdl"
SWEP.WorldModel = "models/weapons/w_pist_glock18.mdl"
SWEP.Weight = 5
SWEP.AutoSwitchTo = false
SWEP.AutoSwitchFrom = false
SWEP.Primary.Recoil = 8
SWEP.Primary.Damage = 21
SWEP.Primary.NumShots = 1
SWEP.Primary.Cone = 0
SWEP.Primary.ClipSize = 20
SWEP.Primary.Delay = 2
SWEP.Primary.DefaultClip = 1
SWEP.Primary.Automatic = true
SWEP.Primary.Ammo = "smg1"
function SWEP:Initialize()
local sound = Sound("sound/clong-2.mp3")
if !self:EmitSound( sound ) then
util.PrecacheSound("Weapon_pist_glock18.Single")
end
end
function SWEP:SecondaryAttack()
end
function SWEP:PrimaryAttack()
if ( !self:CanPrimaryAttack() ) then return end
self.Weapon:EmitSound(Sound("Weapon_pist_glock18.Single"))
self:ShootBullet( 100, 1, 0 )
self:TakePrimaryAmmo( 1 )
self.Owner:ViewPunch( Angle( -1, 0, 0 ) )
self.Weapon:SetNextPrimaryFire( CurTime() + 0.1 )if (SERVER) then
end
end
[/lua]
I already said this.
local sound = Sound("clong-2.mp3")
Edit* hmm I'm not sure but I think it has to be a .wav file also.
Allright, I'll test
Sorry, you need to Log In to post a reply to this thread.