I've been playing around with timers, please see example only code below (note: the example below uses OmegaCore plugin and some of the code is commented out):
-- LUA Script - precede every function and global member with lowercase name of script + '_main'
function plrinzone_keypress_init(e)
local TODESTROY = 0
local mytimervar
StartTimer(e)
end
function plrinzone_keypress_main(e)
if g_Entity[e]['plrinzone']==1 then
Text(50,50,1,"Hello World")
Text(50,70,1,"Hello World2")
Panel(10,10,20,20)
Panel(60,60,80,80)
TextCenterOnX(50,90,4,"Hello World3")
--Prompt("Time elapsed: "..tostring(g_Time));
-- mytimervar=math.floor(GetTimer(e)) / 1000
-- Prompt("Time elapsed (secs): "..tostring(mytimervar));
--if GetTimer(e) >=9999 then
--PromptDuration("Are you going to press a key!",2000);
-- TextCenterOnX(50,50,20,"Are you going to press a key!")
-- StartTimer(e)
--end
--PlaySound(e,0)
if ocGetKey("NUMPAD0") == 1 then
Prompt("You pressed the 0 on the Numeric Pad!");
TODESTROY=0
end
if ocGetKey("MBUTTON") == 1 then
Prompt("You pressed the Middle Mouse Button and destroyed the zone object!");
TODESTROY=1
end
TextCenterOnX(50,50,20,"Are you going to press a key!")
if TODESTROY==1 then
Destroy(e)
ActivateIfUsed(e)
end
end
end
Professional Programmer: Languages- SAS, C++, SQL, PL-SQL, JavaScript, HTML, Darkbasic Pro, Purebasic, others
Hardware: Dell Precision 490; AMD Radeon HD 7570; LG TFT monitor (widescreen).