Jump to content

Problem cleaning a table


Overkillz

Recommended Posts

The question is simple. Why it doesn't get empty only using tableExample = {}

Well, I have a table, but when I want to clean it (Leave it empty) it doesn't work

tableExample = {
	{"spawnpoint","425","3759.4814","-1384.124","7.75377","0","359.94","60"},
	{"spawnpoint","425","3753.4814","-1387.124","8.75377","0","359.94","60"},
	{"spawnpoint","425","3751.4814","-1382.124","9.75377","0","359.94","60"},
	{"spawnpoint","425","3749.4814","-1389.124","10.75377","0","359.94","60"}
}

-- Why doesn't this work ? It should be enought to clean it right ? It still keeping the same spawnpoints if I update it by another table.
tableExample = {}

 

Link to comment
  • Moderators

Your code is true.

I tried this example and then everything was good :

tableExample = {
	{"spawnpoint","425","3759.4814","-1384.124","7.75377","0","359.94","60"},
	{"spawnpoint","425","3753.4814","-1387.124","8.75377","0","359.94","60"},
	{"spawnpoint","425","3751.4814","-1382.124","9.75377","0","359.94","60"},
	{"spawnpoint","425","3749.4814","-1389.124","10.75377","0","359.94","60"}
}
addCommandHandler('s',
function ()
	if ( #tableExample > 0 ) then 
		for i , v in pairs ( tableExample ) do
			outputChatBox(v[1],root,252,225,252,true)
		end 
	else 
		outputChatBox('There is nothing into this table !!!',root,252,225,252,true)
	end 
end) 
addCommandHandler('d',
function ()
	if ( #tableExample > 0 ) then 
		tableExample = { }
		outputChatBox('The table was cleaned !',root,252,225,252,true)
	else 
		outputChatBox('The table is empty !',root,252,225,252,true)
	end 
end ) 


Type 's' to shows you the result on the chatbox and type 'd' to delete everything within the table.

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