General > Developers Corner

Max hp healing Code needed!

(1/2) > >>

aussie0411:
Basically I am helping somebody on a star wars rp server and they need to know how to get the medkit to heal to the health the job is set at. For example, a jedi with 500 health that drops to 400 can't be healed back up to 500 but only up to 100 if he is lower than 100. Anything higher than 100 he can't be healed. How do I change that to the hp the job is set at?

Bytewave:
Instead of just using Entity:SetHealth(number hp), you will want to also use Entity:SetMaxHealth(number maxhp) in your job's info, or set max health in the config file however you're told to.

aussie0411:

--- Quote from: Bytewave on May 21, 2016, 09:19:47 AM ---Instead of just using Entity:SetHealth(number hp), you will want to also use Entity:SetMaxHealth(number maxhp) in your job's info, or set max health in the config file however you're told to.

--- End quote ---

Can you change it for me?

AddExtraTeam("Doom Commander", {
    color = Color(63, 127, 79, 255),
    model = {"models/player/asgclonewars/commander_doom/commander_doom.mdl"},
    description = [[Doom CO]],
    weapons = {"weapon_752_t21", "weapon_752_dc15a", "weapon_752_dc17dual"},
    command = "doomco",
    max = 1,
    salary = 400,
    admin = 0,
   PlayerSpawn = function(ply) GAMEMODE:SetPlayerSpeed(ply, GAMEMODE.Config.walkspeed * 1, GAMEMODE.Config.runspeed * 1) ply:SetHealth("500") ply:SetGravity(1) return CLIENT end,
    PlayerDeath = function(ply) GAMEMODE:SetPlayerSpeed(ply, GAMEMODE.Config.walkspeed * 1, GAMEMODE.Config.runspeed * 1) return CLIENT end,
    vote = false,
    hasLicense = false,
category = "Doom",
})

is the default job, can you add in the hp thing or instruct me on how to do so?

An Error Has Occurred!

array_keys(): Argument #1 ($array) must be of type array, null given

[0] Board index

Go to full version