Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Creators: AelitePrime and H® Shaft
- --Script Name: Continuous Health Regeneration Script
- --Website: http://phasorscripts.wordpress.com/
- --Xfire: eliteprime14789x, and nervebooger2012
- --Version: 3.0
- --Reason for Update:
- -- More Features
- -- time (in seconds) in between each incremental increase in health
- time = 10
- -- Max health of a player
- max_health = 1
- -- Max amount of health the script will regen to.
- max_health_regen = max_health
- -- Number of regens, back to max_health_regen, a player gets per life. If you want to disable set to nil
- max_regens = nil
- -- Number of times the re-generator will give you health for each regen.
- -- If you want to disable it then just make it equal to nil
- -- Example: 1
- -- player_health = 0.1
- -- increment = 0.1
- -- max_health_regen = 1
- -- regen_count = 5
- -- re-generator will stop when you have 0.6 health.
- -- Example: 2
- -- player_health = 0.1
- -- increment = 0.1
- -- max_health_regen = 0.5
- -- regen_count = 5
- -- re-generator will stop when you have 0.5 health.
- -- So the system works like this: player_health = (increment*regen_count)+player_health unless its greather than max_health_regen, then player_health = max_health_regen
- regen_count = nil
- -- increments in which the health is regenerated.
- increment = 0.1
- -- Do not Modify
- regens = {}
- regening = {}
- count = {}
- function GetRequiredVersion()
- return 200
- end
- function OnScriptLoad(process, game, persistent)
- set_regen = registertimer(time * 1000, "regenerator")
- end
- function OnGameEnd(stage)
- if stage == 1 then
- removetimer(set_regen)
- end
- end
- function OnPlayerSpawn(player)
- regens[player] = 0
- regening[player] = false
- count[player] = 0
- writefloat(getobject(getplayerobjectid(player)) + 0xE0, max_health)
- end
- function OnDamageApplication(receiving, causing, tagid, hit, backtap)
- if receiving then
- local r_player = objectidtoplayer(receiving)
- if r_player then
- count[r_player] = 0
- end
- end
- end
- function regenerator(id, c)
- for player = 0,15 do
- if getplayer(player) then
- local bool = true
- local m_playerObjId = getplayerobjectid(player)
- if m_playerObjId then
- local m_object = getobject(m_playerObjId)
- local player_health = round(readfloat(m_object + 0xE0),1)
- if tonumber(max_regens) then
- if regening[player] and player_health == max_health_regen then
- regening[player] = false
- regens[player] = (regens[player] or 0) + 1
- end
- if (regens[player] or 0) >= max_regens then
- bool = false
- end
- end
- if tonumber(regen_count) and (count[player] or 0) >= regen_count then
- bool = false
- end
- if bool and player_health < max_health_regen then
- regening[player] = true
- count[player] = (count[player] or 0) + 1
- writefloat(m_object + 0xE0, player_health + increment)
- if player_health > max_health then
- writefloat(m_object + 0xE0, max_health)
- end
- end
- end
- end
- end
- return true
- end
- function round(val, decimal)
- return math.floor((val * 10^(decimal or 0)) + 0.5) / (10^(decimal or 0))
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement