Jump to content
  • 0

The saved address cannot be changed


dolphinorca
 Share

Question

 

็How to build script save address scan. After that, edit all the address records. (#j9xlo12)

I created it using this script template, and although I succeeded in saving and modifying it, I can't undo it.

I've used other languages, but LUA is a beginner

this is among us script

::strt::
ch=gg.choice ({"noclip on", "noclip off"}) 
if ch==1 then 
gg.setRanges(gg.REGION_CODE_APP) 
gg.searchNumber('0.1', gg.TYPE_FLOAT) 
mphck=gg.getResults(999999999999)
gg.editAll('-9', gg.TYPE_FLOAT) 
for i, v in ipairs(mphck) do
if v.flags == gg.TYPE_FLOAT then
  v.value = "-9"
  v.freeze = false
 end
end
gg.addListItems(mphck)
gg.clearResults () 
gg.toast("MAPHACK ACTIVE") 
end



if ch==2 then 
for i, v in ipairs(mphck) do
if v.flags == gg.TYPE_FLOAT then
  v.value = "0.10000000149"
  v.freeze = ture
 end
end
gg.addListItems(mphck)
--gg.removeListItems(mphck) 
mphck=nil 
gg.toast("MAPHACK DISABLED") 
end


gg.setVisible (false) 
while true do
    if gg.isVisible() then
        
         goto strt
    end
    gg.sleep(100)
end

 

Edited by dolphinorca
Link to comment
Share on other sites

12 answers to this question

Recommended Posts

  • 0
if ch==2 then 
gg.loadResults(gg.getListItems())
mphck = gg.getResults(999999999999)

for i, v in ipairs(mphck) do
if v.flags == gg.TYPE_FLOAT then
  v.value = "0.10000000149"
  v.freeze = true
 end
end
gg.addListItems(mphck)
--gg.removeListItems(mphck) 
gg.clearResults()
gg.clearList()
mphck=nil 
gg.toast("MAPHACK DISABLED") 
end

 

Link to comment
Share on other sites

  • 0

This worked easily.
And there was a misspelling. Noob level failure
gg.loadResults (gg.getListItems ())
mphck = gg.getResults (999999999999)
Why did this need to be added?

26 minutes ago, MonkeySAN said:

if ch==2 then 
gg.loadResults(gg.getListItems())
mphck = gg.getResults(999999999999)

for i, v in ipairs(mphck) do
if v.flags == gg.TYPE_FLOAT then
  v.value = "0.10000000149"
  v.freeze = true
 end
end
gg.addListItems(mphck)
--gg.removeListItems(mphck) 
gg.clearResults()
gg.clearList()
mphck=nil 
gg.toast("MAPHACK DISABLED") 
end

 

 

Link to comment
Share on other sites

  • 0
30 minutes ago, MonkeySAN said:

- to edit must get the results first.

But there is no need to load saved values as search results in the first place. The same can be accomplished without such redundancy using "gg.setValues" function: 

local items = gg.getListItems()
for i, v in ipairs(items) do
  if v.flags == gg.TYPE_FLOAT then
    v.value = "0.10000000149"
  end
end
gg.setValues(items)
Edited by CmP
Link to comment
Share on other sites

  • 0
32 minutes ago, MonkeySAN said:

but how to write it if i want to change just 5 out 10 from the saved list without load the saved list as search results?

There are multiple ways to achieve the same result. Either you can use table returned by "gg.getListItems" function and modify required fields before calling "gg.setValues" function with this table as argument or you can create a new table based on values from returned table, but with required fields having different values on your choice and then call "gg.setValues" function passing the newly created table to it as argument.

Example of implementing the first way: 

local items = gg.getListItems()
local count = #items
local lastIndex = 5
if lastIndex > count then
  lastIndex = count
end
for i = 1, lastIndex do
  items[i].value = "12345"
end
for i = lastIndex + 1, count do
  items[i] = nil
end
gg.setValues(items)

Example of implementing the second way: 

local items = gg.getListItems()
local count = #items
local lastIndex = 5
if lastIndex > count then
  lastIndex = count
end
local newItems = {}
for i = 1, lastIndex do
  local item = items[i]
  newItems[i] = {address = item.address, flags = item.flags, value = "12345"}
end
gg.setValues(newItems)
Link to comment
Share on other sites

  • 0

This will be helpful to me as well.
I came up with a way to save the number of results and the order, add the number of other results until the specified order is reached, and skip it, but it's too annoying.

I want to change the addresses in this order
       ↓
1,2,3,4,5
1+2+3 skip 4 Change
for that purpose
Record the number of addresses in order
Record what is in 4 locations

Link to comment
Share on other sites

  • 0
3 hours ago, MonkeySAN said:

- What does this mean?..last 5 of 10?

Variable "lastIndex" indicates index of the last element of the table that will be edited, meaning that up to first 5 values will be edited. It can be less than 5 when saved list has less values, but it won't be more than 5.

3 hours ago, MonkeySAN said:

- How about if that 5 located in the middle of 10?

say starting from 3 to 7.

The approach is same, just little modification to the code is needed. For example, code of the second example from my previous post can be modified this way:

local items = gg.getListItems()
local count = #items
local firstIndex = 3
local lastIndex = 7
if lastIndex > count then
  lastIndex = count
end
local newItems = {}
for i = firstIndex, lastIndex do
  local item = items[i]
  newItems[#newItems + 1] = {address = item.address, flags = item.flags, value = "12345"}
end
gg.setValues(newItems)
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.