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 


My Trainer Does not work

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

Joined: 31 Aug 2017
Posts: 6

PostPosted: Thu Aug 31, 2017 8:57 am    Post subject: My Trainer Does not work Reply with quote

I want to create a trainer that changes the speed I am using the following code:
Code:
function CEButton1Click(sender)
openProcess("login.exe")
speedhack_setSpeed(CETrainer_CETrackBar1.Position)
end


but it only works if i manually execute the script from manually designer interface.
How do I make it work? pls help Crying or Very sad
Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Thu Aug 31, 2017 9:11 am    Post subject: Reply with quote

I'm curious why you are using openProcess, does your trainer not autoattach to the process? If that's the case then you may need a delay inbetween calling openProcess and speedhack_setSpeed though using the onOpenProcess event/function may make more sense.
Back to top
View user's profile Send private message
snipertarget
How do I cheat?
Reputation: 0

Joined: 31 Aug 2017
Posts: 6

PostPosted: Thu Aug 31, 2017 9:33 am    Post subject: Reply with quote

I was using this function
Code:
function CEButton1Click(sender)
openProcess("Login.exe")
speedhack_setSpeed(CETrainer_CETrackBar1.Position)
end


But I changed to this
Code:
function CEButton1Click(sender)
onOpenProcess("Login.exe")
speedhack_setSpeed(CETrainer_CETrackBar1.Position)
end


And I get this error
Code:
Error:[string "function CEButton1Click(sender)
..."]:2: attempt to call a nil value (global 'onOpenProcess')


I have one trackpad and I want to use the Set Speed Button to change the speed of the game with trainer ;-;
Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Thu Aug 31, 2017 9:37 am    Post subject: Reply with quote

of course you do, onOpenProcess isn't a function to open a process, it's a function you create that will be called on a certain event, ie. when a process is opened.
Back to top
View user's profile Send private message
snipertarget
How do I cheat?
Reputation: 0

Joined: 31 Aug 2017
Posts: 6

PostPosted: Thu Aug 31, 2017 9:45 am    Post subject: Reply with quote

But i open the game myself -_- I just want to execute the lua button code when I press it because it does not work when I export my trainer. I want when I slide the trackpad and press set speed button to make program speedhack change in game pls help ;-;
Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Thu Aug 31, 2017 11:10 am    Post subject: Reply with quote

If you open it yourself then don't use openProcess! That's why I said I was curious about why you were using it but instead of answering the question you took some advice that was given on the off chance that you knew what you were doing.

If you're already attached then you should just need

Code:
function CEButton1Click(sender)
  speedhack_setSpeed(CETrainer_CETrackBar1.Position)
end


if that alone doesn't work then try CETrainer.CETrackBar1.Position instead of an _ and if that doesn't work then print out each part and make sure it's not nil eg.

Code:
function CEButton1Click(sender)
  print('_trackbar is ', CETrainer_CETrackBar1)
  print('_trackbar.position is ', CETrainer_CETrackBar1.position)
  -- in case _ is incorrect
  print('CETrainer is ', CETrainer)
  print('.trackbar is ', CETrainer.CETrackBar1)
  print('.trackbar.position is ', CETrainer.CETrackBar1.position)
  -- incase it is named CETrainer_CETrackBar1 but is on the CETrainer form
  print('trainer._trackbar is ', CETrainer.CETrainer_CETrackBar1)
  print('trainer._trackbar.position is ', CETrainer.CETrainer_CETrackBar1.position)


  --speedhack_setSpeed(CETrainer_CETrackBar1.Position)
end
Back to top
View user's profile Send private message
snipertarget
How do I cheat?
Reputation: 0

Joined: 31 Aug 2017
Posts: 6

PostPosted: Thu Aug 31, 2017 11:43 am    Post subject: Reply with quote

I try what you say but it says there is error :/
Code:
Error:attempt to call a nil value
Error:attempt to call a nil value
_trackbar is  0A607E50
_trackbar.position is  1
CETrainer is  0A5481B0
.trackbar is  0A607E50
.trackbar.position is  1
trainer._trackbar is   
Error:[string "function CEButton1Click(sender)
..."]:10: attempt to index a nil value (field 'CETrainer_CETrackBar1')
_trackbar is  0A607E50
_trackbar.position is  4
CETrainer is  0A5481B0
.trackbar is  0A607E50
.trackbar.position is  4
trainer._trackbar is   
Error:[string "function CEButton1Click(sender)
..."]:10: attempt to index a nil value (field 'CETrainer_CETrackBar1')
Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Thu Aug 31, 2017 12:05 pm    Post subject: Reply with quote

Yeah, I'd expect a few errors because some of those are going to be invalid, the point was to find out for sure which are valid. During testing make sure you click 'execute code' when you change the lua script so that any changes to functions are updated (that's probably where the "Error:attempt to call a nil value" errors came from, trying to call the button event function before it'd actually been created), that's not an issue afterwards since the script is automatically run when it's opened.

Seems like the _trackbar and .trackbar prints are both valid (and point to the same trackbar), I'd guess that's some compatibility between the old CE syntax (that I never used) and the current one.

As such

Code:
function CEButton1Click(sender)
  speedhack_setSpeed(CETrainer_CETrackBar1.Position)
end


should work, since setting the speed will enable the speed hack if it wasn't already, assuming of course that the speedhack works at all and you're already attached. One final check you could do is

Code:
function CEButton1Click(sender)
  print('trying to set speed to', CETrainer_CETrackBar1.Position)
  speedhack_setSpeed(CETrainer_CETrackBar1.Position)
  print('speed is now', speedhack_getSpeed())
end


If it's working as expected then you should see the same number printed out.
Back to top
View user's profile Send private message
snipertarget
How do I cheat?
Reputation: 0

Joined: 31 Aug 2017
Posts: 6

PostPosted: Thu Aug 31, 2017 12:14 pm    Post subject: Reply with quote

I try the code in Manually design I press execute and this is what I get:
Code:
trying to set speed to 0
speed is now 0.0
trying to set speed to 1
speed is now 1.0
trying to set speed to 4
speed is now 4.0


When I make generated trainer with same code and open it I get:
Code:
trying to set speed to 4
speed is now 1.0
trying to set speed to 6
speed is now 1.0
trying to set speed to 8
speed is now 1.0
trying to set speed to 0
speed is now 1.0
trying to set speed to 6
speed is now 1.0

I dont know why ;-;
The speed does not change at all in trainer I make...
Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Thu Aug 31, 2017 12:30 pm    Post subject: Reply with quote

The only thing I can think of then is that speedhack wasn't checked in the "features used" section:
Back to top
View user's profile Send private message
snipertarget
How do I cheat?
Reputation: 0

Joined: 31 Aug 2017
Posts: 6

PostPosted: Thu Aug 31, 2017 12:43 pm    Post subject: Reply with quote

I checked that but it only works before I generate the trainer :/ I dont know what is wrong, I think the trainer is not executing the script when I press the Set Speed Button, do you have any suggestions or script examples I could use? I need to make this work ;-;

Can I add you I need to talk to you I cant post link here or do anything ;-; I want to show you what I am doing maybe you know the problem here...

EDIT: Oh I found the problem, the process was a 32 bit ... I generated trainer in 64 bit -_- ... Thank you so much for the help, I fixed it. ^^
Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Thu Aug 31, 2017 1:03 pm    Post subject: Reply with quote

Hm if it wasn't executing the script then you wouldn't get the prints above either (because those are in the same script/function).

Honestly I don't generally create trainers so I don't know anything else to help out here.
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