• SWEP Issue
    3 replies, posted
So I'm making a TTT weapon for my server, and for some reason it's spamming the console saying "attempt to call method 'GetIronsights' (a nil value)" I only get this when I open up this specific weapon. Any other weapon it's fine. I can't even find the function GetIronsights() in weapon_tttbase, weapon_base, or even terrortown the gamemode itself. Help me out here? Here's the function that's asking for GetIronsights() ( Line 38 ) [lua] function GM:Tick() -- three cheers for micro-optimizations plys = player.GetAll() for i= 1, #plys do ply = plys[i] tm = ply:Team() if tm == TEAM_TERROR and ply:Alive() then -- Drowning if ply:WaterLevel() == 3 then if ply:IsOnFire() then ply:Extinguish() end if ply.drowning then if ply.drowning < CurTime() then local dmginfo = DamageInfo() dmginfo:SetDamage(15) dmginfo:SetDamageType(DMG_DROWN) dmginfo:SetAttacker(GetWorldEntity()) dmginfo:SetInflictor(GetWorldEntity()) dmginfo:SetDamageForce(Vector(0,0,1)) ply:TakeDamageInfo(dmginfo) -- have started drowning properly ply.drowning = CurTime() + 1 end else -- will start drowning soon ply.drowning = CurTime() + 8 end else ply.drowning = nil end -- Slow down ironsighters local wep = ply:GetActiveWeapon() if ValidEntity(wep) and wep:GetIronsights() then -- Right here ply:SetSpeed(true) else ply:SetSpeed(false) end -- Run DNA Scanner think also when it is not deployed if IsValid(ply.scanner_weapon) and wep != ply.scanner_weapon then ply.scanner_weapon:Think() end elseif tm == TEAM_SPEC then if ply.propspec then PROPSPEC.Recharge(ply) if IsValid(ply:GetObserverTarget()) then ply:SetPos(ply:GetObserverTarget():GetPos()) end end -- if spectators are alive, ie. they picked spectator mode, then -- DeathThink doesn't run, so we have to SpecThink here if ply:Alive() then self:SpectatorThink(ply) end end end end [/lua]
[quote] [lua] if ValidEntity(wep) and wep:GetIronsights() then -- Right here [/lua] [/quote] -- Disclaimer: this advice is offered from a purely speculative perspective -- Is it possible that the weapon you're trying to use doesn't have a GetIronsights() function?
No other weapons do. Not even weapon_tttbase or weapon_base [editline]11th July 2012[/editline] ^ but they work fine without this error
.. Any ideas? :/
Sorry, you need to Log In to post a reply to this thread.