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 


[HELP] CE LUA Scripting - ZxPwds ULTIMATE help thread!
Goto page 1, 2, 3  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
ZxPwds
Advanced Cheater
Reputation: 0

Joined: 27 Oct 2015
Posts: 59

PostPosted: Wed Oct 28, 2015 11:22 pm    Post subject: [HELP] CE LUA Scripting - ZxPwds ULTIMATE help thread! Reply with quote

PLEASE READ THE PICTURE ATTACHMENT BEFORE READING!!!


I appologize for any spelling mistakes in advance. I was very drunk when I made this and I wanted to be as blunt as possible and didin't go over my thread post. I saved this into a .txt file and posted it. I really hope somebody will help me.

I will EVEN pay $ for questions answered if you wish not to spoonfeed me. I like to learn and I hope nobody has anything bad to say about this post, Because people will learn from this topic on using LUA scripting in CE.

Hello there cheatengine I've read tutorials on this website for years and years. I've only registered an account now. But since I'm a kid this website has help me on multiple hacking questions without me needing to post a thread. I hack one game and one game only I'm sure everybody has herd of it and it's called gunz online. I only said what game it is that I am hacking incase anybody was wondering. Now I know a little about everything. I know enough to be able to find a way to hack the game successfully without having to download programs and software's I guess you can call it a hobby of mine once I have the free time in my life to do such a thing. I think you can call me a script kiddie but you cannot find a release of mine anywhere on the internet without me giving credits of my knowledge. You can google my name google search "ZxPwd hacks".

Below you will find examples of what I wish to do in LUA scripting. I hope somebody will have the time to read this hole thread and actually take the time to help somebody like me. I'm sure nobody will post a detail thread like this in order to find out what he needs to hack the game he is willing to hack with the amount of knowledge I know which is not much. I would like to thank the people in advance that help me. I will also enter the name of my skype account incase people are nice enough to add me to answer basic questions. I am 22 year old Canadian pot head that will not flood or spam your skype with noobie questions. Please bare with me and try to help me.

PLEASE READ THE PICTURE ATTACHMENT FIRST!





I'm going to first start by saying this. My first thread on Cheat Engine forums was the following link.
LINK: [I cannot post links yet sorry]

This link explains how I wanted to do the following
[Help] Lua WriteMemory / Trainer making help

LINK: [I cannot post links yet sorry]


After getting a really fast and kind reply by ParkourPenguin a member of cheat engine forums he had givin me an example of my request plus he had linked me to a super great trainer tutorial to evolves AA scripting with LUA scripting using cheat engine. I might be late on finding this but I cannot believe how great LUA hacking for games was. Now I have more questions that I hope to try and ask in one thread so I do not need to keep asking.

Please be patient with me everybody I'm not the greatest at this but however I do understand the logic of programming and with help I will accomplish this and hopefully help out a lot of people who search for the same results as me.


__________________________________
THE BEGGINING OF MY HELP REQUEST
----------------------------------


The cheats that I use it super simple. They are Double and Float type values. And what I want to do is basically use hotkeys or a simple checkbox so that once the checkbox is "checked" or "unchecked" to then *Write* the amount I need. Also knowing how
to NOP an address would be much appreciated but I'm concentrating on Write to Float and Write to Double.
_________

QUESTIONS:

Using LUA scripting with cheatengine.

1: Do I need to write a code in LUA saying to look for the current process I am using EX: TheDuel.exe

2: If and Else Functions. I wish to do the Following.


I'm pretty sure this is simple enough for somebody to help
me with. I would really like to know when someone does help
me with the code if I also need to attach the process
because I do not know if CE automatically does it for you or
not but I know in C# or vb.net you need to let it know which
process to hook into before you RPM "WriteProcessMemory".

Code:
function CEToggleBox1Change(sender)
  if (checkbox_getState(UDF1.CEToggleBox1) == 1) then

// In this code I wish to Write the value "2000" to a Double type value

// I wish to make the Caption of the checkbox to *red*

  else

// In this code i wish to Write the value "800" to a Double type value * as this is the regular value *

// I wish to make the Caption of the checkbox to *black*

  end
end



I'm not a spammer but if anybody could help me in this using
skype I promise not to spam you with help. I got basic questions
my skype name is: ZxPwds

Or please give me a reply.



I want to thank the community in advance for your help.



Thread.png
 Description:
 Filesize:  170.16 KB
 Viewed:  10347 Time(s)

Thread.png


Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Thu Oct 29, 2015 12:06 am    Post subject: Reply with quote

Just for an illustration (some one expert should give better than this)

Code:

--- color var
red="0x000000FF"
black="0x00999999"

--- scan double value
function findDoubleValueAndReplace(findValue, replaceWith)
  memscan = createMemScan()
  foundlist = createFoundList(memscan)
  protectionflags = "-W*X-C"
  memscan.firstScan(soExactValue, vtDouble, rtTruncated, findValue, nil,
               "0","7fffffff",protectionflags,
               fsmAligned,"4",
               false, false, false, false)
  memscan.waitTillDone()
  foundlist.initialize()

  for i=0,foundlist.Count-1 do
   fullAccess(  getAddress(foundlist.Address[i])  , 8)
   writeDouble(  foundlist.Address[i], replaceWith)
  end

  sleep(50)
  foundlist.destroy()
  sleep(50)
  memscan.destroy()
end

---- Scan and replace double value
function doscndouble()
  findDoubleValueAndReplace("your_value", 2000)
end

---- Toggle Box Executing
function CEToggleBox1Change(sender)
if (checkbox_getState(UDF1.CEToggleBox1) == 1) then
doscndouble()
local font = getProperty(UDF1.CEToggleBox1, "Font")
setProperty(font, "Color", red)
control_setCaption(UDF1.CEToggleBox1, "2000")
--
local font = getProperty(UDF1.CELabel2, "Font")     ----- Addition to test
setProperty(font, "Color", red)
control_setCaption(UDF1.CELabel2, "2000")
else
local font = getProperty(UDF1.CEToggleBox1, "Font")
setProperty(font, "Color", black)
control_setCaption(UDF1.CEToggleBox1, "800")
--
local font = getProperty(UDF1.CELabel2, "Font")  ----- Addition to test
setProperty(font, "Color", black)
control_setCaption(UDF1.CELabel2, "800")
end
end



test_toggle.CT
 Description:

Download
 Filename:  test_toggle.CT
 Filesize:  2.19 KB
 Downloaded:  735 Time(s)

Back to top
View user's profile Send private message
Fluffer_Nutter
Advanced Cheater
Reputation: 0

Joined: 26 Feb 2015
Posts: 67

PostPosted: Thu Oct 29, 2015 12:47 am    Post subject: Reply with quote

Hey Hey.

Yes you need to hook the process first. Kinda. You can get the hacks set up since you want to use check boxes. Then attach to process then inject / swap. So here is the idea.

Connect to client -> Select hacks -> Inject / Swap

For the client connect it depends on what it is. Is it a exe file. A Flash game. Unity? That will be where you start.

After that comes the check boxes. You have the script made already. And as @Corroder posted he shows you how to do it with a togglebox. The same idea works with check boxes. First you see what state it is in. Then your run the function to tell it what to do.

My honest suggestion is to work 1 thing at a time. When i make a new trainer i do codes last. I make sure it functions 100% the way i like before anything else. Once the look, hook, and functions are done then work on the checkbox function (this will be the short amount of work compared to the rest).

I think that answers your two questions. Good luck in your adventure.

- Fluffer Nutter
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 199

Joined: 25 Jan 2006
Posts: 8518
Location: 127.0.0.1

PostPosted: Thu Oct 29, 2015 1:51 am    Post subject: Reply with quote

For the record, it is Lua, not LUA.
_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
STN
I post too much
Reputation: 42

Joined: 09 Nov 2005
Posts: 2672

PostPosted: Thu Oct 29, 2015 1:56 am    Post subject: Reply with quote

wow
_________________
Cheat Requests/Tables- Fearless Cheat Engine
https://fearlessrevolution.com
Back to top
View user's profile Send private message
ZxPwds
Advanced Cheater
Reputation: 0

Joined: 27 Oct 2015
Posts: 59

PostPosted: Thu Oct 29, 2015 8:13 am    Post subject: Reply with quote

Corroder wrote:
Just for an illustration (some one expert should give better than this)

Code:

--- color var
red="0x000000FF"
black="0x00999999"

--- scan double value
function findDoubleValueAndReplace(findValue, replaceWith)
  memscan = createMemScan()
  foundlist = createFoundList(memscan)
  protectionflags = "-W*X-C"
  memscan.firstScan(soExactValue, vtDouble, rtTruncated, findValue, nil,
               "0","7fffffff",protectionflags,
               fsmAligned,"4",
               false, false, false, false)
  memscan.waitTillDone()
  foundlist.initialize()

  for i=0,foundlist.Count-1 do
   fullAccess(  getAddress(foundlist.Address[i])  , 8)
   writeDouble(  foundlist.Address[i], replaceWith)
  end

  sleep(50)
  foundlist.destroy()
  sleep(50)
  memscan.destroy()
end

---- Scan and replace double value
function doscndouble()
  findDoubleValueAndReplace("your_value", 2000)
end

---- Toggle Box Executing
function CEToggleBox1Change(sender)
if (checkbox_getState(UDF1.CEToggleBox1) == 1) then
doscndouble()
local font = getProperty(UDF1.CEToggleBox1, "Font")
setProperty(font, "Color", red)
control_setCaption(UDF1.CEToggleBox1, "2000")
--
local font = getProperty(UDF1.CELabel2, "Font")     ----- Addition to test
setProperty(font, "Color", red)
control_setCaption(UDF1.CELabel2, "2000")
else
local font = getProperty(UDF1.CEToggleBox1, "Font")
setProperty(font, "Color", black)
control_setCaption(UDF1.CEToggleBox1, "800")
--
local font = getProperty(UDF1.CELabel2, "Font")  ----- Addition to test
setProperty(font, "Color", black)
control_setCaption(UDF1.CELabel2, "800")
end
end



Hey man I really appreciate the reply and help.
there is something I don't understand. Do I need to scan before I I change the value or something ?

Code:
--- scan double value
function findDoubleValueAndReplace(findValue, replaceWith)
  memscan = createMemScan()
  foundlist = createFoundList(memscan)
  protectionflags = "-W*X-C"
  memscan.firstScan(soExactValue, vtDouble, rtTruncated, findValue, nil,
               "0","7fffffff",protectionflags,
               fsmAligned,"4",
               false, false, false, false)
  memscan.waitTillDone()
  foundlist.initialize()

  for i=0,foundlist.Count-1 do
   fullAccess(  getAddress(foundlist.Address[i])  , 8)
   writeDouble(  foundlist.Address[i], replaceWith)
  end

  sleep(50)
  foundlist.destroy()
  sleep(50)
  memscan.destroy()
end


or is this all I need to change the value



Code:
---- Scan and replace double value
function doscndouble()
  findDoubleValueAndReplace("800", 2000)
end

---- Toggle Box Executing
function CEToggleBox1Change(sender)
if (checkbox_getState(UDF1.CEToggleBox1) == 1) then
doscndouble()
local font = getProperty(UDF1.CEToggleBox1, "Font")
setProperty(font, "Color", red)
control_setCaption(UDF1.CEToggleBox1, "2000")
--



I am currently not home so I could not test it. But once I get home I will try it out but I wanted to ask you that before I do. Also the Process name I need to hook to is called "Theduel.exe" can you also show me how I can tell the script that I'm changing the value for "Theduel.exe" ?



This is the code I have now::::











Code:

AboutText=[[Trainer is for GunZ]]

form_show(UDF1)
getAutoAttachList().add("Theduel.exe")

function CloseClick()
  closeCE()
  return caFree
end

UDF1.OnClose = CloseClick
addresslist=getAddressList()


function CEButton1Click(sender)
  showMessage(AboutText)
end






--- scan double value
function findDoubleValueAndReplace(findValue, replaceWith)
  memscan = createMemScan()
  foundlist = createFoundList(memscan)
  protectionflags = "-W*X-C"
  memscan.firstScan(soExactValue, vtDouble, rtTruncated, findValue, nil,
               "0","7fffffff",protectionflags,
               fsmAligned,"4",
               false, false, false, false)
  memscan.waitTillDone()
  foundlist.initialize()

  for i=0,foundlist.Count-1 do
   fullAccess(  getAddress(foundlist.Address[i])  , 8)
   writeDouble(  foundlist.Address[i], replaceWith)
  end

  sleep(50)
  foundlist.destroy()
  sleep(50)
  memscan.destroy()
end



---- Scan and replace double value
function doscndouble()
  findDoubleValueAndReplace("900", 2000)
end



---- Toggle Box Executing
function CEToggleBox1Change(sender)
if (checkbox_getState(UDF1.CEToggleBox1) == 1) then
doscndouble()
local font = getProperty(UDF1.CEToggleBox1, "Font")
setProperty(font, "Color", red)
control_setCaption(UDF1.CEToggleBox1, "2000")
--
local font = getProperty(UDF1.CELabel2, "Font")     ----- Addition to test
setProperty(font, "Color", red)
control_setCaption(UDF1.CELabel2, "2000")
else
local font = getProperty(UDF1.CEToggleBox1, "Font")
setProperty(font, "Color", black)
control_setCaption(UDF1.CEToggleBox1, "900")
--
local font = getProperty(UDF1.CELabel2, "Font")  ----- Addition to test
setProperty(font, "Color", black)
control_setCaption(UDF1.CELabel2, "900")
end
end



Where do I put my address ?
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4300

PostPosted: Thu Oct 29, 2015 10:30 am    Post subject: Reply with quote

ZxPwds wrote:
there is something I don't understand. Do I need to scan before I I change the value or something ?

Well, if you already have a static reference to the address you want to change, then you don't need to scan for it since you already know where it is. You can use readInteger(address+offset) or readQword(address+offset) to traverse the pointer path depending on if your target is 32-bit or 64-bit respectively. You can also use readPointer(address), but that might be a little buggy.

If you're replacing actual instructions in the game's memory (i.e. replacing stuff with NOP), Zanzer's Lua AoB scan script is probably your best bet.

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
ZxPwds
Advanced Cheater
Reputation: 0

Joined: 27 Oct 2015
Posts: 59

PostPosted: Thu Oct 29, 2015 10:56 am    Post subject: Reply with quote

Thank you ParkourPenguin for your reply.


Thanks for the reply. The address I have does not need any pointers/offsets

Jump: 007087C0 // Theduel.exe+3087C0

This is for a Jump hack.

Address: 007087C0
Type: Double
Value: 800
OFFSETS: None

Checkbox Checked: Value change to 2000
Checkbox Unchecked: Value change to 800



.
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4300

PostPosted: Thu Oct 29, 2015 11:20 am    Post subject: Reply with quote

Using the script you posted previously:
Code:
AboutText=[[Trainer is for GunZ]]

form_show(UDF1)
getAutoAttachList().add("Theduel.exe")

function CloseClick()
  closeCE()
  return caFree
end

UDF1.OnClose = CloseClick
addresslist=getAddressList()

function CEButton1Click(sender)
  showMessage(AboutText)
end

---- Toggle Box Executing
function CEToggleBox1Change(sender)
  if (checkbox_getState(UDF1.CEToggleBox1) == 1) then
    writeDouble(getAddress("Theduel.exe")+0x3087C0,2000)

    local font = getProperty(UDF1.CEToggleBox1, "Font")
    setProperty(font, "Color", red)
    control_setCaption(UDF1.CEToggleBox1, "2000")

    local font = getProperty(UDF1.CELabel2, "Font")     ----- Addition to test
    setProperty(font, "Color", red)
    control_setCaption(UDF1.CELabel2, "2000")
  else
    writeDouble(getAddress("Theduel.exe")+0x3087C0,800)

    local font = getProperty(UDF1.CEToggleBox1, "Font")
    setProperty(font, "Color", black)
    control_setCaption(UDF1.CEToggleBox1, "900")

    local font = getProperty(UDF1.CELabel2, "Font")  ----- Addition to test
    setProperty(font, "Color", black)
    control_setCaption(UDF1.CELabel2, "900")
  end
end

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
ZxPwds
Advanced Cheater
Reputation: 0

Joined: 27 Oct 2015
Posts: 59

PostPosted: Thu Oct 29, 2015 12:23 pm    Post subject: Reply with quote

ParkourPenguin wrote:
Using the script you posted previously:
Code:
AboutText=[[Trainer is for GunZ]]

form_show(UDF1)
getAutoAttachList().add("Theduel.exe")

function CloseClick()
  closeCE()
  return caFree
end

UDF1.OnClose = CloseClick
addresslist=getAddressList()

function CEButton1Click(sender)
  showMessage(AboutText)
end

---- Toggle Box Executing
function CEToggleBox1Change(sender)
  if (checkbox_getState(UDF1.CEToggleBox1) == 1) then
    writeDouble(getAddress("Theduel.exe")+0x3087C0,2000)

    local font = getProperty(UDF1.CEToggleBox1, "Font")
    setProperty(font, "Color", red)
    control_setCaption(UDF1.CEToggleBox1, "2000")

    local font = getProperty(UDF1.CELabel2, "Font")     ----- Addition to test
    setProperty(font, "Color", red)
    control_setCaption(UDF1.CELabel2, "2000")
  else
    writeDouble(getAddress("Theduel.exe")+0x3087C0,800)

    local font = getProperty(UDF1.CEToggleBox1, "Font")
    setProperty(font, "Color", black)
    control_setCaption(UDF1.CEToggleBox1, "900")

    local font = getProperty(UDF1.CELabel2, "Font")  ----- Addition to test
    setProperty(font, "Color", black)
    control_setCaption(UDF1.CELabel2, "900")
  end
end





Thats what I did. So no I removed any code that was confuseing me like
the changing caption color on activation I will add that later when I
actually get this hack working. Below I have a picture giving me and error
after I click the togglebox while my checkbox is checked.

why am I seeing this error I don't get what it means.


Below I have a picture of my CE stuff.
I have also included an attachment file of the .CT



help2.png
 Description:
 Filesize:  271.01 KB
 Viewed:  9750 Time(s)

help2.png



LuaBegginer.CT
 Description:

Download
 Filename:  LuaBegginer.CT
 Filesize:  105.51 KB
 Downloaded:  641 Time(s)

Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4300

PostPosted: Thu Oct 29, 2015 2:04 pm    Post subject: Reply with quote

The general process worked for me.

Make sure the name of your checkbox is actually CEToggleBox1. For me, it was CECheckbox1 by default. There also might be an error in the stuff that modifies the font, so try getting rid of that.

If it still doesn't work, try this SSCCE and work backwards:
Lua Script
Code:
form_show(UDF1)

function CECheckbox1Change(sender)
  if (checkbox_getState(UDF1.CECheckbox1) == 1) then
    writeDouble(getAddress("mem"),2000)
  else
    writeDouble(getAddress("mem"),800)
  end
end

AA Script to allocate mem
Code:
[ENABLE]
alloc(mem,1024)
registersymbol(mem)

[DISABLE]
dealloc(mem)
unregistersymbol(mem)


Steps
  1. Open up the CE Tutorial and attach CE to it
  2. Paste AA script into the Auto Assembler (Ctrl+Alt+A), assign it to the cheat table, and enable it
  3. Paste Lua script into the cheat table lua script window
  4. Make a new form (Name = UDF1)
  5. Make a new checkbox in that form (Name = CECheckbox1)
  6. Click on the "Events" menu on the CECheckbox you just made
  7. Set "OnChange" to be "CECheckbox1Change" (a function in the lua script)
  8. Add the address "mem" manually to the table (Address = mem, Type = Double)
  9. Execute the Lua script, and you should see the address changing in the table

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
ZxPwds
Advanced Cheater
Reputation: 0

Joined: 27 Oct 2015
Posts: 59

PostPosted: Thu Oct 29, 2015 2:43 pm    Post subject: Reply with quote

THIS POST HERE IM DOING WAS EDITED TO LATE SO I WILL POST A NEW REPLY BELOW

Last edited by ZxPwds on Thu Oct 29, 2015 3:03 pm; edited 2 times in total
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4300

PostPosted: Thu Oct 29, 2015 3:00 pm    Post subject: Reply with quote

It's just an SSCCE (Short, Self-Contained, Correct Example). It's not meant to directly work in the game you're hacking.

But if you followed the steps and it does work, then the next step would be to try this short version of the script in the game. To do so, attach CE to the game you're hacking, and update the address you're writing to in your Lua script. In this case, replace getAddress("mem") with getAddress("Theduel.exe")+0x3087C0 in both occurrences.

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
ZxPwds
Advanced Cheater
Reputation: 0

Joined: 27 Oct 2015
Posts: 59

PostPosted: Thu Oct 29, 2015 3:07 pm    Post subject: Reply with quote

ParkourPenguin wrote:
It's just an SSCCE (Short, Self-Contained, Correct Example). It's not meant to directly work in the game you're hacking.

But if you followed the steps and it does work, then the next step would be to try this short version of the script in the game. To do so, attach CE to the game you're hacking, and update the address you're writing to in your Lua script. In this case, replace getAddress("mem") with getAddress("Theduel.exe")+0x3087C0 in both occurrences.


Thanks for this reply, it answered what I wanted to know. However I edited the
post prior to this quote of yours. I found the problem on my error i was having.
it was like you said a couple of things were not named correctly.
Now that everything works without any errors when I click my ToggleBox
the value just doesn't change. I'm a little lost on that. I have an image below.

I even used a test button to change the the value using just this




Code:
function CEButton2Click(sender)
 writeDouble(getAddress("Theduel.exe")+0x3087C0,2000)
end


but still the value does not change.



screenshot_help.png
 Description:
 Filesize:  111.19 KB
 Viewed:  9725 Time(s)

screenshot_help.png


Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4300

PostPosted: Thu Oct 29, 2015 3:25 pm    Post subject: Reply with quote

Maybe that memory isn't writable or something. Try this:
Code:
function CEButton2Click(sender)
  fullAccess(getAddress("Theduel.exe")+0x3087C0,8)
  writeDouble(getAddress("Theduel.exe")+0x3087C0,2000)
end

_________________
I don't know where I'm going, but I'll figure it out when I get there.
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
Goto page 1, 2, 3  Next
Page 1 of 3

 
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