Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Putting pointers in a script

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
MenzoFr
How do I cheat?
Reputation: 0

Joined: 10 Aug 2024
Posts: 2

PostPosted: Sat Aug 10, 2024 3:07 pm    Post subject: Putting pointers in a script Reply with quote

I'm trying to do a script that changes a value to 0 and freeze it when the script is enabled and that changes to 1 when script is diasbled.

Here is my script:

Code:
[ENABLE]
{$lua}
-- Function to check and set the value to 0 if it equals 1
function checkValue()
  local value = readInteger(0x28C106A5F60)
  print("Current Value: ", value)  -- Debugging output to see the current value
  if value == 1 then
    print("Changing value to 0")  -- Debugging output to confirm the change is being attempted
    writeInteger(0x28C106A5F60, 0)
  end
end

-- Create a timer that checks the value every 50ms
valTimer = createTimer(MainForm, false)
valTimer.Interval = 50 -- Set interval to 50ms
valTimer.OnTimer = checkValue
valTimer.Enabled = true
{$asm}

[DISABLE]
{$lua}
-- Disable the timer created during the enable phase
if valTimer ~= nil then
  valTimer.Enabled = false
  valTimer.destroy()
  valTimer = nil
end

-- Optionally, reset the value to 1 when the cheat is disabled
writeInteger(0x28C106A5F60, 1)
{$asm}



It works well but i want to make it work by using pointers not a simple address.

Has any of you an idea of how I could do that ?
Note: It's my first time here so sorry if i dont explain smth very well.
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4706

PostPosted: Sat Aug 10, 2024 5:07 pm    Post subject: Reply with quote

Code:
{$lua}
if syntaxcheck then return end

if valTimer then
  valTimer.destroy()
  valTimer = nil
end


[ENABLE]
valTimer = createTimer(MainForm)
valTimer.Interval = 50
valTimer.OnTimer = function(t)
  local addr = getAddressSafe'[[game.exe+1234]+5C]+8'
  if not addr then return end  -- pointer path not valid

  if readInteger(addr) == 1 then
    writeInteger(addr, 0)
  end
end


[DISABLE]
local addr = getAddressSafe'[[game.exe+1234]+5C]+8'
if addr then
  writeInteger(addr, 1)
end

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
MenzoFr
How do I cheat?
Reputation: 0

Joined: 10 Aug 2024
Posts: 2

PostPosted: Sun Aug 11, 2024 8:22 am    Post subject: Reply with quote

It worked, thanks !
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites