Jump to content

Fixed


Recommended Posts

*boop* got a new problem with my script

for i, colshape in ipairs(getElementsByType("colshape")) do
	if isElementWithinColShape(player, colshape) then
		for o, object in ipairs(getElementsByType("object")) do
			if isElementWithinColShape(object, colshape) then
				for _, object in ipairs(getElementsByType("object")) do
					GUIEditor.row[1] = guiGridListAddRow(GUIEditor.gridlist[1])
					guiGridListSetItemText(GUIEditor.gridlist[1], GUIEditor.row[1], column, getElementModel(object), false, false)
				end
			end
		end				
	end
end

Hey guys I got a problem with my function. I have 3 objects within a colshape and I want their model IDs to be added to a gridlist GUI. The problem is, there are 3 objects, but about 15 rows get added to the gridlist with duplicated IDs.

The rows should look like this:

1

2

3

 

But what happens is:

1

2

3

3

3

1

2

3

3

3

 

and this goes on until it loops 3 times. How do I fix it?

Link to comment

I'm not sure if I understand your problem, what is the last loop for? In the first 1 and 2nd loop you have if statements but not in the 3rd? So you basically loop through all the objects again?

Edited by pa3ck
Link to comment

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...