Jump to content
  • 0

How to implement Nearby Search in LUA Script for address that keeps changing


Question

Posted (edited)

Hello,

 

Wondering if someone can please help me. I have a group search and refined value like this:

 

gg.searchNumber("0.10000000149;2.5;6.0::9", gg.TYPE_FLOAT, false, gg.SIGN_EQUAL, 0, -1, 0)
gg.refineNumber("6", gg.TYPE_FLOAT, false, gg.SIGN_EQUAL, 0, -1, 0)

local t = gg.getResults(1)
gg.addListItems(t)
t = nil

 

What I'd like to do is use the result of "6" from above to perform a "NearBy Search" with an "After" distance of 500 for value: -1 DWORD.  The problem is the address of the "6" keeps changing when I restart the game. Is there a proper way to code the script so that it does what I need even when the address of the "6" changes?  I've searched and played around with it and couldn't figure it out at all. Not even sure if it's doable. That's why I'm asking.  Would appreciate any assistance.

Edited by Sami1982

Recommended Posts

  • 1
Posted
gg.searchNumber("0.10000000149;2.5;6.0::9", gg.TYPE_FLOAT, false, gg.SIGN_EQUAL, 0, -1, 0)
gg.refineNumber("6", gg.TYPE_FLOAT, false, gg.SIGN_EQUAL, 0, -1, 0)

-- Get up to 10 results just in case
local results = gg.getResults(10) 
local offset = 0x500
local allResults = {}

-- Loop through each address from results
for _, v in ipairs(results) do
    local baseAddress = v.address
    gg.clearResults()
    gg.searchNumber("-1", gg.TYPE_DWORD, false, gg.SIGN_EQUAL, baseAddress, baseAddress + offset, 0)

-- Get all found results for this address range
    local found = gg.getResults(10)
    for _, addr in ipairs(found) do
        table.insert(allResults, addr) -- Collect each valid result
    end
end

-- Load all results found for target value
if #allResults > 0 then
    gg.loadResults(allResults)
end

 

  • 2
Posted

im not an expert but try this and see if it work for you

gg.searchNumber("0.10000000149;2.5;6.0::9", gg.TYPE_FLOAT, false, gg.SIGN_EQUAL, 0, -1, 0)
gg.refineNumber("6", gg.TYPE_FLOAT, false, gg.SIGN_EQUAL, 0, -1, 0)

local results = gg.getResults(1)
local baseAddress = results[1].address
local offset = 0x500

gg.clearResults()
gg.searchNumber("-1", gg.TYPE_DWORD, false, gg.SIGN_EQUAL, baseAddress, baseAddress + offset, 0)

 

  • 0
Posted (edited)
10 hours ago, Sami1982 said:

Hello,

 

Wondering if someone can please help me. I have a group search and refined value like this:

 

gg.searchNumber("0.10000000149;2.5;6.0::9", gg.TYPE_FLOAT, false, gg.SIGN_EQUAL, 0, -1, 0)
gg.refineNumber("6", gg.TYPE_FLOAT, false, gg.SIGN_EQUAL, 0, -1, 0)

local t = gg.getResults(1)
gg.addListItems(t)
t = nil

 

What I'd like to do is use the result of "6" from above to perform a "NearBy Search" with an "After" distance of 500 for value: -1 DWORD.  The problem is the address of the "6" keeps changing when I restart the game. Is there a proper way to code the script so that it does what I need even when the address of the "6" changes?  I've searched and played around with it and couldn't figure it out at all. Not even sure if it's doable. That's why I'm asking.  Would appreciate any assistance.



But if you did a nearby search of 500 you should be able to find another group search that is better and more static.

Edited by nok1a
  • 0
Posted
9 hours ago, nok1a said:



But if you did a nearby search of 500 you should be able to find another group search that is better and more static.

Yeah unfortunately it's so weird and unreliable. I tried various group searches and backwards pointer searches. It works 4 or 5 times in a row when I restart the game, but then sadly it stops working 😞 

  • 0
Posted (edited)
3 hours ago, MonkeySAN said:

care to share the game name?

and what are you searching for?

Thanks for the response. Sorry It's kind of a long story and confusing lol.  But let me try to better clarify my question. It's pretty specific and straight forward. When I get my refined result from my group search, which is that number "6", I long press on it, and select "search nearby" and I search for -1 Dword with "After distance" of 500. The problem is, the address (as shown in the attached screenshot) is always different when I restart the game. Is there a way to write something in the script to perform this "long press/search nearby" without knowing what that address will be? That's all I need to know.

screen_shot.jpg

Edited by Sami1982
  • 0
Posted
3 hours ago, MonkeySAN said:

im not an expert but try this and see if it work for you

gg.searchNumber("0.10000000149;2.5;6.0::9", gg.TYPE_FLOAT, false, gg.SIGN_EQUAL, 0, -1, 0)
gg.refineNumber("6", gg.TYPE_FLOAT, false, gg.SIGN_EQUAL, 0, -1, 0)

local results = gg.getResults(1)
local baseAddress = results[1].address
local offset = 0x500

gg.clearResults()
gg.searchNumber("-1", gg.TYPE_DWORD, false, gg.SIGN_EQUAL, baseAddress, baseAddress + offset, 0)

 

Genius man!! That's exactly what I needed. Can't thank you enough. 

  • 0
Posted
4 hours ago, MonkeySAN said:

im not an expert but try this and see if it work for you

gg.searchNumber("0.10000000149;2.5;6.0::9", gg.TYPE_FLOAT, false, gg.SIGN_EQUAL, 0, -1, 0)
gg.refineNumber("6", gg.TYPE_FLOAT, false, gg.SIGN_EQUAL, 0, -1, 0)

local results = gg.getResults(1)
local baseAddress = results[1].address
local offset = 0x500

gg.clearResults()
gg.searchNumber("-1", gg.TYPE_DWORD, false, gg.SIGN_EQUAL, baseAddress, baseAddress + offset, 0)

 

Sorry to bother you again. Just one last question. If I had 2 results of that refined "6", how can I write the script to perform the same nearby search for both of them? Thanks again.

  • 0
Posted
1 hour ago, MonkeySAN said:
gg.searchNumber("0.10000000149;2.5;6.0::9", gg.TYPE_FLOAT, false, gg.SIGN_EQUAL, 0, -1, 0)
gg.refineNumber("6", gg.TYPE_FLOAT, false, gg.SIGN_EQUAL, 0, -1, 0)

-- Get up to 10 results just in case
local results = gg.getResults(10) 
local offset = 0x500
local allResults = {}

-- Loop through each address from results
for _, v in ipairs(results) do
    local baseAddress = v.address
    gg.clearResults()
    gg.searchNumber("-1", gg.TYPE_DWORD, false, gg.SIGN_EQUAL, baseAddress, baseAddress + offset, 0)

-- Get all found results for this address range
    local found = gg.getResults(10)
    for _, addr in ipairs(found) do
        table.insert(allResults, addr) -- Collect each valid result
    end
end

-- Load all results found for target value
if #allResults > 0 then
    gg.loadResults(allResults)
end

 

Thank you thank thank every so much bro.  You are awesome! Have a great day

 

 

  • 0
Posted (edited)
3 hours ago, MonkeySAN said:
gg.searchNumber("0.10000000149;2.5;6.0::9", gg.TYPE_FLOAT, false, gg.SIGN_EQUAL, 0, -1, 0)
gg.refineNumber("6", gg.TYPE_FLOAT, false, gg.SIGN_EQUAL, 0, -1, 0)

-- Get up to 10 results just in case
local results = gg.getResults(10) 
local offset = 0x500
local allResults = {}

-- Loop through each address from results
for _, v in ipairs(results) do
    local baseAddress = v.address
    gg.clearResults()
    gg.searchNumber("-1", gg.TYPE_DWORD, false, gg.SIGN_EQUAL, baseAddress, baseAddress + offset, 0)

-- Get all found results for this address range
    local found = gg.getResults(10)
    for _, addr in ipairs(found) do
        table.insert(allResults, addr) -- Collect each valid result
    end
end

-- Load all results found for target value
if #allResults > 0 then
    gg.loadResults(allResults)
end

 

I am really sorry to bother you again.  But I am getting an error:

'for _,addr in ipairs(found) do'

bad argument #1 to 'ipairs' (nil: table expected, got nil) (global 'ipairs')

 

But it's no big deal. I can just close the error and everything works fine. But can you help me add the final results to the saved list?

 

 

Edited by Sami1982
provided more info
  • 0
Posted (edited)

thats not the way to go.

if you gonna make it work, it should work all the way.

all "-1" value that had been found after distance 500 for each address will be store here :

local allResults = {}

could it be that you got more than one results because the other  value load much later in game?

thats why i ask the game name and what value that you are looking for.

i dont like uncertainty.

well..at least for me.

when you know for sure, things can be done with more efficient.

Edited by MonkeySAN
  • 0
Posted (edited)
13 minutes ago, MonkeySAN said:

thats not the way to go.

if you gonna make it work, it should work all the way.

all "-1" value that had been found after distance 500 for each address will store here :

local allResults = {}

could it be that you got more than one results because the other  value load much later in game?

thats why i ask the game name and what value that you are looking for.

i dont like uncertainty.

when you know for sure, things can be done with more efficient.

Yes you are correct. I apologize, I re-edited my last post.  I must've been doing something wrong. I put back the:

Quote

local allResults = {}

and it yields all the -1 results correctly now.   But I am still getting this error:

'table.insert(allResults, addr) --Collect each valid result'

bad argument #1 to 'table.insert' (nil: table expected, got nil) (field 'insert')

But if I close out of the error everything is fine. All I need to do is add the -1 results to the save list and we are done. I really appreciate all your help so far. I don't want to trouble you with installing the game and finding the value. It's encrypted and it's a pain in the butt and I feel terrible burdening you with all that.  

Edited by Sami1982
  • 0
Posted (edited)

now its starting to trouble me.

i really dont like when something i made gave errors without knowing what cause it.

Edited by MonkeySAN
  • 0
Posted
5 minutes ago, MonkeySAN said:

now its starting to trouble me.

i really dont like when something i made gave errors without knowing what cause it.

No no no man don't let it bother you.  You have done a marvelous job for me. You literally solved my problem. I can simply tap on the "save" button and I'm done. No need to trouble you with this any further. I tremendously appreciate your help and knowledge. You are the man!

7 minutes ago, MonkeySAN said:

now its starting to trouble me.

i really dont like when something i made gave errors without knowing what cause it.

But if you insist and it makes you feel better, do you want us to move this to discord and I can show you exactly what's happening with a video?

  • 0
Posted
20 minutes ago, MonkeySAN said:

now its starting to trouble me.

i really dont like when something i made gave errors without knowing what cause it.

Hey guess what??  No more error.  It was all me! stupid me Lol. I think I had some typos or something.   I am so sorry for all this trouble.  But can you just tell me how to add the final -1 results that I got to the save list?

23 minutes ago, MonkeySAN said:

now its starting to trouble me.

i really dont like when something i made gave errors without knowing what cause it.

Got it!  I added them to the save list.  Your script works PERFECTLY.  Thanks again and again a million times my friend. You are the best.  So sorry for the trouble. Have a wonderful day

  • 0
Posted

i still need to see that video but i will not go to Discord.

i got bad history there that i dont want to talk about.

so i will open my message box for a while.

you can PM me there the video or 

the things i asked the very first time.

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.