Regeneration Command

i Search a Command adding Regeneration only for a specified Job on the darkrp gamemode , someone can help me Please ?

This is really not helpful without explaining what you wanted regenerated (assuming health). It also doesn’t help if you give no indication of what you have tried.

But with the little information given, I’d use a think hook,
If item.currentstate < item.maxstate then item.currentstate = item.currentstate +1 (pseudo code)

Sorry i forget about the information with it,

I wanted to add regeneration on a darkrp job like 2 hp every 5 second until 175 hp

You can create a server side timer that runs every 5 seconds and gives players with that job +2 hp if they have less than 175 hp

http://forum.facepunch.com/showthread.php?t=1272495 - everything said in the examples are a bit more complicated than the code I have right now, but they should help and work.

sorry i m new with all of these and i don’t understand the step in the thread you posted , Firewolf2525 .

If you can’t understand that you’re aiming really high or you don’t have any interest in learning, in that case, this is not your forum section



if activator == Team_huiew then
	if activator:Health() > 100 then
		timer.Create(IDSteam .. "huiew", 2, 0, function()
			if not IsValid(activator) then
				timer.Remove(IDSteam .. "huiew")
				return
			end

			activator:SetHealth(activator:Health() - 1)

			if activator:Health() <= 100 then
				timer.Remove(IDSteam .. "huiew")
			end
		end)
	end
end


Here’s a piece of code that does ALL of the hard work for you. If you can’t change this into what you want, then you are seriously not wanting or considering to learn LUA (although what you have to change does not even require knowledge of LUA).

I created something similar for another guy some time ago, here:



local teams;

hook.Add("Initialize", "initializeTeams", function()
    teams = {
        [TEAM_CITIZEN] = 20,
        [TEAM_MOB] = 5,
        [TEAM_MEDIC] = 30
    };
end);

hook.Add("EntityTakeDamage", "resetCooldown", function(ent, dmg)
    if (not IsValid(ent) or not ent:IsPlayer()) then return; end
    ent.nextRegen = CurTime() + 5;
end);

local function ShouldRegen(ply)
    if (not ply.nextRegen) then return false end;
    if (ply.nextRegen > CurTime()) then return false end;
    if (not ply:Alive()) then return false end;
    if (ply:Health() == ply:GetMaxHealth()) then return false end;
    if (not teams[ply:Team()]) then return false end;

    return true;
end

local function GiveHealth(ply)
    ply:SetHealth(math.Clamp(ply:Health() + teams[ply:Team()], 0, ply:GetMaxHealth()));

    ply.nextRegen = CurTime() + 5;
end

hook.Add("Tick", "regenHealth", function()
    local playerCount = player.GetCount();
    local players     = player.GetAll();
    
    for i = 1, playerCount do
        local Player = players*;
        if (not IsValid(Player) or not ShouldRegen(Player)) then continue; end
        GiveHealth(Player);
    end
end);


Just add your jobs in the table and how much you want them to receive every 5 second. If 5 health every 5 seconds is too much then you can simply increase the “ply.NextRegen = CurTime() + 5”

Forgot the top line in my previous code so I just edited it right now