Jump to content
  • 0

Tables and gg.setValues problem


Question

Posted (edited)

Ive done a script thats preloading all the values i need, fair enough, but i get this error when it comes to modifying the values

 

Here's the error:

Script error: luaj.o: /storage/emulated/0/Download/PreloadValues(19).lua:117
`            v[1].value = menu[1]`
attempt to index ? (a number value) with key '1' (local 'v')

Can someone fix this for me, this is demotivating at the moment, thanks in advance!

 

Cant upload to file using the filepicker error -200

 

Dm me on Discord for script or i upload it to gdrive in 20 min

Discord: 0x14C#3100

Edited by YeetMeister

11 answers to this question

Recommended Posts

  • 0
Posted (edited)
13 minutes ago, Enyby said:

"v" is a number on this line.

So "v[1].value" doesnot make sense.

if gg.isVisible(true)
    then
        gg.setVisible(false)
    end

    toggle = {
        menu = false,
        preloadValues = true,
        finishPreload = false,
        skipTimer = true,
        showChannelAd = true,
        errorToast = true, --no errors catched toast / useless atm
    }
    
    function main()
        vPool = gg.getListItems()
        if toggle.menu == true
            then
                SDM()
            else
                if toggle.preloadValues == true
                    then
                        toggle.preloadValues = false
                        if toggle.finishPreload == false
                            then
                                if toggle.skipTimer == true
                                    then
                                        preload()
                                    else
                                        gg.alert([[
                                            you have 10 seconds to figure out what your current Money and Highscore is.
                                            ]])
                                        gg.sleep(10000)
                                        preload()
                                    end
                            else
                                mainMenu()
                            end
                    else
                        mainMenu()
                    end
            end
    end

function SDM()
    menu = gg.choice({
        "Debug Menu",
        "Preload Values",
        "Skip Timer",
        "mainMenu()"
    }, nil, "Secret Debug Menu")
    if menu == 1
        then
            if toggle.menu == true
                then
                    toggle.menu = false
                    gg.alert("Debug Menu = false")
                    main()
                else
                    toggle.menu = true
                    gg.alert("Debug Menu = true")
                    main()
                end
        end
    if menu == 2
        then
            if toggle.preloadValues == true
                then
                    toggle.preloadValues = false
                    gg.alert("Preload Values = false")
                    main()
                else
                    toggle.preloadValues = true
                    gg.alert("Preload Values = true")
                    main()
                end
        end
    if menu == 3
        then
            if toggle.skipTimer == true
                then
                    toggle.skipTimer = false
                    gg.alert("Skip Timer = false")
                    main()
                else
                    toggle.skipTimer = true
                    gg.alert("Skip Timer = true")
                    main()
                end
        end
    if menu == 4
        then
            mainMenu()
        end
    
end

function mainMenu()
    menu = gg.prompt({
        "Modify Money",
        "Modify Current Kills",
        "Modify Highscore",
        "Modify Multiplier"
    }, {
        vPool[1].value,
        vPool[3].value, 
        vPool[6].value, 
        vPool[7].value
    },{
        "number",
        "number",
        "number",
        "number"
    })
    for v, k in pairs(vPool)
        do
            v[1].value = menu[1]
            v[3].value = menu[2]
            v[6].value = menu[3]
            v[7].value = menu[4]
            v[7].freeze = true
            v[7].freezeType = gg.FREEZE_NORMAL
        end
    gg.setValues(v)
end

function preload()
    --1243657
    menu = gg.prompt({
        "Enter Current money",
    }, nil, {"number"})
    gg.searchNumber(menu[1], gg.TYPE_DWORD)
    gg.refineAddress("CD4", -1, gg.TYPE_DWORD, gg.SIGN_EQUAL, 0, -1, 0)
    base = gg.getResults(1)
    base[1].name = "[1] Money"
    vPool[1] = base[1]
    gg.addListItems(base)
    _G.totalGain = {}
    totalGain[1] = {
        address = base[1].address + tonumber(0x4),
        flags = gg.TYPE_FLOAT,
        name = "[2] Total Money Gained",
    }
    vPool[2] = totalGain
    gg.addListItems(totalGain)
    --gg.alert("Preload Done, Preloaded Following Hacks:\n- Money\n- Total Money Gained")
    gg.clearResults()
    base = nil
    gg.searchNumber("1500", gg.TYPE_DWORD)
    gg.refineAddress("D68", -1, gg.TYPE_DWORD, gg.SIGN_EQUAL, 0, -1, 0)
    base = gg.getResults(1)
    base[1].name = "[4] Target Limit"
    vPool[3] = base[1]
    gg.addListItems(base)
    _G.currentKills = {}
    currentKills[1] = {
    address = base[1].address - tonumber(0x4),
    flags = gg.TYPE_DWORD,
    name = "[3] currentKills",
}
    vPool[4] = currentKills
    gg.addListItems(currentKills)
    --gg.alert("Preload Done, Preloaded Following Hacks:\n- Target Limit\n- currentKills")
    gg.clearResults()
    base = nil

    menu = gg.prompt({
        "Enter Current Highscore",
    }, nil, {"number"})
    gg.searchNumber(menu[1], gg.TYPE_FLOAT)
    gg.refineAddress("E5C", -1, gg.TYPE_FLOAT, gg.SIGN_EQUAL, 0, -1, 0)
    base = gg.getResults(1)
    base[1].name = "[6] Highscore"
    vPool[5] = base[1]
    gg.addListItems(base)
    _G.currentScore = {}
        currentScore[1] = {
        address = base[1].address - tonumber(0x4),
        flags = gg.TYPE_FLOAT,
        name = "[5] Current Score",
    }
    vPool[6] = currentScore
    gg.addListItems(currentScore)
    _G.multiplier = {}
    multiplier[1] = {
        address = base[1].address + tonumber(0x4),
        flags = gg.TYPE_DWORD,
        name = "[7] Multiplier",
    }
    vPool[7] = multiplier
    gg.addListItems(multiplier)
    --gg.alert("Preload Done, Preloaded Following Hacks:\n- Highscore\n- Current Score\n- Multiplier")
    gg.clearResults()
    base = nil
    --print(vPool)
    --breakpoint()
    finishPreload = true
end

function breakpoint()
    gg.alert("Breakpoint")
    os.exit()
end

main()

while true  
    do
        while gg.isVisible(true)
            do
                gg.setVisible(true)
                main()
            end
    end

@ function mainMenu()

Edited by YeetMeister
Location of problem
  • 0
Posted
1 hour ago, YeetMeister said:

for v, k in pairs(vPool) do v[1].value = menu[1] v[3].value = menu[2] v[6].value = menu[3] v[7].value = menu[4] v[7].freeze = true v[7].freezeType = gg.FREEZE_NORMAL end

You don't need a loop here. Extract the code from loop body and change all references to "v" to "vPool" and it might work as you expect.

  • 0
Posted
55 minutes ago, CmP said:

You don't need a loop here. Extract the code from loop body and change all references to "v" to "vPool" and it might work as you expect.

Yo Thanks man, but the vPool[7] value doesnt get freezed

  • 0
Posted
55 minutes ago, CmP said:

That's because you use "setValues" function. "addListItems" is the one you need to use to freeze a value.

Gotchu, so i can modify the values with gg.addListItems() too?

  • 0
Posted

In case of modifying value by freezing it to a new value "addListItems" can be used, but in case of just changing value without freezing it "setValues" function is the one to use.

Generally, you shouldn't use "addListItems" on values that you don't want to be added to saved list. Values that are needed to be frozen is exception, because in GG a value can't be frozen without it being added to saved list.

  • 0
Posted
8 minutes ago, CmP said:

In case of modifying value by freezing it to a new value "addListItems" can be used, but in case of just changing value without freezing it "setValues" function is the one to use.

Generally, you shouldn't use "addListItems" on values that you don't want to be added to saved list. Values that are needed to be frozen is exception, because in GG a value can't be frozen without it being added to saved list.

Thanks for the info, i still got a problem with something,

I have a weird lookin table right here and i dont know how to fix it or call the stuff in the table

Here a pic:

 

And the script: 

--[[
0xApi by 0x14C

Explaination:

searchMem(
  value,
  Type(gg.TYPE_FLOAT) for example
  )

refineMem(
  value,
  gg.TYPE_FLOAT
  )

refineAddress(
  address, 
  Type, 
  removeResults(
    only important if the value is not the first one
    )
  )
  
if your value is the third value then input

refineAddress(address, Type, 3)

it will automatically remove the 2 useless values

offset(
  0ffset(0x14C), 
  Type, 
  autoSave or not save, 
  value of the offset for example(77),
)

addItem(
  target Table, 
  table that you want to insert
)

displayTable(
  table
)

displays the content of the table

Leave a Suggestion for more functions, DM me Here:

Discord: 0x14C#3100
]]








vPool = {}
tmp = {
  
}
function searchMem(v, t)
  gg.searchNumber(v, t)
end

function refineMem(v, t, r)
  gg.refineNumber(v, t)
  rem = gg.getResults(r - 1)
  gg.removeResults(rem)
  tmp = gg.getResults(1)
  rem = nil
end

function refineAddress(v, t, r)
  gg.refineAddress(v, -1, t, gg.SIGN_EQUAL, 0, -1, 0)
  rem = gg.getResults(r - 1)
  gg.removeResults(rem)
  tmp = gg.getResults(1)
  rem = nil
  --gg.alert(tostring(tmp))
end

function offset(o, t, s, a)
  if s == true
    then
      v = gg.getResults(1)
      off = o
      r = {}
      r[1] = {
        address = v[1].address + tonumber(off),
        flags = t,
        value = a,
      }
      print(r)
      addItem(vPool, r)
    else
      v = gg.getResults(1)
      off = o
      r = {}
      r[1] = {
        address = v[1].address + tonumber(off),
        flags = t,
      }
    end
end

function addItem(t, p)
  table.insert(t, p)
end

function displayTable(t)
  gg.alert("Table Display:\n"..tostring(t))
end

function clear()
  gg.clearResults()
end

searchMem(.5, 16)
refineAddress(530, 16, 2)
addItem(vPool, tmp)
offset(0x530, 16, true, 0.27799999714)
addItem(vPool, r)
displayTable(vPool)
clear()

 

Screenshot_20200820-030459_Acode.png

  • 0
Posted
10 minutes ago, YeetMeister said:

I have a weird lookin table right here and i dont know how to fix it or call the stuff in the table

To fix what? You forgot to describe the problem.

From the screenshot you attached it is in no way obvious what the problem is. If you wonder why second and third elements of "vPool" table are references to the same table, that's because your code calls "addItem" function with the same arguments twice.

  • 0
Posted
11 hours ago, CmP said:

To fix what? You forgot to describe the problem.

From the screenshot you attached it is in no way obvious what the problem is. If you wonder why second and third elements of "vPool" table are references to the same table, that's because your code calls "addItem" function with the same arguments twice.

wait, it calls additem twice?, idk lol

this weird looking table can be called using vPool[1][1]

but how can i make it that it only needs vPool[1] for example

 

  • 0
Posted (edited)
6 hours ago, YeetMeister said:

wait, it calls additem twice?, idk lol

In "offset" function:

18 hours ago, YeetMeister said:

function offset(o, t, s, a) if s == true then v = gg.getResults(1) off = o r = {} r[1] = { address = v[1].address + tonumber(off), flags = t, value = a, } print(r) addItem(vPool, r) else v = gg.getResults(1) off = o r = {} r[1] = { address = v[1].address + tonumber(off), flags = t, } end end

And right after the call to it:

18 hours ago, YeetMeister said:

offset(0x530, 16, true, 0.27799999714) addItem(vPool, r)

 

6 hours ago, YeetMeister said:

this weird looking table can be called using vPool[1][1]

but how can i make it that it only needs vPool[1] for example

Instead of adding table of tables to "vPool" table, add just tables that contain info about a particular memory item.

For example, in your code instead of

addItem(vPool, r)

do

addItem(vPool, r[1])
Edited by CmP

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.