Hi, i have found and tested Smallg's Timer,
i have put an Trigger Zone so if iam in the zone the timer countdown loops. But if iam going off the Zone and iam go back in the Zone the countdown is not be reset and count where he was stopped.
So my question is, can i input a reset script code ? I want to use this zone if a player goes out of the Game Area, then a countdown timer loops and he will die. But if he go back in de game area and goes out of the game area again, the counter must be reset and count again.
Here is the code:
local timer1 = nil
local timer2 = nil
local timer3 = nil
local lowtime = nil
local damagetick = false
g_escape_timer = {}
local flash_dir = "ON"
function escape_timer_properties(e, timelimit, damage, showtimer, timernormalred, timernormalgreen, timernormalblue,
flashbelow, flashspeed, timerlowred, timerlowgreen, timerlowblue, timerx, timery, timersize)
local et = g_escape_timer[e]
et.timelimit = timelimit
et.damage = damage
et.showtimer = showtimer
et.timernormalred = timernormalred
et.timernormalgreen = timernormalgreen
et.timernormalblue = timernormalblue
et.flashbelow = flashbelow
et.flashspeed = flashspeed
et.timerlowred = timerlowred
et.timerlowgreen = timerlowgreen
et.timerlowblue = timerlowblue
et.timerx = timerx
et.timery = timery
et.timersize = timersize
end
function escape_timer_init(e)
g_escape_timer[e] = {}
local et = g_escape_timer[e]
et.timelimit = 20
et.damage = 100
et.showtimer = 1
et.timernormalred = 255
et.timernormalgreen = 255
et.timernormalblue = 255
et.flashbelow = 25
et.flashspeed = 4
et.timerlowred = 255
et.timerlowgreen = 0
et.timerlowblue = 0
et.timerx = 50
et.timery = 45
et.timersize = 5
end
function escape_timer_main(e)
if g_Entity[e]['plrinzone']==1
then
TextCenterOnXColor(50,50,5,"Outside Play Area",255,255,255)
local function round(num, numDecimalPlaces)
local mult = 10^(numDecimalPlaces or 0)
return math.floor(num * mult + 0.5) / mult
end
local function SecondsToClock(seconds)
local seconds = tonumber(seconds)
if seconds <= 0 then
return "00:00:00";
else
hours = string.format("%02.f", math.floor(seconds/3600));
mins = string.format("%02.f", math.floor(seconds/60 - (hours*60)));
secs = string.format("%02.f", math.floor(seconds - hours*3600 - mins *60));
return hours..":"..mins..":"..secs
end
end
local et = g_escape_timer[e]
if timer1 == nil then
timer1 = g_Time + (et.timelimit*1000)
timer3 = g_Time + (1000/et.flashspeed)
timer2 = g_Time+1000
lowtime = (et.timelimit*1000)*(et.flashbelow/100)
end
local timeremaining = timer1 - g_Time
if timeremaining <= 0 then
timeremaining = 0
if damagetick == false then
HurtPlayer(e,et.damage)
damagetick = true
end
if g_Time > timer2 then
timer2 = g_Time+1000
damagetick = false
end
end
if et.showtimer == 1 then
local timetoshow = SecondsToClock(timeremaining/1000)
if timeremaining > lowtime then
TextCenterOnXColor(et.timerx, et.timery, et.timersize, timetoshow, et.timernormalred, et.timernormalgreen, et.timernormalblue)
else
if flash_dir == "ON" then
TextCenterOnXColor(et.timerx, et.timery, et.timersize, timetoshow, et.timerlowred, et.timerlowgreen, et.timerlowblue)
if g_Time > timer3 then
timer3 = g_Time+(1000/et.flashspeed)
flash_dir = "OFF"
end
else
--need to show blank text cos there's a bug with text not being removed
TextCenterOnXColor(et.timerx, et.timery, et.timersize, " ", et.timerlowred, et.timerlowgreen, et.timerlowblue)
if g_Time > timer3 then
timer3 = g_Time+(1000/et.flashspeed)
flash_dir = "ON"
end
end
end
end
--Prompt(flash_dir)
end
end
The author of this post has marked a post as an answer.
Go to answer