hey i found this old script fow a gearos of war lancer and was trying to figure out why i keep getting script errors.
[ERROR] lua/weapons/chainsaw_gun/shared.lua:34: bad argument #1 to 'pairs' (tabl
e expected, got nil)
1. pairs - [C]:-1
2. unknown - lua/weapons/chainsaw_gun/shared.lua:34
if ( SERVER ) then
AddCSLuaFile( "shared.lua" )
SWEP.HoldType = "smg1"
end
if ( CLIENT ) then
SWEP.PrintName = "Chainsaw gun V2.5"
SWEP.Author = "Left4Lune"
SWEP.Slot = 2
SWEP.SlotPos = 7
SWEP.ViewModelFOV = 76
SWEP.IconLetter = "x"
end
-----------------------Main functions----------------------------
-- function SWEP:Reload() --To do when reloading
-- end
function SWEP:Think() -- Called every frame
end
function SWEP:Deploy()
self.Weapon:EmitSound( "weapons/lancer/lancer_deploy.wav" )
self.Weapon:SendWeaponAnim( ACT_VM_DRAW )
end
function SWEP:Initialize()
for k, v in pairs ( sounds ) do
util.PrecacheSound( "weapons/lancer/saw_"..v..".wav" )
end
end
function SWEP:Reload()
self.Weapon:EmitSound( "weapons/lancer/lancer_reload.wav" )
self.Weapon:DefaultReload(ACT_VM_RELOAD)
end
function SWEP:Holster()
self.Weapon:SendWeaponAnim( ACT_VM_HOLSTER )
timer.Destroy( "IdleSound" )
return true
end
function SWEP:PrimaryAttack()
if self.Weapon:Clip1() == 0 then return end
bullet = {}
bullet.Num = 1
bullet.Src = self.Owner:GetShootPos()
bullet.Dir = self.Owner:GetAimVector()
bullet.Spread = Vector(.026,.026,.026)
bullet.Tracer = 1
bullet.Force = 12.3
bullet.Damage = 11
self.Owner:FireBullets( bullet )
self.Owner:ViewPunch( Angle( math.random(-.35,.35),math.random(-.35,.35),math.random(-.35,.35) ) )
self.Weapon:SetNextPrimaryFire(CurTime() + 0.09)
self.Weapon:EmitSound("weapons/lancer/lancer_fire.wav")
self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK )
self.Owner:SetAnimation( PLAYER_ATTACK1 )
self:TakePrimaryAmmo( 1 )
end
function SWEP:SecondaryAttack()
local tr = self.Owner:GetEyeTrace()
tr.endpos = self.Owner:GetPos() + (self.Owner:GetAimVector() * 150)
local length = (self.Owner:GetShootPos() - tr.Entity:GetPos()):Length()
self.Weapon:SendWeaponAnim( ACT_VM_SECONDARYATTACK )
if length <= 125 then
if tr.Entity:IsValid() and tr.Entity:IsNPC() or tr.Entity:IsPlayer() then
self.Weapon:EmitSound("weapons/lancer/saw_stab"..math.random( 1, 3 )..".wav")
self.Weapon:SendWeaponAnim( ACT_VM_HITCENTER )
util.BlastDamage(self.Owner, self.Owner, tr.HitPos, 4, math.random( 120, 160 ) )
local effectdata = EffectData()
effectdata:SetOrigin( tr.HitPos )
for i=1, 20 do
util.Effect( "bloodsplash_effect", effectdata )
end
elseif !tr.HitWorld then
self.Weapon:EmitSound("weapons/lancer/saw_hitwall1.wav")
self.Weapon:SendWeaponAnim( ACT_VM_HITCENTER )
util.BlastDamage(self.Owner, self.Owner, tr.HitPos, 4, math.random( 120, 160 ) )
local Pos1 = tr.HitPos + tr.HitNormal
local Pos2 = tr.HitPos - tr.HitNormal
util.Decal( "ManhackCut", Pos1, Pos2 )
end
else
self.Weapon:EmitSound( "weapons/lancer/saw_slash1.wav" )
self.Weapon:SendWeaponAnim( ACT_VM_MISSCENTER )
end
self.Weapon:SetNextPrimaryFire( CurTime() + 1.15 )
self.Weapon:SetNextSecondaryFire( CurTime() + 0.65 )
end
-------------------------------------------------------------------
------------General Swep Info---------------
SWEP.Author = "Lune66"
SWEP.Contact = "left4lune@hotmail.com =3"
SWEP.Purpose = "Saw and shoot people."
SWEP.Instructions = "The Lancer from Gears Of War 2."
SWEP.Spawnable = true
SWEP.AdminSpawnable = true
-----------------------------------------------
------------Models---------------------------
SWEP.ViewModelFlip = false
SWEP.ViewModel = "models/weapons/v_lancer.mdl"
SWEP.WorldModel = "models/weapons/w_lancer.mdl"
-----------------------------------------------
-------------Primary Fire Attributes----------------------------------------
SWEP.Primary.Delay = 0.09 --In seconds
SWEP.Primary.Recoil = 0.1 --Gun Kick
SWEP.Primary.Damage = 11 --Damage per Bullet
SWEP.Primary.NumShots = 1 --Number of shots per one fire
SWEP.Primary.Cone = 0 --Bullet Spread
SWEP.Primary.ClipSize = 50 --Use "-1 if there are no clips"
SWEP.Primary.DefaultClip = 550 --Number of shots in next clip
SWEP.Primary.Automatic = true --Pistol fire (false) or SMG fire (true)
SWEP.Primary.Ammo = "smg1" --Ammo Type
-------------End Primary Fire Attributes------------------------------------
-------------Secondary Fire Attributes-------------------------------------
SWEP.Secondary.Delay = 0.1
SWEP.Secondary.Recoil = -0.1
SWEP.Secondary.Damage = 0
SWEP.Secondary.NumShots = 1
SWEP.Secondary.Cone = 0
SWEP.Secondary.ClipSize = 1
SWEP.Secondary.DefaultClip = 2
SWEP.Secondary.Automatic = true
SWEP.Secondary.Ammo = "SMG1_grenade"
-------------End Secondary Fire Attributes--------------------------------
[highlight](User was banned for this post ("wrong section, make one thread not FOUR" - postal))[/highlight]
Well what's the error?
If you want help, tell us what error you are getting and what you have already tried to remedy the issue. Don't just copypaste your code and expect us to fix all your problems, because you won't learn anything that way.
Edit: How exactly is this dumb?
oh sorry, durp
[ERROR] lua/weapons/chainsaw_gun/shared.lua:34: bad argument #1 to 'pairs' (tabl
e expected, got nil)
1. pairs - [C]:-1
2. unknown - lua/weapons/chainsaw_gun/shared.lua:34
There's no sounds table.
[QUOTE=animal chubs;43198087]oh sorry, durp
[ERROR] lua/weapons/chainsaw_gun/shared.lua:34: bad argument #1 to 'pairs' (tabl
e expected, got nil)
1. pairs - [C]:-1
2. unknown - lua/weapons/chainsaw_gun/shared.lua:34[/QUOTE]
The "sounds" table doesn't exist in the context of the function or the lua file from what I see. You should check on that. Also, you should indent your code to make it easier to read.
[QUOTE=Berkin;43198075]If you want help, tell us what error you are getting and what you have already tried to remedy the issue. Don't just copypaste your code and expect us to fix all your problems, because you won't learn anything that way.[/QUOTE]
yeah I know, just forgot to post the error. and i hate trying to figure out other peoples code, not trying to be a bother just trying to get this fixed so i can move on to some other coding issues im having. aslo trying to make a Gears of War Silverback scripted mech. found a good workshop addon that im gonna edit... anyway rambling. I really appreciative all the help.
[QUOTE=Berkin;43198133]The "sounds" table doesn't exist in the context of the function or the lua file from what I see. You should check on that. Also, you should indent your code to make it easier to read.[/QUOTE]
He should put it in [code] tags. Can't indent normal text on this forum.
function SWEP:Initialize()
for k, v in pairs ( sounds ) do
util.PrecacheSound( "weapons/lancer/saw_"..v..".wav" )
end
end
thats the segment of code having the error.
I know, we saw and told you the issue.
in case you don't read your other thread:
wrong section and use code tags
Sorry, you need to Log In to post a reply to this thread.