debugToggle = false objectsToRegister = {} objectsToPlace = {} objectRegister = {} modelRegister = {} textureRegister = {} blacklistObjects = {} -- Blacklist for SanVice: -- blacklistObjects[7479] = true -- blacklistObjects[7316] = true -- blacklistObjects[7317] = true -- blacklistObjects[7318] = true -- blacklistObjects[10904] = true -- blacklistObjects[1205] = true -- blacklistObjects[7324] = true -- blacklistObjects[7319] = true -- blacklistObjects[7320] = true -- blacklistObjects[7321] = true -- blacklistObjects[7322] = true -- blacklistObjects[7323] = true tempObj = false logpath = "log.txt" if fileExists(logpath) then fileDelete(logpath) end logfile = fileCreate(logpath) function displayStatus(text) if debugToggle == false then return end x,y = guiGetScreenSize() dxDrawText(text .. " uwu",0,0,x,y,tocolor(0,255,0),1,"clear","center","center") end function debugWrite(text) if debugToggle == false then return end fileWrite(text) fileFlush(logfile) end function registerObject(...) -- id,model,texture,drawDistance table.insert(objectsToRegister,arg) end function registerObjectNow(id,model,texture,drawDistance) if blacklistObjects[id] then debugWrite("Skipping object " ..tostring(id).. " (" ..texture.. " + " ..model.. ") - Blacklisted.\n") return end if textureRegister[texture] == nil then debugWrite("Loading texture: " ..texture.. "\n") textureRegister[texture] = engineLoadTXD(texture) end if modelRegister[model] == nil then debugWrite("Loading model: " ..model.. "\n") modelRegister[model] = engineLoadDFF(model) end realID = engineRequestModel("object",10768) debugWrite("Making object " ..tostring(id).. ": " ..texture.. " + " ..model.. " = " ..tostring(realID).. "\n") engineImportTXD(textureRegister[texture],realID) engineReplaceModel(modelRegister[model],realID) engineSetModelLODDistance(realID,drawDistance) objectRegister[id] = realID if tempObj then destroyElement(tempObj) end if debugToggle == true then x,y,z = getElementPosition(localPlayer) tempObj = createObject(realID,x,y,z) setElementCollisionsEnabled(tempObj,false) end displayStatus("Loaded model: " ..model.. ", " ..tostring(#objectsToRegister).. " remaining...") end function placeObject(...) -- id,interior,x,y,z,rx,ry,rz,rw,lod table.insert(objectsToPlace,arg) end function placeObjectNow(id,interior,x,y,z,rx,ry,rz,rw,lod) if objectRegister[id] == nil then return end erx,ery,erz = fromQuaternion(rx,ry,rz,rw) obj = createObject(objectRegister[id],x,y + 6000,z,erx,ery,erz) setElementInterior(obj,interior) setElementCollisionsEnabled(obj,false) displayStatus("Placed model: " ..tostring(id).. ", " ..tostring(#objectsToPlace).. " remaining...") end function handleLoading() if debugToggle == true then if #objectsToRegister > 0 then object = table.remove(objectsToRegister,1) registerObjectNow(unpack(object)) return end else while #objectsToRegister > 0 do object = table.remove(objectsToRegister,1) registerObjectNow(unpack(object)) end end if tempObj then destroyElement(tempObj) end if debugToggle == true then if #objectsToPlace > 0 then object = table.remove(objectsToPlace,1) placeObjectNow(unpack(object)) return end else while #objectsToPlace > 0 do object = table.remove(objectsToPlace,1) placeObjectNow(unpack(object)) end end end addEventHandler("onClientRender",root,handleLoading) addEventHandler("onClientResourceStop",root,function(res) if res == resource then for _,value in pairs(objectRegister) do engineFreeModel(value) end end end)