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 


Toggle-able function

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Frouk
Master Cheater
Reputation: 5

Joined: 22 Jun 2021
Posts: 489
Location: mov dword ptr [Ukraine]

PostPosted: Sat Aug 21, 2021 5:11 am    Post subject: Toggle-able function Reply with quote

I wanna to know how to make toggle able function
i'm using this code:
Code:
function godmode(enabled)
if enabled == 1 then
--Do some code
end
end

To make function with enable/disable section[/code]

_________________
void(__cdecl *Haxing)(HWND hGameWindow)
Back to top
View user's profile Send private message
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

Joined: 02 Sep 2011
Posts: 1053
Location: 0x90

PostPosted: Sat Aug 21, 2021 5:21 am    Post subject: Reply with quote

Code:

function toggle(addressDescription)
 local al = getAddressList()
 local mr = al.getMemoryRecordByDescription(addressDescription)
 mr.Active = not mr.Active
end

toggle('Toggle Script')
Back to top
View user's profile Send private message
Frouk
Master Cheater
Reputation: 5

Joined: 22 Jun 2021
Posts: 489
Location: mov dword ptr [Ukraine]

PostPosted: Sat Aug 21, 2021 5:51 am    Post subject: Reply with quote

LeFiXER wrote:
Code:

function toggle(addressDescription)
 local al = getAddressList()
 local mr = al.getMemoryRecordByDescription(addressDescription)
 mr.Active = not mr.Active
end

toggle('Toggle Script')


Like this:
Code:
function freezeTimer()
if toggle then
writeBytes(0x123456,1)
end
if not toggle then
writeBytes(0x123456,0)
end
end

To call function twice and toggle cheat
Code:
freezeTimer() --Enabled
freezeTimer() --Disabled


EDIT:
Code:
function toggleDead(toggle)
if toggle then
toggle = true
writeBytes('PlayerPTR+74',1)
end
if not toggle then
toggle = false
writeBytes('PlayerPTR+74',0)
end
end

toggleDead(true) --Will toggle dead to 1
toggleDead(false) --Will toggle dead to 0

_________________
void(__cdecl *Haxing)(HWND hGameWindow)
Back to top
View user's profile Send private message
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

Joined: 02 Sep 2011
Posts: 1053
Location: 0x90

PostPosted: Sat Aug 21, 2021 5:58 am    Post subject: Reply with quote

I don't think you explicity require a propietary function for this since you can just check if the memory record is active or not. Unless, you're trying to read a value of an address and base the activation on that addresses value; in which case you would do something like this:

Code:

local al = getAddressList()
local mr = al.getMemoryRecordByDescription('address description')

if mr ~= nil then
  if mr.value == 'value' then
    writeBytes(0x123456,1)
  else
    writeBytes(0x123456,0)
  end
end


If you want to constantly check the value then you will have to do one of two things, use a timer or use the createThread function.
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