diff --git a/newmodels_reborn/models/object/1337/big_box/40001.col b/newmodels_reborn/models/object/1337/big_box/40001.col new file mode 100644 index 0000000..fd76936 Binary files /dev/null and b/newmodels_reborn/models/object/1337/big_box/40001.col differ diff --git a/newmodels_reborn/models/object/1337/big_box/40001.dff b/newmodels_reborn/models/object/1337/big_box/40001.dff new file mode 100644 index 0000000..96cd6d3 Binary files /dev/null and b/newmodels_reborn/models/object/1337/big_box/40001.dff differ diff --git a/newmodels_reborn/models/object/1337/big_box/40001.txt b/newmodels_reborn/models/object/1337/big_box/40001.txt new file mode 100644 index 0000000..ec6e287 --- /dev/null +++ b/newmodels_reborn/models/object/1337/big_box/40001.txt @@ -0,0 +1 @@ +txd=object/1337/boxes.txd \ No newline at end of file diff --git a/newmodels_reborn/models/object/1337/boxes.txd b/newmodels_reborn/models/object/1337/boxes.txd new file mode 100644 index 0000000..a11a6ba Binary files /dev/null and b/newmodels_reborn/models/object/1337/boxes.txd differ diff --git a/newmodels_reborn/models/object/1337/small_box/40002.col b/newmodels_reborn/models/object/1337/small_box/40002.col new file mode 100644 index 0000000..3ced88c Binary files /dev/null and b/newmodels_reborn/models/object/1337/small_box/40002.col differ diff --git a/newmodels_reborn/models/object/1337/small_box/40002.dff b/newmodels_reborn/models/object/1337/small_box/40002.dff new file mode 100644 index 0000000..88f2283 Binary files /dev/null and b/newmodels_reborn/models/object/1337/small_box/40002.dff differ diff --git a/newmodels_reborn/models/object/1337/small_box/40002.txt b/newmodels_reborn/models/object/1337/small_box/40002.txt new file mode 100644 index 0000000..ec6e287 --- /dev/null +++ b/newmodels_reborn/models/object/1337/small_box/40002.txt @@ -0,0 +1 @@ +txd=object/1337/boxes.txd \ No newline at end of file diff --git a/newmodels_reborn/scripts/core/server_logic.lua b/newmodels_reborn/scripts/core/server_logic.lua index 91d5451..e7448ef 100644 --- a/newmodels_reborn/scripts/core/server_logic.lua +++ b/newmodels_reborn/scripts/core/server_logic.lua @@ -1,8 +1,15 @@ +-- Apologies for the excess if statements, I'll clean this up later. + local CUSTOM_MODEL_SETTINGS = { ["disableAutoFree"] = true, ["disableTXDTextureFiltering"] = true, ["enableDFFAlphaTransparency"] = true, } +-- Additionally, model settings .txt can contain path to txd, dff, and col files. + +local function stringStartswith(str, start) + return str:sub(1, #start) == start +end local function loadModels() if not pathIsDirectory("models") then @@ -14,7 +21,6 @@ local function loadModels() end for _, modelType in pairs({"vehicle", "object", "ped"}) do local modelTypePath = "models/" .. modelType - -- Directory is optional, user might not have any custom models for this type if pathIsDirectory(modelTypePath) then local filesAndFoldersHere = pathListDir(modelTypePath) if not filesAndFoldersHere then @@ -37,42 +43,57 @@ local function loadModels() local fileType = string.sub(thisFileName, -3) if (fileType == "dff" or fileType == "txd" or fileType == "col" or fileType == "txt") then local customModel = tonumber(string.sub(thisFileName, 1, -5)) - if not customModel then - return false, "invalid " .. modelType .. " custom model: " .. thisFileName - end - if not customModelInfo[customModel] then - if isDefaultID(modelType, customModel) then - return false, "custom " .. modelType .. " model is a default ID: " .. customModel - end - if customModels[customModel] then - return false, "duplicate " .. modelType .. " custom model: " .. customModel - end - customModelInfo[customModel] = {} - end - if fileType == "txt" then - local file = fileOpen(thisFullPath, true) - if not file then - return false, "failed to open file: " .. thisFullPath - end - local info = fileGetContents(file, false) - fileClose(file) - if not info then - return false, "failed to read file: " .. thisFullPath - end - local customModelSettings = {} - local lines = split(info, "\n") - for _, settingName in pairs(lines) do - settingName = settingName:gsub("\r", "") - local settingType = CUSTOM_MODEL_SETTINGS[settingName] - if settingType then - customModelSettings[settingName] = true + if customModel then + if not customModelInfo[customModel] then + if isDefaultID(modelType, customModel) then + return false, "custom " .. modelType .. " model is a default ID: " .. customModel + end + if customModels[customModel] then + return false, "duplicate " .. modelType .. " custom model: " .. customModel end + customModelInfo[customModel] = {} end - customModelInfo[customModel].settings = customModelSettings - else - customModelInfo[customModel][fileType] = thisFullPath - if name then - customModelInfo[customModel].name = name + if fileType == "txt" then + local file = fileOpen(thisFullPath, true) + if not file then + return false, "failed to open file: " .. thisFullPath + end + local info = fileGetContents(file, false) + fileClose(file) + if not info then + return false, "failed to read file: " .. thisFullPath + end + local customModelSettings = {} + local lines = split(info, "\n") + for _, settingStr in pairs(lines) do + settingStr = settingStr:gsub("\r", "") + if CUSTOM_MODEL_SETTINGS[settingStr] then + customModelSettings[settingStr] = true + else + for _, settingModelType in pairs({"txd", "dff", "col"}) do + if stringStartswith(settingStr, settingModelType.."=") then + local settingModelPath = settingStr:sub(5) + local settingModelFullPath = "models/" .. settingModelPath + if not fileExists(settingModelFullPath) then + return false, "setting " .. settingModelType .. " file not found: " .. settingModelPath + end + if customModelInfo[customModel][settingModelType] then + return false, "duplicate " .. settingModelType .. " file for custom " .. modelType .. " model: " .. customModel + end + customModelInfo[customModel][settingModelType] = settingModelFullPath + end + end + end + end + customModelInfo[customModel].settings = customModelSettings + else + if customModelInfo[customModel][fileType] then + return false, "duplicate " .. fileType .. " file for custom " .. modelType .. " model: " .. customModel + end + customModelInfo[customModel][fileType] = thisFullPath + if name then + customModelInfo[customModel].name = name + end end end end @@ -109,6 +130,7 @@ local function loadModels() name = info.name or "Unnamed", settings = info.settings or {}, } + if modelType == "object" then iprint(customModels[customModel]) end end end end