| 
			
				|  | Cheat Engine The Official Site of Cheat Engine
 
 
 |  
 
	
		| View previous topic :: View next topic |  
		| Author | Message |  
		| gavrielsinvani Cheater
 
 ![]() Reputation: 0 
 Joined: 29 May 2019
 Posts: 36
 
 
 | 
			
				|  Posted: Fri Oct 18, 2024 3:43 am    Post subject: Need help with Lua Cheat Table |   |  
				| 
 |  
				| I have this script in my cheat table, 
 
  	  | Code: |  	  | {$lua} local timer = createTimer(nil, false)
 [ENABLE]
 if syntaxcheck then return end
 
 
 local isShutdown = false  -- משתנה כדי למנוע כיבוי כפול
 
 -- הפונקציה להרצת הקוד
 function run_code()
 if not isShutdown then
 local address = getAddress("144480BB0")  -- המרת הכתובת למספר
 if address and address ~= 0 then
 writeBytes(address, 0x48, 0x31, 0xC0)  -- XOR RAX, RAX
 writeBytes(address + 3, 0xC3)  -- RET
 print("Code executed.")
 
 -- מתחיל ספירה של 5 שניות לכיבוי
 timer.Interval = 5000  -- 5 שניות
 timer.OnTimer = shutdown
 timer.Enabled = true
 else
 print("Invalid address.")
 end
 end
 end
 
 -- הפונקציה לכיבוי
 function shutdown()
 if not isShutdown then
 local shutdownAddress = getAddress("144480BB0")
 if shutdownAddress and shutdownAddress ~= 0 then
 writeBytes(shutdownAddress, 0x40, 0x55, 0x53, 0x56, 0x57, 0x41, 0x54)  -- כיבוי
 print("Shutdown executed.")
 isShutdown = true  -- מסמן שהכיבוי התרחש
 
 -- מפסיק את הטיימר לאחר הכיבוי
 timer.Enabled = false
 timer.Interval = 10000  -- 10 שניות לפני הפעלה מחדש
 timer.OnTimer = initialize  -- מפעיל את הפונקציה מחדש
 timer.Enabled = true
 else
 print("Invalid shutdown address.")
 end
 end
 end
 
 -- הפונקציה לאתחול מחדש
 function initialize()
 isShutdown = false  -- מאפס את משתנה הכיבוי
 run_code()  -- מפעיל את הקוד מחדש
 end
 
 -- הפעלת טיימר
 function start_timer()
 timer.Interval = 10000  -- 10 שניות
 timer.OnTimer = run_code
 timer.Enabled = true
 end
 
 start_timer()  -- יוזם את הטיימר
 
 [DISABLE]
 if syntaxcheck then return end
 if timer then
 timer.destroy()
 end
 timer.destroy()
 isShutdown = true  -- מאפס את משתנה הכיבוי
 print("Script disabled.")
 | 
 
 
 The problem is that if I try to turn off the script, the Timer does not turn off, and the script continues to run anyway.
 
 Just can't turn off the timer.
 
 Can someone help me I don't understand what I did wrong
 |  |  
		| Back to top |  |  
		|  |  
		| Csimbi I post too much
 
  Reputation: 97 
 Joined: 14 Jul 2007
 Posts: 3327
 
 
 | 
			
				|  Posted: Fri Oct 18, 2024 7:32 am    Post subject: |   |  
				| 
 |  
				|  |  |  
		| Back to top |  |  
		|  |  
		| gavrielsinvani Cheater
 
 ![]() Reputation: 0 
 Joined: 29 May 2019
 Posts: 36
 
 
 | 
			
				|  Posted: Fri Oct 18, 2024 8:27 am    Post subject: |   |  
				| 
 |  
				| what the problem with this ?
 i have local timer on my script
 |  |  
		| Back to top |  |  
		|  |  
		| ParkourPenguin I post too much
 
  Reputation: 152 
 Joined: 06 Jul 2014
 Posts: 4706
 
 
 | 
			
				|  Posted: Fri Oct 18, 2024 10:27 am    Post subject: |   |  
				| 
 |  
				| Enabling and disabling the script is two different invocations. The [ENABLE] and [DISABLE] tags simply remove code- there is no magic that makes local variables carry over. 
 When the script is enabled, this gets executed: 	  | Code: |  	  | {$lua} if syntaxcheck then return end
 
 local a = 0
 [ENABLE]
 a = 1
 print(a)  -- prints 1
 [DISABLE]
 print(a)  -- prints 0
 | 
 
 And when it's disabled, this gets executed: 	  | Code: |  	  | local a = 0 
 a = 1
 print(a)  -- prints 1
 | 
 
  	  | Code: |  	  | local a = 0 
 print(a)  -- prints 0
 | 
 Use a global instead.
 
 I like cleaning up stuff above [ENABLE] because scripts can get disabled without executing the disable section 	  | Code: |  	  | {$lua} if syntaxcheck then return end
 
 if myTimer then myTimer.destroy(); myTimer = nil end
 
 [ENABLE]
 
 local i = 0
 
 myTimer = createTimer()
 myTimer.Interval = 5000
 myTimer.OnTimer = function(t)
 print(i)
 i = i + 1
 end
 
 [DISABLE]
 -- can be empty: timer destroyed above
 | 
 _________________
 
 I don't know where I'm going, but I'll figure it out when I get there. |  |  
		| Back to top |  |  
		|  |  
		| gavrielsinvani Cheater
 
 ![]() Reputation: 0 
 Joined: 29 May 2019
 Posts: 36
 
 
 | 
			
				|  Posted: Fri Oct 18, 2024 4:21 pm    Post subject: |   |  
				| 
 |  
				|  	  | ParkourPenguin wrote: |  	  | Enabling and disabling the script is two different invocations. The [ENABLE] and [DISABLE] tags simply remove code- there is no magic that makes local variables carry over. 
 When the script is enabled, this gets executed: 	  | Code: |  	  | {$lua} if syntaxcheck then return end
 
 local a = 0
 [ENABLE]
 a = 1
 print(a)  -- prints 1
 [DISABLE]
 print(a)  -- prints 0
 | 
 
 And when it's disabled, this gets executed: 	  | Code: |  	  | local a = 0 
 a = 1
 print(a)  -- prints 1
 | 
 
  	  | Code: |  	  | local a = 0 
 print(a)  -- prints 0
 | 
 Use a global instead.
 
 I like cleaning up stuff above [ENABLE] because scripts can get disabled without executing the disable section 	  | Code: |  	  | {$lua} if syntaxcheck then return end
 
 if myTimer then myTimer.destroy(); myTimer = nil end
 
 [ENABLE]
 
 local i = 0
 
 myTimer = createTimer()
 myTimer.Interval = 5000
 myTimer.OnTimer = function(t)
 print(i)
 i = i + 1
 end
 
 [DISABLE]
 -- can be empty: timer destroyed above
 | 
 | 
 
 I couldn't quite integrate it into my script without having problems,
 Can you help me integrate this way into my script?
 |  |  
		| Back to top |  |  
		|  |  
		| AylinCE Grandmaster Cheater Supreme
 
  Reputation: 37 
 Joined: 16 Feb 2017
 Posts: 1527
 
 
 | 
			
				|  Posted: Fri Oct 18, 2024 7:44 pm    Post subject: |   |  
				| 
 |  
				|  	  | Code: |  	  | {$lua} if syntaxcheck then return end
 if timer then timer.destroy() timer=nil end
 
 [ENABLE]
 
 timer = createTimer()
 
 local isShutdown = false  -- משתנה כדי למנוע כיבוי כפול
 
 -- הפונקציה להרצת הקוד
 function run_code()
 if not isShutdown then
 local address = getAddress("144480BB0")  -- המרת הכתובת למספר
 if address and address ~= 0 then
 writeBytes(address, 0x48, 0x31, 0xC0)  -- XOR RAX, RAX
 writeBytes(address + 3, 0xC3)  -- RET
 print("Code executed.")
 
 -- מתחיל ספירה של 5 שניות לכיבוי
 timer.Interval = 5000  -- 5 שניות
 timer.OnTimer = shutdown
 timer.Enabled = true
 else
 print("Invalid address.")
 end
 end
 end
 
 -- הפונקציה לכיבוי
 function shutdown()
 if not isShutdown then
 local shutdownAddress = getAddress("144480BB0")
 if shutdownAddress and shutdownAddress ~= 0 then
 writeBytes(shutdownAddress, 0x40, 0x55, 0x53, 0x56, 0x57, 0x41, 0x54)  -- כיבוי
 print("Shutdown executed.")
 isShutdown = true  -- מסמן שהכיבוי התרחש
 
 -- מפסיק את הטיימר לאחר הכיבוי
 timer.Enabled = false
 timer.Interval = 10000  -- 10 שניות לפני הפעלה מחדש
 timer.OnTimer = initialize  -- מפעיל את הפונקציה מחדש
 timer.Enabled = true
 else
 print("Invalid shutdown address.")
 end
 end
 end
 
 -- הפונקציה לאתחול מחדש
 function initialize()
 isShutdown = false  -- מאפס את משתנה הכיבוי
 run_code()  -- מפעיל את הקוד מחדש
 end
 
 -- הפעלת טיימר
 function start_timer()
 timer.Interval = 10000  -- 10 שניות
 timer.OnTimer = run_code
 timer.Enabled = true
 end
 
 start_timer()  -- יוזם את הטיימר
 
 [DISABLE]
 
 if syntaxcheck then return end
 isShutdown = true  -- מאפס את משתנה הכיבוי
 print("Script disabled.")
 | 
 _________________
 
 |  |  
		| Back to top |  |  
		|  |  
		| gavrielsinvani Cheater
 
 ![]() Reputation: 0 
 Joined: 29 May 2019
 Posts: 36
 
 
 | 
			
				|  Posted: Sat Oct 19, 2024 7:31 am    Post subject: |   |  
				| 
 |  
				|  	  | AylinCE wrote: |  	  |  	  | Code: |  	  | {$lua} if syntaxcheck then return end
 if timer then timer.destroy() timer=nil end
 
 [ENABLE]
 
 timer = createTimer()
 
 local isShutdown = false  -- משתנה כדי למנוע כיבוי כפול
 
 -- הפונקציה להרצת הקוד
 function run_code()
 if not isShutdown then
 local address = getAddress("144480BB0")  -- המרת הכתובת למספר
 if address and address ~= 0 then
 writeBytes(address, 0x48, 0x31, 0xC0)  -- XOR RAX, RAX
 writeBytes(address + 3, 0xC3)  -- RET
 print("Code executed.")
 
 -- מתחיל ספירה של 5 שניות לכיבוי
 timer.Interval = 5000  -- 5 שניות
 timer.OnTimer = shutdown
 timer.Enabled = true
 else
 print("Invalid address.")
 end
 end
 end
 
 -- הפונקציה לכיבוי
 function shutdown()
 if not isShutdown then
 local shutdownAddress = getAddress("144480BB0")
 if shutdownAddress and shutdownAddress ~= 0 then
 writeBytes(shutdownAddress, 0x40, 0x55, 0x53, 0x56, 0x57, 0x41, 0x54)  -- כיבוי
 print("Shutdown executed.")
 isShutdown = true  -- מסמן שהכיבוי התרחש
 
 -- מפסיק את הטיימר לאחר הכיבוי
 timer.Enabled = false
 timer.Interval = 10000  -- 10 שניות לפני הפעלה מחדש
 timer.OnTimer = initialize  -- מפעיל את הפונקציה מחדש
 timer.Enabled = true
 else
 print("Invalid shutdown address.")
 end
 end
 end
 
 -- הפונקציה לאתחול מחדש
 function initialize()
 isShutdown = false  -- מאפס את משתנה הכיבוי
 run_code()  -- מפעיל את הקוד מחדש
 end
 
 -- הפעלת טיימר
 function start_timer()
 timer.Interval = 10000  -- 10 שניות
 timer.OnTimer = run_code
 timer.Enabled = true
 end
 
 start_timer()  -- יוזם את הטיימר
 
 [DISABLE]
 
 if syntaxcheck then return end
 isShutdown = true  -- מאפס את משתנה הכיבוי
 print("Script disabled.")
 | 
 | 
 
 Thanks, I have another problem that I couldn't solve.
 
 i have this script:
 
  	  | Code: |  	  | define(baseAddr,147CA0c34) define(autoCCFlag,baseAddr+1AC)
 define(CCNum,baseAddr+1B4)
 define(cha,[146FAD8D8]+2268)
 define(RedDotCount+2c,13FFF002C)
 registersymbol(RedDotCount+2c)
 registersymbol(cha)
 registersymbol(autoChaFlag)
 registersymbol(CCNum)
 alloc(scriptHook,256,140000000)
 alloc(Check,128,140000000)
 label(Return)
 label(goback)
 label(continue)
 
 autoChaFlag:
 db 0
 
 delay:
 dw 0
 
 scriptHook:
 mov eax,[cha]
 add eax,1
 cmp eax,#30
 je goback
 cmp eax,#40
 jne continue
 goback:
 mov eax,0
 continue:
 sub rsp,28
 mov rcx,146FADC38
 mov rcx,[rcx]
 mov [CCNum],eax
 mov edx,[CCNum]
 call 142500B30
 add rsp,28
 cmp eax,[cha]
 mov [delay], 0
 je scriptHook
 mov [delay], 0
 mov [autoChaFlag],0
 jmp Return
 
 Check:
 inc [delay]
 cmp dword ptr [delay], #3000 // 2.5 min
 jg scriptHook
 cmp [autoChaFlag],1
 je scriptHook
 
 Return:
 call 14464FFD0
 jmp 1443F8144+5
 
 1443F8144:
 jmp Check
 
 | 
 
 This script runs every 2.5 minutes.
 
 I want the following code to run 5 seconds before the code above runs
 
  	  | Code: |  	  | 144480BB0: XOR RAX,RAX
 RET
 
 144447F90:
 XOR RAX,RAX
 RET
 
 144472180:
 XOR RAX,RAX
 RET
 
 | 
 And only after the main script runs after 2.5 minutes, turn it off with the following code:
 
  	  | Code: |  	  | 144480BB0: db 40 55 53 56 57 41 54
 
 144447F90:
 db 40 55 53 56 57 41 54
 
 144472180:
 db 40 55 53 56 57 41 54
 | 
 |  |  
		| Back to top |  |  
		|  |  
		|  |  
  
	| 
 
 | 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
 
 |  |