Jump to content
  • 0

How to edit every other result?


MrMikeMichael

Question

This is the best I could come up with. However it's not quite doing what I need it to do.

In my script the second result is the only result that will have it's address reduced by 9 and it's value changed to 0.

What I want is that if I have 6 results, game guardian will change result number 1, 3 and 5s adress by -9 and value 0

And if I have 7 results it'll change result number 2, 4, and 6 adress by -9 and value 0

Also I'd like to add a ON/OFF function to it if at all possible. If not I'll be happy just to have it enable the hack. 

 

menu=gg.choice

({'Test'},nil,'Help anyone?')

if menu==1 then

gg.setRanges(gg.REGION_C_ALLOC)

-- concept arrays (Its not my real once) 

gg.searchNumber('h  61 74 30 29 20 2A 20 5F 5A 42 75 66 66 65 72 50 61 72 61 6D 73 2E 79 20 2B 20 31 2E 30 3B 0A 20 20 20 20 67 6C 5F 46 72 61 67 44 65 70 74 68 20 3D 20 75 5F 78 6C 61 74 30 20 2F 20 75 5F 78 6C 61 74 31 3B 0A 20 20 20 20 72 65 74 75 72 6E 3B 0A 7D 0A 0A 23 65 6E 64 69 66 0A', gg.TYPE_BYTE)--408 results

gg.searchNumber('h 72 61 67 44 65 70 74 68 20 3D 20 75 5F 78 6C 61 74 30 20 2F 20 75 5F 78 6C 61 74 31 3B 0A 20 20 20 20 72 65 74 75 72 6E 3B 0A 7D 0A 0A 23 65 6E 64 69 66 0A', gg.TYPE_BYTE)--288 results

gg.refineNumber('h 6C 61 74 31 3B 0A 20 20 20 20 72 65 74 75 72 6E 3B 0A 7D 0A 0A 23 65 6E 64 69 66 0A, gg.TYPE_BYTE)--120 results

gg.refineNumber('h 20 20 20 72 65 74 75 72 6E 3B 0A 7D 0A 0A 23 65 6E 64 69 66 0A', gg.TYPE_BYTE)--96 results

gg.refineAddress('C', 0xF) --6 or 7 results

local t = gg.getResults(1,1)-- Will skip 1 result and select result number 2 (Can I further specify here?)

for i,v in pairs(t) do

t[i].address = t[i].address - -9 -- how I reduced my address (Is there a better way?)

t[i].flags = gg.TYPE_FLOAT -- What flag number is FLOAT?

t[i].value = 0 

t[i].freeze = false 

gg.setValues(t)

gg.addListItems(t)

gg.toast("Done")

end

end

 

Hope it wasn't all to confusing ♥️

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

On 3/11/2022 at 6:48 AM, MrMikeMichael said:

What I want is that if I have 6 results, game guardian will change result number 1, 3 and 5s adress by -9 and value 0

And if I have 7 results it'll change result number 2, 4, and 6 adress by -9 and value 0

Main question to this algorithm description is whether addresses of target results after applying the offset (-9) to them will be divisible by 4, because according to your code, you want to edit value of float type. Float values are required to be aligned to 4 byte boundary, i.e. result of division of address of a float value by 4 is required to be integer. For example, 0x11223344 is a valid address for float value, but 0x11223345 isn't. Correspondingly, to avoid attempts of modifying float values at invalid addresses, there needs to be a check of address validity in implementation of the algorithm.

Accounting for the above, the algorithm can be implemented, for example, like the following: 

local count = gg.getResultsCount()
local results = gg.getResults(count)
if count == 6 or count == 7 then
  local targetValues = {}
  local startIndex = (count == 6) and 1 or 2
  for i = startIndex, 6, 2 do
    local targetAddress = results[i].address - 9
    if targetAddress % 4 == 0 then -- check whether address is valid for a float value
      table.insert(targetValues, {address = targetAddress, flags = gg.TYPE_FLOAT, value = "0"})
    end
  end
  gg.setValues(targetValues)
  --gg.addListItems(targetValues) -- add values to saved list, if needed
end
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.