Jump to content

Keep control to gg.getResults


Recommended Posts

Your_Table gg.getResults(gg.getResultsCount()) ---> this function returns a table contains a key/index that contain address , value , and flags etc
if you want to refresh values u need to type :

Your_Table = gg.getValues(Your_Table)
if you want to change it's values(if u have more than 2) then you need to make a loop and type : 

for key,values in pairs(Your_Table) do 
Your_Table[key].value = AnyValueYouWant


to avoid writing this every time if you have many values/functions etc you can make a function that does that with less writing and You just need to declaire it one time on your script
and since in lua we can insert a function inside a table and call it we can do it like so :

function UP()

function temp_table.update(self)

local  temp_table = {} -- empty temp table
temp_table.results = gg.getResults(gg.getResultsCount()) -- results
temp_table.update = function(self,setvalue) -- update function

-------------------------------------> Updates the values
 for key,values in pairs(self.results) do
  self.results = gg.getValues(self.results)

------------------------------------> the self parametre allow us to call the function and make it act on its self and since it self is a table that mean it will update it self(the function call look like thistable= update(thistable) but we instead call it like this thistable:update()

return temp_table

we can add if then else or any loop/conditions/
we can also add an explicit parametre to the update function like gg.setValues(Your_Table) and the final function will look like this : 


function UP()

  local  temp_table = {}

    temp_table.results = gg.getResults(gg.getResultsCount())

    temp_table.update = function(self,setvalue)

        for key,values in pairs(self.results) do

                if setvalue ~= nil then setvalue = tostring(setvalue)

                    self.results[key].value = setvalue



                self.results= gg.getValues(self.results)

                gg.alert(tostring(self.results[key].value)..' Updated')



     return temp_table


note : you can also use assert for type(key) == 'table' so the function update rest intact

Finally after You use gg.SearchValue() 
instead of writing : Your_Table = gg.getResults(gg.getResultsCounts())
just type Your_Table = UP()

and inside the while true do
add Your_Table:update()

and if you want to set values just type Your_Table:update(1598)

code example : 


LIVE code:

You can use this method to toggle ON/OFF menu  and to check if specifc value met requirement for example postions like if u have X,Y values u can make a condition if X == 15 then .. etc (inside update function) 
I hope you get the point Enjoy

Edited by XEKEX
add colors to make it easy to understand /prevent lost , deleted a mistake
Link to comment
Share on other sites

  • 1 month later...
On 1/18/2023 at 11:33 AM, lalakay said:

How to Freeze value using your script

You can try to save the the result to a table and use for loop to freeze the values then add update function to that table and it will keep he values freezed : 
for index,values in pairs(your_table) do 
your_table[index].freeze = FREEZE_NORMAL (or true idk x) )
your_table:update = function(self)
-- body

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

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