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 


Using a received datastring

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

Joined: 10 Jan 2016
Posts: 68

PostPosted: Thu Sep 15, 2016 7:49 am    Post subject: Using a received datastring Reply with quote

Good day
im working on an app...thet sends verification data to an php script...which returns data in data strings...but for some reason i cant use them...
the data parts<which contains functions etc of the app> arrives ok this side...and i cam view them up to where i want to implement the functions...can some body hlp pls...Smile

the section where the data gets returned...

Code:
   obj = JSON.decode((data));
     

        if (obj.error ~= '') then
            showMessage(obj.error)
            return
        else
        showMessage("Logged On SucessFully! Welcome ".. self.editu.Text.."\nLogged on : ".. TimeStamp)
           

    Callmain = RunMain('MainRun')
   Callmain()

        end
    end



AND
the area where i build it from the received string...
--up to showMessage(myHacks) i get the correct printout of the data
but my error occur on the very next line...:
local dataTable =loadstring(myHacks)();

Code:
function RunMain(dataname)
   myHacks=obj.mainData;
    showMessage(myHacks);
   local dataTable =loadstring(myHacks)();

   local data = dataTable[dataname]
   return data;

end;



the returned data which i wish to use in app:

Code:

$file1 = "return {

MainRun=function()
   function ResetChrome()
      success = 0
      local test = openProcess('chrome.exe') if test ==nil then return showMessage('Chrome was not found!!'),timer_setEnabled(openNextProcTimer,false) end
      strings_add(getAutoAttachList(),process)
      timer_setEnabled(openNextProcTimer,true)
   end
   
   
   function enableCheatsGuiWhatEver()
      -- initialize UI (or reinitialize UI)
      -- or whatever you want to do afer finding right process:
      -- enabling controls, cheats
      local PID=getOpenedProcessID()
      control_setCaption(AttachFirst[1],'Attaching Form!')
      control_setEnabled(AttachFirst[3], true)
      control_setCaption(AttachFirst[9], 'Currently attached to PID: ' .. PID)
      success = 1
      showMessage('Attached successfully!')
   end
   
   
   -- this function returns true if good process, false if bad
   function checkProcessMajor()
      reinitializeSymbolhandler()
      -- for Chrome flash
      if getAddress('pepflashplayer.dll')~=0 or
      getAddress('AdobeCPGetAPI') ~=0 then
         return true
      end
      
      
      -- you can change above condition to something else.
      -- for example you can make aobscan check - if pattern found -> return true
      return false -- return false by default
   end
   
   function getPids()
      local SL=createStringlist()
      getProcesslist(SL)
      local tempPIDtable={}
      for i=0,strings_getCount(SL)-1 do
         local entry = strings_getString(SL,i)
         local processname = entry:sub(10,255)
         local PID = tonumber('0x'..entry:sub(1,8))
         if processname == process then
            if alreadycheckedPIDS[PID]~=true then
               table.insert(tempPIDtable,PID)
            end
         end
      end
      object_destroy(SL)
      return tempPIDtable
   end
   
   
   function checkProcess(sender)
      timer_setEnabled(sender,false)
      -- add currently opened process to ignore list
      -- (openNextProc will ignore those)
      alreadycheckedPIDS[getOpenedProcessID()]=true
      if checkProcessMajor() then
         -- OUR TARGET FOUND
         timer_setEnabled(openNextProcTimer,false)
         alreadycheckedPIDS={}
         enableCheatsGuiWhatEver()
      else
         timer_setEnabled(openNextProcTimer,true)
      end
   end
   
   
   function onOpenProcess()
      if success == 1 then return end
      timer_setEnabled(checkProcessTimer,true)
   end
   checkProcessTimer = createTimer(nil,false)
   timer_setInterval(checkProcessTimer, 100)
   timer_onTimer(checkProcessTimer, checkProcess)
   function AttachToChrome()
      control_setCaption(AttachFirst[1],'Attaching Form! - Please wait searching for the process...')
      ResetChrome()
   end
   
   
   function AttachList()
      AttachItems = combobox_getItems(AttachFirst[10])
      AttachIndex = combobox_getItemIndex(AttachFirst[10])
      if AttachIndex == -1 then return end
      if AttachIndex == 0 then return showMessage('Please pick a process from the list') end
      Proc_name=strings_getString(AttachItems,AttachIndex)
      
      if strings_getString(AttachItems,AttachIndex)=='chrome.exe' then return AttachToChrome() end
      openProcess(strings_getString(AttachItems,AttachIndex))
      errorOnLookupFailure(false)
      reinitializeSymbolhandler()
      err=getAddress('kernel32.dll')==0
      if err==true then
         showMessage('Couldn\'t find the process')
      else
         local PID=getOpenedProcessID()
         control_setCaption(AttachFirst[9], 'Currently attached to PID: ' .. PID)
         control_setEnabled(AttachFirst[3], true)
         showMessage('Attached successfully!')
      end
   end
   
   
   
   function database_Updt(dataname)
      m_hacks2=obj.buildData
      
      local dataTable =loadstring(m_hacks2)()
      
      local data = dataTable[dataname]
      return data;
      
   end;
   
   function read_data()
      
      
      
      gid={}
      local datastring = {}
      local datastring2 = {}
      local k = string.len(gidstr);
      local l =0;
      local m =1;
      
      datastring[m]=''
      x=1
      x1=1
      repeat
         datastring[m]=' '
         datastring2[m]=' '
         x, y = string.find(gidstr,'x',x+1,true)
         if x~=nil and y ~= nil then
            datastring[m]=string.sub(gidstr, x1, x)
            datastring[m]=string.gsub(datastring[m],'x',' ')
            gid1 = datastring[m]
            
            
            hx=''
            hx1=''
            hx2=''
            a=0
            b=0
            hx = string.format('%X',gid1)
            
            hx2 = string.reverse(hx)
            if math.mod(string.len(hx2),2)~=0
            then
               hx2=hx2..'0'
            end
            a=string.len(hx2)
            b=1
            repeat
               hx1=hx1..' '..string.sub(hx2,b+1,b+1)..string.sub(hx2,b,b)
               b=b+2
            until b>=a+2
            datastring2[m]=hx1
            print(datastring2[m])
            print(string.len(datastring2[m]))
            showMessage('='..hx1..'=')
            if (string.len(datastring2[m])>6) then
               print(string.len(datastring2[m]))
               gid[m]='00 00'..datastring2[m]..'00 00'
               showMessage('m='..gid[m]..'=')
            end
            print(gid[m])
            m=m+1
            x1=x
            
         end
         
      until x==nil
      
      gid1=gid[1]
      gid2=gid[2]
      gid3=gid[3]
      gid4=gid[4]
      gid5=gid[5]
      sub1=datastring[7]
      sub2=datastring[8]
      
      
      
      
   end
   
   
   
   
   function ExecuteHack()
      read_data()
      
      
      showMessage('Building Hacks...pls be patient....Click \'OK\' to continue')
      control_setEnabled(AttachFirst[3], false)
      
      
      
      InformationText='Building Hack data\n\n Please DO NOT refresh the game or close the app\nElse the hack(s) won\'t work \n\nCurrently building :...Ship_repair'
      
      
      setProperty(AttachFirst[6] , 'Color', '0xffffff')
      setProperty(AttachFirst[6] , 'Style', '[fsBold]')
      setProperty(AttachFirst[6] , 'Height', '16')
      control_setCaption(AttachFirst[6],InformationText)
      processMessages()
      GolD1=database_Updt('gold1')
      
      GolD1()
      
      
      
      InformationText='Building Hack data\n\n Please DO NOT refresh the game or close the app\nElse the hack(s) won\'t work \n\nCurrently building :...Other hacks'
      setProperty(AttachFirst[6] , 'Color', 0xffffff)
      setProperty(AttachFirst[6] , 'Height', '16')
      control_setCaption(AttachFirst[6],InformationText)
      processMessages()
      CallAll = database_Updt('call_all')
      CallAll()
      InformationText='All hack data built...Loading hack table'
      control_setCaption(AttachFirst[6],InformationText)
      processMessages()
      AobswapD(MainScan,'d0 30 20 47')
      CreateTrainer()
      
   end
   
   
   
   
   function ProgramDetection()
      if openProcess('fiddler') or openProcess('Fiddler') or openProcess('charles') or openProcess('Charles') then
         --if openProcess('fiddler') or openProcess('Fiddler') or openProcess('charles') or openProcess('Charles') or openProcess('cheatengine') or openProcess('Cheatengine') then
         
         closeCloudApp()
      end
   end
   function cecheck()
      getProcesslist(cecheck_list)
      local count = 0
      for i=0,cecheck_list.count-1 do
         if cecheck_list[i]:find('cheatengine') then
            count = count + 1
         end
      end
      if count >=1 then
         --   closeCloudApp()
      end
      cecheck_list.clear()

   end
   
end
}";



the error i receive is :

Error:[string "if cheatEngineIs64Bit() then..."]:1306: attempt to call a nil value[/code]


Last edited by Ludwig on Thu Sep 15, 2016 7:59 am; edited 1 time in total
Back to top
View user's profile Send private message
predprey
Master Cheater
Reputation: 24

Joined: 08 Oct 2015
Posts: 486

PostPosted: Thu Sep 15, 2016 7:53 am    Post subject: Reply with quote

open up your source in notepad++ or preferred IDE, post the region of code around line 1306 here. seems the function you're calling on that line is nil.
Back to top
View user's profile Send private message
Ludwig
Advanced Cheater
Reputation: 0

Joined: 10 Jan 2016
Posts: 68

PostPosted: Thu Sep 15, 2016 8:00 am    Post subject: Reply with quote

here is the area around line 1306...local dataTable =loadstring(myHacks)();
the area where i build it from the received string...
--up to showMessage(myHacks) i get the correct printout of the data
but my error occur on the very next line...:
local dataTable =loadstring(myHacks)();

Code:
function RunMain(dataname)
   myHacks=obj.mainData;
    showMessage(myHacks);
   local dataTable =loadstring(myHacks)();

   local data = dataTable[dataname]
   return data;

end;
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Thu Sep 15, 2016 8:05 am    Post subject: Reply with quote

copyToClipboard(myHacks)

and then paste it in the lua engine window

check if you get an error (e. g there might be some invisible garbage)

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

Joined: 10 Jan 2016
Posts: 68

PostPosted: Thu Sep 15, 2016 8:13 am    Post subject: Reply with quote

thnx darkbyte...it didnt like these...:
InformationText='Building Hack data\n\n Please DO NOT refresh the game or close the app\nElse the hack(s) won\'t work \n\nCurrently building :...Other hacks'

and

InformationText='Building Hack data\n\n Please DO NOT refresh the game or close the app\nElse the hack(s) won\'t work \n\nCurrently building :...Ship_repair'
Back to top
View user's profile Send private message
predprey
Master Cheater
Reputation: 24

Joined: 08 Oct 2015
Posts: 486

PostPosted: Thu Sep 15, 2016 8:53 am    Post subject: Reply with quote

Ludwig wrote:
here is the area around line 1306...local dataTable =loadstring(myHacks)();
the area where i build it from the received string...
--up to showMessage(myHacks) i get the correct printout of the data
but my error occur on the very next line...:
local dataTable =loadstring(myHacks)();

Code:
function RunMain(dataname)
   myHacks=obj.mainData;
    showMessage(myHacks);
   local dataTable =loadstring(myHacks)();

   local data = dataTable[dataname]
   return data;

end;


can you post your loadstring function here.
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4289

PostPosted: Thu Sep 15, 2016 9:22 am    Post subject: Reply with quote

predprey wrote:
can you post your loadstring function here.

loadstring is a part of Lua.
https://www.lua.org/pil/8.html

If the error is an attempt to call a nil value, then loadstring is returning nil, which means there's some sort of error with the code in the string. It also returns a string saying what the error is, so use that to determine what's wrong with your code. assert() is an easy way of doing this:
Code:
assert(loadstring(myHacks))()

_________________
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
predprey
Master Cheater
Reputation: 24

Joined: 08 Oct 2015
Posts: 486

PostPosted: Thu Sep 15, 2016 10:12 am    Post subject: Reply with quote

ParkourPenguin wrote:
predprey wrote:
can you post your loadstring function here.

loadstring is a part of Lua.
https://www.lua.org/pil/8.html

If the error is an attempt to call a nil value, then loadstring is returning nil, which means there's some sort of error with the code in the string. It also returns a string saying what the error is, so use that to determine what's wrong with your code. assert() is an easy way of doing this:
Code:
assert(loadstring(myHacks))()


lololol i done embarassed myself there Embarassed

just thought the extra brackets at the end in "loadstring(myhacks)()" felt odd.
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