Posted: Sat Dec 15, 2018 10:52 am Post subject: Issue with os.time()
I'm stumped as to why my script isn't working how I want it to. In this 1st example it works properly.
local StartTime = os.time()
local EndTime = StartTime+10
timer = createTimer(nil, true)
timer_setInterval(timer, 1)
function Loop()
if os.time() >= endtime then
writeBytes ("[Game.exe + 01F5DDA4] + 34A",255)
end
end
timer_onTimer(timer, Loop)
But in this 2nd example it wont work and I cant figure out why.
local TimeToStart = 0
local StartTime = 0
local EndTime = 0
timer = createTimer(nil, true)
timer_setInterval(timer, 1)
function Loop()
if isKeyPressed (0x32) then
local StartTime = os.time()
local EndTime = StartTime+10
TimeToStart = 1
elseif os.time() >= EndTime and (TimeToStart == 1) then
writeBytes ("[Game.exe + 01F5DDA4] + 34A",255)
end
end
timer_onTimer(timer, Loop)
Any help with understanding why it isn't working in the 2nd example would be hugely appreciated. Thanks in advance
Hey darkbyte. I'm sorry I neglected to give more information on what was happening.
Well with the 1st example the code is executing after the 10 seconds has passed but with the 2nd example the code is executing immediately and ignoring (os.time() >= EndTime)
It must have something to do with running within the Create timer. that's the only real difference between the 1st and 2nd example
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum