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 


2 functions on push and relese button

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

Joined: 09 Dec 2013
Posts: 4

PostPosted: Thu Mar 06, 2014 3:13 am    Post subject: 2 functions on push and relese button Reply with quote

How to do is:
push VK_V - > 1 function
relese VK_V - > 2 function
in lua code?
I searched, but couldn't find this feature
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Thu Mar 06, 2014 6:02 am    Post subject: Reply with quote

that's not implemented but you can do something like this:
create a hotkey that reacts on VK_V and calls function 1
then in function 1 launch a timer that constantly checks if isKeyPressed(VK_V) is true, and if not, stop the timer and call function 2

_________________
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
SetDmg
How do I cheat?
Reputation: 0

Joined: 09 Dec 2013
Posts: 4

PostPosted: Thu Mar 06, 2014 7:30 pm    Post subject: Reply with quote

Here's what happened but he constantly switches the two functions, where is my mistake?

Code:

CheatStatus = component_findComponentByName(TrainerSH, "CheatStatus")
form_show(TrainerSH)
control_setCaption(TrainerSH, "Trainer [Not Included]")
autoAttachList = getAutoAttachList()
stringlist_add(autoAttachList, "Game.exe")
function SpeedDef()
control_setCaption(CheatStatus, "Speed Default")
speedValue = "1"
end
function SpeedLow()
control_setCaption(CheatStatus, "Speed Low")
SpeedValue = "1.5"
end
function Speedx2()
control_setCaption(CheatStatus, "Speed x2")
SpeedValue = "2"
end

--Push/Release Button
function EnableSpeed()
control_setCaption(CheatStatus, "Speed Enabled")
speedhack_setSpeed(SpeedValue)

CheckPressTimer = createTimer(trainerForm)
timer_setInterval(CheckPressTimer, 100)
timer_onTimer(CheckPressTimer, CheckPress)
end

function CheckPress()
if isKeyPressed(VK_SHIFT) then
SpeedDef()
return false
end
end
--push/Release Button

function OnCheckHotkeys()
if isKeyPressed(VK_F2) then
SpeedLow()
return
end
if isKeyPressed(VK_F3) then
Speedx2()
return
end
end
function onOpenProcess(processid)
control_setCaption(TrainerSH, "Trainer [Included]")
hotKeyTimer = createTimer(trainerForm)
timer_setInterval(hotKeyTimer, 100)
timer_onTimer(hotKeyTimer, OnCheckHotkeys)
createHotkey(EnableSpeed, VK_SHIFT)
end
function FromClose(sender)
closeCE()
return caFree
end
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Fri Mar 07, 2014 3:50 pm    Post subject: Reply with quote

get rid of the createHotkey. It gets called every few milliseconds.
Use the hotkeyTimer instead (or destroy the EnableSpeed hotkey)

In OnCheckHotkeys check if VK_SHIFT is down and if so, activate the speedhack if it isn't already active and set a flag indicating that the speedhack is active. (And don't check if that flag is true)

In OnCheckHotkeys also check if VK_SHIFT is NOT down. And if so deactivate the speedhack if it is active.

_________________
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
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