Jump to content
  • 0

Please Help me with my script


allroundergaming

Question

I don't understand why my script is not working what I am doing wrong here is the script that I created

 gg.clearResults()

gg.searchNumber('-574,128,128',4)

gg.searchAddress("7AC4102570")

if gg.getResultCount()==0 then

    print('No results.')

    os.exit()

end

r = gg.getResults(1)

gg.clearResults()

 r = gg.getValues({

    {

        address = r[1].address-356,

        flags = 4

    },

    {

        address = r[1].address-352,

        flags = 4

    },

    {

        address = r[1].address-348, 

        flags = 4

    },

    {

        address = r[1].address-344,

        flags = 4

    },

    {

        address = r[1].address-340,

        flags = 4

    },

    {

        address = r[1].address-336,

        flags = 4

    },

})

 for i=1, #r do

    if i==6 then r.value=6 end

    if i==9 then r.value=9 end

    if i==0 then r.value=0 end

    r.freeze = true

end

 

gg.addListItems(r)

it should edit the value like this :- 6;6;9;6;6;9

But it edits the value like this :- 6;6;9;6;6;6

 someone please please help me.

 

THANK YOU.

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

6 hours ago, allroundergaming said:

I don't understand why my script is not working what I am doing wrong here is the script that I created

 gg.clearResults()

gg.searchNumber('-574,128,128',4)

gg.searchAddress("7AC4102570")

if gg.getResultCount()==0 then

    print('No results.')

    os.exit()

end

r = gg.getResults(1)

gg.clearResults()

 r = gg.getValues({

    {

        address = r[1].address-356,

        flags = 4

    },

    {

        address = r[1].address-352,

        flags = 4

    },

    {

        address = r[1].address-348, 

        flags = 4

    },

    {

        address = r[1].address-344,

        flags = 4

    },

    {

        address = r[1].address-340,

        flags = 4

    },

    {

        address = r[1].address-336,

        flags = 4

    },

})

 for i=1, #r do

    if i==6 then r.value=6 end

    if i==9 then r.value=9 end

    if i==0 then r.value=0 end

    r.freeze = true

end

 

gg.addListItems(r)

it should edit the value like this :- 6;6;9;6;6;9

But it edits the value like this :- 6;6;9;6;6;6

 someone please please help me.

 

THANK YOU.

	gg.clearResults()
	gg.searchNumber('-574,128,128',4) -- why search this if you don t use it?
	gg.searchAddress("7AC4102570")
	if gg.getResultCount()==0 then
	    print('No results.')
	    os.exit()
	end
	r = gg.getResults(1)
	gg.clearResults()
	 r = gg.getValues({
	    {
	        address = r[1].address-356,
	        flags = 4
	    },
	    {
	        address = r[1].address-352,
	        flags = 4
	    },
	    {
	        address = r[1].address-348, 
	        flags = 4
	    },
	    {
	        address = r[1].address-344,
	        flags = 4
	    },
	    {
	        address = r[1].address-340,
	        flags = 4
	    },
	    {
	        address = r[1].address-336,
	        flags = 4
	    },
	})
	 for i=1, #r do
	    if i==6 then r.value=6 end -- you should use r[i].value
	    if i==9 then r.value=9 end
	    if i==0 then r.value=0 end -- 'i' can t be equal 0
	    r.freeze = true
	end
	 
	gg.addListItems(r)
	

Link to comment
Share on other sites

You don't need to use "getValues" function, if you just need to set the values (whether with freeze or without) regardless of their current value.

gg.clearResults()
gg.searchNumber('-574,128,128',4)
gg.searchAddress("7AC4102570")
if gg.getResultCount()==0 then
  print('No results.')
  os.exit()
end
r = gg.getResults(1)
gg.clearResults()
local addr = r[1].address
local v = {
  {address = addr - 356, value = 6},
  {address = addr - 352, value = 6},
  {address = addr - 348, value = 9},
  {address = addr - 344, value = 6},
  {address = addr - 340, value = 6},
  {address = addr - 336, value = 9}
}
for i, v in ipairs(v) do
  v.flags = 4
  v.freeze = true
end
gg.addListItems(v)
Link to comment
Share on other sites

2 hours ago, CmP said:

You don't need to use "getValues" function, if you just need to set the values (whether with freeze or without) regardless of their current value.


gg.clearResults()
gg.searchNumber('-574,128,128',4)
gg.searchAddress("7AC4102570")
if gg.getResultCount()==0 then
  print('No results.')
  os.exit()
end
r = gg.getResults(1)
gg.clearResults()
local addr = r[1].address
local v = {
  {address = addr - 356, value = 6},
  {address = addr - 352, value = 6},
  {address = addr - 348, value = 9},
  {address = addr - 344, value = 6},
  {address = addr - 340, value = 6},
  {address = addr - 336, value = 9}
}
for i, v in ipairs(v) do
  v.flags = 4
  v.freeze = true
end
gg.addListItems(v)

Clean code

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.