Jump to content
  • 0

help searchNumber in for loop


MarioRossi93i
 Share

Question

	local g = gg
local ls = {'test1','test2'}
local val = {"10;0;0;1::","20;0;0;2::"}
local c = g.multiChoice(ls,{false,false},'prova')
if c==nil then
    print('Canceled')
os.exit()
end
for i=1, #ls do
    if c[i] then
        s = val[i]
        g.searchNumber(s,4)
        print(s)
    end
end

hi, the problem is that script performs only first search, but if i comment the line with searchNumber() script works as expected and displays both values. can you help me understand where i am wrong please? the purpose is to carry out the searches set in the table val if they are selected.

Thank you all

Link to comment
Share on other sites

10 answers to this question

Recommended Posts

  • 0

If there are results in results list, "searchNumber" function performs refine search. For new search don't forget to call "clearResults" function before calling "searchNumber" function.

42 minutes ago, MarioRossi93i said:

this is what s happen to me

Second search happens instantly after the first one and only results from the first search are used to search in, that's why you get 0 results after both searches.

Link to comment
Share on other sites

  • 0
local g = gg
local ls = {'test1','test2'}
local val = {"10;0;0;1::","20;0;0;2::"}
local c = g.multiChoice(ls,{false,false},'prova')
if c==nil then print('Canceled') os.exit() end
-- table to store search results
local results = {}
for i=1, #ls do
    if c[i] then
        s = val[i]
        g.searchNumber(s,4)
       -- ['getResults'] = function (maxCount, skip, addressMin, addressMax, valueMin, valueMax, type, fractional, pointer) end, -- gg.getResults(int maxCount [, int skip = 0 [, long addressMin = nil [, long addressMax = nil [, string valueMin = nil [, string valueMax = nil [, int type = nil [, string fractional = nil [, int pointer = nil]]]]]]]]) -> table || string with error
        results[i] = g.getResults(999, nil, nil, nil, nil, nil, nil, nil, nil)
        g.clearResults()
        print(s)
        print(results)
    end
end
-- So the first results list is stored in the table
-- results in index 1 ( results[1] ).
-- the second search results list is also stored in the results table
-- but index 2
-- for editing you will use the code bellow
for k, v in ipairs (results[1]) do
	v.value = '45' -- The value you want to change to
	v.flags = gg.TYPE_DWORD -- value type
	v.freeze = false -- true if you want to freeze
	v.freezeType = gg.FREEZE_NORMAL -- remove both freeze and freeze type if you dont want to freeze the value
end
g.setValues(results[1])

 

Edited by MAARS
Link to comment
Share on other sites

  • 0

and here where is the error pls? first search doesn t work, 2 and 3 works, why?

	local g = gg
--g.setVisible(false)
local c,i,ls,n,src
	local chr = {}
	chr[1] = {
    n = "Sub Zero",
    s = "1.000;900;1.000;850::"
}
	chr[2] = {
    n = "Goro",
    s = "1200;1200;1000;1150::"
}
	chr[3] = {
    n = "Baraka",
    s = "1100;1225;1050;1050::"
}
	ls = {}
	for i=1, #chr do
    ls[i] = chr[i].n
end
	local c = g.multiChoice(ls,{false,false,false},'Select characters you want hack')
	if c==nil then
    print('Canceled')
    os.exit()
end
	g.clearResults()
	for n=1, #chr do
	    if c[n] then
        src = chr[n].s
        g.searchNumber(src,4)
        print(src)
        g.clearResults()
    end
	end

 

Thank you all!

 

 

Link to comment
Share on other sites

  • 0
14 minutes ago, MarioRossi93i said:

chr[1] = {     n = "Sub Zero",     s = "1.000;900;1.000;850::" }

Incorrect search string for type "Dword".

"searchNumber" function returns string in case of failure so it is possible to check whether function completed successfully: 

local ret = gg.searchNumber("1.000", gg.TYPE_DWORD)
if type(ret) == "string" then
  print("Error: " .. ret)
else
  print("Success")
end
Link to comment
Share on other sites

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
 Share

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