| 
			
				|  | Cheat Engine The Official Site of Cheat Engine
 
 
 |  
 
	
		| View previous topic :: View next topic |  
		| Author | Message |  
		| mhxppt How do I cheat?
 
 ![]() Reputation: 0 
 Joined: 28 Nov 2024
 Posts: 3
 
 
 | 
			
				|  Posted: Thu Nov 28, 2024 3:17 am    Post subject: Need help with Lua script |   |  
				| 
 |  
				| I want to write a LUA script to search for groups with 4:0 4:0 w:4 4:120 4:700, then change all occurrences of 120 to 0 in the search results and lock them. Please help me, thank you very much |  |  
		| Back to top |  |  
		|  |  
		| AylinCE Grandmaster Cheater Supreme
 
  Reputation: 37 
 Joined: 16 Feb 2017
 Posts: 1527
 
 
 | 
			
				|  Posted: Thu Nov 28, 2024 4:32 am    Post subject: |   |  
				| 
 |  
				| Group scanning, freezing of found addresses and the option to start and end them with a hotkey: 
 
  	  | Code: |  	  | local resAddrTbl = {} 
 function FindAndValue(find_this,byt)
 local memscan = createMemScan()
 local foundlist = createFoundList(memscan)
 memscan.firstScan(soExactValue, vtGrouped, rtRounded, find_this, nil, 0, "00007fffffffffff", "+W-C", fsmAligned, "4", false, false, false, false)
 memscan.waitTillDone()
 foundlist.initialize()
 
 local address = foundlist.Address
 --print(foundlist.Count)
 if foundlist.Count>0 then
 for i = 0, foundlist.Count - 1 do
 --print(address[i].." - "..readInteger(address[i],true).." - "..readInteger(address[i].."+04",true)
 --      .." - "..readInteger(address[i].."+08",true).." - "..readInteger(address[i].."+0C",true).." - "..readInteger(address[i].."+10",true))
 resAddress = address[i].."+"..byt
 table.insert(resAddrTbl, resAddress)
 
 foundlist.destroy()
 memscan.destroy()
 return resAddrTbl
 end
 else
 foundlist.destroy()
 memscan.destroy()
 --showMessage("Code Not found!")
 return resAddrTbl
 end
 end
 
 ------bytes:- 0 - 4 - 8 - 12 -- 16
 find_this = "4:0 4:0 w:4 4:120 4:700"
 
 ------- > freeze ..
 
 aa2 = getFreezeTimer()
 timer_setEnabled(aa2, false)
 timer_setInterval(aa2, 50)
 local frzEnabled = 1
 
 aa2.OnTimer=function()
 if #resAddrTbl==0 then
 FindAndValue(find_this, "0C")  -- byt: 12 = 0C
 end
 if (#resAddrTbl > 0) then
 for l,k in pairs(resAddrTbl) do
 --print(l,k,readInteger(k))
 writeInteger(tostring(k),"0")
 end
 end
 end
 
 function frz1()
 if frzEnabled==1 then
 timer_setEnabled(aa2, true)
 frzEnabled=2
 else
 timer_setEnabled(aa2, false)
 frzEnabled=1
 end
 end
 
 -- search and freeze (or unfreeze) key: F8
 if frzKey1 then frzKey1.Destroy() frzKey1=nil end
 frzKey1=createHotkey(frz1, VK_F8)
 | 
 _________________
 
 |  |  
		| Back to top |  |  
		|  |  
		| mhxppt How do I cheat?
 
 ![]() Reputation: 0 
 Joined: 28 Nov 2024
 Posts: 3
 
 
 | 
			
				|  Posted: Thu Nov 28, 2024 7:09 pm    Post subject: |   |  
				| 
 |  
				| Thank you very much for your help, Master. However, after pressing F8 again, it only modifies the first result found. I need to modify all the results, which may be up to 400 entries. Also, I need to use a button to call this code instead of the shortcut key. I hope to get your help again, thank you very much |  |  
		| Back to top |  |  
		|  |  
		| AylinCE Grandmaster Cheater Supreme
 
  Reputation: 37 
 Joined: 16 Feb 2017
 Posts: 1527
 
 
 | 
			
				|  Posted: Fri Nov 29, 2024 12:33 am    Post subject: |   |  
				| 
 |  
				|  	  | Code: |  	  | local resAddrTbl = {} 
 function FindAndValue(find_this,byt)
 local memscan = createMemScan()
 local foundlist = createFoundList(memscan)
 memscan.firstScan(soExactValue, vtGrouped, rtRounded, find_this, nil, 0, "00007fffffffffff", "+W-C", fsmAligned, "4", false, false, false, false)
 memscan.waitTillDone()
 foundlist.initialize()
 
 local address = foundlist.Address
 --print(foundlist.Count)
 if foundlist.Count>0 then
 for i = 0, foundlist.Count - 1 do
 --print(address[i].." - "..readInteger(address[i],true).." - "..readInteger(address[i].."+04",true)
 --      .." - "..readInteger(address[i].."+08",true).." - "..readInteger(address[i].."+0C",true).." - "..readInteger(address[i].."+10",true))
 resAddress = address[i].."+"..byt
 table.insert(resAddrTbl, resAddress)
 end
 foundlist.destroy()
 memscan.destroy()
 else
 foundlist.destroy()
 memscan.destroy()
 showMessage("Code Not found!")
 end
 return resAddrTbl
 end
 
 ------bytes:- 0 - 4 - 8 - 12 -- 16
 find_this = "4:0 4:0 w:4 4:120 4:700"
 
 ------- > freeze ..
 
 aa2 = getFreezeTimer()
 timer_setEnabled(aa2, false)
 timer_setInterval(aa2, 50)
 local frzEnabled = 1
 
 aa2.OnTimer=function()
 if #resAddrTbl==0 then
 FindAndValue(find_this, "0C")  -- byt: 12 = 0C
 end
 if (#resAddrTbl > 0) then
 for l,k in pairs(resAddrTbl) do
 --print(l,k,readInteger(k))
 writeInteger(tostring(k),"0")
 end
 end
 end
 
 function frz1()
 if frzEnabled==1 then
 timer_setEnabled(aa2, true)
 frzEnabled=2
 else
 timer_setEnabled(aa2, false)
 frzEnabled=1
 end
 end
 
 UDF1.CEButton1.OnClick=function(sender) -- your form and button name?
 frz1()
 end
 | 
 _________________
 
 |  |  
		| Back to top |  |  
		|  |  
		| mhxppt How do I cheat?
 
 ![]() Reputation: 0 
 Joined: 28 Nov 2024
 Posts: 3
 
 
 | 
			
				|  Posted: Sat Nov 30, 2024 2:17 am    Post subject: |   |  
				| 
 |  
				| It works now, thank you very much for your help, Master |  |  
		| 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
 
 |  |