HUD
Functions

Vehicle: set Health Max

Allows to set vehicles maximum health.

Used in: VCMod Main addon.

Server Entity Vehicle:VC_setHealthMax(Integer health)

Arguments

1. Integer health; Health
New health amount.

Example

// 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
Page modified:
...2018-12-03 16:51:25