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 


Lua Auto Click for triggerbot

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
SEKTION
Cheater
Reputation: 0

Joined: 05 Nov 2017
Posts: 39
Location: Behind the keyboard

PostPosted: Mon Nov 18, 2019 1:50 pm    Post subject: Lua Auto Click for triggerbot Reply with quote

Code:

[ENABLE]
{$lua}
local cross = "iw4sp.exe+33BAA8"
local crshair = readInteger(cross)
while crshair == 16 do
      crshair = readInteger(cross)
      doKeyPress(VK_LBUTTON)
end

{$asm}

[DISABLE]


This should work as a triggerbot but its not working!!! Crying or Very sad
Whats wrong with the script???
Any help will be greatly appreciated!!!

_________________
TH3 UND3N14BL3
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 37

Joined: 16 Feb 2017
Posts: 1521

PostPosted: Mon Nov 18, 2019 3:26 pm    Post subject: Reply with quote

doKeyPress(VK_LBUTTON) ?

doKeyPress(VK_L) --Isn't that the "L" button anyway?

_________________
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
SEKTION
Cheater
Reputation: 0

Joined: 05 Nov 2017
Posts: 39
Location: Behind the keyboard

PostPosted: Mon Nov 18, 2019 11:58 pm    Post subject: Reply with quote

VK_L sends letter 'L'
I also tried mouse_event(MOUSEEVENTF_LEFTDOWN)
But nothing works
Every keyboard button work but not the mouse
Is there anything else??

_________________
TH3 UND3N14BL3
Back to top
View user's profile Send private message
SEKTION
Cheater
Reputation: 0

Joined: 05 Nov 2017
Posts: 39
Location: Behind the keyboard

PostPosted: Wed Nov 20, 2019 9:59 am    Post subject: Reply with quote

Okay I got it working with the following code
Code:

local cross = '["iw4sp.exe"+0008E4E4]+28'
local crshair = readInteger(cross)

while crshair == 16 do
      mouse_event(MOUSEEVENTF_LEFTDOWN)
      sleep(100)
      mouse_event(MOUSEEVENTF_LEFTUP)
      crshair = readInteger(cross)
end


It does work but only once like upon activation it shoots once and then nothing...
so somehow the loop is not working as it should be???

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

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

PostPosted: Wed Nov 20, 2019 10:48 am    Post subject: Reply with quote

perhaps crshair isn't 16 right after the mouse release and then exits the loop
_________________
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
SEKTION
Cheater
Reputation: 0

Joined: 05 Nov 2017
Posts: 39
Location: Behind the keyboard

PostPosted: Wed Nov 20, 2019 12:35 pm    Post subject: Reply with quote

It has only two values, 16 when pointing on enemy and 0 when not pointing.
so when I activate the script the value should be 0 to enter the loop and then 16 to autoshoot and after that it again becomes 0 because crosshair displaces
so shouldn't the loop continue??
sorry I forgot to add
Here's a slightly changed code but its also shooting only once
Code:

local cross = '["iw4sp.exe"+0008E4E4]+28'
local crshair = readInteger(cross)

while crshair == 0 do
      crshair = readInteger(cross)
      if crshair == 16 then
         mouse_event(MOUSEEVENTF_LEFTDOWN)
         sleep(100)
         mouse_event(MOUSEEVENTF_LEFTUP)
         crshair = readInteger(cross)
      end
end

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

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

PostPosted: Wed Nov 20, 2019 1:12 pm    Post subject: Reply with quote

are you sure that the crosshair is back at 0 immediately as you release the mouse ?

Code:

local cross = '["iw4sp.exe"+0008E4E4]+28'
local crshair = readInteger(cross)

while crshair == 0 do
      crshair = readInteger(cross)
      if crshair == 16 then
         mouse_event(MOUSEEVENTF_LEFTDOWN)
         sleep(100)
         mouse_event(MOUSEEVENTF_LEFTUP)
         crshair = readInteger(cross)
         if (crshair~=0) then
           print('Not 0!')
         end
      end
end


Also, if it is working, that code will freeze CE, unless you run it in it's own thread

_________________
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
mgr.inz.Player
I post too much
Reputation: 222

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

PostPosted: Wed Nov 20, 2019 1:27 pm    Post subject: Reply with quote

Code:
{$Lua}
if syntaxcheck then return end

[ENABLE]
superLuaAutoClickForTriggerbot_thread = createNativeThread(function (thread)
  thread.freeOnTerminate(false)
  thread.Name = 'superLuaAutoClickForTriggerbot_thread'
  local crshair
  while not thread.Terminated do
    local crshair = readInteger('["iw4sp.exe"+0008E4E4]+28')
    if crshair == 16 then
       mouse_event(MOUSEEVENTF_LEFTDOWN)
       sleep(100)
       mouse_event(MOUSEEVENTF_LEFTUP)
    end
    sleep(10)
  end
end)

[DISABLE]
if superLuaAutoClickForTriggerbot_thread then -- kill thread
   superLuaAutoClickForTriggerbot_thread.terminate()
   superLuaAutoClickForTriggerbot_thread.waitfor()
   superLuaAutoClickForTriggerbot_thread.destroy()
   superLuaAutoClickForTriggerbot_thread=nil
end

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

Joined: 05 Nov 2017
Posts: 39
Location: Behind the keyboard

PostPosted: Thu Nov 21, 2019 2:07 am    Post subject: Reply with quote

Dark Byte wrote:
are you sure that the crosshair is back at 0 immediately as you release the mouse ?
Also, if it is working, that code will freeze CE, unless you run it in it's own thread


Crosshair is back to 0 immediately not after I release the mouse but when It points somewhere else other than on the enemy

This does freeze CE but until value turns to 16 and also I tried to run in its own thread but this crashes the game

_________________
TH3 UND3N14BL3
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 37

Joined: 16 Feb 2017
Posts: 1521

PostPosted: Thu Nov 21, 2019 4:43 am    Post subject: Reply with quote

Why the mouse movement "16"?
Can't you just code "16" to shoot at the enemy?
For example: "SPACE" = shoot (keyPress = Space (position> "16")

This happens instantaneously and does not trigger a crash.

_________________
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
SEKTION
Cheater
Reputation: 0

Joined: 05 Nov 2017
Posts: 39
Location: Behind the keyboard

PostPosted: Thu Nov 21, 2019 5:42 am    Post subject: Reply with quote

mgr.inz.Player wrote:
Code:
{$Lua}
if syntaxcheck then return end

[ENABLE]
superLuaAutoClickForTriggerbot_thread = createNativeThread(function (thread)
  thread.freeOnTerminate(false)
  thread.Name = 'superLuaAutoClickForTriggerbot_thread'
  local crshair
  while not thread.Terminated do
    local crshair = readInteger('["iw4sp.exe"+0008E4E4]+28')
    if crshair == 16 then
       mouse_event(MOUSEEVENTF_LEFTDOWN)
       sleep(100)
       mouse_event(MOUSEEVENTF_LEFTUP)
    end
    sleep(10)
  end
end)

[DISABLE]
if superLuaAutoClickForTriggerbot_thread then -- kill thread
   superLuaAutoClickForTriggerbot_thread.terminate()
   superLuaAutoClickForTriggerbot_thread.waitfor()
   superLuaAutoClickForTriggerbot_thread.destroy()
   superLuaAutoClickForTriggerbot_thread=nil
end

Sorry for late response, CEF won't let me post two replies back to back
I'm yet to try your code and then let you know

EDIT
This worksss!!!!! Thank You very much @mgr.inz.Player
So what you did is created a thread and until that thread is running, the loop will continue.Right??

And also I have a few questions just for my knowledge
1-What is 'if syntaxcheck then return end'?

2-And at last what is 'superLuaAutoClickForTriggerbot_thread=nil' for?

EDIT 2
I somewhat figured out the two questions but these two I still can't understand
If someone can explain them cuz I'm a beginner and it's the first time I came upon the lua createThread function

_________________
TH3 UND3N14BL3
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: Sat Nov 23, 2019 7:53 am    Post subject: This post has 1 review(s) Reply with quote

The statement (not thread.Terminated) is true until you deactivate.

Deactivation will:
- set thread.Terminated (the line superLuaAutoClickForTriggerbot_thread.terminate() ) from false to true. (so "not thread.Terminated" will become false)
- then CE waits a while (the line superLuaAutoClickForTriggerbot_thread.waitfor() )
- so it can safely destroy TThread object (superLuaAutoClickForTriggerbot_thread.destroy() )


1
Shortly, CE executes ENABLE section and then DISABLE section in "syntaxcheck mode". It happens when you add new or edit existing script.
And that means it will execute embedded Lua scripts too. That line is to prevent Lua code execution when CE does syntaxcheck.


2
It's a common practice to set variables to nil after destroying/freeing object they pointed to. Especially global variables (variables created without "local" statement)
Example:
memoryscanner = createMemScan()
...
...
...
memoryscanner.destroy()
memoryscanner = nil

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

Joined: 05 Nov 2017
Posts: 39
Location: Behind the keyboard

PostPosted: Sun Nov 24, 2019 9:53 am    Post subject: Reply with quote

Very thanks to you for clarification!!!
_________________
TH3 UND3N14BL3
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