Jump to content
  • 0

help me with getResults and value in offset


Question

Posted

Hello,
what im trying is to get all results and put them in table array,
lets say all result are 100,


then i need to check 1 by 1 with offset,
if the value after calculate offset is the same as i want,
then only add that into saved list,


i also see some previous example in this link

Read value in offset (#an95zfus)

and here what my code looks like :

gg.searchNumber('119;1;16777216::50', 4)
gg.refineNumber('119', 4)

local searchResults = gg.getResults(100)
local q = {}
local checkValue = '16777216'
if #searchResults == 0 then
	os.exit
end
for i, v in ipairs(searchResults) do
	q[i] = {address = v.address + 0xC, flags = 4}
end
q = gg.getValues(q)
for i, v in ipairs(q) do
	if v.value == checkValue then
		gg.addListItems({{address = q[1].address - 0xC, flags = 4, value = 25, freeze = true, name = 'SKILL'}})
	end
end

 

1 answer to this question

Recommended Posts

  • 0
Posted

There is a bit more efficient approach for this case: since all needed information to check target values is present in results of the initial search, just adapt the check to work based on them. It can be implemented in various ways, below is one for example: 

gg.clearResults()
gg.searchNumber("119;1;16777216::50", gg.TYPE_DWORD)
local results = gg.getResults(gg.getResultsCount())
local expectedValueAddresses = {}
for i, v in ipairs(results) do
  if v.value == 16777216 then
    expectedValueAddresses[v.address] = true
  end
end
gg.refineNumber("119", gg.TYPE_DWORD)
local targetValues = {}
for i, v in ipairs(results) do
  if expectedValueAddresses[v.address + 0xC] then
    targetValues[#targetValues + 1] = {
      address = v.address,
      flags = v.flags,
      value = 25,
      freeze = true,
      name = "SKILL"
    }
  end
end
gg.addListItems(targetValues)

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.