I have made my SWEP and called it weapon_c13.lua and put in in the Lua>Weapons folder in g-mod
This is the error in the console:
[QUOTE]TODO: SavePresets
TODO: SavePresets
TODO: SavePresets
TODO: SavePresets
TODO: SavePresets
TODO: SavePresets
TODO: SavePresets
TODO: SavePresets
-- Hit Numbers loaded --
Requesting texture value from var "$dummyvar" which is not a texture value (material: NULL material)
Default clips will be not be modified
--- Missing Vgui material texturemissing
TEST [lua/weapons/pill_wep_alyxgun.lua][lua/weapons/weapon_c13.lua]
TEST [lua/weapons/pill_wep_annabelle.lua][lua/weapons/weapon_c13.lua]
TEST [lua/weapons/pill_wep_csniper.lua][lua/weapons/weapon_c13.lua]
TEST [lua/weapons/pill_wep_holstered.lua][lua/weapons/weapon_c13.lua]
TEST [lua/weapons/pill_wep_magnade.lua][lua/weapons/weapon_c13.lua]
TEST [lua/weapons/pill_wep_morphgun.lua][lua/weapons/weapon_c13.lua]
TEST [lua/weapons/pill_wep_pro.lua][lua/weapons/weapon_c13.lua]
TEST [lua/weapons/pill_wep_translocator.lua][lua/weapons/weapon_c13.lua]
TEST [lua/weapons/pktfw_base_gun.lua][lua/weapons/weapon_c13.lua]
TEST [lua/weapons/pktfw_base_melee.lua][lua/weapons/weapon_c13.lua]
TEST [lua/weapons/pktfw_base_shotgun.lua][lua/weapons/weapon_c13.lua]
TEST [lua/weapons/pktfw_bat.lua][lua/weapons/weapon_c13.lua]
TEST [lua/weapons/pktfw_bonesaw.lua][lua/weapons/weapon_c13.lua]
TEST [lua/weapons/pktfw_bottle.lua][lua/weapons/weapon_c13.lua]
TEST [lua/weapons/pktfw_fireaxe.lua][lua/weapons/weapon_c13.lua]
TEST [lua/weapons/pktfw_fists.lua][lua/weapons/weapon_c13.lua]
TEST [lua/weapons/pktfw_flamethrower.lua][lua/weapons/weapon_c13.lua]
TEST [lua/weapons/pktfw_grenadelauncher.lua][lua/weapons/weapon_c13.lua]
TEST [lua/weapons/pktfw_knife.lua][lua/weapons/weapon_c13.lua]
TEST [lua/weapons/pktfw_kukri.lua][lua/weapons/weapon_c13.lua]
TEST [lua/weapons/pktfw_medigun.lua][lua/weapons/weapon_c13.lua]
TEST [lua/weapons/pktfw_minigun.lua][lua/weapons/weapon_c13.lua]
TEST [lua/weapons/pktfw_pistol.lua][lua/weapons/weapon_c13.lua]
TEST [lua/weapons/pktfw_revolver.lua][lua/weapons/weapon_c13.lua]
TEST [lua/weapons/pktfw_rocketlauncher.lua][lua/weapons/weapon_c13.lua]
TEST [lua/weapons/pktfw_scattergun.lua][lua/weapons/weapon_c13.lua]
TEST [lua/weapons/pktfw_shotgun.lua][lua/weapons/weapon_c13.lua]
TEST [lua/weapons/pktfw_shovel.lua][lua/weapons/weapon_c13.lua]
TEST [lua/weapons/pktfw_smg.lua][lua/weapons/weapon_c13.lua]
TEST [lua/weapons/pktfw_sniper.lua][lua/weapons/weapon_c13.lua]
TEST [lua/weapons/pktfw_stickylauncher.lua][lua/weapons/weapon_c13.lua]
TEST [lua/weapons/pktfw_syringegun.lua][lua/weapons/weapon_c13.lua]
TEST [lua/weapons/pktfw_wrench.lua][lua/weapons/weapon_c13.lua]
TEST [lua/weapons/remotecontroller.lua][lua/weapons/weapon_c13.lua]
TEST [lua/weapons/weapon_lightsaber.lua][lua/weapons/weapon_c13.lua]
TEST [lua/weapons/weapon_nyangun.lua][lua/weapons/weapon_c13.lua]
[ERROR] lua/weapons/weapon_c13.lua:59: unexpected symbol near '='
1. unknown - lua/weapons/weapon_c13.lua:0
Failed to load custom font file 'c:/program files (x86)/steam/steamapps/common/garrysmod/garrysmod/resource/fonts/hidden.ttf'
Failed to load custom font file 'c:/program files (x86)/steam/steamapps/common/garrysmod/garrysmod/resource/fonts/typenoksidi.ttf'
Compact freed 299008 bytes
JOY_AXIS_X: mapped to Turn (absolute)
JOY_AXIS_Y: mapped to Look (absolute)
JOY_AXIS_Z: unmapped
JOY_AXIS_R: mapped to Forward (absolute)
JOY_AXIS_U: mapped to Side (absolute)
JOY_AXIS_V: unmapped
Advanced Joystick settings initialized
Redownloading all lightmaps
[/QUOTE]
Here is the code of my file
[QUOTE]AddCSLuaFile()
SWEP.Base = "weapon_base"
SWEP.PrintName = "C13 Optimist"
SWEP.Instructions = "Advanced combat device with enhanced firing system. Fires 3 bullets per shot."
SWEP.Author = "Professor Smiley"
SWEP.Spawnable = true
SWEP.AdminSpawnable = false
SWEP.ViewModelFlip = false
SWEP.HoldType = "ar2"
SWEP.ViewModelFOV = 75
SWEP.ViewModelFlip = true
SWEP.ViewModel = "models/weapons/v_rif_ak47.mdl"
SWEP.WorldModel = "models/weapons/w_rif_ak47.mdl"
SWEP.ShowViewModel = true
SWEP.ShowWorldModel = true
SWEP.ViewModelBoneMods = {}
SWEP.IronSightsPos = Vector(5.51, -8.242, -0.84)
SWEP.IronSightsAng = Vector(0, 0, 0)
SWEP.Primary.Recoil = 1.50
SWEP.Primary.Damage = 25
SWEP.Primary.NumShots = 3
SWEP.Primary.Spread = 0.10
SWEP.Primary.Cone = 0.10
SWEP.Primary.ClipSize = 45
SWEP.Primary.DefaultClip = 90
SWEP.Primary.Ammo = "ar2"
SWEP.Primary.Automatic = true
SWEP.Primary.Delay = 0.5
SWEP.Seconday.ClipSize = -1
SWEP.Seconday.DefaultClip = -1
SWEP.Seconday.Automatic = false
SWEP.Seconday.Ammo = "none"
function SWEP:Initialize()
util.PrechacheSound( "cynosure/blast.wav" )
self:SetWeaponHoldType( self.HoldType )
end
function SWEP:PrimaryAttack()
if ( not self:CanPrimaryAttack() ) then
return
end
local Bullet = {}
Bullet.Num = SWEP.Primary.NumShots
Bullet.Src = self.Owner:GetShootPos()
Bullet.Dir = self.Owner:GetAimVector()
Bullet.Spread = Vector( self.Primary.Spread, self.Primary.Spread, 0 )
Bullet.Tracer = 1
Bullet.Damage = self.Primary.Damage
Bullet.AmmoType = self.Primary.Ammo = "ar2"
self:ShootEffects()
self:FireBullets( Bullet )
self:EmitSount( "cynosure/blast.wav" )
self:TakePrimaryAmmo( 3 )
self:GetNextPrimaryFire( CurTime() + self.Primary.Delay )
end
SWEP.VElements = {
["barrel"] = { type = "Model", model = "models/props_c17/canister02a.mdl", bone = "v_weapon.AK47_Clip", rel = "", pos = Vector(0, 0, 0), angle = Angle(0, 0, 0), size = Vector(0.5, 0.5, 0.5), color = Color(60, 60, 60, 255), surpresslightning = false, material = "bmw", skin = 0, bodygroup = {} },
["sight"] = { type = "Model", model = "models/props_c17/pulleywheels_small01.mdl", bone = "v_weapon.AK47_Parent", rel = "", pos = Vector(-0.519, 3.635, 10.909), angle = Angle(-87.663, 0, 22.208), size = Vector(0.5, 0.5, 0.5), color = Color(120, 120, 120, 255), surpresslightning = false, material = "metal2", skin = 0, bodygroup = {} }
}
SWEP.WElements = {
["barrel"] = { type = "Model", model = "models/props_c17/canister02a.mdl", bone = "ValveBiped.Bip01_R_Hand", rel = "", pos = Vector(5.714, 1.557, -4.676), angle = Angle(106.363, -108.701, -71.3), size = Vector(0.755, 0.755, 0.755), color = Color(60, 60, 60, 255), surpresslightning = false, material = "bmw", skin = 0, bodygroup = {} },
["sight"] = { type = "Model", model = "models/props_c17/pulleywheels_small01.mdl", bone = "ValveBiped.Bip01_R_Hand", rel = "", pos = Vector(18.181, 1.5, -11.948), angle = Angle(-12.858, 0, -160.131), size = Vector(0.5, 0.5, 0.5), color = Color(120, 120, 120, 255), surpresslightning = false, material = "metal2", skin = 0, bodygroup = {} }
}
[/QUOTE]
What did i do wrong here? Any idea?
This is my first mod
[editline]8th December 2014[/editline]
how come there are 2 users viewing this post (excluding me) for like 20 minutes but still no reply?
put it in code tags and we'll help.
Well considering console gives you a lua error... You should probably start therr
[quote]
weapon_c13.lua:59: unexpected symbol near '='
1. unknown - lua/weapons/weapon_c13.lua:0
[/quote]
Line 58 of weapon_c13.lua has something wrong near an equals sign
-snip-
was a 'half asleep' job, failed to notice multiple issues.
Hey dude, the ammo doesnt deplete, and the model isnt what i wanted its an ak. and how am i supposed to enable ironsights when secondary fires a shotgun? and primary is like a 1hit kill auto rifle.
nevermind i'll just steal some gun with Gmad and re-modell it
[QUOTE=Cd5ssmffan;46668856]nevermind i'll just steal some gun with Gmad and re-modell it[/QUOTE]
The community of facepunch will not spoon feed you code, especially with that attitude, I suggest you look up the gmod wiki and start with the tutorials.
So instead of learning how to make a SWEP, one of the easier things to do, you resort to "stealing" a gun and just changing the model? Why are you even making this gun? If it's for a server you are making/developing I would suggest stopping now before you waste your time, because obviously you are not doing this to learn.
Also [CODE]self:EmitSount[/CODE] is probably why the primary fire isnt working on the gun, it errors out there and never takes ammo or sets the delay.
[lua]
AddCSLuaFile()
SWEP.Base = "weapon_base"
SWEP.PrintName = "C13 Optimist"
SWEP.Instructions = "Advanced combat device with enhanced firing system. Fires 3 bullets per shot."
SWEP.Author = "Professor Smiley"
SWEP.Spawnable = true
SWEP.AdminSpawnable = false
SWEP.ViewModelFlip = false
SWEP.HoldType = "ar2"
SWEP.ViewModelFOV = 75
SWEP.ViewModelFlip = true
SWEP.ViewModel = "models/weapons/v_rif_ak47.mdl"
SWEP.WorldModel = "models/weapons/w_rif_ak47.mdl"
SWEP.ShowViewModel = true
SWEP.ShowWorldModel = true
SWEP.ViewModelBoneMods = {}
SWEP.IronSightsPos = Vector(5.51, -8.242, -0.84)
SWEP.IronSightsAng = Vector(0, 0, 0)
SWEP.Primary.Recoil = 1.50
SWEP.Primary.Damage = 25
SWEP.Primary.NumShots = 3
SWEP.Primary.Spread = 0.10
SWEP.Primary.Cone = 0.10
SWEP.Primary.ClipSize = 45
SWEP.Primary.DefaultClip = 90
SWEP.Primary.Ammo = "ar2"
SWEP.Primary.Automatic = true
SWEP.Primary.Delay = 0.5
function SWEP:Initialize()
util.PrechacheSound( "cynosure/blast.wav" )
self:SetWeaponHoldType( self.HoldType )
end
function SWEP:PrimaryAttack()
if ( not self:CanPrimaryAttack() ) then return end
local Bullet = {}
Bullet.Num = self.Primary.NumShots
Bullet.Src = self.Owner:GetShootPos()
Bullet.Dir = self.Owner:GetAimVector()
Bullet.Spread = Vector( self.Primary.Spread, self.Primary.Spread, 0 )
Bullet.Tracer = 1
Bullet.Damage = self.Primary.Damage
Bullet.AmmoType = self.Primary.Ammo
self:ShootEffects()
self:FireBullets( Bullet )
self:EmitSount( Sound("cynosure/blast.wav") )
self:TakePrimaryAmmo( 3 )
self:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
end
SWEP.VElements = {
["barrel"] = { type = "Model", model = "models/props_c17/canister02a.mdl", bone = "v_weapon.AK47_Clip", rel = "", pos = Vector(0, 0, 0), angle = Angle(0, 0, 0), size = Vector(0.5, 0.5, 0.5), color = Color(60, 60, 60, 255), surpresslightning = false, material = "bmw", skin = 0, bodygroup = {} },
["sight"] = { type = "Model", model = "models/props_c17/pulleywheels_small01.mdl", bone = "v_weapon.AK47_Parent", rel = "", pos = Vector(-0.519, 3.635, 10.909), angle = Angle(-87.663, 0, 22.208), size = Vector(0.5, 0.5, 0.5), color = Color(120, 120, 120, 255), surpresslightning = false, material = "metal2", skin = 0, bodygroup = {} }
}
SWEP.WElements = {
["barrel"] = { type = "Model", model = "models/props_c17/canister02a.mdl", bone = "ValveBiped.Bip01_R_Hand", rel = "", pos = Vector(5.714, 1.557, -4.676), angle = Angle(106.363, -108.701, -71.3), size = Vector(0.755, 0.755, 0.755), color = Color(60, 60, 60, 255), surpresslightning = false, material = "bmw", skin = 0, bodygroup = {} },
["sight"] = { type = "Model", model = "models/props_c17/pulleywheels_small01.mdl", bone = "ValveBiped.Bip01_R_Hand", rel = "", pos = Vector(18.181, 1.5, -11.948), angle = Angle(-12.858, 0, -160.131), size = Vector(0.5, 0.5, 0.5), color = Color(120, 120, 120, 255), surpresslightning = false, material = "metal2", skin = 0, bodygroup = {} }
}
[/lua]
This should be fixed, self:EmitSound() needs an argument of the sound, "cynosure/blast.wav" is just a string, Sound("cynosure/blast.wav") is a path and a file for the sound to play, also you don't GetNextPrimaryFire() when trying to set Delay, that function just gets the number of when the NextPrimaryFire can be performed, you use SetNextPrimaryFire() to set it.
Also util.Precache sound also takes an arguemnt of Sound() not just string.
There is still the typo in that code that says EmitSount instead of EmitSound
[CODE]self:EmitSount()[/CODE]
oh and don't forget [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/util/PrecacheSound]util.PrecacheSound[/url] instead of
[CODE]util.PrechacheSound()[/CODE]
Honestly it looks like this code he submitted in the OP was already stolen if he has no clue how to code.
[QUOTE=Cd5ssmffan;46668856]nevermind i'll just steal some gun with Gmad and re-modell it[/QUOTE]
You're the epitome of everything wrong with the workshop community. We didn't immediately give you code, so now you're going to go to someone else's addon that THEY worked on and you're going to download it, slap some GB model onto it and call it your own.
Sorry, you need to Log In to post a reply to this thread.