Jump to content
TheGameExploiter

How to combine offset with add to value in lua?

Recommended Posts

Hi, I am trying to learn lua, so I have been playing around with script's I've recorded. I am now tring to combine and offset search with an add to value command, but I can't figure it out.

Would somone please take a look at the two bits of code and, then point me in the right direction so I can figure this out?

 

I want to combine this:-

data = gg.prompt({'\vHow much cash do you need? \nPlease use numbers only!'},{0})
p = gg.getResults(1)
local q ={}
q[1] = {}
q[1].address = p[1].address + 36 --dont forget to ajust memory offset
q[1].flags = 4
q[1].value = data[1]
gg.setValues(q)
gg.alert('done')


With this:-

data = gg.prompt({'\vHow much cash do you need? \nPlease use numbers only!'},{0})
p = gg.getResults(1)
for i, v in ipairs(p) do
	if v.flags == gg.TYPE_DWORD then
		v.value = v.value + data[1]
	end
end
gg.setValues(p)
p = nil
gg.alert('I added $'..data[1].. ' to your account')

 

Thanks in advance to anyone that can help me 😄

 

 

 

Share this post


Link to post
Share on other sites

Posted (edited)

i dont get it.

the first one..

get the offset address from the results and change its value with data[1].

the second one..

get results and add data[1] to its value.

strange is....no search process.

sorry...im still learning too.

Edited by MonkeySAN

Share this post


Link to post
Share on other sites
7 hours ago, MonkeySAN said:

i dont get it.

the first one..

get the offset address from the results and change its value with data[1].

the second one..

get results and add data[1] to its value.

strange is....no search process.

sorry...im still learning too.

No there is no search process because the search was performed at the start the script. These are just snippets from the larger code.

 

I have them extracted to there own lua file so I can test them. I comment one of them out and test on a search result I have already found.

 

Thanks for the reply 👍

 

Share this post


Link to post
Share on other sites
Posted (edited)
data = gg.prompt({'\vHow much cash do you need? \nPlease use numbers only!'},{0})
p = gg.getResults(1)
local q ={}
q[1] = {}
q[1].address = p[1].address + 36 -- offset from the results
q[1].flags = 4
q[1].value = data[1]
gg.setValues(q)
gg.alert('done')
q[1].address = p[1].address + 0 -- the results itself
q[1].flags = 4
q[1].value = v.value + data[1]
gg.setValues(q)
gg.alert('I added $'..data[1].. ' to your account')

im not clear of what you want to do but maybe this will help...?

Edited by MonkeySAN

Share this post


Link to post
Share on other sites
Posted (edited)

Thank you for your effort @MonkeySAN but from a quick look, its not what I want to do.

 

I am tring to add an amount to my offset result.

Something like this, but my method does not work

data = gg.prompt({'\vHow much cash do you need? \nPlease use numbers only!'},{0})
p = gg.getResults(1)
local q ={}
q[1] = {}
q[1].address = p[1].address + 36 --dont forget to ajust memory offset
q[1].flags = 4
q[1].value = for i, v in ipairs(p) do
	if v.flags == gg.TYPE_DWORD then
		v.value = v.value + data[1]
	end
end
gg.setValues(p)
gg.alert('I added $'..data[1].. ' to your account')

 

This is the error I get:-

Script ended:
Script error: luaj.o: load /storage/emulated/0/Pictures/OffsetTest.lua: luaj.o: /storage/emulated/0/Pictures/OffsetTest.lua:41
`q[1].value = for i, v in ipairs(p) do`
unexpected symbol near 'for'
	at luaj.LuaValue.a(src:997)
	at luaj.Globals.c_(src:255)
	at android.ext.Script.d(src:5992)
	at android.ext.Script$ScriptThread.run(src:5785)
Caused by: luaj.o: /storage/emulated/0/Pictures/OffsetTest.lua:41
`q[1].value = for i, v in ipairs(p) do`
unexpected symbol near 'for'
	at luaj.a.h.a(src:295)
	at luaj.a.h.c(src:299)
	at luaj.a.h.h(src:1537)
	at luaj.a.h.i(src:1548)
	at luaj.a.h.j(src:1628)
	at luaj.a.h.b(src:1741)
	at luaj.a.h.k(src:1759)
	at luaj.a.h.g(src:1459)
	at luaj.a.h.a(src:1854)
	at luaj.a.h.x(src:2176)
	at luaj.a.h.z(src:2273)
	at luaj.a.h.A(src:2290)
	at luaj.a.h.a(src:2306)
	at luaj.a.u.a(src:121)
	at luaj.a.t.a(src:99)
	at luaj.Globals.a(src:364)
	at luaj.Globals.a(src:352)
	at luaj.Globals.a(src:267)
	at luaj.Globals.c_(src:249)
	... 2 more

As I said, I'm trying to learn but I just can't figure this out.

Edited by TheGameExploiter

Share this post


Link to post
Share on other sites
Posted (edited)

maybe this will work?

i think its not the proper way or maybe not the way you want it but it get the job done..i think.

data = gg.prompt({'\vHow much cash do you need? \nPlease use numbers only!'},{0})
p = gg.getResults(1)
local q ={}
q[1] = {}
q[1].address = p[1].address + 36 --dont forget to ajust memory offset
q[1].flags = 4
gg.addListItems(q)
gg.clearResults()

local p = gg.getListItems()
gg.loadResults(p)
local t = gg.getResults(1)

for i, v in pairs(t) do
   if v.flags == 4 then
       v.value = v.value + data[1]
end
end
gg.setValues(t)
gg.addListItems(t)
gg.alert('I added $'..data[1].. ' to your account')

it get the offset address from p results and save it in the list.

then call it back and add with data[1]

same as you...im still learning.

Edited by MonkeySAN

Share this post


Link to post
Share on other sites

This is great, and makes perfect sense. I've not tested it yet and even if it doesn't work, you've given me something I can work with.

Thanks for your help, I really appreciate it. 👍🍻

Share this post


Link to post
Share on other sites

You are most welcome.

do tell me the good news...ok.

Share this post


Link to post
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...