Jump to content
  • 0

Set the value faster!


Question

Posted

Hi!

My code:

function setVal (address, value)

    local t = {{

        address = address,

        flags = 4,

        value = value,

        freeze = true,

    }}

    gg.setValues(t)

end

gg.searchNumber("2219816;6::25", gg.TYPE_DWORD)

gg.refineNumber("2219816", gg.TYPE_DWORD)

local p = gg.getResultCount()

local m = gg.getResults(p)

 

for i = 1,p do

    addr = m[i].address

    setVal (addr + 64, 7)

    setVal (addr + 80, 8)

    setVal (addr + 96, 9)

    setVal (addr + 112, 10)

end

my problem is that there are a lot of 2219816 values, and the modification takes a long time.

Do you guys have any method that can help me to do it quickly?

Thanks!

Recommended Posts

  • 0
Posted
6 hours ago, Lover1500 said:

results is over 2000k. really? which is slower searching and setting value in yours?

finding the value is very fast, but setvalue is very long!

2 hours ago, HEROGAMEOfficial said:

Search code which has not changed, Near the hack code.

yes it is common ground!

  • 0
Posted

Maybe it can help:

gg.searchNumber("2219816;6::25", gg.TYPE_DWORD)
gg.refineNumber("2219816", gg.TYPE_DWORD)
local results = gg.getResults(gg.getResultCount())
local t = {}
for _, __ in next, results do
	t[#t + 1] = {__.address = __.address + 64, flags = __.flags, __.value = 7}
	t[#t + 1] = {__.address = __.address + 80, flags = __.flags, __.value = 8}
	t[#t + 1] = {__.address = __.address + 96, flags = __.flags, __.value = 9}
	t[#t + 1] = {__.address = __.address + 112, flags = __.flags, __.value = 10}
	t[#t + 1] = {__.address = __.address + 64, flags = __.flags, __.value = 7}
end
gg.setValues(t)

 

  • 0
Posted

Don't call "setValues" function in loop. The code above from @HEROGAMEOfficial's post illustrates the approach that should be used instead: construct table with all desired values and pass it to "setValues" function. Something like this: 

gg.searchNumber("2219816;6::25", gg.TYPE_DWORD)
gg.refineNumber("2219816", gg.TYPE_DWORD)
local count = gg.getResultsCount()
local results = gg.getResults(count)
local values = {}
for i, v in ipairs(results) do
  local index = (i - 1) * 4
  local addr = v.address
  values[index + 1] = {address = addr + 64, flags = gg.TYPE_DWORD, value = "7"}
  values[index + 2] = {address = addr + 80, flags = gg.TYPE_DWORD, value = "8"}
  values[index + 3] = {address = addr + 96, flags = gg.TYPE_DWORD, value = "9"}
  values[index + 4] = {address = addr + 112, flags = gg.TYPE_DWORD, value = "10"}
end
gg.setValues(values)
  • 0
Posted (edited)
1 hour ago, hoangninyb said:

IMG_20211014_083831.thumb.jpg.88864087a7860fea26e5bac757bb0342.jpg

Hai kawan! Ini tidak bekerja!

Try it (fixed):

gg.searchNumber("2219816;6::25", gg.TYPE_DWORD)
gg.refineNumber("2219816", gg.TYPE_DWORD)
local results = gg.getResults(gg.getResultCount())
local t = {}
for _, __ in next, results do
	t[#t + 1] = {__.address = __.address + 64, flags = __.flags, value = 7}
	t[#t + 1] = {__.address = __.address + 80, flags = __.flags, value = 8}
	t[#t + 1] = {__.address = __.address + 96, flags = __.flags, value = 9}
	t[#t + 1] = {__.address = __.address + 112, flags = __.flags, value = 10}
	t[#t + 1] = {__.address = __.address + 64, flags = __.flags, value = 7}
end
gg.setValues(t)

 

Edited by HEROGAMEOfficial
  • 0
Posted
1 hour ago, CmP said:

Don't call "setValues" function in loop. The code above from @HEROGAMEOfficial's post illustrates the approach that should be used instead: construct table with all desired values and pass it to "setValues" function. Something like this: 

gg.searchNumber("2219816;6::25", gg.TYPE_DWORD)
gg.refineNumber("2219816", gg.TYPE_DWORD)
local count = gg.getResultsCount()
local results = gg.getResults(count)
local values = {}
for i, v in ipairs(results) do
  local index = (i - 1) * 4
  local addr = v.address
  values[index + 1] = {address = addr + 64, flags = gg.TYPE_DWORD, value = "7"}
  values[index + 2] = {address = addr + 80, flags = gg.TYPE_DWORD, value = "8"}
  values[index + 3] = {address = addr + 96, flags = gg.TYPE_DWORD, value = "9"}
  values[index + 4] = {address = addr + 112, flags = gg.TYPE_DWORD, value = "10"}
end
gg.setValues(values)

Very Thanksthank you very much!  it works great

1 hour ago, HEROGAMEOfficial said:

Try it (fixed):

gg.searchNumber("2219816;6::25", gg.TYPE_DWORD)
gg.refineNumber("2219816", gg.TYPE_DWORD)
local results = gg.getResults(gg.getResultCount())
local t = {}
for _, __ in next, results do
	t[#t + 1] = {__.address = __.address + 64, flags = __.flags, value = 7}
	t[#t + 1] = {__.address = __.address + 80, flags = __.flags, value = 8}
	t[#t + 1] = {__.address = __.address + 96, flags = __.flags, value = 9}
	t[#t + 1] = {__.address = __.address + 112, flags = __.flags, value = 10}
	t[#t + 1] = {__.address = __.address + 64, flags = __.flags, value = 7}
end
gg.setValues(t)

 

Thanks for helping me! problem solved! it's great!

  • 0
Posted
2 minutes ago, hoangninyb said:

can i freeze them forever?

Only as long as you keep GG running. To freeze values from script there is "addListItems" function. Set "freeze" field of tables to "true" for them to be frozen after the call to the function. For example: 

local results = gg.getResults(10)
local values = {}
for i, v in ipairs(results) do
  values[i] = {address = v.address + 0x1234, flags = gg.TYPE_DWORD, value = "4321", freeze = true} -- value will be frozen to 4321
end
gg.addListItems(values)
  • 0
Posted

@CmP

can you help me!

this is my code and i have edited it many times but it still gives me error like in the picture!

 

gg.refineNumber("2219816;6::25", gg.TYPE_DWORD)

local count = gg.getResultsCount()               

local results = gg.getResults(count)

for i, v in ipairs(results) do

  v.address = v.address + -16

end

local values = gg.getValues(results)

 

function ModAPet()

local P = gg.prompt({"🄸🄽🅂🄴🅁🅃 🄸🄳 🅅🄰🄻🅄🄴🅂\n •━━━ ✽ • ✽ ━━━•\n\nSKILL - 1","SKILL - 2","SKILL - 3"},{"9014","6014","13618"},{"number","number","number"})

 gg.clearResults()

gg.loadResults(gg.getListItems())

gg.refineNumber(IDAP, gg.TYPE_DWORD)

local count = gg.getResultsCount()

local results = gg.getResults(count)

local values = {}

for i, v in ipairs(results) do

  local index = (i - 1) * 4

  local addr = v.address

  values[index + 1] = {address = addr + 48, flags = gg.TYPE_DWORD, value = P[1], freeze = true}

  values[index + 2] = {address = addr + 64, flags = gg.TYPE_DWORD, value = P[2], freeze = true}

  values[index + 3] = {address = addr + 80, flags = gg.TYPE_DWORD, value = P[3], freeze = true}

  values[index + 4] = {address = addr + 96, flags = gg.TYPE_DWORD, value = "0", freeze = true}

end

gg.setValues(values)

gg.addListItems(values)

end

 

 

local mapping = {

[10111]={name ="🔘Jock", IDAP = "10111", func = ModAPet},

[10112]={name ="🔘Mick", IDAP = "10112", func = ModAPet},

[10113]={name ="🔘Key", IDAP = "10113", func = ModAPet},

[10114]={name ="🔘Jonseen", IDAP = "10114", func = ModAPet},

[10115]={name ="🔘Brickey", IDAP = "10115", func = ModAPet}

}

 

local menuNames = {}

local menuFunctions = {}

local menuID = {}

for i, v in ipairs(values) do

  local item = mapping[v.value]

  if item ~= nil then

    table.insert(menuNames, item.name)

    table.insert(menuFunctions, item.func)

    table.insert(menuID, item.IDAP)

  end

end

 

local choice = gg.choice(menuNames)

if choice ~= nil then

  menuFunctions[choice]()

end

 

IMG_20211014_140934.thumb.jpg.735c3142439fe0224058eecfa7e4fb89.jpg

  • 0
Posted
50 minutes ago, hoangninyb said:

gg.refineNumber(IDAP, gg.TYPE_DWORD)

The problem is because you use global variable without previously assigning a value to it. By default global variables have value "nil", a special value that means absence of value. So when nil is passed to "refineNumber" function, it raises an error, because it expected first argument to be string.

A simple way of fixing the problem (with minimal changes to the code) may be to assign needed value to global variable "IDAP" before "ModAPet" function is called: 

if choice ~= nil then
  IDAP = menuID[choice]
  menuFunctions[choice]()
end

A better option may be to refactor the code to make "ModAPet" function accept parameter of search string to use for the call to "refineNumber".

  • 0
Posted
26 minutes ago, CmP said:

Một tùy chọn tốt hơn có thể là cấu trúc lại mã để làm cho hàm "ModAPet" chấp nhận tham số của chuỗi tìm kiếm để sử dụng cho lệnh gọi "refominh".

Can you give me a small example?

  • 0
Posted
40 minutes ago, CmP said:

A simple way of fixing the problem (with minimal changes to the code) may be to assign needed value to global variable "IDAP" before "ModAPet" function is called: 

if choice ~= nil then
  IDAP = menuID[choice]
  menuFunctions[choice]()
end

Try this option first. If it works, you don't necessarily need to change the code further.

  • 0
Posted
8 minutes ago, CmP said:

Hãy thử tùy chọn này trước. Nếu nó hoạt động, bạn không nhất thiết phải thay đổi mã thêm.

it works fine man! I'm just curious about the new methods! can be said to be eager to learn🤣🤣🤣

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.