Jump to content
ThienTeakee

How to group values to edit in a search?

Recommended Posts

29 minutes ago, ThienTeakee said:

C'mon man. We all need to learn and improve ourself. My English is bad but I don't care because you guys still understand what I said

yup...im learning too.

Share this post


Link to post
Share on other sites

1 minute ago, CmP said:

edited[#edited + 1] = {address = v.address, flags = v.flags, value = 1011011011}

better:

v.value = 1011011011
edited[#edited + 1] = v

do not waste time and memory for duplicate same table.

Share this post


Link to post
Share on other sites

Didn't notice that 

gg.setRanges(gg.REGION_ANONYMOUS)
gg.searchNumber('1014350479;1012202996;1083179008;1050253722;1031127695;1065353216;1065353216;1067282596:61', 4) -- search
local t1 = gg.getResults(5000)
for i = 1 ,#t1 do
if(t1[i].value==1014350479)then
    t1[i].value = 1011011011
    elseif(t1[i].value==1050253722 or t1[i].value ==1031127695)then
    t1[i].value = 1
	end
end
gg.setValues(t1)

 

Edited by ItsSC
Removed garbage code. Move set values out from loop.

Share this post


Link to post
Share on other sites
1 minute ago, Enyby said:

better:


v.value = 1011011011
edited[#edited + 1] = v

do not waste time and memory for duplicate same table.

Yeah, absolutely, thanks for pointing that out.

Share this post


Link to post
Share on other sites

Strictly speaking fastest is reuse results table:

local results = gg.getResults(5000)
for i, v in ipairs(results) do
  if v.value == 1014350479 then
    v.value = 1011011011
  elseif v.value == 1050253722 or v.value == 1031127695 then
    v.value = 1
  else
    results[i] = nil
  end
end
gg.setValues(results)
results = nil

 

Share this post


Link to post
Share on other sites
11 minutes ago, ItsSC said:

for i = 1 ,#t1 do

better use ipairs for speed. or you need make local variable for store

t[i]

. Index over table is not a free. Better use it one time per loop iteration if it is possible.

for i, v in ipairs(results) do

Already do it for you.

Share this post


Link to post
Share on other sites

Oh, that's a good idea, haven't thought about it. Just like it was mentioned few posts above, another thing has been learned. It's amazing that new things can be learned even about the topics that looks easy.

Edited by CmP
Minor grammatical correction

Share this post


Link to post
Share on other sites
17 minutes ago, Enyby said:

results[i] = nil

this line erase element from table. So setValues do not re-set values and we avoid possibility erase changed value with old one.

Also this operation really fast if run on list table (array-like table, called sequence in lua manual). And this is not rebuild table or reallocate memory, just exclude one value.

So this way really fast. But if you try (after few remove) add to table some new value, or remove value from hash part - it can call rebuild table with memory reallocation, which is slow.

Share this post


Link to post
Share on other sites
1 minute ago, Enyby said:

this line erase element from table. So setValues do not re-set values and we avoid possibility erase changed value with old one.

Also this operation really fast if run on list table (array-like table, called sequence in lua manual). And this is not rebuild table or reallocate memory, just exclude one value.

So this way really fast. But if you try (after few remove) add to table some new value, or remove value from hash part - it can call rebuild table with memory reallocation, which is slow.

So basically, it runs checking for all results at once, while my method is checking one by one? 

Share this post


Link to post
Share on other sites
29 minutes ago, Enyby said:

Iterate over results, build table and pass it to setValues.

Best solution if you have small amount of results.

 

25 minutes ago, CmP said:

The group search is not ordered, so I would prefer second approach from those Enyby mentioned. For this case it would be something like the following: 

So that the only way is build a table and do a loop with if & elseif to edit? If this is PHP I will do that smoothly 😂

Share this post


Link to post
Share on other sites
4 minutes ago, Enyby said:

call rebuild table with memory reallocation, which is slow.

By the way, for this reason, this code:

local t = {1, 2, 3, ..., 1000}

much faster than this:

local t = {}
t[1] = 1
t[2] = 2
t[3] = 3
...
t[1000] = 1000

For the table, an array of the right size is immediately allocated, and not reallocated repeatedly as it is populated.
Although, again, this is true when the number of elements is thousands and tens of thousands, and not when there are hundreds of them. In this case, there will be no apparent difference.

Share this post


Link to post
Share on other sites
26 minutes ago, Enyby said:

Strictly speaking fastest is reuse results table:


local results = gg.getResults(5000)
for i, v in ipairs(results) do
  if v.value == 1014350479 then
    v.value = 1011011011
  elseif v.value == 1050253722 or v.value == 1031127695 then
    v.value = 1
  else
    results[i] = nil
  end
end
gg.setValues(results)
results = nil

 

yup....just put it in my script.

its goddam so fast.

Share this post


Link to post
Share on other sites
4 minutes ago, ItsSC said:

So basically, it runs checking for all results at once, while my method is checking one by one? 

No. Any loop work one-by-one. But you do same work again and again.

You can compile both examples to LASM and compare count of instructions.

You will be unpleasantly surprised by the number of instructions in your code.

for i = 1 ,#t1 do
if(t1[i].value==1014350479)then -- get t1[i]
    t1[i].value = 1011011011 -- get t1[i] again
    elseif(t1[i].value==1050253722 or t1[i].value ==1031127695)then -- get t1[i] two times
    t1[i].value = 1 -- get t1[i] again
	end
end

Lua do not optimize any code. So if you write get same value few times - lua do it for you. With decrease performance, because it is pointless work.

Share this post


Link to post
Share on other sites
10 minutes ago, ThienTeakee said:

So that the only way is build a table and do a loop with if & elseif to edit?

It's not the only way, but it is suitable for your case. The most efficient implementation of this way from the ones proposed in this topic can be found in this post: 

How to group values to edit in a search? (#2mhgpa6)

It reuses the table returned by "getResults" function that leads to better performance of the code, but as it was mentioned above, it does not really matter when results count is relatively small.

Edited by CmP

Share this post


Link to post
Share on other sites
6 minutes ago, zam535582 said:

its goddam so fast.

You can make it is faster, by cache get 'value' from inner table:

local results = gg.getResults(5000)
for i, v in ipairs(results) do
  local value = v.value
  if value == 1014350479 then
    v.value = 1011011011
  elseif value == 1050253722 or value == 1031127695 then
    v.value = 1
  else
    results[i] = nil
  end
end
gg.setValues(results)
results = nil

 

Share this post


Link to post
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

  • Similar Content

    • By Wisteria
      Sorry to say admin.. Forgive me if thi is wrong saying.. 
      But the most difficult hack anyone can introduce in this platform seems to be homescapes hack.. No scrip for it no hack for it at all.. I have made request and help yet everyone who creates scripts close their eyes from it.. That shows no one is capable of making the hack script... Pls is anyone capable of creating it????? 
    • By mlbb123190
      can some help me to fix this my record script in gg,,im newbee here please someone??
       
      -- main code
      gg.searchNumber("198D;1D;1D;0D;0F;0D::21", gg.TYPE_DWORD, false, gg.SIGN_EQUAL, 0, -1)
      gg.processResume()
      gg.processResume()
      gg.refineNumber("5", gg.TYPE_DWORD, false, gg.SIGN_EQUAL, 0, -1)
      revert = gg.getResults(100, nil, nil, nil, nil, nil, nil, nil, nil)
      local t = gg.getResults(100, nil, nil, nil, nil, nil, nil, nil, nil)
      for i, v in ipairs(t) do
          if v.flags == gg.TYPE_DWORD then
              v.value = "99999999"
              v.freeze = true
          end
      end
      gg.addListItems(t)
      t = nil
      gg.processResume()
      revert = gg.getResults(100, nil, nil, nil, nil, nil, nil, nil, nil)
      local t = gg.getResults(100, nil, nil, nil, nil, nil, nil, nil, nil)
      for i, v in ipairs(t) do
          if v.flags == gg.TYPE_DWORD then
              v.value = "5"
              v.freeze = true
          end
      end
      gg.addListItems(t)
      t = nil
      gg.processResume()
       
       
       
       
      i appreciate any help!!
      thank you!!
      unliammo.txt
    • By mkconsult
      Hello,
      Have rooted phone. But unable to hack ludo king in both online and offline mode. Even downloaded lua script available . every time after refine search 3results are coming. Wen I edit value to 6 in all 3. On dice it show 6 but actual show other no.  But it work wen I play with computer since i get 1 search result. Wat to do. 
    • By Hamy200
      https://play.google.com/store/apps/details?id=com.futureplay.battleground
      Hello! Does anyone know how to hack Battlelands Royale e.g Speedhack, godmode, ammo etc.
      I have tried the speedhack on gameguardian but it doesn't work and changing the ammo also doesn't work. 
      There are other LUA scripts but they don't work.
      Thanks
       
       
       
    • By loversSlayer
      Want to use group search with variable.
      Its easy to search with one var like (var, gg.TYPE_), but i want to know is there way that i could put var in group search like (1;1~100;var;98::16, gg TYPE_)
      For me its only way to search for value in script cause its always so different.
×
×
  • Create New...