JAY.ANN Posted March 14, 2022 Share Posted March 14, 2022 (edited) 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 March 14, 2022 by JAY.ANN Link to comment
Administrators Tut Posted March 14, 2022 Administrators Share Posted March 14, 2022 Good to hear you resolved this issue, I've gone ahead and locked this post Link to comment
Recommended Posts