Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Continuous Health Regeneration v1 for Sapp
- -- by H® Shaft and AelitePrime
- -- This script will continuously regenerate health of injured players based on options you set.
- -- time (in seconds) in between each incremental increase in health
- TIME = 10
- -- Max health of a player. 1 = normal 100% health
- MAX_HEALTH = 1
- -- Max amount of health the script will regenerate to (must be a number).
- MAX_HEALTH_REGEN = MAX_HEALTH
- -- Number of regens, back to MAX_HEALTH_REGEN, a player gets PER LIFE. If you want to disable (thus it always regenerates) set to nil
- MAX_REGENS = nil
- -- increments in which the health is regenerated. 0.1 = 10%
- INCREMENT = 0.1
- -- Number of times the re-generator will give you health for each regen.
- -- If you want to disable it then just make it nil (thus it regenerates repeatedly)
- REGEN_COUNT = 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 it works like this: player_health = (INCREMENT*REGEN_COUNT)+player_health unless its greather than MAX_HEALTH_REGEN, then player_health = MAX_HEALTH_REGEN
- -- don't edit below --
- api_version = "1.10.0.0"
- function OnScriptLoad()
- register_callback(cb['EVENT_GAME_START'], "OnGameStart")
- register_callback(cb['EVENT_GAME_END'], "OnGameEnd")
- register_callback(cb['EVENT_SPAWN'], "OnPlayerSpawn")
- register_callback(cb['EVENT_DAMAGE_APPLICATION'], "OnDamageApplication")
- regens = {}
- regening = {}
- count = {}
- set_regen = nil
- if get_var(0, "$gt") ~= "n/a" then
- game_started = true
- if set_regen == nil then
- set_regen = timer(TIME * 1000, "regenerator")
- end
- else
- game_started = false
- end
- end
- function OnGameStart()
- game_started = true
- if set_regen == nil then
- set_regen = timer(TIME * 1000, "regenerator")
- end
- end
- function OnGameEnd()
- game_started = false
- set_regen = nil
- end
- function OnPlayerSpawn(PlayerIndex)
- if (game_started == true) then
- regens[PlayerIndex] = 0
- regening[PlayerIndex] = false
- count[PlayerIndex] = 0
- local player_object = get_dynamic_player(PlayerIndex)
- if (player_object ~= 0) then
- write_float(player_object + 0xE0, MAX_HEALTH)
- end
- end
- end
- function OnDamageApplication(PlayerIndex, CauserIndex, MetaID, Damage, HitString, Backtap)
- if (game_started == true) then
- if player_alive(PlayerIndex) then
- count[PlayerIndex] = 0
- end
- end
- end
- function regenerator()
- for PlayerIndex = 1,16 do
- if player_alive(PlayerIndex) then
- local player_object = get_dynamic_player(PlayerIndex)
- if (player_object ~= 0) then
- local player_health = tonumber(math.round(read_float(player_object + 0xE0),1))
- local bool = true
- if (player_health < 1) then
- if tonumber(MAX_REGENS) then
- if regening[PlayerIndex] and player_health == MAX_HEALTH_REGEN then
- regening[PlayerIndex] = false
- regens[PlayerIndex] = (regens[PlayerIndex] or 0) + 1
- end
- if (regens[PlayerIndex] or 0) >= MAX_REGENS then
- bool = false
- end
- end
- end
- if (tonumber(REGEN_COUNT) and ((count[PlayerIndex] or 0) >= REGEN_COUNT)) then
- bool = false
- end
- if (bool and player_health < MAX_HEALTH_REGEN) then
- regening[PlayerIndex] = true
- count[PlayerIndex] = (count[PlayerIndex] or 0) + 1
- write_float(player_object + 0xE0, player_health + INCREMENT)
- if player_health > MAX_HEALTH then
- write_float(player_object + 0xE0, MAX_HEALTH)
- end
- end
- end
- end
- end
- return game_started
- end
- function math.round(num, idp)
- return tonumber(string.format("%." .. (idp or 0) .. "f", num))
- end
- function OnError(Message)
- print(debug.traceback())
- end
- -- Created by H® Shaft
- -- Visit http://halorace.org/forum/index.php
- -- The player -db-GoNe/Juhleek - a well spoken liar, cheat.
- -- -db- is: "diverging from the believable" - How ironic. A race clan where admins use rcon to favor themselves to win.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement