Server Entity Vehicle:VC_setHealthMax(Integer health)
1. Integer health; Health
New health amount.
// Makes all vehicles with these models 5 times as hard to kill. Place code in "lua/autorun/CustomFileName.lua" (could be garrysmod/addons/lua/autorun or garrysmod/lua/autorun/)
if SERVER then
local models = {
"models/tdmcars/emergency/dod_charger12.mdl",
"models/tdmcars/emergency/chargersrt8.mdl"
}
hook.Add("VC_postVehicleInit", "VC_postVehicleInit_MakeCarsStronger", function(ent)
if table.HasValue(models, ent:GetModel()) then
local healthMax = ent:VC_getHealthMax()
local newHealth = healthMax*5
ent:VC_setHealthMax(newHealth) // Lets set the max health first
ent:VC_setHealth(newHealth) // Lets now set the current health. If this is higher than the maxHealth it will clamp it
end
end)
end