Use os.time instead of GetTimer(e).
Take a look this mater smallg script, see how he is using os.time.
-- LUA Script - precede every function and global member with lowercase name of script + '_main'
-- Door Prompts 'Closed' can be opened with entity collected specified by 'USE KEY'
open = {}
local timer = {}
function door_auto_init(e)
open[e] = 0
timer[e] = 0
end
function door_auto_main(e)
PlayerDist = GetPlayerDistance(e)
if open[e] == 0 then
if PlayerDist < 150 and g_PlayerHealth > 0 then
if g_Entity[e]['activated'] == 0 then
if g_Entity[e]['haskey'] == -1 then
SetActivated(e,1)
else
if g_Entity[e]['haskey'] == 1 then
Prompt("Unlock the door?")
if g_KeyPressE == 1 then
SetActivated(e,1)
end
else
Prompt("This door is locked")
end
end
else
if g_Entity[e]['activated'] == 1 then
if g_Entity[e]['animating'] == 0 then
timer[e] = os.time()
SetAnimation(0)
PlayAnimation(e)
g_Entity[e]['animating'] = 1
SetActivated(e,2)
ActivateIfUsed(e)
PlaySound(e,0)
end
else
if g_Entity[e]['activated'] == 2 then
-- door collision off after 1 second
if os.time() > timer[e] + 2 then
CollisionOff(e)
open[e] = 1
--PromptDuration("os.time: " ..os.time() .." - timer[e]: " ..timer[e],3000)
end
end
end
end
end
else
if GetPlayerDistance(e) > 180 then
-- door is open
if g_Entity[e]['activated'] == 2 then
if g_Entity[e]['animating'] == 0 then
--StartTimer(e)
timer[e] = os.time()
SetAnimation(1)
PlayAnimation(e)
g_Entity[e]['animating'] = 1
SetActivated(e,1)
PlaySound(e,1)
end
else
if os.time() > timer[e] + 2 then
CollisionOn(e)
open[e] = 0
--timer[e] = os.time()
end
end
end
end
--timer[e] = 0
end
3com
Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz
OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics