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 


use mouse click as hotkey

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

Joined: 06 Jan 2015
Posts: 2

PostPosted: Tue Jan 06, 2015 4:03 am    Post subject: use mouse click as hotkey Reply with quote

hi. i want to use left mouse click as hotkey for speed hack. i want to be enable speed hack only when the click is paressde. when i release the click speed hack is desable. how can i do this? i know sonethig about lua but don`t enough for do this by myself
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

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

PostPosted: Tue Jan 06, 2015 4:19 am    Post subject: Reply with quote

Code:

wantedSpeed=10
lastSpeed=1

function checkKeys(timer)
  if isKeyPressed(VK_LBUTTON) then
    if lastSpeed==1 then
      speedhack_setSpeed(wantedSpeed)
      lastSpeed=wantedSpeed
    end
  else
    if lastSpeed~=1 then
      speedhack_setSpeed(1)
      lastSpeed=1
    end
  end
end

if t~=nil then
  t.destroy()
  t=nil
end

t=createTimer()
t.Interval=50
t.OnTimer=checkKeys
t.Enabled=true

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

Joined: 06 Jan 2015
Posts: 2

PostPosted: Sat Jan 10, 2015 9:11 am    Post subject: Reply with quote

Error:[string "wantedSpeed=5..."]:24: attempt to index global 't' (a nil value)
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

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

PostPosted: Sat Jan 10, 2015 10:16 am    Post subject: Reply with quote

Use 6.4 or try createTimer(nil)
_________________
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
flamingonion
How do I cheat?
Reputation: 0

Joined: 11 Feb 2018
Posts: 3

PostPosted: Sun Feb 11, 2018 9:09 pm    Post subject: Reply with quote

Dark Byte wrote:
Code:

wantedSpeed=10
lastSpeed=1

function checkKeys(timer)
  if isKeyPressed(VK_LBUTTON) then
    if lastSpeed==1 then
      speedhack_setSpeed(wantedSpeed)
      lastSpeed=wantedSpeed
    end
  else
    if lastSpeed~=1 then
      speedhack_setSpeed(1)
      lastSpeed=1
    end
  end
end

if t~=nil then
  t.destroy()
  t=nil
end

t=createTimer()
t.Interval=50
t.OnTimer=checkKeys
t.Enabled=true


wonderful script! I've been using this with a bit of modification to suit my need for fps game as follow:
wantedSpeed=0.3
lastSpeed=1

function checkKeys(timer)
if isKeyPressed(VK_RBUTTON) then
if lastSpeed==1 then
speedhack_setSpeed(wantedSpeed)
lastSpeed=wantedSpeed
end
else
if lastSpeed~=1 then
speedhack_setSpeed(1)
lastSpeed=1
end
end
end

if t~=nil then
t.destroy()
t=nil
end

t=createTimer()
t.Interval=50
t.OnTimer=checkKeys
t.Enabled=true

this basically slowdown game speed whenever I hold down my right mouse button for a more max payne effect. However I'd love to have it tweaked a little bit so every left mouse button could return the speed to normal if the right mouse was being held down. Can you please help me with that?
thank you so much!
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

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

PostPosted: Mon Feb 12, 2018 2:24 am    Post subject: Reply with quote

replace
Code:

if isKeyPressed(VK_RBUTTON) then

with
Code:

if isKeyPressed(VK_RBUTTON) and (not isKeyPressed(VK_LBUTTON)) then

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

Joined: 11 Feb 2018
Posts: 3

PostPosted: Tue Feb 13, 2018 9:07 pm    Post subject: Reply with quote

Dark Byte wrote:
replace
Code:

if isKeyPressed(VK_RBUTTON) then

with
Code:

if isKeyPressed(VK_RBUTTON) and (not isKeyPressed(VK_LBUTTON)) then

wonderful code! thank you so much!
godbless!
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