mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-29 01:08:54 +00:00
fix: correct colours for new errors
This commit is contained in:
@@ -10,11 +10,11 @@ local addonResourcesState = {
|
||||
['esx_progressbar'] = GetResourceState('esx_progressbar') ~= 'missing',
|
||||
['esx_notify'] = GetResourceState('esx_notify') ~= 'missing',
|
||||
['esx_textui'] = GetResourceState('esx_textui') ~= 'missing',
|
||||
['esx_context'] = GetResourceState('esx_context') ~= 'missing'
|
||||
['esx_context'] = GetResourceState('esx_context') ~= 'missing',
|
||||
}
|
||||
|
||||
local function IsResourceFound(resource)
|
||||
return addonResourcesState[resource] or print(('[^1ERROR^7] ^5%s^7 is Missing!'):format(resource))
|
||||
return addonResourcesState[resource] or error(('Resource [^5%s^1] is Missing!'):format(resource))
|
||||
end
|
||||
|
||||
function ESX.SearchInventory(items, count)
|
||||
@@ -381,7 +381,7 @@ function ESX.Game.SpawnVehicle(vehicleModel, coords, heading, cb, networked)
|
||||
local dist = #(playerCoords - vector)
|
||||
if dist > 424 then -- Onesync infinity Range (https://docs.fivem.net/docs/scripting-reference/onesync/)
|
||||
local executingResource = GetInvokingResource() or "Unknown"
|
||||
return error(("Resource ^5%s^7 Tried to spawn vehicle on the client but the position is too far away (Out of onesync range)."):format(executingResource))
|
||||
return error(("Resource ^5%s^1 Tried to spawn vehicle on the client but the position is too far away (Out of onesync range)."):format(executingResource))
|
||||
end
|
||||
|
||||
CreateThread(function()
|
||||
|
||||
@@ -322,17 +322,17 @@ if not Config.OxInventory then
|
||||
|
||||
RegisterNetEvent("esx:addWeapon")
|
||||
AddEventHandler("esx:addWeapon", function()
|
||||
error("event ^5'esx:addWeapon'^7 Has Been Removed. Please use ^5xPlayer.addWeapon^7 Instead!")
|
||||
error("event ^5'esx:addWeapon'^1 Has Been Removed. Please use ^5xPlayer.addWeapon^1 Instead!")
|
||||
end)
|
||||
|
||||
RegisterNetEvent("esx:addWeaponComponent")
|
||||
AddEventHandler("esx:addWeaponComponent", function()
|
||||
error("event ^5'esx:addWeaponComponent'^7 Has Been Removed. Please use ^5xPlayer.addWeaponComponent^7 Instead!")
|
||||
error("event ^5'esx:addWeaponComponent'^1 Has Been Removed. Please use ^5xPlayer.addWeaponComponent^1 Instead!")
|
||||
end)
|
||||
|
||||
RegisterNetEvent("esx:setWeaponAmmo")
|
||||
AddEventHandler("esx:setWeaponAmmo", function()
|
||||
error("event ^5'esx:setWeaponAmmo'^7 Has Been Removed. Please use ^5xPlayer.addWeaponAmmo^7 Instead!")
|
||||
error("event ^5'esx:setWeaponAmmo'^1 Has Been Removed. Please use ^5xPlayer.addWeaponAmmo^1 Instead!")
|
||||
end)
|
||||
|
||||
RegisterNetEvent("esx:setWeaponTint")
|
||||
@@ -342,7 +342,7 @@ if not Config.OxInventory then
|
||||
|
||||
RegisterNetEvent("esx:removeWeapon")
|
||||
AddEventHandler("esx:removeWeapon", function()
|
||||
error("event ^5'esx:removeWeapon'^7 Has Been Removed. Please use ^5xPlayer.removeWeapon^7 Instead!")
|
||||
error("event ^5'esx:removeWeapon'^1 Has Been Removed. Please use ^5xPlayer.removeWeapon^1 Instead!")
|
||||
end)
|
||||
|
||||
RegisterNetEvent("esx:removeWeaponComponent")
|
||||
|
||||
@@ -16,7 +16,7 @@ end
|
||||
|
||||
RegisterNetEvent("esx:serverCallback", function(requestId, invoker, ...)
|
||||
if not serverRequests[requestId] then
|
||||
return error(("Server Callback with requestId ^5%s^7 Was Called by ^5%s^7 but does not exist."):format(requestId, invoker))
|
||||
return error(("Server Callback with requestId ^5%s^1 Was Called by ^5%s^1 but does not exist."):format(requestId, invoker))
|
||||
end
|
||||
|
||||
serverRequests[requestId](...)
|
||||
@@ -31,7 +31,7 @@ end
|
||||
|
||||
RegisterNetEvent("esx:triggerClientCallback", function(eventName, requestId, invoker, ...)
|
||||
if not clientCallbacks[eventName] then
|
||||
return error(("Client Callback not registered, name: ^5%s^7, invoker resource: ^5%s^7"):format(eventName, invoker))
|
||||
return error(("Client Callback not registered, name: ^5%s^1, invoker resource: ^5%s^1"):format(eventName, invoker))
|
||||
end
|
||||
|
||||
clientCallbacks[eventName](function(...)
|
||||
|
||||
@@ -6,5 +6,5 @@ end)
|
||||
|
||||
AddEventHandler("esx:getSharedObject", function()
|
||||
local Invoke = GetInvokingResource()
|
||||
error(("Resource ^5%s^7 Used the ^5getSharedObject^7 Event, this event ^1no longer exists!^7 Visit https://documentation.esx-framework.org/tutorials/tutorials-esx/sharedevent for how to fix!"):format(Invoke))
|
||||
error(("Resource ^5%s^1 Used the ^5getSharedObject^1 Event, this event ^1no longer exists!^1 Visit https://documentation.esx-framework.org/tutorials/tutorials-esx/sharedevent for how to fix!"):format(Invoke))
|
||||
end)
|
||||
|
||||
@@ -2,7 +2,7 @@ Locales = {}
|
||||
|
||||
function Translate(str, ...) -- Translate string
|
||||
if not str then
|
||||
error(("Resource ^5%s^7 You did not specify a parameter for the Translate function or the value is nil!"):format(GetInvokingResource() or GetCurrentResourceName()))
|
||||
error(("Resource ^5%s^1 You did not specify a parameter for the Translate function or the value is nil!"):format(GetInvokingResource() or GetCurrentResourceName()))
|
||||
return "Given translate function parameter is nil!"
|
||||
end
|
||||
if Locales[Config.Locale] then
|
||||
|
||||
@@ -289,7 +289,7 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory,
|
||||
function self.setAccountMoney(accountName, money, reason)
|
||||
reason = reason or "unknown"
|
||||
if not tonumber(money) then
|
||||
error(("Tried To Set Account ^5%s^0 For Player ^5%s^0 To An Invalid Number -> ^5%s^7"):format(accountName, self.playerId, money))
|
||||
error(("Tried To Set Account ^5%s^1 For Player ^5%s^1 To An Invalid Number -> ^5%s^1"):format(accountName, self.playerId, money))
|
||||
return
|
||||
end
|
||||
if money >= 0 then
|
||||
@@ -302,10 +302,10 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory,
|
||||
self.triggerEvent("esx:setAccountMoney", account)
|
||||
TriggerEvent("esx:setAccountMoney", self.source, accountName, money, reason)
|
||||
else
|
||||
error(("Tried To Set Invalid Account ^5%s^0 For Player ^5%s^0!"):format(accountName, self.playerId))
|
||||
error(("Tried To Set Invalid Account ^5%s^1 For Player ^5%s^1!"):format(accountName, self.playerId))
|
||||
end
|
||||
else
|
||||
error(("Tried To Set Account ^5%s^0 For Player ^5%s^0 To An Invalid Number -> ^5%s^7"):format(accountName, self.playerId, money))
|
||||
error(("Tried To Set Account ^5%s^1 For Player ^5%s^1 To An Invalid Number -> ^5%s^1"):format(accountName, self.playerId, money))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -316,7 +316,7 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory,
|
||||
function self.addAccountMoney(accountName, money, reason)
|
||||
reason = reason or "Unknown"
|
||||
if not tonumber(money) then
|
||||
error(("Tried To Set Account ^5%s^0 For Player ^5%s^0 To An Invalid Number -> ^5%s^7"):format(accountName, self.playerId, money))
|
||||
error(("Tried To Set Account ^5%s^1 For Player ^5%s^1 To An Invalid Number -> ^5%s^1"):format(accountName, self.playerId, money))
|
||||
return
|
||||
end
|
||||
if money > 0 then
|
||||
@@ -328,10 +328,10 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory,
|
||||
self.triggerEvent("esx:setAccountMoney", account)
|
||||
TriggerEvent("esx:addAccountMoney", self.source, accountName, money, reason)
|
||||
else
|
||||
error(("Tried To Set Add To Invalid Account ^5%s^0 For Player ^5%s^0!"):format(accountName, self.playerId))
|
||||
error(("Tried To Set Add To Invalid Account ^5%s^1 For Player ^5%s^1!"):format(accountName, self.playerId))
|
||||
end
|
||||
else
|
||||
error(("Tried To Set Account ^5%s^0 For Player ^5%s^0 To An Invalid Number -> ^5%s^7"):format(accountName, self.playerId, money))
|
||||
error(("Tried To Set Account ^5%s^1 For Player ^5%s^1 To An Invalid Number -> ^5%s^1"):format(accountName, self.playerId, money))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -342,7 +342,7 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory,
|
||||
function self.removeAccountMoney(accountName, money, reason)
|
||||
reason = reason or "Unknown"
|
||||
if not tonumber(money) then
|
||||
error(("Tried To Set Account ^5%s^0 For Player ^5%s^0 To An Invalid Number -> ^5%s^7"):format(accountName, self.playerId, money))
|
||||
error(("Tried To Set Account ^5%s^1 For Player ^5%s^1 To An Invalid Number -> ^5%s^1"):format(accountName, self.playerId, money))
|
||||
return
|
||||
end
|
||||
if money > 0 then
|
||||
@@ -351,7 +351,7 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory,
|
||||
if account then
|
||||
money = account.round and ESX.Math.Round(money) or money
|
||||
if self.accounts[account.index].money - money > self.accounts[account.index].money then
|
||||
error(("Tried To Underflow Account ^5%s^0 For Player ^5%s^0!"):format(accountName, self.playerId))
|
||||
error(("Tried To Underflow Account ^5%s^1 For Player ^5%s^1!"):format(accountName, self.playerId))
|
||||
return
|
||||
end
|
||||
self.accounts[account.index].money = self.accounts[account.index].money - money
|
||||
@@ -359,10 +359,10 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory,
|
||||
self.triggerEvent("esx:setAccountMoney", account)
|
||||
TriggerEvent("esx:removeAccountMoney", self.source, accountName, money, reason)
|
||||
else
|
||||
error(("Tried To Set Add To Invalid Account ^5%s^0 For Player ^5%s^0!"):format(accountName, self.playerId))
|
||||
error(("Tried To Set Add To Invalid Account ^5%s^1 For Player ^5%s^1!"):format(accountName, self.playerId))
|
||||
end
|
||||
else
|
||||
error(("Tried To Set Account ^5%s^0 For Player ^5%s^0 To An Invalid Number -> ^5%s^7"):format(accountName, self.playerId, money))
|
||||
error(("Tried To Set Account ^5%s^1 For Player ^5%s^1 To An Invalid Number -> ^5%s^1"):format(accountName, self.playerId, money))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -621,7 +621,7 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory,
|
||||
local weaponLabel, playerPed <const> = nil, GetPlayerPed(self.source)
|
||||
|
||||
if not playerPed then
|
||||
return error("xPlayer.removeWeapon ^5invalid^7 player ped!")
|
||||
return error("xPlayer.removeWeapon ^5invalid^1 player ped!")
|
||||
end
|
||||
|
||||
for k, v in ipairs(self.loadout) do
|
||||
@@ -778,13 +778,13 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory,
|
||||
end
|
||||
|
||||
if type(index) ~= "string" then
|
||||
error("xPlayer.getMeta ^5index^7 should be ^5string^7!")
|
||||
error("xPlayer.getMeta ^5index^1 should be ^5string^1!")
|
||||
return
|
||||
end
|
||||
|
||||
local metaData = self.metadata[index]
|
||||
if metaData == nil then
|
||||
return Config.EnableDebug and error(("xPlayer.getMeta ^5%s^7 not exist!"):format(index)) or nil
|
||||
return Config.EnableDebug and error(("xPlayer.getMeta ^5%s^1 not exist!"):format(index)) or nil
|
||||
end
|
||||
|
||||
if subIndex and type(metaData) == "table" then
|
||||
@@ -803,14 +803,14 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory,
|
||||
if type(key) == "string" then
|
||||
returnValues[key] = self.getMeta(index, key)
|
||||
else
|
||||
error(("xPlayer.getMeta subIndex should be ^5string^7 or ^5table^7! that contains ^5string^7, received ^5%s^7!, skipping..."):format(type(key)))
|
||||
error(("xPlayer.getMeta subIndex should be ^5string^1 or ^5table^1! that contains ^5string^1, received ^5%s^1!, skipping..."):format(type(key)))
|
||||
end
|
||||
end
|
||||
|
||||
return returnValues
|
||||
end
|
||||
|
||||
error(("xPlayer.getMeta subIndex should be ^5string^7 or ^5table^7!, received ^5%s^7!"):format(_type))
|
||||
error(("xPlayer.getMeta subIndex should be ^5string^1 or ^5table^1!, received ^5%s^1!"):format(_type))
|
||||
return
|
||||
end
|
||||
|
||||
@@ -823,11 +823,11 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory,
|
||||
---@return nil
|
||||
function self.setMeta(index, value, subValue)
|
||||
if not index then
|
||||
return error("xPlayer.setMeta ^5index^7 is Missing!")
|
||||
return error("xPlayer.setMeta ^5index^1 is Missing!")
|
||||
end
|
||||
|
||||
if type(index) ~= "string" then
|
||||
return error("xPlayer.setMeta ^5index^7 should be ^5string^7!")
|
||||
return error("xPlayer.setMeta ^5index^1 should be ^5string^1!")
|
||||
end
|
||||
|
||||
if value == nil then
|
||||
@@ -838,13 +838,13 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory,
|
||||
|
||||
if not subValue then
|
||||
if _type ~= "number" and _type ~= "string" and _type ~= "table" then
|
||||
return error(("xPlayer.setMeta ^5%s^7 should be ^5number^7 or ^5string^7 or ^5table^7!"):format(value))
|
||||
return error(("xPlayer.setMeta ^5%s^1 should be ^5number^1 or ^5string^1 or ^5table^1!"):format(value))
|
||||
end
|
||||
|
||||
self.metadata[index] = value
|
||||
else
|
||||
if _type ~= "string" then
|
||||
return error(("xPlayer.setMeta ^5value^7 should be ^5string^7 as a subIndex!"):format(value))
|
||||
return error(("xPlayer.setMeta ^5value^1 should be ^5string^1 as a subIndex!"):format(value))
|
||||
end
|
||||
|
||||
if not self.metadata[index] or type(self.metadata[index]) ~= "table" then
|
||||
@@ -859,16 +859,16 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory,
|
||||
|
||||
function self.clearMeta(index, subValues)
|
||||
if not index then
|
||||
return error("xPlayer.clearMeta ^5index^7 is Missing!")
|
||||
return error("xPlayer.clearMeta ^5index^1 is Missing!")
|
||||
end
|
||||
|
||||
if type(index) ~= "string" then
|
||||
return error("xPlayer.clearMeta ^5index^7 should be ^5string^7!")
|
||||
return error("xPlayer.clearMeta ^5index^1 should be ^5string^1!")
|
||||
end
|
||||
|
||||
local metaData = self.metadata[index]
|
||||
if metaData == nil then
|
||||
return Config.EnableDebug and error(("xPlayer.clearMeta ^5%s^7 does not exist!"):format(index)) or nil
|
||||
return Config.EnableDebug and error(("xPlayer.clearMeta ^5%s^1 does not exist!"):format(index)) or nil
|
||||
end
|
||||
|
||||
if not subValues then
|
||||
@@ -879,7 +879,7 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory,
|
||||
if type(metaData) == "table" then
|
||||
metaData[subValues] = nil
|
||||
else
|
||||
return error(("xPlayer.clearMeta ^5%s^7 is not a table! Cannot clear subValue ^5%s^7."):format(index, subValues))
|
||||
return error(("xPlayer.clearMeta ^5%s^1 is not a table! Cannot clear subValue ^5%s^1."):format(index, subValues))
|
||||
end
|
||||
elseif type(subValues) == "table" then
|
||||
-- If subValues is a table, we will clear multiple subValues within the table
|
||||
@@ -889,14 +889,14 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory,
|
||||
if type(metaData) == "table" then
|
||||
metaData[subValue] = nil
|
||||
else
|
||||
error(("xPlayer.clearMeta ^5%s^7 is not a table! Cannot clear subValue ^5%s^7."):format(index, subValue))
|
||||
error(("xPlayer.clearMeta ^5%s^1 is not a table! Cannot clear subValue ^5%s^1."):format(index, subValue))
|
||||
end
|
||||
else
|
||||
error(("xPlayer.clearMeta subValues should contain ^5string^7, received ^5%s^7, skipping..."):format(type(subValue)))
|
||||
error(("xPlayer.clearMeta subValues should contain ^5string^1, received ^5%s^1, skipping..."):format(type(subValue)))
|
||||
end
|
||||
end
|
||||
else
|
||||
return error(("xPlayer.clearMeta ^5subValues^7 should be ^5string^7 or ^5table^7, received ^5%s^7!"):format(type(subValues)))
|
||||
return error(("xPlayer.clearMeta ^5subValues^1 should be ^5string^1 or ^5table^1, received ^5%s^1!"):format(type(subValues)))
|
||||
end
|
||||
self.triggerEvent('esx:updatePlayerData', 'metadata', self.metadata)
|
||||
end
|
||||
|
||||
@@ -695,13 +695,13 @@ AddEventHandler("onResourceStart", function(key)
|
||||
end
|
||||
|
||||
StopResource(key)
|
||||
error(("WE STOPPED A RESOURCE THAT WILL BREAK ^1ESX^7, PLEASE REMOVE ^5%s^7"):format(key))
|
||||
error(("WE STOPPED A RESOURCE THAT WILL BREAK ^1ESX^1, PLEASE REMOVE ^5%s^1"):format(key))
|
||||
end
|
||||
end)
|
||||
|
||||
for key in pairs(DoNotUse) do
|
||||
if GetResourceState(key) == "started" or GetResourceState(key) == "starting" then
|
||||
StopResource(key)
|
||||
error(("WE STOPPED A RESOURCE THAT WILL BREAK ^1ESX^7, PLEASE REMOVE ^5%s^7"):format(key))
|
||||
error(("WE STOPPED A RESOURCE THAT WILL BREAK ^1ESX^1, PLEASE REMOVE ^5%s^1"):format(key))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -11,7 +11,7 @@ end
|
||||
|
||||
RegisterNetEvent("esx:triggerServerCallback", function(eventName, requestId, invoker, ...)
|
||||
if not serverCallbacks[eventName] then
|
||||
return error(("Server Callback not registered, name: ^5%s^7, invoker resource: ^5%s^7"):format(eventName, invoker))
|
||||
return error(("Server Callback not registered, name: ^5%s^1, invoker resource: ^5%s^1"):format(eventName, invoker))
|
||||
end
|
||||
|
||||
local source = source
|
||||
@@ -35,7 +35,7 @@ end
|
||||
|
||||
RegisterNetEvent("esx:clientCallback", function(requestId, invoker, ...)
|
||||
if not clientRequests[requestId] then
|
||||
return error(("Client Callback with requestId ^5%s^7 Was Called by ^5%s^7 but does not exist."):format(requestId, invoker))
|
||||
return error(("Client Callback with requestId ^5%s^1 Was Called by ^5%s^1 but does not exist."):format(requestId, invoker))
|
||||
end
|
||||
|
||||
clientRequests[requestId](...)
|
||||
|
||||
@@ -7,7 +7,7 @@ do
|
||||
local connectionString = GetConvar("mysql_connection_string", "")
|
||||
|
||||
if connectionString == "" then
|
||||
error(connectionString .. "\n^1Unable to start Multicharacter - unable to determine database from mysql_connection_string^0", 0)
|
||||
error(connectionString .. "\n^1Unable to start Multicharacter - unable to determine database from mysql_connection_string^1", 0)
|
||||
elseif connectionString:find("mysql://") then
|
||||
connectionString = connectionString:sub(9, -1)
|
||||
DATABASE = connectionString:sub(connectionString:find("/") + 1, -1):gsub("[%?]+[%w%p]*$", "")
|
||||
@@ -151,7 +151,7 @@ local function DeleteCharacter(source, charid)
|
||||
Wait(50)
|
||||
SetupCharacters(source)
|
||||
else
|
||||
error("\n^1Transaction failed while trying to delete " .. identifier .. "^0")
|
||||
error("\n^1Transaction failed while trying to delete " .. identifier .. "^1")
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user