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

Alright, here is an example of function with parameter: 

-- Function to do a new search for dword value passed to the function through parameter "value"
function search(value)
  gg.clearResults()
  gg.searchNumber(value, gg.TYPE_DWORD)
end

-- Example of function usages
search("123")
search("500600")

Same way your "ModAPet" function can accept that id as parameter.

  • 0
Posted
18 minutes ago, CmP said:

Được rồi, đây là một ví dụ về hàm có tham số: 





Tương tự như cách hàm "ModAPet" của bạn có thể chấp nhận id đó làm tham số

I got it! thank you very much!

  • 0
Posted (edited)
10 hours ago, hoangninyb said:

@CmP

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

 

@CmP is it possible to add a search value to the name?

i searched with 2219816;6::25

if 2219816 and v.address = v.address + -16 the value is 10111 then name ="Jock 2219816"

Or if 6 and v.address = v.address + -16 the value is 10111 then name = "Jock 6"

Can you do that?

Edited by hoangninyb
  • 0
Posted
16 hours ago, hoangninyb said:

is it possible to add a search value to the name?

Yes, use string concatenation. For example: 

local str1 = "Value " .. "123" -- "Value 123"
local str2 = 456 .. " value" -- "456 value"
print(str1 .. str2) -- "Value 123456 value"
  • 0
Posted (edited)
1 hour ago, CmP said:

Có, sử dụng nối chuỗi. Ví dụ: 

    
     

i did like this and it works!

 

gg.refineNumber("2219816", 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_1 = gg.getValues(results)

 

gg.refineNumber("6", 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_2 = 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_1 ="Jock 2219816", name_2 ="Jock 6", IDAP = "10111", func = ModAPet},

 

[10112]={name_1 ="Mick 2219816", name_2 ="Mick 6", IDAP = "10112", func = ModAPet},

 

[10113]={name_1 ="Key 2219816", name_2 ="Key 6", IDAP = "10113", func = ModAPet},

 

[10114]={name_1 ="Jonseen 2219816", name_2 ="Jonseen 6", IDAP = "10114", func = ModAPet},

 

[10115]={name_1 ="Brickey 2219816", name_2 ="Brickey 6", IDAP = "10115", func = ModAPet}

 

}

 

 

 

local menuNames = {}

 

local menuFunctions = {}

 

local menuID = {}

for i, v in ipairs(values_1) do

 

  local item = mapping[v.value]

 

  if item ~= nil then

 

    table.insert(menuNames, item.name_2)

 

    table.insert(menuFunctions, item.func)

 

    table.insert(menuID, item.IDAP)

 

  end

 

end

for i, v in ipairs(values_1) do

  local item = mapping[v.value]

  if item ~= nil then

    table.insert(menuNames, item.name_1)

    table.insert(menuFunctions, item.func)

    table.insert(menuID, item.IDAP)

  end

end

for i, v in ipairs(values_2) do

 

  local item = mapping[v.value]

 

  if item ~= nil then

 

    table.insert(menuNames, item.name_2)

 

    table.insert(menuFunctions, item.func)

 

    table.insert(menuID, item.IDAP)

 

  end

 

end

 

 

 

local choice = gg.choice(menuNames)

 

if choice ~= nil then

 

  menuFunctions[choice]()

 

end

12 minutes ago, hoangninyb said:

i did like this and it works!

 

gg.refineNumber("2219816", 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_1 = gg.getValues(results)

 

gg.refineNumber("6", 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_2 = 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_1 ="Jock 2219816", name_2 ="Jock 6", IDAP = "10111", func = ModAPet},

 

[10112]={name_1 ="Mick 2219816", name_2 ="Mick 6", IDAP = "10112", func = ModAPet},

 

[10113]={name_1 ="Key 2219816", name_2 ="Key 6", IDAP = "10113", func = ModAPet},

 

[10114]={name_1 ="Jonseen 2219816", name_2 ="Jonseen 6", IDAP = "10114", func = ModAPet},

 

[10115]={name_1 ="Brickey 2219816", name_2 ="Brickey 6", IDAP = "10115", func = ModAPet}

 

}

 

 

 

local menuNames = {}

 

local menuFunctions = {}

 

local menuID = {}

for i, v in ipairs(values_1) do

 

  local item = mapping[v.value]

 

  if item ~= nil then

 

    table.insert(menuNames, item.name_2)

 

    table.insert(menuFunctions, item.func)

 

    table.insert(menuID, item.IDAP)

 

  end

 

end

 

for i, v in ipairs(values_2) do

 

  local item = mapping[v.value]

 

  if item ~= nil then

 

    table.insert(menuNames, item.name_2)

 

    table.insert(menuFunctions, item.func)

 

    table.insert(menuID, item.IDAP)

 

  end

 

end

 

 

 

local choice = gg.choice(menuNames)

 

if choice ~= nil then

 

  menuFunctions[choice]()

 

end

@CmP For example, the menu above is menu A and I have another menu B, can I transfer the data of menu A to menu B?  only the data selected in menu A will appear in menu B!

Edited by hoangninyb
  • 0
Posted (edited)

@CmP

For example, the menu above is menu A and I have another menu B, can I transfer the data of menu A to menu B? only the data selected in menu A will appear in menu B!

and how to not get error when i click cancel in prompt

Edited by hoangninyb

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.