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 


Can someone help me fix my code.

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

Joined: 21 Feb 2016
Posts: 115

PostPosted: Wed Jul 20, 2016 2:18 pm    Post subject: Can someone help me fix my code. Reply with quote

[solved]

Last edited by usernotfound on Thu Aug 18, 2016 5:44 pm; edited 2 times in total
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Wed Jul 20, 2016 5:34 pm    Post subject: Reply with quote

Just need to registersymbol(StringUser)
Code:
local value = UDF1.CEEdit1.Text .. string.char(0)
writeString("StringUser", value)
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 138

Joined: 06 Jul 2014
Posts: 4275

PostPosted: Wed Jul 20, 2016 6:26 pm    Post subject: Reply with quote

Trying to use dealloc like that won't work. AA scripts keep track of the memory they allocate; Lua scripts don't. Use globalalloc to only allocate it once, and all you need to change is the injection point.

Do not copy and paste code without knowing what it does.
You should use CETrainer.CEToggleBox57.Checked instead of that old function.
The ellipses are not a part of the script but are used to represent missing parts of the original script.
With regards to string.format, %X is a placeholder for representing an integer in uppercase hexadecimal and is not relevant for strings. Use the placeholder %s instead to substitute a string.
Unless the username and password are always numbers, you have no logical excuse for wrapping the text in tonumber.

As for the second Lua script, you still have the same problem of memory leak.
Use a registered symbol to change the delay. Either store it separately in memory, or directly change the immediate in the instruction.


Zanzer: unfortunately that code won't make writeString also write the null character. You'll have to write that byte manually or use the AA and string.format.

_________________
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
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Wed Jul 20, 2016 6:36 pm    Post subject: Reply with quote

You saying I have to test my scripts too?! What a bother.
Code:
local value = UDF1.CEEdit1.Text
local bytes = stringToByteTable(value)
table.insert(bytes, 0)
writeBytes("StringUser", bytes)
Back to top
View user's profile Send private message
usernotfound
Expert Cheater
Reputation: 0

Joined: 21 Feb 2016
Posts: 115

PostPosted: Wed Jul 20, 2016 6:37 pm    Post subject: Reply with quote

ParkourPenguin wrote:
Trying to use dealloc like that won't work. AA scripts keep track of the memory they allocate; Lua scripts don't. Use globalalloc to only allocate it once, and all you need to change is the injection point.

Do not copy and paste code without knowing what it does.
You should use CETrainer.CEToggleBox57.Checked instead of that old function.
The ellipses are not a part of the script but are used to represent missing parts of the original script.
With regards to string.format, %X is a placeholder for representing an integer in uppercase hexadecimal and is not relevant for strings. Use the placeholder %s instead to substitute a string.
Unless the username and password are always numbers, you have no logical excuse for wrapping the text in tonumber.

As for the second Lua script, you still have the same problem of memory leak.
Use a registered symbol to change the delay. Either store it separately in memory, or directly change the immediate in the instruction.


Zanzer: unfortunately that code won't make writeString also write the null character. You'll have to write that byte manually or use the AA and string.format.


Hey Parkour thanks for the reply yet again, you definitely have a much better understanding of all this then I do, if it wouldn't be too much trouble would you mind giving me a small example with the code I've posted so far? So I could reference it for the future, would be very much appreciated.


Last edited by usernotfound on Thu Aug 18, 2016 5:45 pm; edited 1 time in total
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 138

Joined: 06 Jul 2014
Posts: 4275

PostPosted: Wed Jul 20, 2016 6:59 pm    Post subject: Reply with quote

Fixing the memory leak:
Code:
autoAssemble([[globalalloc(mycode,1024)
globalalloc(mystring,256)

mycode:
  // do whatever
  jmp wherever

mystring:
  db 'A string',0]])

function CEToggleBox57Change(sender)
  if sender.Checked then
    autoAssemble([[injectionPoint:
      jmp mycode]])    -- jmp to your code
  else
    autoAssemble([[injectionPoint:
      originalCode]])  -- restore original code
  end
end

To change the delay:
Code:
autoAssemble([[globalalloc(delay,4)

someCode:
  mov eax,[delay]

delay:
  dd 0]])

writeInteger("delay",5)

_________________
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
++METHOS
I post too much
Reputation: 92

Joined: 29 Oct 2010
Posts: 4197

PostPosted: Thu Jul 21, 2016 4:49 am    Post subject: Reply with quote

Hey, OP, don't be rude! If someone takes the time out of their day to offer you help when you asked for it, don't just ignore them...say thanks. Even if you don't use their suggestion, at least show them some common courtesy.
Back to top
View user's profile Send private message
usernotfound
Expert Cheater
Reputation: 0

Joined: 21 Feb 2016
Posts: 115

PostPosted: Thu Jul 21, 2016 9:58 am    Post subject: Reply with quote

Terribly sorry I meant to reply to this thread but have been an issue with my ISP that I just resolved, but thank you so much Parkour & Zanzer I finally have the script working the way I wanted it to. Again really sorry for the late reply, I didn't mean to ignore anyone at all.
Back to top
View user's profile Send private message
++METHOS
I post too much
Reputation: 92

Joined: 29 Oct 2010
Posts: 4197

PostPosted: Thu Jul 21, 2016 10:13 am    Post subject: Reply with quote

I had just woken up and I am generally pretty jaded about some things. Very Happy
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