Ill tell you right now, this is my first time coding lua. I only know java coding and it has some similarities... some.
So i fixed the hold type i've been having trouble with for a couple of hours. finally. but then this happens when it is used on my server.
I get this error repeatedly when reloading, and this error causes the sweps to have no reload animation.
[lua][weapons\lee_cs_base\shared.lua:110] attempt to compare number with nil[/lua]
So what i had to do was add this.
[lua]function SWEP:Initialize()
self:SetWeaponHoldType( self.HoldType )
self:SetNPCMinBurst( 30 )
self:SetNPCMaxBurst( 30 )
self:SetNPCFireRate( 0.01 )
self:SetNWInt("crouchcone", self.CrouchCone)
self:SetNWInt("crouchwalkcone", self.CrouchWalkCone)
self:SetNWInt("walkcone", self.WalkCone)
self:SetNWInt("aircone", self.AirCone)
self:SetNWInt("standcone", self.StandCone)
self:SetNWInt("ironsightscone", self.IronsightsCone)
self.Reloadaftershoot = 0
self.nextreload = 0
self.Weapon:SetNetworkedBool( "Ironsights", false )
end[/lua]
Without it my weapons would not reload and the cone/crosshair appeared to be really small.
Back to my first error.
it shows i have something wrong with the base. here it is.
I have no more ideas. i just want this fixed. any one kind enough to help me?
[lua]/*---------------------------------------------------------*/
local HitImpact = function(attacker, tr, dmginfo)
local hit = EffectData()
hit:SetOrigin(tr.HitPos)
hit:SetNormal(tr.HitNormal)
hit:SetScale(20)
util.Effect("ground_hit", hit)
return true
end
if (SERVER) then
AddCSLuaFile( "shared.lua" )
SWEP.Weight = 5
SWEP.AutoSwitchTo = false
SWEP.AutoSwitchFrom = false
end
if ( CLIENT ) then
SWEP.ViewModelFOV = 72
SWEP.Slot = 1
SWEP.SlotPos = 1
SWEP.DrawCrosshair = false
SWEP.DrawAmmo = true
SWEP.CSMuzzleFlashes = false
// This is the font that's used to draw the death icons
surface.CreateFont( "csd", ScreenScale( 30 ), 500, true, true, "csKillIcons" )
surface.CreateFont( "cs", ScreenScale( 60 ), 500, true, true, "csSelectIcons" )
end
SWEP.Author = "LeErOy NeWmAn"
SWEP.Contact = ""
SWEP.Purpose = ""
SWEP.Instructions = ""
SWEP.Category = "Counter Strike: Source (LeErOy NeWmAn)"
SWEP.Spawnable = false
SWEP.AdminSpawnable = false
SWEP.ViewModel = "models/weapons/v_pist_deagle.mdl"
SWEP.WorldModel = "models/weapons/w_pist_deagle.mdl"
SWEP.MuzzleEffect = "lee_muzzle_rifle"
SWEP.MuzzleAttachment = "1"
SWEP.Primary.Sound = Sound( "Weapon_AK47.Single" )
SWEP.Primary.Recoil = 0.000000000000001
SWEP.Primary.Damage = 400
SWEP.Primary.ClipSize = 6000
SWEP.Primary.NumShots = 10
SWEP.Primary.Cone = 00000000.1
SWEP.Primary.DefaultClip = 10000
SWEP.Primary.Delay = 0
SWEP.Primary.Automatic = false
SWEP.Primary.Ammo = "gravity"
SWEP.Primary.point = false
SWEP.Primary.ClipSize = -1
SWEP.Primary.DefaultClip = -1
SWEP.Primary.Automatic = false
SWEP.Primary.Ammo = "none"
SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = -1
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = "none"
/*---------------------------------------------------------
---------------------------------------------------------*/
function SWEP:Initialize()
if ( SERVER ) then
self:SetWeaponHoldType( self.HoldType )
self:SetNPCMinBurst( 30 )
self:SetNPCMaxBurst( 30 )
self:SetNPCFireRate( 0.01 )
end
self.Weapon:SetNetworkedBool( "Ironsights", false )
self.Reloadaftershoot = 0
self.nextreload = 0
self:SetNWInt("crouchcone", self.CrouchCone)
self:SetNWInt("crouchwalkcone", self.CrouchWalkCone)
self:SetNWInt("walkcone", self.WalkCone)
self:SetNWInt("aircone", self.AirCone)
self:SetNWInt("standcone", self.StandCone)
self:SetNWInt("ironsightscone", self.IronsightsCone)
end
/*---------------------------------------------------------
Reload does nothing
---------------------------------------------------------*/
function SWEP:Reload()
if ( self.nextreload > CurTime() ) then return end
if ( self.Reloadaftershoot > CurTime() ) then return end
self.Weapon:DefaultReload( ACT_VM_RELOAD );
self.nextreload = CurTime() + 0.7
self.Owner:SetNetworkedInt("ScopeLevel", 0)
self.Owner:SetFOV( 0, 0.18 )
self:SetIronsights( false )
end
/*---------------------------------------------------------
Think does nothing
---------------------------------------------------------*/
function SWEP:Think()
if self.Owner:OnGround() and (self.Owner:KeyDown(IN_FORWARD) or self.Owner:KeyDown(IN_BACK) or self.Owner:KeyDown(IN_MOVERIGHT) or self.Owner:KeyDown(IN_MOVELEFT)) then
if self.Owner:KeyDown(IN_DUCK) then
self.Primary.Cone = self:GetNWInt("crouchwalkcone")
else
self.Primary.Cone = self:GetNWInt("walkcone")
end
elseif self.Owner:OnGround() and self.Owner:KeyDown(IN_DUCK) then
self.Primary.Cone = self:GetNWInt("crouchcone")
elseif not self.Owner:OnGround() then
self.Primary.Cone = self:GetNWInt("aircone")
else
if (self:GetIronsights() == true) then
self.Primary.Cone = self:GetNWInt("ironsightscone")
else
self.Primary.Cone = self:GetNWInt("standcone")
end
end
end
/*---------------------------------------------------------
PrimaryAttack
---------------------------------------------------------*/
function SWEP:PrimaryAttack()
self.Reloadaftershoot = CurTime() + self.Primary.Delay
self.Weapon:SetNextSecondaryFire( CurTime() + self.Primary.Delay )
self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
if ( !self:CanPrimaryAttack() ) then return end
// Play shoot sound
self.Weapon:EmitSound( self.Primary.Sound )
self:CSShootBullet( self.Primary.Damage, self.Primary.Recoil, self.Primary.NumShots, self.Primary.Cone )
self.Owner:ViewPunch(Angle(math.Rand(-0.5,-2.5) * self.Primary.Recoil, math.Rand(-1,1) *self.Primary.Recoil, 0))
// Remove 1 bullet from our clip
self:TakePrimaryAmmo( 1 )
if ( self.Owner:IsNPC() ) then return end
// In singleplayer this function doesn't get called on the client, so we use a networked float
// to send the last shoot time. In multiplayer this is predicted clientside so we don't need to
// send the float.
if ( (SinglePlayer() && SERVER) || CLIENT ) then
self.Weapon:SetNetworkedFloat( "LastShootTime", CurTime() )
end
self:SetNWInt("crouchcone", self:GetNWInt("crouchcone" ) + self.AccuracyDec)
self:SetNWInt("crouchwalkcone", self:GetNWInt("crouchwalkcone" ) + self.AccuracyDec)
self:SetNWInt("walkcone", self:GetNWInt("walkcone" ) + self.AccuracyDec)
self:SetNWInt("aircone", self:GetNWInt("aircone" ) + self.AccuracyDec)
self:SetNWInt("standcone", self:GetNWInt("standcone" ) + self.AccuracyDec)
self:SetNWInt("ironsightscone", self:GetNWInt("ironsightscone") + self.AccuracyDec)
end
/*---------------------------------------------------------
Name: SWEP:PrimaryAttack( )
Desc: +attack1 has been pressed
---------------------------------------------------------*/
function SWEP:CSShootBullet( dmg, recoil, numbul, cone )
numbul = numbul or 1
cone = cone or 0.01
local bullet = {}
bullet.Num = numbul
bullet.Src = self.Owner:GetShootPos() // Source
bullet.Dir = self.Owner:GetAimVector() // Dir of bullet
bullet.Spread = Vector( cone, cone, 0 ) // Aim Cone
bullet.Tracer = 1 // Show a tracer on every x bullets
bullet.Force = self.Primary.Damage / 2 // Amount of force to give to phys objects
bullet.Damage = dmg
bullet.Callback = HitImpact
self.Owner:FireBullets( bullet )
self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK ) // View model animation
self.Owner:MuzzleFlash() // Crappy muzzle light
self.Owner:SetAnimation( PLAYER_ATTACK1 )
local fx = EffectData()
fx:SetEntity(self.Weapon)
fx:SetOrigin(self.Owner:GetShootPos())
fx:SetNormal(self.Owner:GetAimVector())
fx:SetAttachment(self.MuzzleAttachment)
util.Effect(self.MuzzleEffect,fx)
if ( self.Owner:IsNPC() ) then ret
use lua tags [noparse][lua][/lua][/noparse]
[lua]
function SWEP:Reload()
if (CurTime() != nill or null) and (self.nextreload != nill or null) and (self.Reloadaftershoot != nill or null) then
if ( self.nextreload > CurTime() ) then return end
if ( self.Reloadaftershoot > CurTime() ) then return end
end
self.Weapon:DefaultReload( ACT_VM_RELOAD );
self.nextreload = CurTime() + 0.7
self.Owner:SetNetworkedInt("ScopeLevel", 0)
self.Owner:SetFOV( 0, 0.18 )
self:SetIronsights( false )
end
[/lua]
Thanks, really appreciated.
[QUOTE=Tactical_crabby;26842968]Thanks, really appreciated.[/QUOTE]
Sure, no problem, but what I posted only stops it from running instead of erroring, you should figure out why its nill.
yea I realized it. i just got that fixed now. thanks.
Sorry, you need to Log In to post a reply to this thread.