Open MrDadosz opened 5 years ago
I notice in your "test2" resource, it's returning true for isTimer
. With the following code I'm returning false for both isTimer
and getTimerDetails
resource 1:
addEvent("onTimerFire", true)
timer = false
function init()
timer = setTimer(timerFunc, 10000, 0)
end
addEventHandler("onResourceStart", resourceRoot, init)
function timerFunc()
triggerEvent("onTimerFire", root, timer)
end
resource 2
function checkTimerDetails(timer)
print(isTimer(timer), toJSON(getTimerDetails(timer)))
end
addEventHandler("onTimerFire", root, checkTimerDetails)
outputs: false [ false ]
Is this an old or recent bug?
Sorry, I spent a lot of time figuring out why my script isn't working and I'm wrong about isTimer. Script returns: false, false, nil, nil You can't use getTimerDetails and isTimer but you can check type of the variable and it returns wrong data. In the resource where you created timer it returns lua-timer02000288. In other resource when you're using getElementType on the timer it returns userdata02000288. In my opinion you should be able to check if variable is a timer and get details from it etc. or update info about it on wiki:
https://wiki.multitheftauto.com/wiki/Timer "Also timers are not under the resource hierarchy, because they are not elements, for instance, if you create a timer, it will not be destroyed when the resource in which it was created is stopped, so in this case you should kill the timer manually." - stopping the resource kills the timer (or you can't access it from other resources).
resources.zip Same resource: true, -5, nil, 1000, lua-timer02000288 - everything is okay Other resource: false, false, nil, nil, userdata02000288 - shows timer as userdata, can't check if it's a timer and can't get details of it.
I can confirm isTimer and isElement both return false on a timer from another resource. The timer is passed through an exported function. You can't destroy it or interact with it at all. It's a real bummer cause I have this system in my gamemode where it destroys elements from certain resources.
Describe the bug You can't check timer details from timer, that was created in other resource. isTimer function is working, but getTimerDetails isn't.
To reproduce
Expected behaviour You could check timer details even if they're created in other resource.
Version Server: Ubuntu 14, MTA:SA Server v1.5.6-release-14688 Client: Windows 10, Multi Theft Auto v1.5.6-release-16068.8.014