SoySuperxD Posted January 18, 2023 Share Posted January 18, 2023 (edited) ERROR EN LA CONSOLA: ERROR: items/itemsS.lua:671: attempt to index global 'trash' (a nil value) El error me aparece cada vez que inicio el server y cada vez que le hago restart a cualquier script, no entiendo, me tiene cabezón. Resalto la línea 671 del error en amarrillo. (línea del supuesto error) local sistemaitems function loadTrash() local query = dbQuery(connection, "SELECT * FROM bins;" ) local result, numrows = dbPoll(query, -1) if (result and numrows > 0) then for index, trashPos in pairs(result) do trashPos = fromJSON(trash["pos"]) or "[[ 0,0,0,0,0,0,0,0 ]]" sistemaitems = createObject(1359, trashPos[1],trashPos[2], trashPos[3]-0.4, trashPos[4], trashPos[5], trashPos[6]) setElementData(sistemaitems, "sistemaID", trash['id']) setElementInterior(sistemaitems, trashPos[7]) setElementDimension(sistemaitems, trashPos[8]) end end end addCommandHandler("papelera", function(playerSource, cmd) if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(playerSource)), aclGetGroup("Console")) then local x, y, z = getElementPosition(playerSource) local rx, ry, rz = getElementRotation(playerSource) local int = getElementInterior(playerSource) local Dim = getElementDimension(playerSource) local Query, _, insertID = dbQuery(connection,"INSERT INTO bins (pos) VALUES(?)", toJSON({x, y, z, rx, ry, rz, int ,Dim})) local checkQuery, _, insertID = dbPoll ( Query, -1 ) if checkQuery then outputChatBox("#7cc776[Inventario] #ffffff Papelera creada.", playerSource, 255,255, 255, true) sistemaitems = createObject(1359, x, y, z-0.4, rx, ry, rz) setElementData(sistemaitems, "sistemaID", insertID) setElementInterior(sistemaitems, int) setElementDimension(sistemaitems, Dim) end end end) El código es parte de un sistema de papelera para desechar items, todo lo demás corre muy bien. Será algún problema con mi sistema de ID? Edited January 18, 2023 by SoySuperxD Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now