Jump to content

(SOLVED) Some troubles with tables and for ... do


JAY.ANN

Recommended Posts

Hello everyone. I need some help with my script. Somehow when I use (for ... do) it reads a half of a table(?), lol.

requestDeleteAdminVeh is a function that gets selected element of MTA gridlist what's the part of my admin panel.
veh - selected gridlist element which has vehicle element as a data;
deleteAll - boolean for deleting all admin vehicles;

submitDeleteAdminVeh is a function that destroys the vehicle element, removes it from table and refreshes the gridlist with number plates.

 

I have a trouble with the first function, I guess. When I delete all vehicles there is always lefts one. It's kinda strange, lmao, because as for me - the script is OK.

local TableAdmVehicle = {}

function requestDeleteAdminVeh( veh, deleteAll )
	if deleteAll == true then
		for i, v in pairs( TableAdmVehicle ) do
		submitDeleteAdminVeh( v )
		end
	else
		if isElement( veh ) then
		submitDeleteAdminVeh( veh )
		end
	end
end
addEvent( "requestDeleteAdminVeh", true )
addEventHandler( "requestDeleteAdminVeh", getRootElement(), requestDeleteAdminVeh )

function submitDeleteAdminVeh( veh )
	for i, v in ipairs( TableAdmVehicle ) do
	destroyElement( veh )
	table.remove( TableAdmVehicle, i )
	end
	for i, v in ipairs( TableAdmVehicle ) do 
	updateAdminVehiclePlate( i, v )
	end
refreshAdmVehicleTabServer( )
end

 

SOLVED - Used a timer to relieve the script 

Edited by JAY.ANN
Link to comment
  • JAY.ANN changed the title to (SOLVED) Some troubles with tables and for ... do
  • Tut locked this topic
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

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