<?xml version="1.0" encoding="utf-8"?>
<CheatTable CheatEngineTableVersion="18">
  <Forms>
    <UDF1 Class="TCEForm" Encoding="Ascii85">b7Ej%2nldAU:MM2b.}cxWeIh0Gi32eO*FvcXJqq8%{mcIVTxi7$uD4D$iNz(nNpI$e2szKIkBK5Ge3[Ftek-X00</UDF1>
  </Forms>
  <CheatEntries/>
  <UserdefinedSymbols/>
  <LuaScript>getAutoAttachList().add('Cricket2013.exe')

offsets = {
           StructStart    = 0x000,
           PlayerName     = 0x068, -- pointer
           PlayerSurname  = 0x06C, -- pointer
           DOB            = 0x014, -- 4bytes
           Nationality    = 0x01C, -- 4bytes (use Lua tables)

           ContractTerm   = 0x028, -- 4bytes (use Lua tables)
           ContractSalary = 0x02C, -- 4bytes

           BatPreferences = 0x080, -- 4bytes (use Lua tables)
           BatHandWK      = 0x091, -- 4bytes (use Lua tables)
           BatAbility     = 0x095, -- 2bytes
           BowlAbility    = 0xB8D, -- 2bytes
           BowlType       = 0xB90, -- 4bytes (use Lua tables)

           Retirement     = 0x09B, -- 4bytes (use Lua tables)

           PlayerType     = 0x0AC, -- 4bytes (use Lua tables)
           Injury         = 0x0B8, -- 4bytes
          }

playerStructStart = "[[[Cricket2013.exe+005D4D20]+c8]+b0]"

-- other global variables:
results = {}
ChosenPlayer = nil


function num2HEX(num)
  return string.format('%X',num)
end

function easyReading(address)
  local T = {}
  for k,v in pairs(offsets) do
    T[k]=v+address
  end
  return T
end


function customScan()
  local results = {} -- will contain found addresses (every address as string)

  local ID= readInteger(playerStructStart)
  local check1 = readString(  readInteger(playerStructStart..'+'..num2HEX(offsets.PlayerName))  )
  local check2 = readString(  readInteger(playerStructStart..'+'..num2HEX(offsets.PlayerSurname))  )

  if ID==nil or ID==0 or check1==nil or check2==nil then return results end
  local value = num2HEX(ID)

  local MS = createMemScan()
  local FL = createFoundList(MS)

  -- firstScan(scanoption, vartype, roundingtype, input1, input2,
  --           startAddress, stopAddress, protectionflags,
  --           alignmenttype, "alignmentparam",
  --           isHexadecimalInput, isNotABinaryString, isunicodescan, iscasesensitive)

  --    scanOption: soUnknownValue, soExactValue, soValueBetween, soBiggerThan, soSmallerThan
  --    vartype: vtByte, vtWord, vtDword, vtQword, vtSingle, vtDouble, vtString,
  --             vtByteArray, vtGrouped, vtBinary, vtAll
  --    roundingtype: rtRounded, rtTruncated, rtExtremerounded
  --    alignmenttype: fsmNotAligned, fsmAligned, fsmLastDigits

  MS.firstScan(soExactValue, vtDword, rtTruncated, value, nil,
               "0","7fffffff","+W*X-C",
               fsmAligned,"8",          -- I used 8 byte alignment
               true, false, false, false)
  MS.waitTillDone(); FL.initialize()

  if FL.Count~=0 then
    for i=0,FL.Count-1 do

      local addr = ( "0x"..FL.Address[i] ) + 0
      local tab = easyReading(addr)

      local PlayerName = readString( readInteger(tab.PlayerName) )
      local PlayerSurname = readString( readInteger(tab.PlayerSurname) )

      if PlayerName and PlayerSurname then
        local line = (PlayerName..' '..PlayerSurname):upper()
        if line:match(edtFilter.Text:upper()) then
         results[#results+1] = tab
        end
      end

    end
  end

  sleep(50); FL.destroy()
  sleep(50); MS.destroy()
  return results
end



-- Function for adding items in listview
function addItem(index,NameSurname)
  local newListItem = myListView.Items.add()
  local subItems    = newListItem.getSubItems()

  --newListItem.Caption = index
  subItems.add(index)
  subItems.add(NameSurname)
end

function btnReloadClick(btn)
  btn.Enabled = false

  myListView.Items.clear()
  results = customScan()
  if #results==0 then btn.Enabled = true; return end

  myProgressBar.initProgressBar(0,#results,0)
  myListView.Columns[1].AutoSize = false -- to fasten things
  myListView.Columns[2].AutoSize = false -- to fasten things
  processMessages()

  for index = 1,#results do
    local PlayerName = readString( readInteger(results[index].PlayerName) )
    local PlayerSurname = readString( readInteger(results[index].PlayerSurname) )
    addItem(index,PlayerName..' '..PlayerSurname)
    myProgressBar.Position = index
  end

  myListView.Columns[1].AutoSize = true
  myListView.Columns[2].AutoSize = true
  btn.Enabled = true

end

function myListView_UserSelectedItem(lv)
  if lv.ItemIndex &lt; 0 then return end
  ChosenPlayer = results[lv.ItemIndex+1]
  refresh()
end











-- GUI helper functions
function destroyComponents(f)
  while f.ComponentCount&gt;0 do local o=f.Component[0]
    if o.destroy then o.destroy() end
  end
end

-- Function for adding columns in listview
function addColumn(lv,cap,minW,maxW,W)
  local col=lv.getColumns().add()
  col.Caption=cap
  col.MinWidth=minW; col.MaxWidth=maxW; col.Width=W
end

function BelowSibling(control, sibling, leftSpacing, topSpacing)
  control.Anchors = control.Anchors:gsub(  "]"  ,  ", akTop, akLeft]"  )
  control.BorderSpacing.Left = leftSpacing or 0
  control.BorderSpacing.Top = topSpacing or 0

  control.AnchorSideLeft.Control = sibling
  control.AnchorSideTop.Control = sibling

  control.AnchorSideLeft.Side = 'asrTop'
  if control.Parent == sibling then control.AnchorSideTop.Side = 'asrTop'
  else                              control.AnchorSideTop.Side = 'asrBottom' end
end

function NextToSibling(control, sibling, leftSpacing, topSpacing)
  control.Anchors = control.Anchors:gsub(  "]"  ,  ", akTop, akLeft]"  )
  control.BorderSpacing.Left = leftSpacing or 0
  control.BorderSpacing.Top = topSpacing or 0

  control.AnchorSideLeft.Control = sibling
  control.AnchorSideTop.Control = sibling

  control.AnchorSideTop.Side = 'asrTop'
  if control.Parent == sibling then control.AnchorSideLeft.Side = 'asrTop'
  else                              control.AnchorSideLeft.Side = 'asrBottom' end
end

function NextToSiblingCenter(control, sibling, leftSpacing, topSpacing)
  NextToSibling(control, sibling, leftSpacing, topSpacing)
  control.AnchorSideTop.Side = 'asrCenter'
end

function BottomAnchor(control, sibling, bottomSpacing)
  control.Anchors = control.Anchors:gsub(  "]"  ,  ", akBottom]"  )
  control.BorderSpacing.Bottom = bottomSpacing or 0

  control.AnchorSideBottom.Control = sibling
  if control.Parent == sibling then control.AnchorSideBottom.Side = 'asrBottom'
  else                              control.AnchorSideBottom.Side = 'asrTop' end
end

function RightAnchor(control, sibling, rightSpacing)
  control.Anchors = control.Anchors:gsub(  "]"  ,  ", akRight]"  )
  control.BorderSpacing.Right = rightSpacing or 0

  control.AnchorSideRight.Control = sibling
  if control.Parent == sibling then control.AnchorSideRight.Side = 'asrBottom'
  else                              control.AnchorSideRight.Side = 'asrTop' end
end

function addEasyAnchoringFunctionsToObject(obj)
  obj.BelowSibling = function (sibling, leftSpacing, topSpacing)
                      BelowSibling(obj, sibling, leftSpacing, topSpacing)
                    end

  obj.NextToSibling = function (sibling, leftSpacing, topSpacing)
                       NextToSibling(obj, sibling, leftSpacing, topSpacing)
                     end

  obj.NextToSiblingCenter = function (sibling, leftSpacing, topSpacing)
                       NextToSiblingCenter(obj, sibling, leftSpacing, topSpacing)
                     end

  obj.BottomAnchor = function (sibling, bottomSpacing)
                       BottomAnchor(obj, sibling, bottomSpacing)
                     end

  obj.RightAnchor = function (sibling, rightSpacing)
                       RightAnchor(obj, sibling, rightSpacing)
                     end
end

function createButtonEx(owner) local o=createButton(owner)
  addEasyAnchoringFunctionsToObject(o)
  return o
end

function createLabelEx(owner) local o=createLabel(owner)
  addEasyAnchoringFunctionsToObject(o)
  return o
end

function createEditEx(owner) local o=createEdit(owner)
  addEasyAnchoringFunctionsToObject(o)
  return o
end

function createComboBoxEx(owner) local o=createComboBox(owner)
  addEasyAnchoringFunctionsToObject(o)
  return o
end

function createPanelEx(owner) local o=createPanel(owner)
  addEasyAnchoringFunctionsToObject(o)
  return o
end

function createListViewEx(owner) local o=createListView(owner)
  o.addColumn = function (cap,minW,maxW,W) addColumn(o,cap,minW,maxW,W) end
  addEasyAnchoringFunctionsToObject(o)
  return o
end

function createProgressBarEx(owner) local o=createProgressBar(owner)
  o.initProgressBar = function (a,b,p) o.Min=a; o.Max=b; o.Position = p end
  return o
end




-- INIT GUI
destroyComponents(UDF1)
UDF1.setSize(600,400)

reloadButton=createButtonEx(UDF1)
 reloadButton.setPosition(10,10)
 reloadButton.AutoSize = true
 reloadButton.Caption = 'Reload Players'
 reloadButton.OnClick = btnReloadClick

myListView = createListViewEx(UDF1)
 myListView.ViewStyle = 'vsReport'
 myListView.ReadOnly = true
 myListView.RowSelect = true
 myListView.Width = 250
 myListView.Anchors = '[akRight]'

 myListView.BelowSibling(reloadButton,0,5) -- BelowSibling(sibling, leftSpacing, topSpacing)
 myListView.BottomAnchor(UDF1,40)          -- BottomAnchor(sibling, bottomSpacing)

 myListView.addColumn('', 0, 0, 0) -- addColumn(cap,minW,maxW,W)
 myListView.addColumn('No', 30, 80, 30)
 myListView.addColumn('Player name and surname', 140, 1000, 140)

 myListView.Constraints.MinWidth = 250
 myListView.Constraints.MinHeight = 250

 myListView.OnSelectItem = myListView_UserSelectedItem

lblFilter = createLabelEx(UDF1)
 lblFilter.NextToSibling(reloadButton,5,0)
 lblFilter.Caption = 'must match:'

edtFilter = createEditEx(UDF1)
 edtFilter.NextToSibling(lblFilter,5,-15) -- NextToSibling(control, sibling, leftSpacing, topSpacing)

myProgressBar = createProgressBarEx(UDF1)
 myProgressBar.Align = alBottom
 myProgressBar.initProgressBar(0,0,0)

 UDF1.OnClose = function()
                  destroyComponents(UDF1)
                  return caHide
                end
UDF1.show()

panel = createPanelEx(UDF1)
 panel.NextToSibling(myListView,10,0)
 panel.BottomAnchor(UDF1,40)
 panel.RightAnchor(UDF1,5)










-- functions from previous table
function getControlText(control,b1,b2)
  local number = tonumber(control.Text)
  if number==nil then
    control.Color = 0x9090ff   -- bright Red
    control.Width = control.Width + 1  -- oddly, resizing is better than "repaint"
    control.Width = control.Width - 1  --
    return nil -- not a number, nothing more to do
  else
    control.Color = 0x20000000   -- clDefault
    control.Width = control.Width + 1  -- oddly, .... (see above)
    control.Width = control.Width - 1  --
  end

  if b1 then
    b1,b2 = math.min(b1,b2),math.max(b1,b2)
    if number &lt; b1 or number &gt; b2 then
      control.Color = 0x90ffff   -- bright Yellow
      return nil -- outside boundaries, nothing more to do
    end
  end

  return number+0 -- return number (with +0 we are sure it is type=number)
end

--override CE Lua functions
if oldwriteBytes==nil then oldwriteBytes = writeBytes end
if oldwriteInteger==nil then oldwriteInteger = writeInteger end

function writeBytes(a,v)
  if v~=nil then oldwriteBytes(a,v) end
end

function writeInteger(a,v)
  if v~=nil then oldwriteInteger(a,v) end
end
----------


function readShortint(address)
  local value = readInteger(address)
  if value~=nil then
    return bAnd(0xFFFF, value )
  else
    return nil
  end
end

function writeShortint(a,v)
  if v~=nil then
     oldwriteBytes(a, v%256, v/256)
  end
end

function createMirrorTable(T)
 local Tprin = {}
 for k,v in pairs(T) do
   Tprin[v]=k
 end
 return Tprin
end

-- will fill combobox, items are sorted by key
function fillCombobox(combobox,T)
  if not combobox then return end

  combobox.Items.clear()
  tmp = {}
  for k,v in pairs(T) do tmp[#tmp+1] = {k=k,v=v} end
  table.sort(tmp,function (a,b) return a.k &lt; b.k end)
  for _,v in pairs(tmp) do
    combobox.Items.add(v.v)
  end
end






-- place those controls inside "panel", not Form
lblNation = createLabelEx(panel)
lblNation.Caption = "Nationality"
lblNation.BelowSibling(panel,10,10)

lblPlayerType = createLabelEx(panel)
lblPlayerType.Caption = "Player Type"
lblPlayerType.BelowSibling(lblNation,0,15)

lblBatH = createLabelEx(panel)
lblBatH.Caption = "Bat Hand/WickedKeep"
lblBatH.BelowSibling(lblPlayerType,0,15)

lblContract = createLabelEx(panel)
lblContract.Caption = "Contract Term"
lblContract.BelowSibling(lblBatH,0,15)

lblBowlType = createLabelEx(panel)
lblBowlType.Caption = "Bowling Type"
lblBowlType.BelowSibling(lblContract,0,15)


cNation = createComboBoxEx(panel)
cNation.ReadOnly = true
cNation.NextToSiblingCenter(lblNation,10,0)
cNation.RightAnchor(panel,15)

cPlayerType = createComboBoxEx(panel)
cPlayerType.ReadOnly = true
cPlayerType.NextToSiblingCenter(lblPlayerType,10,0)
cPlayerType.RightAnchor(panel,15)

cBatH = createComboBoxEx(panel)
cBatH.ReadOnly = true
cBatH.NextToSiblingCenter(lblBatH,10,0)
cBatH.RightAnchor(panel,15)

cConT = createComboBoxEx(panel)
cConT.ReadOnly = true
cConT.NextToSiblingCenter(lblContract,10,0)
cConT.RightAnchor(panel,15)

cBowlType = createComboBoxEx(panel)
cBowlType.ReadOnly = true
cBowlType.NextToSiblingCenter(lblBowlType,10,0)
cBowlType.RightAnchor(panel,15)




Nationalities = {
  [43]='Australia',
  [44]='England',
  [45]='India',
  [46]='New Zealand',
  [47]='Pakistan',
  [48]='South Africa',
  [49]='Sri Lanka',
  [50]='West Indies',
  [51]='Bangladesh',
  [52]='Zimbabwe',
  [178]='Australia(K)',
  [179]='New Zealand(K)',
  [180]='South Africa(K)',
  [181]='Zimbabwe(K)'
}
NationalitiesMirror = createMirrorTable(Nationalities)
fillCombobox(cNation,Nationalities)

PlayerTypes = {
  [1]='Batsman',
  [2]='All Rounder',
  [3]='Bowler',
  [4]='Opening All Rounder in one day and t20',
  [8]='Opening Batsman in all formats',
  [12]='Opening All Rounder in all formats',
  [16]='Opening Batsman in one day and t20',
  [24]='Opening Batsman in T20 only',
  [28]='Opening All Rounder in t20 only'
}
PlayerTypesMirror = createMirrorTable(PlayerTypes)
fillCombobox(cPlayerType,PlayerTypes)

BatHs = {
   [1]='Left Hand Batsman',
   [2]='Right Hand Batsman',
   [4]='LHB+WicketKeeper',
   [6]='RHB+WicketKeeper',
   [8]='LHB+Occasional WK',
  [10]='RHB+Occasional WK'
}
BatHsMirror = createMirrorTable(BatHs)
fillCombobox(cBatH,BatHs)

ConTs = {
  [1]='No contract',
  [2]='1 year',
  [3]='2 years',
  [4]='3 years',
  [5]='4 years',
  [6]='5 years',
  [7]='6 years'
}
ConTsMirror = createMirrorTable(ConTs)
fillCombobox(cConT,ConTs)

BowlTypes = {
  [0] ='Slow Left Arm Bowler',
  [4] ='Left Handed LS',
  [8] ='Left Arm Medium',
  [12]='Left Arm Fast Medium',
  [16]='Left Arm Medium Fast',
  [20]='Left Arm Fast',
  [32]='Off Spinner ',
  [36]='Right Handed LS',
  [40]='Right Arm Medium',
  [44]='Right Arm Fast Medium',
  [48]='Right Arm Medium Fast',
  [52]='Right Arm Fast',
}
BowlTypesMirror = createMirrorTable(BowlTypes)
fillCombobox(cBowlType,BowlTypes)

function refresh()
  -- Nationality
  local country = Nationalities[ readInteger(ChosenPlayer.Nationality) ]
  if country then cNation.Text = country else cNation.ItemIndex=-1
  end

  -- Player type
  local PT = PlayerTypes[ readInteger(ChosenPlayer.PlayerType) ]
  if PT then cPlayerType.Text = PT else cPlayerType.ItemIndex=-1
  end

  -- BatH/WK
  local BatHand = BatHs[ readInteger(ChosenPlayer.BatHandWK) ]
  if BatHand then cBatH.Text = BatHand else cBatH.ItemIndex=-1
  end

  -- Contract Term
  local ConTerm = ConTs[ readInteger(ChosenPlayer.ContractTerm) ]
  if ConTerm then cConT.Text = ConTerm else cConT.ItemIndex=-1
  end

  -- Bowling Type
  local BType = readInteger(ChosenPlayer.BowlType)
  if BType then
    local BType2 = bAnd(BType,60)  -- %111100
    cBowlType.Text = BowlTypes[ BType2 ]
  else cBowlType.ItemIndex=-1
  end

end

</LuaScript>
</CheatTable>
