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 Script / Help?

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

Joined: 29 May 2016
Posts: 215

PostPosted: Tue Feb 28, 2017 12:52 pm    Post subject: Lua Script / Help? Reply with quote

So I used the CETrainer Generator from here, this is my code:

Code:
function CreateTrainer()
   local HackData = {};
   function HackData:HacksData()

      self.trainer.form.Caption = [[Metal Gear Solid V Trainer]]
      self.trainer.title.Caption = [[]]
      self.trainer.credits.Caption = [[ Hack was made by Kalas]]
      self.hacktable =    {
      
{'Infinite Health',[[aobscanmodule(aobHealth,mgsvtpp.exe,F3 41 0F 11 16 * * * * C8)
alloc(newmem,$100,"mgsvtpp.exe"+4124F14)

label(code)
label(return)

newmem:

code:
  movss [r14],xmm3 // XMM3 Stores Player Cap.
  jmp return

aobHealth:
  jmp newmem
return:
registersymbol(aobHealth)]],[[]],[[Enabled]], 'true',[[Disabled]],[[aobHealth:
  db F3 41 0F 11 16

unregistersymbol(aobHealth)
dealloc(newmem)]]},


{'Infinite Ammo',[[aobscanmodule(aobAmmo,mgsvtpp.exe,66 44 89 1C 48 49)
alloc(newmem,$100,"mgsvtpp.exe"+3E02EA9)

aobscanmodule(aobAmmo_INV,mgsvtpp.exe,66 41 0F 42 D1)
alloc(newmema,$100,"mgsvtpp.exe"+3E02EED)

label(code)
label(return)

label(codea)
label(returna)

newmem:

code:
  mov r11,[rax+rcx*2] // Ammo in Chamber.
  mov [rax+rcx*2],r11w
  jmp return

aobAmmo:
  jmp newmem
return:
registersymbol(aobAmmo)

newmema:

codea:
  //cmovb dx,r9w // Ammo in Invetory.
  jmp returna

aobAmmo_INV:
  jmp newmema
returna:
registersymbol(aobAmmo_INV)]],[[]],[[Enabled]], 'true',[[aobAmmo:
  db 66 44 89 1C 48

unregistersymbol(aobAmmo)
dealloc(newmem)

aobAmmo_INV:
  db 66 41 0F 42 D1

unregistersymbol(aobAmmo_INV)
dealloc(newmema)]],[[Disabled]]},


{'Infinite Suppressor',[[aobscanmodule(aobSup,mgsvtpp.exe,46 88 4C 01 04)
alloc(newmem,$100,"mgsvtpp.exe"+3E032F0)

label(code)
label(return)

newmem:

code:
  mov r9,10 // 10 (HEX) = 16 (INT) - Mov 16 to R9.
  mov [rcx+r8+04],r9l
  jmp return

aobSup:
  jmp newmem
return:
registersymbol(aobSup)]],[[]],[[Enabled]], 'true',[[aobSup:
  db 46 88 4C 01 04

unregistersymbol(aobSup)
dealloc(newmem)]],[[Disabled]]},


{'Infinite GMP',[[aobscanmodule(aobMoney,mgsvtpp.exe,89 07 80 8B 88 0E 00 00 05)
alloc(newmem,$100,"mgsvtpp.exe"+3E97754)

label(code)
label(return)

newmem:

code:
  mov eax,(int)5000000 // Mov 5Mil to eax.
  mov [rdi],eax
  or byte ptr [rbx+00000E88],05
  jmp return

aobMoney:
  jmp newmem
  nop
  nop
  nop
  nop
return:
registersymbol(aobMoney)]],[[]],[[Enabled]], 'true',[[aobMoney:
  db 89 07 80 8B 88 0E 00 00 05

unregistersymbol(aobMoney)
dealloc(newmem)]],[[Disabled]]},


{'Infinite Timer',[[aobscanmodule(aobTimer,mgsvtpp.exe,F3 0F 11 8B E4 00 00 00 77)
registersymbol(aobTimer)

aobTimer:
  db 90 90 90 90 90 90 90 90]],[[]],[[Enabled]], 'true',[[aobTimer:
  db F3 0F 11 8B E4 00 00 00

unregistersymbol(aobTimer)]],[[Disabled]]},


{'No Recoil / No Spread',[[aobscanmodule(aobRecoil,mgsvtpp.exe,89 86 98 00 00 00 * * * * C0)
registersymbol(aobRecoil)

aobRecoil:
  db 90 90 90 90 90 90

aobscanmodule(aobSpread,mgsvtpp.exe,F3 0F 11 4E 3C 0F B7 46 20 66 0F 6E C0 0F 5B C0 * * * * C0 48 FF C9 75)
registersymbol(aobSpread)

aobSpread:
  db 90 90 90 90 90

aobscanmodule(aobSpread2,mgsvtpp.exe,89 86 98 00 00 00 F3)
alloc(newmem,$100,"mgsvtpp.exe"+3F17176)

aobscanmodule(aobFirstPerson1,mgsvtpp.exe,F3 44 0F 11 96 C8 00 00 00 48)
alloc(newmema,$100,"mgsvtpp.exe"+3F193EE)

aobscanmodule(aobFirstPerson2,mgsvtpp.exe,F3 0F 11 96 B8 00 00 00)
registersymbol(aobFirstPerson2)

aobFirstPerson2:
  db 90 90 90 90 90 90 90 90

label(code)
label(return)

newmem:

code:
  mov eax,(float)0
  mov [rsi+00000098],eax
  jmp return

aobSpread2:
  jmp newmem
  nop
return:
registersymbol(aobSpread2)

label(codea)
label(returna)

newmema:

codea:
  movss [rsi+000000C8],xmm10
  mov [rsi+C8],(float)0
  jmp returna

aobFirstPerson1:
  jmp newmema
  nop
  nop
  nop
  nop
returna:
registersymbol(aobFirstPerson1)]],[[]],[[Enabled]], 'true',[[aobRecoil:
  db 89 86 98 00 00 00

unregistersymbol(aobRecoil)

aobSpread:
  db F3 0F 11 4E 3C

unregistersymbol(aobSpread)

aobSpread2:
  db 89 86 98 00 00 00

unregistersymbol(aobSpread2)
dealloc(newmem)

aobFirstPerson2:
  db F3 0F 11 96 B8 00 00 00

unregistersymbol(aobFirstPerson2)

aobFirstPerson1:
  db F3 44 0F 11 96 C8 00 00 00

unregistersymbol(aobFirstPerson1)
dealloc(newmema)]],[[Disabled]]}
                  };
   for i=1,#self.hacktable do
      strings_add(self.listitems, self.hacktable[i][1]);
      self.hackstatus[i] = false;
   end
end
function HackData:Info()
   self.activateall = false; -- State.
   self.hackstatus = {};
   self.trainer = {};
   self.trainer.form = createForm(false);
   self.trainer.form.onClose = function (sender) sender.hide(); closeCE(); end;
   self.trainer.form.width = 400;
   self.trainer.form.height = 300;
   setProperty(self.trainer.form, 'Position', 'poScreenCenter');
   setProperty(self.trainer.form, 'BorderIcons', '[biSystemMenu]');
   setProperty(self.trainer.form, 'BiDiMode', 'bdLeftToRight');
   self.trainer.credits = createLabel(self.trainer.form);
   self.trainer.title = createLabel(self.trainer.form);
   local FontHeight = getProperty(self.trainer.title, 'Font');
   setProperty(FontHeight , 'Color', 0x000000FE);
   setProperty(FontHeight , 'Style', '[fsBold]');
   setProperty(FontHeight , 'Height', '20');
   self.trainer.group = createGroupBox(self.trainer.form);
   self.trainer.subtitle = createLabel(self.trainer.group);
   local FontHeight = getProperty(self.trainer.subtitle, 'Font');
   setProperty(FontHeight , 'Color', 0x00007F00);
   setProperty(FontHeight , 'Style', '[fsBold]');
   setProperty(FontHeight , 'Height', '16');
   self.trainer.desctitle = createLabel(self.trainer.group);
   local FontHeight = getProperty(self.trainer.desctitle, 'Font');
   setProperty(FontHeight , 'Color', 0x00F21200);
   self.trainer.desc = createLabel(self.trainer.group);
   self.trainer.list = createListBox(self.trainer.group);
   self.trainer.enable = createButton(self.trainer.group);
   self.trainer.enableall = createButton(self.trainer.group);
   local x,y = control_getSize(self.trainer.form);
   self.trainer.credits.left = 5;
   self.trainer.credits.top = y - 17;
   self.trainer.title.left = 10;
   self.trainer.title.top = 2.5;
   self.trainer.group.width = math.floor(x * 0.965);
   self.trainer.group.height = math.floor(y * 0.85);
   self.trainer.group.left = 5;
   self.trainer.group.top = math.floor((y * 1.095) - y);
   self.trainer.group.caption = 'Hacks';
   self.trainer.subtitle.left = 5;
   self.trainer.subtitle.top = 0;
   self.trainer.subtitle.caption = 'Select an hack from the list, then press enable!';
   local x,y = control_getSize(self.trainer.group);
   self.trainer.list.width = math.floor((x * 0.75) - 6);
   self.trainer.list.height = 64;
   self.trainer.list.left = 5;
   self.trainer.list.top = 20;
   local x,y = control_getSize(self.trainer.list);
   self.trainer.enable.width = math.floor((x * 0.34)-6);
   self.trainer.enable.height = 32;
   self.trainer.enable.left = x + 6;
   self.trainer.enable.top = 19;
   self.trainer.enable.caption = 'Enable';
   self.trainer.enable.onClick = function (sender) self:ActivateHack(sender) end;
   self.trainer.enableall.width = math.floor((x * 0.34)-6);
   self.trainer.enableall.height = 32;
   self.trainer.enableall.left = x + 6;
   self.trainer.enableall.top = 53;
   self.trainer.enableall.caption = 'Enable all';
   self.trainer.enableall.onClick = function (sender) self:ActivateAllHacks(sender) end;
   self.trainer.desctitle.left = 5;
   self.trainer.desctitle.top = y + 20;
   self.trainer.desctitle.caption = 'Selected hack description :';
   self.trainer.desc.left = 5;
   self.trainer.desc.top = y + 35;
   self.trainer.desc.caption = 'No hack was selected...';
   self.listitems = self.trainer.list.getItems();
   HackData:HacksData();
   setMethodProperty(self.trainer.list, 'OnSelectionChange', function () HackData:ChangeDesc() end)
   self.trainer.form.show();
end
function HackData:ActivateAllHacks(sender)
   self.activateall = true;
   for i = 0, #self.hacktable do
      i = i-1
      self.trainer.list.ItemIndex = i
      HackData:ActivateHack()
   end
   self.activateall = false;
end
function HackData:ActivateHack(sender)
   self.listitems = self.trainer.list.getItems();
   local index = self.trainer.list.ItemIndex + 1;
   if (index == 0 or self.hacktable[index] == nil) then
      return;
   end
   if (self.hackstatus[index] == false) then
      if (type(self.hacktable[index][2])=='string') then
         local asm = autoAssemble(self.hacktable[index][2]);
         if (asm == true) then
            if (AobSwapCheck~=true and AobSwapCheck~=nil) then
               AobSwapCheck=nil;
               if self.activateall == false then
                  return showMessage('Hack failed to enable!');
               else
                  return
               end
            end
            AobSwapCheck=nil;
            if self.activateall == false then
               if (self.hacktable[index][4]~='' and self.hacktable[index][4]~= nil) then
                  showMessage(self.hacktable[index][4]);
               else
                  showMessage('Hack was enabled successfully!');
               end
            end
            local str = strings_getString(self.listitems, index - 1);
            strings_setString( self.listitems, index - 1, str .. ' - Enabled!' );
            self.hackstatus[index] = true;
            HackData:ChangeDesc()
         else
            if self.activateall == false then
               return showMessage('Hack failed to enable!');
            else
               return
            end
         end
      end
   elseif (self.hackstatus[index] == true and (self.hacktable[index][5] == true or self.hacktable[index][5] == 'true') and self.activateall == false) then
      if (type(self.hacktable[index][6])=='string') then
         local asm = autoAssemble(self.hacktable[index][6]);
         if (asm == true) then
            if (AobSwapCheck~=true and AobSwapCheck~=nil) then
               AobSwapCheck=nil;
               return showMessage('Hack failed to enable!');
            end
            AobSwapCheck=nil;
            if (self.hacktable[index][7]~='' and self.hacktable[index][7]~= nil) then
               showMessage(self.hacktable[index][7]);
            else
               showMessage('Hack was disabled successfully!');
            end
            strings_setString( self.listitems, index - 1, self.hacktable[index][1] );
            self.hackstatus[index] = false;
         else
            return showMessage('Hack failed to disable!');
         end
      end
   end
   HackData:ChangeDesc();
end
function HackData:ChangeDesc(sender)
   local index = self.trainer.list.ItemIndex + 1
   if (index == 0 or self.hacktable[index] == nil) then
      return
   end
   if (self.hacktable[index][3] ~= '' and self.hacktable[index][3] ~= nil) then
      self.trainer.desc.caption = self.hacktable[index][3];
   else
      self.trainer.desc.caption = "There's no descriptions available about this hack";
   end
   if (self.hackstatus[index] == true and (self.hacktable[index][5] == false or self.hacktable[index][5] == 'false')) then
      self.trainer.enableall.Enabled = false;
      self.trainer.enable.Enabled = false;
   elseif (self.hackstatus[index] == true and (self.hacktable[index][5] == true or self.hacktable[index][5] == 'true')) then
      self.trainer.enableall.Enabled = false;
      self.trainer.enable.Enabled = true;
      self.trainer.enable.Caption = 'Disable';
   else
      self.trainer.enableall.Enabled = true;
      self.trainer.enable.Enabled = true;
      self.trainer.enable.Caption = 'Enable';
   end
end
HackData:Info()
end
processes = {'mgsvtpp.exe'}
retryamount = 0
function CheckIfFound()
   if retryamount==600 then return object_destroy(AutoAttachWhenFound), Failure() end
   retryamount = retryamount+1
   local SL=createStringlist()
    getProcesslist(SL)
   function inTable(tbl, item)
      for key, value in pairs(tbl) do
         if value:upper() == item:upper() then return true end
      end
      return false
   end
   for i=0,strings_getCount(SL)-1 do
      local entry = strings_getString(SL,i)
      local processname = entry:sub(10,255)
      if inTable(processes,processname) then
      openProcess(processes[1])
      object_destroy(AutoAttachWhenFound)
      showMessage("Game was found!\nYou may enable now the hacks!")
      CreateTrainer()
      break
      end
   end
end
function Failure()
   showMessage("Sorry but we couldn't find the game opened!\nThe program will shut down now")
   closeCE()
end
showMessage("Please make sure the game is opened\nPress OK to attach")
AutoAttachWhenFound = createTimer(nil,true)
timer_setInterval(AutoAttachWhenFound, 500)
timer_onTimer(AutoAttachWhenFound, CheckIfFound)



MY Issue is that I don't understand where or how to make a lua script?
Back to top
View user's profile Send private message
Corroder
Master Cheater
Reputation: 8

Joined: 10 Apr 2015
Posts: 404

PostPosted: Tue Feb 28, 2017 9:20 pm    Post subject: Reply with quote

What the script you post is lua script (+ some AA script there)
to writing script via Cheat Engine, there are three ways :

1. via CE Menu > Table > Show Cheat Lua Script (Ctrl+Alt_L)
2. via CE Menu > Memory View > Tools > Lua Engine (Ctrl + L)
3. via CE Menu (for AA script) > Memory View > Tools > Auto Assemble (Ctrl+A)
Back to top
View user's profile Send private message
KalasWD
Expert Cheater
Reputation: 0

Joined: 29 May 2016
Posts: 215

PostPosted: Wed Mar 01, 2017 5:12 am    Post subject: Reply with quote

Yea I saved it as EXE, CTRL+ALT+L.

Thank you so much tho
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