1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Sign up for news, events and more!

    You're currently visiting the official DarkRP Forums as a guest. Sign up now to participate in our community and we'll let you know when we have news.

Certain job to heal each second

Discussion in 'DarkRP Modding Questions & Help' started by [AG] KaydenWaffles, Oct 24, 2014.

  1. [AG] KaydenWaffles

    [AG] KaydenWaffles New Member

    So I have a Deadpool class on my DarkRP 2.5.1 server. It is TEAM_DEADPOOL.

    This is actually a request from the co-owner because he loves Deadpool.
    Is somebody able to put together some code for how to make the Deadpool class automatically heal 1 HP every second?

    And where would I place this file.

    Thank you.
  2. Cake

    Cake Active Member

    local HealthRegen = {}
    HealthRegen.Amount = 1
    HealthRegen.GiveDelay = 0.05
    HealthRegen.MaxRegen= 100

    hook.Add( "Think", "RegenHealth", function()
    for k,v in pairs( player.GetAll() ) do
    if v:Alive() and v:Health() < HealthRegen.MaxRegen and ( !v.lastregen or v.lastregen < CurTime() - HealthRegen.GiveDelay ) and team.GetName(v:Team())=="Deadpool" then
    v.lastregen = CurTime()
    v:SetHealth( v:Health() + HealthRegen.Amount )
    end )

    No idea if it works or not, looks like it should. And there is probably a better way to do it.

    Modified from this thread http://facepunch.com/showthread.php?t=1059592

    EDIT: Forgot to say where to put it, it goes in lua->autorun->server

Share This Page