diff --git a/newmodels_reborn/scripts/core/client_logic.lua b/newmodels_reborn/scripts/core/client_logic.lua index a312f19..cfbd2cd 100644 --- a/newmodels_reborn/scripts/core/client_logic.lua +++ b/newmodels_reborn/scripts/core/client_logic.lua @@ -13,7 +13,7 @@ local function applyElementCustomModel(element) local loadedModel = loadedModels[customModel] if not loadedModel then return end - if _getElementModel(element) == loadedModel.id then return end + if getElementModelMTA(element) == loadedModel.id then return end local upgrades, handling, paintjob if getElementType(element) == "vehicle" then @@ -22,7 +22,7 @@ local function applyElementCustomModel(element) paintjob = getVehiclePaintjob(element) end - _setElementModel(element, loadedModel.id) + setElementModelMTA(element, loadedModel.id) if upgrades then for _, v in pairs(upgrades) do @@ -246,7 +246,7 @@ addEventHandler("onClientElementDataChange", root, function(key, prevCustomModel if prevCustomModel then -- Force-set the base model of the previous custom model if resetting the custom model if (not newCustomModel) and prevLoadedModelBaseModel then - _setElementModel(source, prevLoadedModelBaseModel) + setElementModelMTA(source, prevLoadedModelBaseModel) end -- Free the previous custom model if it's not used by any other element @@ -277,10 +277,10 @@ local function restoreElementBaseModels() -- Restore the base models of all elements with custom models for _, elementType in pairs(VALID_ELEMENT_TYPES) do for _, element in pairs(getElementsByType(elementType, root, true)) do - local model = _getElementModel(element) + local model = getElementModelMTA(element) for _, loadedModel in pairs(loadedModels) do if loadedModel.id == model then - _setElementModel(element, loadedModel.baseModel) + setElementModelMTA(element, loadedModel.baseModel) break end end diff --git a/newmodels_reborn/scripts/core/shared_exported.lua b/newmodels_reborn/scripts/core/shared_exported.lua index 897db41..ef4cf1b 100644 --- a/newmodels_reborn/scripts/core/shared_exported.lua +++ b/newmodels_reborn/scripts/core/shared_exported.lua @@ -10,15 +10,15 @@ VALID_ELEMENT_TYPES = { "vehicle", "ped", "player", "object", "pickup" } local resources = {} -_createObject = createObject -_createVehicle = createVehicle -_getVehicleType = getVehicleType -_createPed = createPed -_createPickup = createPickup -_setPickupType = setPickupType +createObjectMTA = createObject +createVehicleMTA = createVehicle +getVehicleTypeMTA = getVehicleType +createPedMTA = createPed +createPickupMTA = createPickup +setPickupTypeMTA = setPickupType -_getElementModel = getElementModel -_setElementModel = setElementModel +getElementModelMTA = getElementModel +setElementModelMTA = setElementModel function getSharedCustomModelsTable() if IS_IMPORTED then @@ -123,15 +123,15 @@ end local function createElementWithModel(elementType, modelid, ...) if elementType == "object" then - return _createObject(modelid, ...) + return createObjectMTA(modelid, ...) elseif elementType == "vehicle" then - return _createVehicle(modelid, ...) + return createVehicleMTA(modelid, ...) elseif elementType == "ped" then - return _createPed(modelid, ...) + return createPedMTA(modelid, ...) elseif elementType == "pickup" then -- Special local x, y, z, respawnTime, ammo = unpack({ ... }) - return _createPickup(x, y, z, 3, modelid, respawnTime, ammo) + return createPickupMTA(x, y, z, 3, modelid, respawnTime, ammo) end return false end @@ -165,9 +165,9 @@ end function getVehicleType(id) local customModelInfo = getSharedCustomModelsTable()[id] if customModelInfo then - return _getVehicleType(customModelInfo.baseModel) + return getVehicleTypeMTA(customModelInfo.baseModel) end - return _getVehicleType(id) + return getVehicleTypeMTA(id) end function createPed(id, ...) @@ -185,7 +185,7 @@ function createPickup(x, y, z, theType, id, respawnTime, ammo) assert(type(id) == "number", "Invalid model ID passed: " .. tostring(id)) pickup = createElementSafe("pickup", id, x, y, z, respawnTime, ammo) else - pickup = _createPickup(x, y, z, theType, id, respawnTime, ammo) + pickup = createPickupMTA(x, y, z, theType, id, respawnTime, ammo) end setElementResource(pickup, sourceResource) return pickup @@ -208,23 +208,23 @@ function setPickupType(thePickup, theType, id, ammo) end setElementData(thePickup, getCustomModelDataKey("pickup"), nil, not isClientsideScript) - return _setPickupType(thePickup, theType, id, ammo) + return setPickupTypeMTA(thePickup, theType, id, ammo) end -- Returns a custom model ID (if custom) or a default model ID (if default) function getElementModel(element) assert(isElement(element), "Invalid element passed: " .. tostring(element)) assert(isValidElement(element), "Invalid element type passed: " .. getElementType(element)) - return tonumber(getElementData(element, getCustomModelDataKey(element))) or _getElementModel(element) + return tonumber(getElementData(element, getCustomModelDataKey(element))) or getElementModelMTA(element) end function getElementBaseModel(element) if not isClientsideScript then - return _getElementModel(element) + return getElementModelMTA(element) end local customModel = tonumber(getElementData(element, getCustomModelDataKey(element))) if not customModel then - return _getElementModel(element) + return getElementModelMTA(element) end local customModelInfo = getSharedCustomModelsTable()[customModel] return customModelInfo and customModelInfo.baseModel or nil @@ -236,9 +236,9 @@ function setElementModel(element, id) assert(isValidElement(element), "Invalid element type passed: " .. getElementType(element)) assert(tonumber(id), "Non-number ID passed") local baseModel = getBaseModelIdFromCustomModelId(id) - local currModel = _getElementModel(element) + local currModel = getElementModelMTA(element) if currModel ~= baseModel then - _setElementModel(element, baseModel) + setElementModelMTA(element, baseModel) end if baseModel ~= id then diff --git a/newmodels_reborn/scripts/optional/debug/s_debug.lua b/newmodels_reborn/scripts/optional/debug/s_debug.lua index 4a43f97..6f6683e 100644 --- a/newmodels_reborn/scripts/optional/debug/s_debug.lua +++ b/newmodels_reborn/scripts/optional/debug/s_debug.lua @@ -1,61 +1,74 @@ addCommandHandler("testveh", function(thePlayer, cmd, id) id = tonumber(id) if not id then - return outputChatBox("Syntax: /"..cmd.." ") + return outputChatBox("Syntax: /"..cmd.." ", thePlayer) end local x,y,z = getElementPosition(thePlayer) local rx,ry,rz = getElementRotation(thePlayer) - local veh = createVehicle(id, x, y, z, rx, ry, rz) - if not veh then - return outputChatBox("Failed to create vehicle.") + local element = createVehicle(id, x, y, z, rx, ry, rz) + if not element then + return outputChatBox("Failed to create vehicle.", thePlayer) end - setElementDimension(veh, getElementDimension(thePlayer)) - setElementInterior(veh, getElementInterior(thePlayer)) + setElementDimension(element, getElementDimension(thePlayer)) + setElementInterior(element, getElementInterior(thePlayer)) setElementPosition(thePlayer, x+2, y, z) - outputChatBox("Vehicle created with ID "..id..".") + outputChatBox("Vehicle created with ID "..id..".", thePlayer) end, false, false) addCommandHandler("testobj", function(thePlayer, cmd, id) id = tonumber(id) if not id then - return outputChatBox("Syntax: /"..cmd.." ") + return outputChatBox("Syntax: /"..cmd.." ", thePlayer) end local x,y,z = getElementPosition(thePlayer) local rx,ry,rz = getElementRotation(thePlayer) - local veh = createObject(id, x, y, z, rx, ry, rz) - if not veh then - return outputChatBox("Failed to create object.") + local element = createObject(id, x, y, z, rx, ry, rz) + if not element then + return outputChatBox("Failed to create object.", thePlayer) end - setElementDimension(veh, getElementDimension(thePlayer)) - setElementInterior(veh, getElementInterior(thePlayer)) + setElementDimension(element, getElementDimension(thePlayer)) + setElementInterior(element, getElementInterior(thePlayer)) setElementPosition(thePlayer, x+2, y, z) - outputChatBox("Object created with ID "..id..".") + outputChatBox("Object created with ID "..id..".", thePlayer) end, false, false) addCommandHandler("testped", function(thePlayer, cmd, id) id = tonumber(id) if not id then - return outputChatBox("Syntax: /"..cmd.." ") + return outputChatBox("Syntax: /"..cmd.." ", thePlayer) end local x,y,z = getElementPosition(thePlayer) - local rx,ry,rz = getElementRotation(thePlayer) - local veh = createPed(id, x, y, z, rz) - if not veh then - return outputChatBox("Failed to create ped.") + local _,_,rz = getElementRotation(thePlayer) + local element = createPed(id, x, y, z, rz) + if not element then + return outputChatBox("Failed to create ped.", thePlayer) end - setElementDimension(veh, getElementDimension(thePlayer)) - setElementInterior(veh, getElementInterior(thePlayer)) + setElementDimension(element, getElementDimension(thePlayer)) + setElementInterior(element, getElementInterior(thePlayer)) setElementPosition(thePlayer, x+2, y, z) - outputChatBox("Ped created with ID "..id..".") + outputChatBox("Ped created with ID "..id..".", thePlayer) end, false, false) addCommandHandler("testskin", function(thePlayer, cmd, id) id = tonumber(id) if not id then - return outputChatBox("Syntax: /"..cmd.." ") + return outputChatBox("Syntax: /"..cmd.." ", thePlayer) end if not setElementModel(thePlayer, id) then - return outputChatBox("Failed to set skin.") + return outputChatBox("Failed to set skin.", thePlayer) + end + outputChatBox("Skin set to ID "..id..".", thePlayer) +end, false, false) + +addCommandHandler("testspawn", function(thePlayer) + local dataName = getCustomModelDataKey("player") + local x,y,z = getElementPosition(thePlayer) + local _, _, rz = getElementRotation(thePlayer) + local customModel = tonumber(getElementData(thePlayer, dataName)) + spawnPlayer(thePlayer, x,y,z, rz, getElementModelMTA(thePlayer), getElementInterior(thePlayer), getElementDimension(thePlayer)) + setElementData(thePlayer, dataName, nil) + if customModel then + setElementData(thePlayer, dataName, customModel) end - outputChatBox("Skin set to ID "..id..".") + outputChatBox("Player spawned with skin "..( customModel or getElementModelMTA(thePlayer) )..".", thePlayer) end, false, false)