View previous topic :: View next topic |
Author |
Message |
Lorizzuoso Cheater
Reputation: 0
Joined: 09 Apr 2022 Posts: 27
|
Posted: Sat Apr 09, 2022 6:13 pm Post subject: Lua script |
|
|
Hello,does anyone know how to make a lua script that constantly adds a value to an address?And when i press deactivate it resets the address value to 0.
Thanks.
|
|
Back to top |
|
 |
LeFiXER Grandmaster Cheater Supreme
Reputation: 20
Joined: 02 Sep 2011 Posts: 1066 Location: 0x90
|
Posted: Sun Apr 10, 2022 1:04 am Post subject: |
|
|
You can achieve this with a timer that will automatically disable upon meeting certain criteria, for example:
Code: |
-- If the timer exists then destroy it
if timer then timer.destroy(); timer = nil end
local timer = createTimer(getMainForm())
local address = AddressList.getMemoryRecordByDescription('address_description_here')
timer.Interval = 100
timer.OnTimer = function()
address.value = address.value + 10
if tonumber(address.value) = 100 then
timer.destroy()
timer = nil
end
end
|
|
|
Back to top |
|
 |
Lorizzuoso Cheater
Reputation: 0
Joined: 09 Apr 2022 Posts: 27
|
Posted: Sun Apr 10, 2022 2:13 am Post subject: Lua script |
|
|
[ENABLE]
{$lua}
if timer then timer.destroy(); timer = nil end
local timer = createTimer(getMainForm())
local address = AddressList.getMemoryRecordByDescription('Head rotation')
timer.Interval = 100
timer.OnTimer = function()
0x300E4E8D = 0x300E4E8D + 10
if tonumber(0x300E4E8D) = 100 then
timer.destroy()
timer = nil
end
end
[DISABLE]
{$lua}
So 300E4E8D it's the address that write that value but there's an error,"unexpected symbol near 0x300E4E8D", it doesn't like the 0x?
|
|
Back to top |
|
 |
LeFiXER Grandmaster Cheater Supreme
Reputation: 20
Joined: 02 Sep 2011 Posts: 1066 Location: 0x90
|
Posted: Sun Apr 10, 2022 3:17 am Post subject: |
|
|
Code: |
[ENABLE]
{$LUA}
if timer then timer.destroy(); timer = nil end
local timer = createTimer(getMainForm())
-- This line retrieves the entry in the table and assigns it to the variable address
local address = AddressList.getMemoryRecordByDescription('Head rotation')
timer.Interval = 100
timer.OnTimer = function()
-- Check if the entry exists in the table, if not, destroy the timer
if address == nil then
timer.destroy()
timer = nil
else
-- Take the value of the address and then add 10 to it
address.value = address.value + 10
-- Convert the value to a number and then compare it against 100, if the value equals 100 then destroy the timer
if tonumber(address.value) = 100 then
timer.destroy()
timer = nil
end
end
{$ASM}
[DISABLE]
...
|
|
|
Back to top |
|
 |
Lorizzuoso Cheater
Reputation: 0
Joined: 09 Apr 2022 Posts: 27
|
Posted: Sun Apr 10, 2022 11:28 am Post subject: Lua script |
|
|
My bad forgot to tell that this address might not be static and even with this an error appears:"lua error in the script at line 2:[string "local syntax check,memrec=..."]18:then expected near "="
|
|
Back to top |
|
 |
|