Hello, I'm recieving this erros:
Attempt to call a table value
FireBullets - [c]: -1
FireGun - wep_default/init:102
Unknown - df_plane/init:141
Here's the code
df_plane/init.lua
[CODE]
function ENT:Think()
local p = self:GetPhysicsObject()
if IsValid(self:GetDriver()) and self:GetDriver():Alive() and self:GetDriver():Team() != TEAM_SPECTATOR then
if self:GetDriver():IsFrozen() || !GAMEMODE:InRound() then
p:EnableMotion(false)
else
p:EnableMotion(true)
p:Wake()
//Throttle controls
if self.in_speed then
self:SetThrottle(math.Approach(self:GetThrottle(), self.MAX_SPEED, self.THROTTLE_SPEED))
elseif self.in_duck then
self:SetThrottle(math.Approach(self:GetThrottle(), self.MIN_SPEED, self.THROTTLE_SPEED))
end
if self:GetThrottle() > self.MAX_SPEED then self:SetThrottle(self:GetThrottle() - 2) end
//Primary weapon
if self.in_attack then
if IsValid(self:GetWeapon()) then
self:GetWeapon():FireGun()
end
end
//Primary weapon
if self.in_attack2 then
if IsValid(self:GetDriver():GetCurrentWeapon()) then
//if self:GetHasFuelPod() then self:GetDriver():ShowTip("NoWepGotFuel") return end
self:GetDriver():GetCurrentWeapon():FireGun()
end
end
local vel = self:WorldToLocal(self:GetVelocity()+self:GetPos())
self.Engine_Sound:ChangePitch(math.Clamp((self:GetThrottle() * 0.18) + (vel.x / 175)^3,20,250),0)
if self:GetThrottle() == 0 then
self:SetPlaybackRate(0)
else
self:SetPlaybackRate(self:GetThrottle() / self.MAX_SPEED * 0.5)
end
if self:GetLastDamage() + 20 < CurTime() and self:GetDamage() > 0 then
self:SetDamage(self:GetDamage() - 2)
end
if self:GetDriver():KeyDown(IN_FORWARD) then
if self.first_time_boost then
if self:GetBoost() < 50 then
self.boost_enabled = false
else
self:GetDriver():Boost(1)
end
self.first_time_boost = false
end
if self:GetBoost() > 0 and self.boost_enabled then
local discharge_rate = -3
if self:GetLanded() then discharge_rate = -1 end
self:AddBoost(discharge_rate)
self:SetThrottle(self.MAX_SPEED * 1.5)
else
self:SetThrottle(self.MAX_SPEED * 1)
end
else
self.first_time_boost = true
self.boost_enabled = true
if self:GetThrottle() > self.MAX_SPEED then
self:SetThrottle(self.MAX_SPEED)
end
local charge_rate = 4
if self:GetBoost() < 25 then
charge_rate = 1
elseif self:GetBoost() < 50 then
charge_rate = 2
elseif self:GetBoost() < 75 then
charge_rate = 3
if self:GetBoost() >= 50 and self:GetBoost() <= 53 then
self:GetDriver():SendLua([[surface.PlaySound("/df/ready_beep.wav")]])
end
else
end
self:SetBoost(math.Approach(self:GetBoost(), 100, charge_rate))
end
end
else
self:Remove();
end
self:NextThink(CurTime() + 0.1)
return true
end
[/CODE]
wep_default/init.lua
[CODE]
function ENT:FireGun()
if self:GetPlane():GetAmmo() > 1 && self:GetNextFire() < CurTime() then
local dir = self:GetAngles():Forward()
//if self.last_auto_aim_refresh + 0.05 < CurTime() then
self.auto_target = nil
local box_size = 0.1
local range = 4096
local min = self:GetPlane():GetPos() + (self:GetPlane():GetUp() * -box_size) + (self:GetPlane():GetRight() * -box_size)
local max = self:GetPlane():GetPos() + (self:GetPlane():GetUp() * box_size) + (self:GetPlane():GetRight() * box_size) + (self:GetPlane():GetForward() * range)
local ents_in_box = ents.FindInBox(min,max)
local dist = range
for k,v in pairs(ents_in_box) do
if v:GetClass() == "df_plane" and v != self:GetPlane() and v:GetTeam() != self:GetPlane():GetTeam() then
local distance = v:GetPos():Distance(self:GetPlane():GetPos())
if distance < dist then
self.auto_target = v
dist = distance
//self:GetPlane():GetDriver():ChatPrint("Targetting player: ".. v:GetDriver():Nick().." "..math.random(1,10))
end
end
end
self.last_auto_aim_refresh = CurTime()
//end
if IsValid(self.auto_target) then
dir = ((self.auto_target:GetPos() + VectorRand() * 5) - self:GetPos()):GetNormal()
dir = (dir + self:GetAngles():Forward()) / 2
///print(dir)
end
local bot = self:GetPlane():GetDriver():IsBot()
local bullet = {}
bullet.Num = 2
bullet.Src = self:GetPos() + (self:GetForward() * 10)
bullet.Dir = dir
bullet.Tracer = 3
if bot then
bullet.Spread = Vector(self.bot_spread,self.bot_spread,self.bot_spread)
else
bullet.Spread = Vector(self.spread,self.spread,self.spread)
end
bullet.Force = 2
bullet.Damage = 4
bullet.Callback = OnPlaneBulletHit;
self:FireBullets(bullet)
bullet.Src = self.gun2:GetPos() + (self.gun2:GetForward() * 10)
bullet.Dir = dir
self.gun2:FireBullets(bullet)
//if math.random(1,3) == 1 then
local effectdata = EffectData()
effectdata:SetEntity(self)
effectdata:SetScale(self.gun2:EntIndex())
util.Effect( "gun_muzzle_flash", effectdata )
//end
self:EmitSound("npc/turret_floor/shoot"..math.random(1,3)..".wav", 70,100)
self:SetNextFire(CurTime() + 0.05)
end
end
[/CODE]
Sorry, you need to Log In to post a reply to this thread.