I've wrote this one, work fine, but once.
If you want to test it:
timer1 = {}
function delay_script_init(e)
Include ("door_auto.lua")
timer1[e] = os.time()
--timer1[e] = 0
end
function delay_script_main(e)
GetEntityPlayerVisibility(e)
PlayerDist = GetPlayerDistance(e)
if PlayerDist < 150 and g_Entity[e]['plrvisible'] == 1 then
--timer1[e] = os.time()
--Prompt("timer1[e]: " ..timer1[e])
if os.time() > timer1[e] + 30 then
--PromptDuration("os.time1: " ..os.time() .." - timer1[e]: " ..timer1[e],3000)
ActivateIfUsed(e)
SwitchScript(e,"door_auto")
timer1[e] = os.time()
end
end
end
As you can see, I'm calling "door_auto.lua" smallg's script. Thanks a lot smallg.
Add this script to your item. I've trid with a door, and it work fine, but honestly at 4:00 am, not idea how to make it work always.
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