Skip to content

Commit

Permalink
chore: ox_lib update to version 3.10.1
Browse files Browse the repository at this point in the history
  • Loading branch information
bitpredator committed Oct 11, 2023
1 parent c92c96d commit a2964cb
Show file tree
Hide file tree
Showing 10 changed files with 119 additions and 37 deletions.
2 changes: 1 addition & 1 deletion server-data/resources/[ox]/ox_lib/fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ rdr3_warning 'I acknowledge that this is a prerelease build of RedM, and I am aw
--[[ Resource Information ]]--
name 'ox_lib'
author 'Overextended'
version '3.9.1'
version '3.10.1'
license 'LGPL-3.0-or-later'
repository 'https://github.com/overextended/ox_lib'
description 'A library of shared functions to utilise in other resources.'
Expand Down
4 changes: 2 additions & 2 deletions server-data/resources/[ox]/ox_lib/imports/callback/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ lib.callback = setmetatable({}, {
})

---@param event string
---@param delay number | false prevent the event from being called for the given time
--- Sends an event to the server and halts the current thread until a response is returned.
---@param delay? number | false prevent the event from being called for the given time.
---Sends an event to the server and halts the current thread until a response is returned.
function lib.callback.await(event, delay, ...)
return triggerServerCallback(nil, event, delay, false, ...)
end
Expand Down
47 changes: 47 additions & 0 deletions server-data/resources/[ox]/ox_lib/imports/print/shared.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---@enum PrintLevel
local printLevel = {
error = 1,
warn = 2,
info = 3,
verbose = 4,
debug = 5,
}

local levelPrefixes = {
'^1[ERROR]',
'^3[WARN]',
'^7[INFO]',
'^4[VERBOSE]',
'^6[DEBUG]',
}

local resourcePrintLevel = printLevel[GetConvar('ox:printlevel:' .. cache.resource, GetConvar('ox:printlevel', 'info'))]
local template = ('^5[%s] %%s %%s^7'):format(cache.resource)
local jsonOptions = { sort_keys = true, indent = true }

---Prints to console conditionally based on what ox:printlevel is.
---Any print with a level more severe will also print. If ox:printlevel is info, then warn and error prints will appear as well, but debug prints will not.
---@param level PrintLevel
---@param ... any
local function libPrint(level, ...)
if level > resourcePrintLevel then return end

local args = { ... }

for i = 1, #args do
local arg = args[i]
args[i] = type(arg) == 'table' and json.encode(arg, jsonOptions) or tostring(arg)
end

print(template:format(levelPrefixes[level], table.concat(args, '\t')))
end

lib.print = {
error = function(...) libPrint(printLevel.error, ...) end,
warn = function(...) libPrint(printLevel.warn, ...) end,
info = function(...) libPrint(printLevel.info, ...) end,
verbose = function(...) libPrint(printLevel.verbose, ...) end,
debug = function(...) libPrint(printLevel.debug, ...) end,
}

return lib.print
50 changes: 41 additions & 9 deletions server-data/resources/[ox]/ox_lib/imports/require/shared.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,61 @@ local _require = require
function lib.require(modname)
if type(modname) ~= 'string' then return end

local modpath = modname:gsub('%.', '/')
local module = loaded[modname]

if module then return module end

local success, result = pcall(_require, modname)

if success then
loaded[modname] = result
return result
end

local resourceSrc

if not modpath:find('^@') then
local idx = 1

while true do
local di = debug.getinfo(idx, 'S')

if di then
if not di.short_src:find('^@ox_lib/imports/require') and not di.short_src:find('^%[C%]') and not di.short_src:find('^citizen') then
resourceSrc = di.short_src:gsub('^@(.-)/.+', '%1')
break
end
else
resourceSrc = cache.resource
break
end

idx += 1
end

if resourceSrc ~= cache.resource then
modname = ('@%s.%s'):format(resourceSrc, modname)
end
end

if not module then
if module == false then
error(("^1circular-dependency occurred when loading module '%s'^0"):format(modname), 2)
end

local success, result = pcall(_require, modname)

if success then
loaded[modname] = result
return result
if not resourceSrc then
resourceSrc = modpath:gsub('^@(.-)/.+', '%1')
modpath = modpath:sub(#resourceSrc + 3)
end

local modpath = modname:gsub('%.', '/')

for path in package.path:gmatch('[^;]+') do
local scriptPath = path:gsub('?', modpath):gsub('%.+%/+', '')
local resourceFile = LoadResourceFile(cache.resource, scriptPath)
local resourceFile = LoadResourceFile(resourceSrc, scriptPath)

if resourceFile then
loaded[modname] = false
scriptPath = ('@@%s/%s'):format(cache.resource, scriptPath)
scriptPath = ('@@%s/%s'):format(resourceSrc, scriptPath)

local chunk, err = load(resourceFile, scriptPath)

Expand Down
10 changes: 5 additions & 5 deletions server-data/resources/[ox]/ox_lib/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
"confirm": "Bestätigen",
"more": "Mehr..."
},
"txadmin_announcement": "Server announcement by %s",
"txadmin_dm": "Direct Message from %s",
"txadmin_warn": "You have been warned by %s",
"txadmin_warn_content": "%s \nAction ID: %s",
"txadmin_scheduledrestart": "Scheduled Restart"
"txadmin_announcement": "Serverankündigung von %s",
"txadmin_dm": "Direktnachricht von %s",
"txadmin_warn": "Du wurdest von %s gewarnt",
"txadmin_warn_content": "%s \nVerwarn ID: %s",
"txadmin_scheduledrestart": "Geplanter Neustart"
}
14 changes: 7 additions & 7 deletions server-data/resources/[ox]/ox_lib/locales/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
"ui": {
"cancel": "Annuleren",
"close": "Sluiten",
"confirm": "Bevestig",
"more": "More..."
"confirm": "Bevestigen",
"more": "Meer..."
},
"txadmin_announcement": "Server announcement by %s",
"txadmin_dm": "Direct Message from %s",
"txadmin_warn": "You have been warned by %s",
"txadmin_warn_content": "%s \nAction ID: %s",
"txadmin_scheduledrestart": "Scheduled Restart"
"txadmin_announcement": "Server mededeling door %s",
"txadmin_dm": "Bericht van %s",
"txadmin_warn": "Je hebt een waarschuwing gekregen van %s",
"txadmin_warn_content": "%s \nActie ID: %s",
"txadmin_scheduledrestart": "Geplande Server Restart"
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ local input
---@field autosize? boolean
---@field required? boolean
---@field format? string
---@field returnString? boolean
---@field clearable? string
---@field description? string

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ AddStateBagChangeHandler('setVehicleProperties', '', function(bagName, _, value)
end)
]]

local gameBuild = GetGameBuildNumber()

---@param vehicle number
---@return VehicleProperties?
function lib.getVehicleProperties(vehicle)
Expand Down Expand Up @@ -269,7 +271,7 @@ function lib.getVehicleProperties(vehicle)
doors = damage.doors,
tyres = damage.tyres,
bulletProofTyres = GetVehicleTyresCanBurst(vehicle),
driftTyres = GetDriftTyresEnabled(vehicle),
driftTyres = gameBuild >= 2372 and GetDriftTyresEnabled(vehicle),
-- no setters?
-- leftHeadlight = GetIsLeftVehicleHeadlightDamaged(vehicle),
-- rightHeadlight = GetIsRightVehicleHeadlightDamaged(vehicle),
Expand Down Expand Up @@ -298,18 +300,14 @@ function lib.setVehicleProperties(vehicle, props, fixVehicle)
local pearlescentColor, wheelColor = GetVehicleExtraColours(vehicle)

SetVehicleModKit(vehicle, 0)
SetVehicleAutoRepairDisabled(vehicle, true)
-- SetVehicleAutoRepairDisabled(vehicle, true)

if props.extras then
for id, disable in pairs(props.extras) do
SetVehicleExtra(vehicle, tonumber(id) --[[@as number]], disable == 1)
end
end

if fixVehicle then
SetVehicleFixed(vehicle)
end

if props.plate then
SetVehicleNumberPlateText(vehicle, props.plate)
end
Expand Down Expand Up @@ -637,9 +635,13 @@ function lib.setVehicleProperties(vehicle, props, fixVehicle)
SetVehicleTyresCanBurst(vehicle, props.bulletProofTyres)
end

if props.driftTyres then
if gameBuild >= 2372 and props.driftTyres then
SetDriftTyresEnabled(vehicle, true)
end

if fixVehicle then
SetVehicleFixed(vehicle)
end

return true
end
end

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion server-data/resources/[ox]/ox_lib/web/build/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<link rel="icon" type="image/svg+xml" href="/src/favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>NUI React Boilerplate</title>
<script type="module" crossorigin src="./assets/index-c23fc323.js"></script>
<script type="module" crossorigin src="./assets/index-6e94cd7b.js"></script>
<link rel="stylesheet" href="./assets/index-281f5198.css">
</head>
<body>
Expand Down

0 comments on commit a2964cb

Please sign in to comment.