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 


How to set a timer for a value?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
++METHOS
I post too much
Reputation: 92

Joined: 29 Oct 2010
Posts: 4197

PostPosted: Sun Apr 28, 2013 9:33 pm    Post subject: How to set a timer for a value? Reply with quote

I am writing a script that has a registersymbol called d_enable. When enabled, the value is set to 1. However, I would like the value to automatically change back to 0 after 1000 miliseconds. Is this possible?

Thanks.
Back to top
View user's profile Send private message
DaSpamer
Grandmaster Cheater Supreme
Reputation: 52

Joined: 13 Sep 2011
Posts: 1578

PostPosted: Sun Apr 28, 2013 9:42 pm    Post subject: Reply with quote

This will disable it.
you can remove the last line, and add it to your function that enables the hack, so it will start the timer and after 1000ms (1 second) will disable it.
Code:
function AutoDisable()
   if (readInteger('d_enable')==1) then
      writeInteger('d_enable', 0)
   end
end
DisableTimer = createTimer(nil,false)
timer_setInterval(DisableTimer, 1000)
timer_onTimer(DisableTimer, AutoDisable)
timer_setEnabled(DisableTimer,true)

_________________
HEY Hitler
Do you get lazy when making trainers?
Well no more!
My CETrainer will generate it for you in seconds, so you won't get lazy! Very Happy

http://forum.cheatengine.org/viewtopic.php?t=564919
Back to top
View user's profile Send private message
++METHOS
I post too much
Reputation: 92

Joined: 29 Oct 2010
Posts: 4197

PostPosted: Sun Apr 28, 2013 9:46 pm    Post subject: Reply with quote

Thanks for the reply.

Is there any trick to adding this to my script, directly?
Back to top
View user's profile Send private message
DaSpamer
Grandmaster Cheater Supreme
Reputation: 52

Joined: 13 Sep 2011
Posts: 1578

PostPosted: Sun Apr 28, 2013 9:47 pm    Post subject: Reply with quote

Assembly script?
_________________
HEY Hitler
Do you get lazy when making trainers?
Well no more!
My CETrainer will generate it for you in seconds, so you won't get lazy! Very Happy

http://forum.cheatengine.org/viewtopic.php?t=564919
Back to top
View user's profile Send private message
++METHOS
I post too much
Reputation: 92

Joined: 29 Oct 2010
Posts: 4197

PostPosted: Sun Apr 28, 2013 9:48 pm    Post subject: Reply with quote

Yeah.
Back to top
View user's profile Send private message
DaSpamer
Grandmaster Cheater Supreme
Reputation: 52

Joined: 13 Sep 2011
Posts: 1578

PostPosted: Sun Apr 28, 2013 9:49 pm    Post subject: Reply with quote

GNIREENIGNE wrote:
Yeah.

If you're using only assembly, then I will into it...
Check if it possible to call sleep...
because in LUA you could do this

Code:
sleep(1000)
writeInteger('d_enable', 0)

Note: Cheat Engine will not respond during that second.

_________________
HEY Hitler
Do you get lazy when making trainers?
Well no more!
My CETrainer will generate it for you in seconds, so you won't get lazy! Very Happy

http://forum.cheatengine.org/viewtopic.php?t=564919
Back to top
View user's profile Send private message
++METHOS
I post too much
Reputation: 92

Joined: 29 Oct 2010
Posts: 4197

PostPosted: Sun Apr 28, 2013 10:00 pm    Post subject: Reply with quote

Thanks. Unfortunately, I do not have any programming background, so most of it is over my head.
Back to top
View user's profile Send private message
DaSpamer
Grandmaster Cheater Supreme
Reputation: 52

Joined: 13 Sep 2011
Posts: 1578

PostPosted: Sun Apr 28, 2013 10:09 pm    Post subject: This post has 1 review(s) Reply with quote

I do not h ave any programming background also =).
All I know is thanks to mgr.inz.Player all the scripts he has wrote, I tried to analyze it and understand it.

I'll check.

_________________
HEY Hitler
Do you get lazy when making trainers?
Well no more!
My CETrainer will generate it for you in seconds, so you won't get lazy! Very Happy

http://forum.cheatengine.org/viewtopic.php?t=564919
Back to top
View user's profile Send private message
++METHOS
I post too much
Reputation: 92

Joined: 29 Oct 2010
Posts: 4197

PostPosted: Sun Apr 28, 2013 10:25 pm    Post subject: Reply with quote

No worries. I figured it out.

I just set another registersymbol called time. Set the value to whatever I want and subtract 1 from it. Just perform a couple of compares to jump where I want and set the d_enable back to 0.

I appreciate your help, though.

Thanks.
Back to top
View user's profile Send private message
DaSpamer
Grandmaster Cheater Supreme
Reputation: 52

Joined: 13 Sep 2011
Posts: 1578

PostPosted: Sun Apr 28, 2013 10:30 pm    Post subject: Reply with quote

But doing so, might cause an endless loop or crash.
I wonder what kind of hack is it?
you could use this:
Code:

push #1000
call sleep
mov [d_enable],0

But the bad part is that it freezes the game.

_________________
HEY Hitler
Do you get lazy when making trainers?
Well no more!
My CETrainer will generate it for you in seconds, so you won't get lazy! Very Happy

http://forum.cheatengine.org/viewtopic.php?t=564919
Back to top
View user's profile Send private message
++METHOS
I post too much
Reputation: 92

Joined: 29 Oct 2010
Posts: 4197

PostPosted: Sun Apr 28, 2013 10:40 pm    Post subject: Reply with quote

So far, so good. Part of the script:

Code:

enemy:
push ebx
mov ebx,[eax+C4]
mov ebx,[ebx+2C]
mov ebx,[ebx+0C]
cmp ebx,00000000
pop ebx
jne originalcode
cmp [v_enable],1
je enemyvac
cmp [d_enable],1
je enemydrop
jmp originalcode

enemydrop:
cmp [time],0
jg drop
jmp reset

drop:
sub [time],1
mov [eax+38],(float)130.0
jmp exit

reset:
mov [d_enable],0
jmp originalcode


x_c:
dd 0
y_c:
dd 0
z_c:
dd 0
s_enable:
dd 0
l_enable:
dd 0
v_enable:
dd 0
d_enable:
dd 0
time:
dd 0
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