i was making a Extreme vehicle upgrade addon for my server and im having some problems with is
Path is EVU/lua/autorun/vehicleupgrade.lua then the code is
[code]
local function ENT:OnTakeDamage( dmginfo )
if ENT:IsVehicle() then
ENT.StartHealth = 500
ENT.MaxHealth = 500
--ENT.Gas = 1000
self:SetMaxHealth(ENT.MaxHealth)
self:SetHealth(ENT.StartHealth)
if dmginfo:IsExplosionDamage() and dmginfo:GetDamage() >= 50 then
self:Detonate(dmginfo)
end
if self:Health() - dmginfo:GetDamage() <= 0 then
self:Detonate(dmginfo)
timer.Create( "carremover_timer", 60, 0, function()
self:Remove()
end)
else
end
end
end
function ENT:Detonate(dmginfo)
self.BombActive = false
local eplx = ents.Create("env_explosion")
eplx:SetPos(self:GetPos())
eplx:SetKeyValue("iMagnitude", "0")
eplx:SetOwner(dmginfo:GetAttacker())
eplx:Spawn()
eplx:Fire("explode", "", 0)
eplx:Fire("kill", "", 0)
util.BlastDamage( self, dmginfo:GetAttacker(), self:GetPos(), 300, 200 )
local effect = EffectData()
effect:SetOrigin(self:GetPos())
effect:SetScale(5)
util.Effect("immolate", effect)
self:SetMaterial("models/props_pipes/guttermetal01a.vmt")
self:SetColor(Color(100,100,100,255))
local phys = self:GetPhysicsObject()
phys:ApplyForceCenter( Vector(0,0,phys:GetMass() * 425) )
phys:AddAngleVelocity( Vector(math.random(-100, 100),math.random(-100, 100),math.random(-100, 100)) )
self.smoke:Fire("kill", "", 0)
self.fire:Fire("kill", "", 0)
end
function Horn()
if ply:InVehicle() then
if ply:KeyDown( KEY_H ) then
local veh = ply:GetVehicle() or {}
if IsValid( veh ) && veh:GetClass() != "prop_vehicle_prisoner_pod" then
player:GetVehicle():EmitSound("/beepbeep1.wav", 100, 100)
end
end
end
end
function HUD()
local ply = LocalPlayer()
draw.RoundedBox(25, 25, 50, 200, 100, Color(51, 58, 51, 255))
draw.SimpleText("Car Health:" .. self:Health() .. "%", "Default", 100, 50, Color(86, 104, 86, 255), 0, 0)
end
/*
function RegisterChatCommand(strCommand, Func)
if( !strCommand || !Func ) then return; end
for k, v in pairs( chatcommands ) do
if( strCommand == k ) then
return;
end
end
chatcommands[ tostring( strCommand ) ] = Func;
end
function blacklist()
RegisterChatCommand("!blacklist", function(ply, args)
if( ply:IsAdmin() ) then
local pname = args[1];
for _, v in pairs( player.GetAll() ) do
if( string.find(v:Nick(), pname) ) then
v:ChatPrint("Blacklisted from Vehicle");
end
end
end
else
player:PrintMessage("Your not an admin sorry")
return false
end)
end
*/
/*function gas()
timer.Create( "gas_timer", 10, 0, function()
end)
end
*/
[/code]
Any errors? What exactly do you need help with?
[code] player:PrintMessage("You're not an admin sorry")
return false[/code]
fix'd
edit:justkidding, what are your errors
-random duplicate-
it doesnt show errors it just an addon that does completely nothen like i well shot 5 or 6 m9k nukes nope nothen does not explode
[QUOTE=xrayhunter1;42745771]it doesnt show errors it just an addon that does completely nothen like i well shot 5 or 6 m9k nukes nope nothen does not explode[/QUOTE]
The first line of code you set the vehicles health to 500 every time.
so should i delete something? or add something?
[QUOTE=xrayhunter1;42747176]so should i delete something? or add something?[/QUOTE]
You should use the OnEntityCreated hook to check if it's a vehicle, then set it's health. Not set the health every time an entity takes damage, as you will just set it to 500 every time.
You can't have that code in a clientside file, I assume it is since you use LocalPlayer().
Sorry, you need to Log In to post a reply to this thread.