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 


CEButton function not working

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
ghjbm
!BEWARE! Deletes post on answer
Reputation: 0

Joined: 08 Aug 2021
Posts: 2

PostPosted: Sun Aug 08, 2021 2:04 pm    Post subject: CEButton function not working Reply with quote

Hey, the function "CEButton1Click(sender)" in my script doesn't work (it doesn't print anything when I click the button), I also tried using checkboxes with "function CECHeckbox1Change(sender), also didn't work. Sorry if there are some stupid mistakes in my code but I'm a beginner at both cheat engine and lua. Plese help.


My Code:

local address1 = "[[[[[[[GameAssembly.dll+01C81784]+5C]+8]+2C]+C]+4C]+34]+2C"

local address2 = "[[[[[[[GameAssembly.dll+01C65CB0]+20]+5C]+0]+2C]+C]+DC]+224"

local address3 = "[[[[[[[GameAssembly.dll+01C85200]+2C]+20]+5C]+8]+18]+14]+8"

local address4 = "[[[[[[[GameAssembly.dll+01C2CC54]+140]+C]+5C]+10]+98]+84]+B8"

local address5 = "[[[[[[[UnityPlayer.dll+014487A8]+4]+8]+10]+80]+D0]+2C]+328"

local address6 = "[[[[[[[UnityPlayer.dll+01425DC0]+398]+10]+18]+AC]+10]+9C]+3F0"

t=createTimer(nil)
t.Interval=1000
t.OnTimer=function(t)


local mr2=AddressList.getMemoryRecordByDescription('Timer1')
local mr3=AddressList.getMemoryRecordByDescription('Timer2')
local mr4=AddressList.getMemoryRecordByDescription('Timer3')


function CETrackBar1Change(sender)
local sliderValue=trackbar_getPosition(TRAINERFORM_CETrackBar1)
writeFloat("[[[[[[[GameAssembly.dll+01C71C08]+20]+4C]+AC]+C]+5C]+58]+14",sliderValue)
val = readFloat("[[[[[[[GameAssembly.dll+01C71C08]+20]+4C]+AC]+C]+5C]+58]+14")
control_setCaption(TRAINERFORM_CELabel2,val)
--print(val)
end

if TRAINERFORM_CECheckbox1.Checked == true then
writeInteger(address1, 1)
else writeInteger(address1, 0)
end

if TRAINERFORM_CECheckbox2.Checked == true then
writeInteger(address2, 0)
mr2.Active = true
else mr2.Active = false
end

if TRAINERFORM_CECheckbox3.Checked == true then
writeInteger(address3, 0)
mr3.Active = true
else mr3.Active = false
end

if TRAINERFORM_CECheckbox4.Checked == true then
writeInteger(address4, 0)
mr4.Active = true
else mr4.Active = false
end

function CEButton1Click(sender)
print("...")
end


TRAINERFORM.OnClose = function(sender)
t.Enabled = false
t.destroy()
end


form_show(TRAINERFORM)
end

t.Enabled=true
Back to top
View user's profile Send private message
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

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

PostPosted: Sun Aug 08, 2021 3:32 pm    Post subject: Reply with quote

Code:

function [UDF_FORM_NAME]_CEButton1Click(sender)

end


Place your UDF form name minus the square brackets.
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 31

Joined: 16 Feb 2017
Posts: 1247

PostPosted: Sun Aug 08, 2021 5:01 pm    Post subject: Reply with quote

If you don't give an "OnClick" control (Events) in the form edit window, try this:
Samle form name myTrainer or UDF1

Code:
UDF1.CEButton1.OnClick=function(sender)
print("Hello")
end

UDF1.CECHeckbox1.OnChange=function(sender)
if sender.checked==true then
print("True")
else
print("False")
end
end

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
ghjbm
!BEWARE! Deletes post on answer
Reputation: 0

Joined: 08 Aug 2021
Posts: 2

PostPosted: Mon Aug 09, 2021 3:58 am    Post subject: Reply with quote

Thanks a lot. I have another problem, when I close the trainer it says "Error: Access Violation"
Back to top
View user's profile Send private message
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

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

PostPosted: Mon Aug 09, 2021 4:17 am    Post subject: Reply with quote

Potentially there is an object which has not been destroyed upon closing.

Code:

t=createTimer(nil)


Here you haven't assigned a parent for the timer. If you place your Lua form name between the parentheses it will make sure that the timer is destroyed when you close your Lua form, or if you don't want to do that you can pass Cheat Engine as the parent like so:

Code:

t=createTimer(getMainForm())
...
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 31

Joined: 16 Feb 2017
Posts: 1247

PostPosted: Mon Aug 09, 2021 11:54 am    Post subject: Reply with quote

In my case too Timer should be standalone and ordinary.

Kill him on start and exit..
Code:
-- kill
if mytm1 then mytm1.Destroy() mytm1=nil end
--create
mytm1=createTimer() mytm1.Interval=1000 mytm1.Enabled=false --- or true


Timer and "TFont" sometimes overlap, I prefer standalone rendering rather than form designer.

opps!

Code:
TRAINERFORM.OnClose = function(sender)
closeCE()
return cafree
end

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
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