Jump to content

Tigr_2020

Members
  • Posts

    1
  • Joined

  • Last visited

Tigr_2020's Achievements

I ordered some spaghetti with marinara sauce and I got egg noodles and ketchup. I'm an average nobody.

I ordered some spaghetti with marinara sauce and I got egg noodles and ketchup. I'm an average nobody. (2/54)

0

Reputation

  1. Hello everyone, Today I encountered an error with the xml file, an error is shown in the debug: [23-02-25 18:05:30] WARNING: [gameplay]/drag/drag_s.lua:413: Unable to read XML file database.xml @ 'xmlLoadFile' [Line 0: Error document empty.] [23-02-25 18:05:30] WARNING: [gameplay]/drag/drag_s.lua:440: Unable to read XML file database.xml @ 'xmlLoadFile' [Line 0: Error document empty.] The database.xml file is empty Server side: -- CORE function updateTopTimeDatabase(topTime, vehicleName) local playerSerial = source:getSerial() local playerName = string.gsub(source:getName(), "#%x%x%x%x%x%x", "") local dataFile = nil if fileExists("database.xml") then dataFile =xmlLoadFile("database.xml") else dataFile = xmlCreateFile("database.xml", "accounts") end if (dataFile) then local nodesXml = xmlNodeGetChildren(dataFile) local isTopTimeAdding = true for i, n in ipairs(nodesXml) do if xmlNodeGetAttribute(n, "id") == playerSerial then if (tonumber(xmlNodeGetAttribute(n, "time")) > topTime) then xmlDestroyNode(n) else isTopTimeAdding = false end end end if (isTopTimeAdding == true) then local xmlNumbers = xmlCreateChild(dataFile, "data") xmlNodeSetAttribute(xmlNumbers, "id", tostring(playerSerial)) xmlNodeSetAttribute(xmlNumbers, "name", playerName) xmlNodeSetAttribute(xmlNumbers, "vehicle", vehicleName) xmlNodeSetAttribute(xmlNumbers, "time", topTime) end xmlSaveFile(dataFile) xmlUnloadFile(dataFile) dataFile = nil end dataFile =xmlLoadFile("database.xml") if (dataFile) then local nodesXml = xmlNodeGetChildren(dataFile) local nodesTable = {} for i, n in ipairs(nodesXml) do local toptimeName = xmlNodeGetAttribute(n, "name") local toptimeVehicle = xmlNodeGetAttribute(n, "vehicle") local toptimeTime = xmlNodeGetAttribute(n, "time") table.insert(nodesTable, {toptimeName, toptimeVehicle, toptimeTime}) end local personalBest = {vehicleName, topTime} namespace.triggerC(source, "drag-system.onClientShowTopTimeBoard", source, sortTopTimes(nodesTable), personalBest) nodesTable = nil xmlSaveFile(dataFile) xmlUnloadFile(dataFile) dataFile = nil end end namespace.addE("drag-system.onUpdateTopTimeDatabase", true) namespace.addEH("drag-system.onUpdateTopTimeDatabase", namespace.g_root, updateTopTimeDatabase)
×
×
  • Create New...