Posted: Thu Aug 10, 2017 2:19 pm Post subject: How to disable a AA script soon after enabling it?
For example as soon as the script is enabled, a timer will start counting 5 seconds, then after the 5 seconds is up the script will automatically disable.
{$lua}
if syntaxcheck then return end
-- CE 6.7 provides the memory record as memrec
-- if the user isn't running CE >= 6.7 or the name changes at some point
-- this is an alternative, though it depends on the user not changing the name
-- using the ID is a little more reliable but you have to open the CT to find it
-- or use the extra memrec info lua extension found on the CE forums
local memrec = memrec or getAddressList().getMemoryRecordByDescription("Script Name")
local timer = createTimer()
timer.Interval = 5 * 1000 -- 1000 milliseconds per second
timer.OnTimer = function(theTimerCallingThisFunction)
memrec.Active = false -- deactivate the script
timer.destroy() -- destroy the timer so it doesn't keep running
end
{$asm}
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