View previous topic :: View next topic |
Author |
Message |
reverser69 Expert Cheater
Reputation: 0
Joined: 03 Sep 2014 Posts: 112
|
Posted: Wed Jul 14, 2021 6:54 pm Post subject: [help] seting timer for disablig scripts |
|
|
hi all
i wrote a Lua script nut there's something wrong with it. when I disable it and re-enable it CE freezes.
Code: | [ENABLE]
//code from here to '[DISABLE]' will be used to enable the cheat
{$lua}
function autodisable(sender)
hud_ac = getAddressList().getMemoryRecordByID(17448)
hud_ac.Active=false
hud_deac = getAddressList().getMemoryRecordByID(17449)
hud_deac.Active=false
end
if t == nil then
t=createTimer(nil)
---if (getAddressList().getMemoryRecordByID(17448).Active==true) or (getAddressList().getMemoryRecordByID(17449).Active==true) then
t.OnTimer=autodisable
t.Interval=1000
t.Enabled=true
---end
end
{$asm}
[DISABLE]
//code from here till the end of the code will be used to disable the cheat
{$lua}
t.Destroy() |
also, how can I log or print all active timers?
|
|
Back to top |
|
 |
Frouk Grandmaster Cheater
Reputation: 5
Joined: 22 Jun 2021 Posts: 510
|
Posted: Thu Jul 15, 2021 1:51 am Post subject: |
|
|
You can just write this lua in cheat engine lua table and then call function in AA
This will call function example
Code: | if t == nil then
t=createTimer(nil)
---if (getAddressList().getMemoryRecordByID(17448).Active==true) or (getAddressList().getMemoryRecordByID(17449).Active==true) then
t.OnTimer=autodisable
t.Interval=1000
t.Enabled=true
---end |
You disabled if and end
Code: | ---This is comment block |
You can't use ---, this is just comment block start in single line
|
|
Back to top |
|
 |
reverser69 Expert Cheater
Reputation: 0
Joined: 03 Sep 2014 Posts: 112
|
Posted: Thu Jul 15, 2021 7:22 am Post subject: |
|
|
what i want to do is this:
I call two functions of the game via create thread. i kill the thread. but the script remains active. i want to deactivate them after the tread is terminate (ret instruction).
any idea how can I do it better than the above script?
|
|
Back to top |
|
 |
LeFiXER Grandmaster Cheater Supreme
Reputation: 20
Joined: 02 Sep 2011 Posts: 1069 Location: 0x90
|
Posted: Thu Jul 15, 2021 10:07 am Post subject: |
|
|
Code: |
[ENABLE]
//code from here to '[DISABLE]' will be used to enable the cheat
{$lua}
function autodisable(sender)
hud_ac = getAddressList().getMemoryRecordByID(17448)
hud_ac.Active=false
hud_deac = getAddressList().getMemoryRecordByID(17449)
hud_deac.Active=false
end
if t == nil then
t=createTimer(nil)
---if (getAddressList().getMemoryRecordByID(17448).Active==true) or (getAddressList().getMemoryRecordByID(17449).Active==true) then
t.OnTimer=autodisable
t.Interval=1000
t.Enabled=true
---end
end
{$asm}
[DISABLE]
//code from here till the end of the code will be used to disable the cheat
{$lua}
t.Destroy()
|
A single-line Lua comment is initialised with '--'
Here is how I achieved the same thing (disabling the script after a set time defined by the user once the script has been activated)
Code: |
local scriptName = 'script_name' -- Enter the name of the script here
local t = createTimer(getMainForm())
t.Interval = 5000 -- In milliseconds, set to 5 seconds to enable time for the script to execute
t.OnTimer = function(disableScript)
local al = getAddressList()
local mr = al.getMemoryRecordByDescription(scriptName)
if mr == nil then -- if the script doesn't exist in the table
t.destroy() -- destroy the timer
else if mr ~= nil and mr.Active == true then -- if script exists and is activated
Sleep(3000) -- wait 3 seconds so it doesn't auto-deactivate
mr.Active = false -- deactivate script
t.Destroy() -- destroy the timer
end
end
end
|
Just put that below the AA code in your script and once the script is activated it will deactivate after 8 seconds, defined by the timer interval + the length of time to sleep. You can adjust these values as per your requirement.
|
|
Back to top |
|
 |
reverser69 Expert Cheater
Reputation: 0
Joined: 03 Sep 2014 Posts: 112
|
Posted: Thu Jul 15, 2021 3:28 pm Post subject: |
|
|
@LeFiXER
i use a "ret" instruction in my cheat. so i think this lua won't be executed?!
|
|
Back to top |
|
 |
LeFiXER Grandmaster Cheater Supreme
Reputation: 20
Joined: 02 Sep 2011 Posts: 1069 Location: 0x90
|
Posted: Fri Jul 16, 2021 7:28 am Post subject: |
|
|
reverser69 wrote: | @LeFiXER
i use a "ret" instruction in my cheat. so i think this lua won't be executed?! |
It shouldn't matter. CE will execute Auto Assembler first and then the Lua script providing it falls under the [ENABLE] section of the script.
|
|
Back to top |
|
 |
|