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 


writeBytes line
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
iroku
Advanced Cheater
Reputation: 0

Joined: 18 Oct 2012
Posts: 54

PostPosted: Sat Apr 06, 2013 4:12 pm    Post subject: writeBytes line Reply with quote

hi, im now startin to learn some Lua.

I want to find the value of an adress and change it

could i use the readbytes and write bytes to do this ?



readBytes("ggpofba.exe"+5AABC4+24+20+14+38128,2) \\reads value of adress
writeBytes("ggpofba.exe"+5AABC4+24+20+14+38128, 99) \\changes value to 99

or if i dont even want to know its value, can i just run the writeBytes line of code?
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

Joined: 09 May 2003
Posts: 25796
Location: The netherlands

PostPosted: Sat Apr 06, 2013 4:21 pm    Post subject: Reply with quote

yes,
something like this using a ceaddress string format:
Code:

writeBytes("[[[[ggpofba.exe+5AABC4]+24]+20]+14]+38128", 99)

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
iroku
Advanced Cheater
Reputation: 0

Joined: 18 Oct 2012
Posts: 54

PostPosted: Sat Apr 06, 2013 5:55 pm    Post subject: Reply with quote

Dark Byte wrote:
yes,
something like this using a ceaddress string format:
Code:

writeBytes("[[[[ggpofba.exe+5AABC4]+24]+20]+14]+38128", 99)


i got it to work like this:

Code:
form_centerScreen(UDF2)
form_show(UDF2)

function CECheckbox3Click(sender)
timer_value = readBytes("[[[[ggpofba.exe+5AABC4]+24]+20]+14]+38128", 2)
if timer_value <= 99 then
writeBytes("[[[[ggpofba.exe+5AABC4]+24]+20]+14]+38128", 99)
local timer = os.time()
repeat until os.time() > timer + 1
end
end


but it doesnt repeat ( i have to keep clicking to set it to 99)
Back to top
View user's profile Send private message
Mohsen
Advanced Cheater
Reputation: 1

Joined: 04 Apr 2013
Posts: 69
Location: PE

PostPosted: Sun Apr 07, 2013 4:19 am    Post subject: Reply with quote

local t = createTimer(nil)
timer_onTimer(t, CECheckbox3Click)


wiki.cheatengine.org/index.php?title=Timer
Back to top
View user's profile Send private message
iroku
Advanced Cheater
Reputation: 0

Joined: 18 Oct 2012
Posts: 54

PostPosted: Sun Apr 07, 2013 11:23 am    Post subject: Reply with quote

Mohsen wrote:
local t = createTimer(nil)
timer_onTimer(t, CECheckbox3Click)


wiki.cheatengine.org/index.php?title=Timer


ty it worked.kindda



Code:
form_centerScreen(UDF2)
form_show(UDF2)

function CECheckbox3Click(sender)
timer_value = readBytes("[[[[ggpofba.exe+5AABC4]+24]+20]+14]+38128", 2)
if timer_value <= 99 then
writeBytes("[[[[ggpofba.exe+5AABC4]+24]+20]+14]+38128", 99)
end
local t = createTimer(nil) 
 timer_onTimer(t, CECheckbox3Click)   
 timer_setInterval(t,300) --Call CECheckbox3Click(sender) every 3 ms
 timer_setEnabled(t, true)
end


It workes for the first 2 or 3 seconds than CE crashes... It once gave me a STACKOVERFLOW error but now it just freezes...

I olso have question about this code :/

Main function is to write 99 value into Adress when CECheckbox3Click is active

local t = createTimer(nil) \\ t is now a timer that system creates and is set when ontimer event starts... so this event comes at:

Code:
timer_onTimer(t, CECheckbox3Click)


mm timer is created when CECheckbox3click starts, ok so when i click on the tick box, a timer is created


Code:
timer_setInterval(t,3000)

Code:
timer_setEnabled(t, true)


i have a problem with what thse are doing

timer_setInterval -- Sets the speed on how often the timer should trigger. In milliseconds (1000=1 second)

so he checks every 3000ms. And on check, he repeats CECheckbox3Click

But, isnt that like saying click on checkbox every 3 seconds ? What i really wanted was to writetoadress, not the Click itself.

This does seem to work (only until it freezes) but im not sure im telling him to repeat the right function...

Anyways, why is he crashing? is this the time to add like a debbugger code ?
Back to top
View user's profile Send private message
Mohsen
Advanced Cheater
Reputation: 1

Joined: 04 Apr 2013
Posts: 69
Location: PE

PostPosted: Sun Apr 07, 2013 11:34 am    Post subject: Reply with quote

Pay some minutes to read the link I gave you !

Quote:
Owner may be nil, but you will be responsible for destroying it


Do object_destroy(t) to avoid stack overflow.
You make a call to this function when ever you are done with timer and don't need it anymore.
Back to top
View user's profile Send private message
iroku
Advanced Cheater
Reputation: 0

Joined: 18 Oct 2012
Posts: 54

PostPosted: Sun Apr 07, 2013 11:51 am    Post subject: Reply with quote

Mohsen wrote:
Pay some minutes to read the link I gave you !


I did. Ty for the link.

Quote:
Owner may be nil, but you will be responsible for destroying it


Quote:
Do object_destroy(t) to avoid stack overflow.
You make a call to this function when ever you are done with timer and don't need it anymore.


yes but i was planning on destroying it on click to disable checkbox.

So if im playing and after 3 seconds i get stackoverflow, do i have to destroy it every 3 seconds ? with or without any clicking.
Ill only be done with timer when i stop playing
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

Joined: 09 May 2003
Posts: 25796
Location: The netherlands

PostPosted: Sun Apr 07, 2013 11:59 am    Post subject: Reply with quote

the script is fine. Perhaps something else is broken. (e.g the form)
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
iroku
Advanced Cheater
Reputation: 0

Joined: 18 Oct 2012
Posts: 54

PostPosted: Sun Apr 07, 2013 1:04 pm    Post subject: Reply with quote

Dark Byte wrote:
the script is fine. Perhaps something else is broken. (e.g the form)


code is as of now:

Code:
form_show(UDF2)

function CECheckbox3Click(sender)
timer_value = readBytes("[[[[ggpofba.exe+5AABC4]+24]+20]+14]+38128", 2)
if timer_value <= 99 then
writeBytes("[[[[ggpofba.exe+5AABC4]+24]+20]+14]+38128", 99)
end
local t = createTimer(nil)  --
 timer_onTimer(t, CECheckbox3Click)
 timer_setInterval(t,300)
 timer_setEnabled(t, true)
end


i have some prints of the form events and properties not sure that helps..

dont i need to kill object at least every second(time it takes to stack up and freeze)
Maybe i could add another timer... 1 for the Clickbox function and another to kil object..



Formdesigner.png
 Description:
form designer
 Filesize:  409.67 KB
 Viewed:  19464 Time(s)

Formdesigner.png



UDF2 TCE_FORM events.png
 Description:
form events
 Filesize:  238 KB
 Viewed:  19464 Time(s)

UDF2 TCE_FORM events.png



UDF2 TCE_FORM Properties.png
 Description:
UDF2 TCE_FORM Properties
 Filesize:  356.64 KB
 Viewed:  19464 Time(s)

UDF2 TCE_FORM Properties.png



CECheckbox3_TCECheckBox_events.png
 Description:
CECheckbox3_TCECheckBox_events
 Filesize:  207.08 KB
 Viewed:  19464 Time(s)

CECheckbox3_TCECheckBox_events.png



CECheckbox3_TCECheckBox_properties.png
 Description:
CECheckbox3_TCECheckBox_properties
 Filesize:  289.21 KB
 Viewed:  19464 Time(s)

CECheckbox3_TCECheckBox_properties.png


Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

Joined: 09 May 2003
Posts: 25796
Location: The netherlands

PostPosted: Sun Apr 07, 2013 1:33 pm    Post subject: Reply with quote

it helps if you indent your code
This is your code:
Code:

form_show(UDF2)

function CECheckbox3Click(sender)
  timer_value = readBytes("[[[[ggpofba.exe+5AABC4]+24]+20]+14]+38128", 2)
  if timer_value <= 99 then
    writeBytes("[[[[ggpofba.exe+5AABC4]+24]+20]+14]+38128", 99)
  end
  local t = createTimer(nil)  --
  timer_onTimer(t, CECheckbox3Click)
  timer_setInterval(t,300)
  timer_setEnabled(t, true)
end


As you see, you create the timer each time the checkboxclick event is executed, each time causing more timers to be created exponentially (first 1, then 2, then 4, then 8, then 16, ....)

try this instead:
Code:

form_show(UDF2)

function CECheckbox3Click(sender)
  timer_value = readBytes("[[[[ggpofba.exe+5AABC4]+24]+20]+14]+38128", 2)
  if timer_value <= 99 then
    writeBytes("[[[[ggpofba.exe+5AABC4]+24]+20]+14]+38128", 99)
  end
end

local t = createTimer(nil)  --
timer_onTimer(t, CECheckbox3Click)
timer_setInterval(t,300)
timer_setEnabled(t, true)


also, readBytes returns 2 bytes but you are only storing 1 byte in a variable ( timer_value )

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
iroku
Advanced Cheater
Reputation: 0

Joined: 18 Oct 2012
Posts: 54

PostPosted: Sun Apr 07, 2013 3:12 pm    Post subject: Reply with quote

Dark Byte wrote:

try this instead:
Code:

form_show(UDF2)

function CECheckbox3Click(sender)
  timer_value = readBytes("[[[[ggpofba.exe+5AABC4]+24]+20]+14]+38128", 2)
  if timer_value <= 99 then
    writeBytes("[[[[ggpofba.exe+5AABC4]+24]+20]+14]+38128", 99)
  end
end

local t = createTimer(nil)  --
timer_onTimer(t, CECheckbox3Click)
timer_setInterval(t,300)
timer_setEnabled(t, true)


also, readBytes returns 2 bytes but you are only storing 1 byte in a variable ( timer_value )


mm yea he doesnt freeze. Not super sure why. my point of view? the fact that it had an "end" after timer was set, ddid what you said (exp timer setting) making the code end after writebytes made it do 1 timer and never "end" or redo another timer

i think i understand what you said.
Quote:
also, readBytes returns 2 bytes but you are only storing 1 byte in a variable ( timer_value )


so if he read 99 he stores only 9. ( since the function looks for <=99 to run...it still runs as i want to) but how would i add 2 bytes value into (timer_value) ?

It works. And doesnt crash... but, as i run script he auto sets timer to 99, i dont even check the click box.. im not sure if this is due to not having code for "not checked" clickbox.. ill have to finish it up and see..
Back to top
View user's profile Send private message
daspamer
Grandmaster Cheater Supreme
Reputation: 54

Joined: 13 Sep 2011
Posts: 1588

PostPosted: Sun Apr 07, 2013 3:14 pm    Post subject: Reply with quote

its because you set it enabled automatically ...
Code:
timer_setEnabled(t, true)


Try this..
Code:
form_show(UDF2)

function CECheckbox3Click(sender)
timer_setEnabled(t, true)
  timer_value = readBytes("[[[[ggpofba.exe+5AABC4]+24]+20]+14]+38128", 2)
  if timer_value <= 99 then
    writeBytes("[[[[ggpofba.exe+5AABC4]+24]+20]+14]+38128", 99)
  end
end

local t = createTimer(nil)  --
timer_onTimer(t, CECheckbox3Click)
timer_setInterval(t,300)
timer_setEnabled(t, false)

_________________
I'm rusty and getting older, help me re-learn lua.
Back to top
View user's profile Send private message Visit poster's website
iroku
Advanced Cheater
Reputation: 0

Joined: 18 Oct 2012
Posts: 54

PostPosted: Sun Apr 07, 2013 3:37 pm    Post subject: Reply with quote

Mother of hack wrote:


Try this..
Code:
form_show(UDF2)

function CECheckbox3Click(sender)
timer_setEnabled(t, true)
  timer_value = readBytes("[[[[ggpofba.exe+5AABC4]+24]+20]+14]+38128", 2)
  if timer_value <= 99 then
    writeBytes("[[[[ggpofba.exe+5AABC4]+24]+20]+14]+38128", 99)
  end
end

local t = createTimer(nil)  --
timer_onTimer(t, CECheckbox3Click)
timer_setInterval(t,300)
timer_setEnabled(t, false)


m, well i did execute script and it didnt set the timer to 99, problem is it changes value to 99 on click and now timer doesnt work Smile so while it did not start to writeadress it did not work...
Back to top
View user's profile Send private message
mgr.inz.Player
I post too much
Reputation: 222

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Sun Apr 07, 2013 3:49 pm    Post subject: Reply with quote

Try this one,

F10+SHIFT = enable/disable

Code:

form_show(UDF2)


function CECheckbox3Click(sender)
timer_setEnabled(t, true)
  timer_value = readInteger("[[[[ggpofba.exe+5AABC4]+24]+20]+14]+38128")
  if timer_value <= 99 then
    writeInteger("[[[[ggpofba.exe+5AABC4]+24]+20]+14]+38128", 99)
  end
end

if t~=nil then object_destroy(t);t=nil;end
t = createTimer(nil,false)
timer_onTimer(t, CECheckbox3Click)
timer_setInterval(t,300)

if hkTest~=nil then object_destroy(hkTest);hkTest=nil;end
hkTest = createHotkey(function ()
                        timer_setEnabled(t, not timer_getEnabled(t) )
                      end, VK_F10, VK_SHIFT)

_________________
Back to top
View user's profile Send private message MSN Messenger
iroku
Advanced Cheater
Reputation: 0

Joined: 18 Oct 2012
Posts: 54

PostPosted: Sun Apr 07, 2013 4:32 pm    Post subject: Reply with quote

mgr.inz.Player wrote:
Try this one,

F10+SHIFT = enable/disable

Code:

form_show(UDF2)


function CECheckbox3Click(sender)
timer_setEnabled(t, true)
  timer_value = readInteger("[[[[ggpofba.exe+5AABC4]+24]+20]+14]+38128")
  if timer_value <= 99 then
    writeInteger("[[[[ggpofba.exe+5AABC4]+24]+20]+14]+38128", 99)
  end
end

if t~=nil then object_destroy(t);t=nil;end
t = createTimer(nil,false)
timer_onTimer(t, CECheckbox3Click)
timer_setInterval(t,300)

if hkTest~=nil then object_destroy(hkTest);hkTest=nil;end
hkTest = createHotkey(function ()
                        timer_setEnabled(t, not timer_getEnabled(t) )
                      end, VK_F10, VK_SHIFT)


check out Formdesigner.png up thethread.
Its a simple Form with a clickbox

you tick it, it sets timer value to 99.

your code is adding hotkeys to the form ? if i have a hotkey to enable/disable timer value why would i want a Form with a clickbox?

The problem is. I m jst now, starting to learn Lua. The code you gave me, means i have to learn what it says in order for it to make sense, even before i attempt to write it.
Like now, ill go and spend an hour looking for:

writeInteger
readInteger

I do apreciate the intention but it would be great if you could explain your code in a way i can understand it as well.
From what i understandrom it, its not really what im looking for...

*got the Integer. integers numbers that can be written without a fractional or decimal component. So in a way work a lot like read/writebytes yes ? It woudnt make much of a difference function wise. Would it run better ? i can understand how ncely coded software works better.

So i tried your first part of the code(i wasnt looking for hotkeys but i can see how usefull they could be if i was in-game and wanted to change it,its just not what im after tho)


Code:

fform_show(UDF2)


function CECheckbox3Click(sender)
timer_setEnabled(t, true)
  timer_value = writeInteger("[[[[ggpofba.exe+5AABC4]+24]+20]+14]+38128")
  if timer_value <= 99 then
    writeInteger("[[[[ggpofba.exe+5AABC4]+24]+20]+14]+38128", 99)
  end
end

if t~=nil then object_destroy(t);t=nil;end
 t = createTimer(nil,false)
timer_onTimer(t, CECheckbox3Click)
timer_setInterval(t,300)


you changed the place where the "event" took place and added an if statment. If timer was true (our created timer is nil,false) than destroy it and set t to nill.
Reading this right ? not sure...

Still thats how i read and that how i wrote it. Didnt work.
BUT. I though the key point must had been changing the event, so i tried it with the previous code. with Read/WriteBytes



Code:
form_show(UDF2)


function CECheckbox3Click(sender)
timer_setEnabled(t, true)
  timer_value = readBytes("[[[[ggpofba.exe+5AABC4]+24]+20]+14]+38128")
  if timer_value <= 99 then
    writeBytes("[[[[ggpofba.exe+5AABC4]+24]+20]+14]+38128", 99)
  end
end

if t~=nil then object_destroy(t);t=nil;end
 t = createTimer(nil,false)
timer_onTimer(t, CECheckbox3Click)
timer_setInterval(t,300)


And you were right on the money Smile hehehe tyyy, learning a lot!

had to change

local t = createTimer (got acess violation error).
The t = createTimer \\ worked.. i dont know what this implies tho lolol.


Last edited by iroku on Sun Apr 07, 2013 5:26 pm; edited 1 time in total
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
Goto page 1, 2  Next
Page 1 of 2

 
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