Skip to content

Commit c63620f

Browse files
authored
Merge pull request #1424 from esx-framework/dev
🔁 Dev -> main
2 parents 2c14e5b + 6728540 commit c63620f

File tree

13 files changed

+63
-58
lines changed

13 files changed

+63
-58
lines changed

[core]/es_extended/client/common.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ end)
44

55
AddEventHandler("esx:getSharedObject", function()
66
local Invoke = GetInvokingResource()
7-
print(("[^1ERROR^7] 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))
7+
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))
88
end)

[core]/es_extended/client/functions.lua

+9-7
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,13 @@ function ESX.RefreshContext(...)
140140
end
141141

142142
function ESX.RegisterInput(command_name, label, input_group, key, on_press, on_release)
143-
RegisterCommand(on_release and '+' .. command_name or command_name, on_press)
144-
Core.Input[command_name] = ESX.HashString(command_name)
143+
local command = on_release and '+' .. command_name or command_name
144+
RegisterCommand(command, on_press)
145+
Core.Input[command_name] = ESX.HashString(command)
145146
if on_release then
146147
RegisterCommand('-' .. command_name, on_release)
147148
end
148-
RegisterKeyMapping(command_name, label or '', input_group or 'keyboard', key or '')
149+
RegisterKeyMapping(command, label or '', input_group or 'keyboard', key or '')
149150
end
150151

151152
function ESX.UI.Menu.RegisterType(menuType, open, close)
@@ -321,7 +322,7 @@ function ESX.Game.Teleport(entity, coords, cb)
321322
end
322323

323324
function ESX.Game.SpawnObject(object, coords, cb, networked)
324-
local obj = CreateObject(ESX.Streaming.RequestModel(object), coords.x, coords.y. coords.z, networked == nil or networked, false, true)
325+
local obj = CreateObject(ESX.Streaming.RequestModel(object), coords.x, coords.y, coords.z, networked == nil or networked, false, true)
325326
return cb and cb(obj) or obj
326327
end
327328

@@ -352,7 +353,7 @@ function ESX.Game.SpawnVehicle(vehicleModel, coords, heading, cb, networked)
352353
local dist = #(playerCoords - vector)
353354
if dist > 424 then -- Onesync infinity Range (https://docs.fivem.net/docs/scripting-reference/onesync/)
354355
local executingResource = GetInvokingResource() or "Unknown"
355-
return print(("[^1ERROR^7] Resource ^5%s^7 Tried to spawn vehicle on the client but the position is too far away (Out of onesync range)."):format(executingResource))
356+
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))
356357
end
357358

358359
CreateThread(function()
@@ -491,8 +492,9 @@ end
491492

492493
function ESX.Game.RaycastScreen(depth, ...)
493494
local world, normal = GetWorldCoordFromScreenCoord(.5, .5)
495+
local origin = world + normal
494496
local target = world + normal * depth
495-
return target, ESX.Game.GetShapeTestResultAsync(StartShapeTestLosProbe(world + normal, target, ...))
497+
return target, ESX.Game.GetShapeTestResultSync(StartShapeTestLosProbe(origin.x, origin.y, origin.z, target.x, target.y, target.z, ...))
496498
end
497499

498500
function ESX.Game.GetClosestEntity(entities, isPlayerEntities, coords, modelFilter)
@@ -507,7 +509,7 @@ function ESX.Game.GetClosestEntity(entities, isPlayerEntities, coords, modelFilt
507509

508510
if modelFilter then
509511
filteredEntities = {}
510-
512+
511513
for currentEntityIndex = 1, #entities do
512514
if modelFilter[GetEntityModel(entities[currentEntityIndex])] then
513515
filteredEntities[#filteredEntities + 1] = entities[currentEntityIndex]

[core]/es_extended/client/main.lua

+6-6
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function ESX.SpawnPlayer(skin, coords, cb)
3737
while not HasCollisionLoadedAroundEntity(playerPed) and (GetGameTimer() - timer) < 5000 do
3838
Wait(0)
3939
end
40-
40+
4141
NetworkResurrectLocalPlayer(coords.x, coords.y, coords.z, coords.heading, true, true, false)
4242
TriggerEvent('playerSpawned', coords)
4343
cb()
@@ -337,17 +337,17 @@ if not Config.OxInventory then
337337

338338
RegisterNetEvent("esx:addWeapon")
339339
AddEventHandler("esx:addWeapon", function()
340-
print("[^1ERROR^7] event ^5'esx:addWeapon'^7 Has Been Removed. Please use ^5xPlayer.addWeapon^7 Instead!")
340+
error("event ^5'esx:addWeapon'^7 Has Been Removed. Please use ^5xPlayer.addWeapon^7 Instead!")
341341
end)
342342

343343
RegisterNetEvent("esx:addWeaponComponent")
344344
AddEventHandler("esx:addWeaponComponent", function()
345-
print("[^1ERROR^7] event ^5'esx:addWeaponComponent'^7 Has Been Removed. Please use ^5xPlayer.addWeaponComponent^7 Instead!")
345+
error("event ^5'esx:addWeaponComponent'^7 Has Been Removed. Please use ^5xPlayer.addWeaponComponent^7 Instead!")
346346
end)
347347

348348
RegisterNetEvent("esx:setWeaponAmmo")
349349
AddEventHandler("esx:setWeaponAmmo", function()
350-
print("[^1ERROR^7] event ^5'esx:setWeaponAmmo'^7 Has Been Removed. Please use ^5xPlayer.addWeaponAmmo^7 Instead!")
350+
error("event ^5'esx:setWeaponAmmo'^7 Has Been Removed. Please use ^5xPlayer.addWeaponAmmo^7 Instead!")
351351
end)
352352

353353
RegisterNetEvent("esx:setWeaponTint")
@@ -357,7 +357,7 @@ if not Config.OxInventory then
357357

358358
RegisterNetEvent("esx:removeWeapon")
359359
AddEventHandler("esx:removeWeapon", function()
360-
print("[^1ERROR^7] event ^5'esx:removeWeapon'^7 Has Been Removed. Please use ^5xPlayer.removeWeapon^7 Instead!")
360+
error("event ^5'esx:removeWeapon'^7 Has Been Removed. Please use ^5xPlayer.removeWeapon^7 Instead!")
361361
end)
362362

363363
RegisterNetEvent("esx:removeWeaponComponent")
@@ -721,4 +721,4 @@ end)
721721

722722
RegisterNetEvent('esx:updatePlayerData', function(key, val)
723723
ESX.SetPlayerData(key, val)
724-
end)
724+
end)

[core]/es_extended/client/modules/callback.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ end
1616

1717
RegisterNetEvent("esx:serverCallback", function(requestId, invoker, ...)
1818
if not serverRequests[requestId] then
19-
return print(("[^1ERROR^7] Server Callback with requestId ^5%s^7 Was Called by ^5%s^7 but does not exist."):format(requestId, invoker))
19+
return error(("Server Callback with requestId ^5%s^7 Was Called by ^5%s^7 but does not exist."):format(requestId, invoker))
2020
end
2121

2222
serverRequests[requestId](...)
@@ -31,7 +31,7 @@ end
3131

3232
RegisterNetEvent("esx:triggerClientCallback", function(eventName, requestId, invoker, ...)
3333
if not clientCallbacks[eventName] then
34-
return print(("[^1ERROR^7] Client Callback not registered, name: ^5%s^7, invoker resource: ^5%s^7"):format(eventName, invoker))
34+
return error(("Client Callback not registered, name: ^5%s^7, invoker resource: ^5%s^7"):format(eventName, invoker))
3535
end
3636

3737
clientCallbacks[eventName](function(...)

[core]/es_extended/config.lua

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
Config = {}
2-
Config.Locale = GetConvar("esx:locale", "en")
2+
3+
local txAdminLocale = GetConvar("txAdmin-locale", "en")
4+
local esxLocale = GetConvar("esx:locale", "invalid")
5+
6+
Config.Locale = (esxLocale ~= "invalid") and esxLocale or (txAdminLocale ~= "custom" and txAdminLocale) or "en"
37

48
Config.OxInventory = GetResourceState("ox_inventory") ~= 'missing'
59

[core]/es_extended/locale.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Locales = {}
22

33
function Translate(str, ...) -- Translate string
44
if not str then
5-
print(("[^1ERROR^7] Resource ^5%s^7 You did not specify a parameter for the Translate function or the value is nil!"):format(GetInvokingResource() or GetCurrentResourceName()))
5+
error(("Resource ^5%s^7 You did not specify a parameter for the Translate function or the value is nil!"):format(GetInvokingResource() or GetCurrentResourceName()))
66
return "Given translate function parameter is nil!"
77
end
88
if Locales[Config.Locale] then

[core]/es_extended/server/classes/player.lua

+28-28
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory,
273273
function self.setAccountMoney(accountName, money, reason)
274274
reason = reason or "unknown"
275275
if not tonumber(money) then
276-
print(("[^1ERROR^7] Tried To Set Account ^5%s^0 For Player ^5%s^0 To An Invalid Number -> ^5%s^7"):format(accountName, self.playerId, money))
276+
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))
277277
return
278278
end
279279
if money >= 0 then
@@ -286,10 +286,10 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory,
286286
self.triggerEvent("esx:setAccountMoney", account)
287287
_TriggerEvent("esx:setAccountMoney", self.source, accountName, money, reason)
288288
else
289-
print(("[^1ERROR^7] Tried To Set Invalid Account ^5%s^0 For Player ^5%s^0!"):format(accountName, self.playerId))
289+
error(("Tried To Set Invalid Account ^5%s^0 For Player ^5%s^0!"):format(accountName, self.playerId))
290290
end
291291
else
292-
print(("[^1ERROR^7] Tried To Set Account ^5%s^0 For Player ^5%s^0 To An Invalid Number -> ^5%s^7"):format(accountName, self.playerId, money))
292+
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))
293293
end
294294
end
295295

@@ -300,7 +300,7 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory,
300300
function self.addAccountMoney(accountName, money, reason)
301301
reason = reason or "Unknown"
302302
if not tonumber(money) then
303-
print(("[^1ERROR^7] Tried To Set Account ^5%s^0 For Player ^5%s^0 To An Invalid Number -> ^5%s^7"):format(accountName, self.playerId, money))
303+
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))
304304
return
305305
end
306306
if money > 0 then
@@ -312,10 +312,10 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory,
312312
self.triggerEvent("esx:setAccountMoney", account)
313313
_TriggerEvent("esx:addAccountMoney", self.source, accountName, money, reason)
314314
else
315-
print(("[^1ERROR^7] Tried To Set Add To Invalid Account ^5%s^0 For Player ^5%s^0!"):format(accountName, self.playerId))
315+
error(("Tried To Set Add To Invalid Account ^5%s^0 For Player ^5%s^0!"):format(accountName, self.playerId))
316316
end
317317
else
318-
print(("[^1ERROR^7] Tried To Set Account ^5%s^0 For Player ^5%s^0 To An Invalid Number -> ^5%s^7"):format(accountName, self.playerId, money))
318+
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))
319319
end
320320
end
321321

@@ -326,7 +326,7 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory,
326326
function self.removeAccountMoney(accountName, money, reason)
327327
reason = reason or "Unknown"
328328
if not tonumber(money) then
329-
print(("[^1ERROR^7] Tried To Set Account ^5%s^0 For Player ^5%s^0 To An Invalid Number -> ^5%s^7"):format(accountName, self.playerId, money))
329+
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))
330330
return
331331
end
332332
if money > 0 then
@@ -335,18 +335,18 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory,
335335
if account then
336336
money = account.round and ESX.Math.Round(money) or money
337337
if self.accounts[account.index].money - money > self.accounts[account.index].money then
338-
print(("[^1ERROR^7] Tried To Underflow Account ^5%s^0 For Player ^5%s^0!"):format(accountName, self.playerId))
338+
error(("Tried To Underflow Account ^5%s^0 For Player ^5%s^0!"):format(accountName, self.playerId))
339339
return
340340
end
341341
self.accounts[account.index].money = self.accounts[account.index].money - money
342342

343343
self.triggerEvent("esx:setAccountMoney", account)
344344
_TriggerEvent("esx:removeAccountMoney", self.source, accountName, money, reason)
345345
else
346-
print(("[^1ERROR^7] Tried To Set Add To Invalid Account ^5%s^0 For Player ^5%s^0!"):format(accountName, self.playerId))
346+
error(("Tried To Set Add To Invalid Account ^5%s^0 For Player ^5%s^0!"):format(accountName, self.playerId))
347347
end
348348
else
349-
print(("[^1ERROR^7] Tried To Set Account ^5%s^0 For Player ^5%s^0 To An Invalid Number -> ^5%s^7"):format(accountName, self.playerId, money))
349+
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))
350350
end
351351
end
352352

@@ -396,7 +396,7 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory,
396396
self.triggerEvent("esx:removeInventoryItem", item.name, item.count)
397397
end
398398
else
399-
print(("[^1ERROR^7] Player ID:^5%s Tried remove a Invalid count -> %s of %s"):format(self.playerId, count, itemName))
399+
error(("Player ID:^5%s Tried remove a Invalid count -> %s of %s"):format(self.playerId, count, itemName))
400400
end
401401
end
402402
end
@@ -598,7 +598,7 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory,
598598
local weaponLabel, playerPed <const> = nil, _GetPlayerPed(self.source)
599599

600600
if not playerPed then
601-
return print("[^1ERROR^7] xPlayer.removeWeapon ^5invalid^7 player ped!")
601+
return error("xPlayer.removeWeapon ^5invalid^7 player ped!")
602602
end
603603

604604
for k, v in ipairs(self.loadout) do
@@ -755,12 +755,12 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory,
755755
end
756756

757757
if type(index) ~= "string" then
758-
return print("[^1ERROR^7] xPlayer.getMeta ^5index^7 should be ^5string^7!")
758+
return error("xPlayer.getMeta ^5index^7 should be ^5string^7!")
759759
end
760760

761761
local metaData = self.metadata[index]
762762
if metaData == nil then
763-
return Config.EnableDebug and print(("[^1ERROR^7] xPlayer.getMeta ^5%s^7 not exist!"):format(index)) or nil
763+
return Config.EnableDebug and error(("xPlayer.getMeta ^5%s^7 not exist!"):format(index)) or nil
764764
end
765765

766766
if subIndex and type(metaData) == "table" then
@@ -779,14 +779,14 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory,
779779
if type(key) == "string" then
780780
returnValues[key] = self.getMeta(index, key)
781781
else
782-
print(("[^1ERROR^7] xPlayer.getMeta subIndex should be ^5string^7 or ^5table^7! that contains ^5string^7, received ^5%s^7!, skipping..."):format(type(key)))
782+
error(("xPlayer.getMeta subIndex should be ^5string^7 or ^5table^7! that contains ^5string^7, received ^5%s^7!, skipping..."):format(type(key)))
783783
end
784784
end
785785

786786
return returnValues
787787
end
788788

789-
return print(("[^1ERROR^7] xPlayer.getMeta subIndex should be ^5string^7 or ^5table^7!, received ^5%s^7!"):format(_type))
789+
return error(("xPlayer.getMeta subIndex should be ^5string^7 or ^5table^7!, received ^5%s^7!"):format(_type))
790790
end
791791

792792
return metaData
@@ -798,28 +798,28 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory,
798798
---@return void
799799
function self.setMeta(index, value, subValue)
800800
if not index then
801-
return print("[^1ERROR^7] xPlayer.setMeta ^5index^7 is Missing!")
801+
return error("xPlayer.setMeta ^5index^7 is Missing!")
802802
end
803803

804804
if type(index) ~= "string" then
805-
return print("[^1ERROR^7] xPlayer.setMeta ^5index^7 should be ^5string^7!")
805+
return error("xPlayer.setMeta ^5index^7 should be ^5string^7!")
806806
end
807807

808808
if value == nil then
809-
return print("[^1ERROR^7] xPlayer.setMeta value is missing!")
809+
return error("xPlayer.setMeta value is missing!")
810810
end
811811

812812
local _type = type(value)
813813

814814
if not subValue then
815815
if _type ~= "number" and _type ~= "string" and _type ~= "table" then
816-
return print(("[^1ERROR^7] xPlayer.setMeta ^5%s^7 should be ^5number^7 or ^5string^7 or ^5table^7!"):format(value))
816+
return error(("xPlayer.setMeta ^5%s^7 should be ^5number^7 or ^5string^7 or ^5table^7!"):format(value))
817817
end
818818

819819
self.metadata[index] = value
820820
else
821821
if _type ~= "string" then
822-
return print(("[^1ERROR^7] xPlayer.setMeta ^5value^7 should be ^5string^7 as a subIndex!"):format(value))
822+
return error(("xPlayer.setMeta ^5value^7 should be ^5string^7 as a subIndex!"):format(value))
823823
end
824824

825825
if not self.metadata[index] or type(self.metadata[index]) ~= "table" then
@@ -834,16 +834,16 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory,
834834

835835
function self.clearMeta(index, subValues)
836836
if not index then
837-
return print("[^1ERROR^7] xPlayer.clearMeta ^5index^7 is Missing!")
837+
return error("xPlayer.clearMeta ^5index^7 is Missing!")
838838
end
839839

840840
if type(index) ~= "string" then
841-
return print("[^1ERROR^7] xPlayer.clearMeta ^5index^7 should be ^5string^7!")
841+
return error("xPlayer.clearMeta ^5index^7 should be ^5string^7!")
842842
end
843843

844844
local metaData = self.metadata[index]
845845
if metaData == nil then
846-
return Config.EnableDebug and print(("[^1ERROR^7] xPlayer.clearMeta ^5%s^7 does not exist!"):format(index)) or nil
846+
return Config.EnableDebug and error(("xPlayer.clearMeta ^5%s^7 does not exist!"):format(index)) or nil
847847
end
848848

849849
if not subValues then
@@ -854,7 +854,7 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory,
854854
if type(metaData) == "table" then
855855
metaData[subValues] = nil
856856
else
857-
return print(("[^1ERROR^7] xPlayer.clearMeta ^5%s^7 is not a table! Cannot clear subValue ^5%s^7."):format(index, subValues))
857+
return error(("xPlayer.clearMeta ^5%s^7 is not a table! Cannot clear subValue ^5%s^7."):format(index, subValues))
858858
end
859859
elseif type(subValues) == "table" then
860860
-- If subValues is a table, we will clear multiple subValues within the table
@@ -864,14 +864,14 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory,
864864
if type(metaData) == "table" then
865865
metaData[subValue] = nil
866866
else
867-
print(("[^1ERROR^7] xPlayer.clearMeta ^5%s^7 is not a table! Cannot clear subValue ^5%s^7."):format(index, subValue))
867+
error(("xPlayer.clearMeta ^5%s^7 is not a table! Cannot clear subValue ^5%s^7."):format(index, subValue))
868868
end
869869
else
870-
print(("[^1ERROR^7] xPlayer.clearMeta subValues should contain ^5string^7, received ^5%s^7, skipping..."):format(type(subValue)))
870+
error(("xPlayer.clearMeta subValues should contain ^5string^7, received ^5%s^7, skipping..."):format(type(subValue)))
871871
end
872872
end
873873
else
874-
return print(("[^1ERROR^7] xPlayer.clearMeta ^5subValues^7 should be ^5string^7 or ^5table^7, received ^5%s^7!"):format(type(subValues)))
874+
return error(("xPlayer.clearMeta ^5subValues^7 should be ^5string^7 or ^5table^7, received ^5%s^7!"):format(type(subValues)))
875875
end
876876
self.triggerEvent('esx:updatePlayerData', 'metadata', self.metadata)
877877
end

[core]/es_extended/server/common.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ end)
2020

2121
AddEventHandler("esx:getSharedObject", function()
2222
local Invoke = GetInvokingResource()
23-
print(("[^1ERROR^7] 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))
23+
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))
2424
end)
2525

2626
exports("getSharedObject", function()

0 commit comments

Comments
 (0)