Skip to content

Commit

Permalink
chore: ox_lib update to version '3.11.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
bitpredator committed Oct 31, 2023
1 parent 6838a34 commit 143602e
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 9 deletions.
3 changes: 2 additions & 1 deletion .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@
[workflows/dependency-review.yml]: chore(deps): bump actions/checkout from 3 to 4
[voice-ui/pnpm-lock.yaml]: chore(deps-dev): bump follow-redirects in /voice-ui
[voice-ui/pnpm-lock.yaml]: chore(deps-dev): bump browserify-sign from 4.2.1 to 4.2.2 in /voice-ui
7. [npwd + es_extended]: chore: removed support for npwd_crypto @bitpredator
7. [npwd + es_extended]: chore: removed support for npwd_crypto @bitpredator
8. [ox_lib]: chore: ox_lib update to version '3.11.0' @bitpredator
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.10.1'
version '3.11.0'
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
22 changes: 17 additions & 5 deletions server-data/resources/[ox]/ox_lib/imports/cron/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ currentDate.sec = 0
---@field debug? boolean

---@class OxTask : OxTaskProperties
---@field expression string
---@field private scheduleTask fun(self: OxTask): boolean?
local OxTask = {}
OxTask.__index = OxTask
Expand Down Expand Up @@ -208,6 +209,10 @@ function OxTask:getAbsoluteNextTime()
})
end

function OxTask:getTimeAsString(timestamp)
return os.date('%A %H:%M, %d %B %Y', timestamp or self:getAbsoluteNextTime())
end

---@type OxTask[]
local tasks = {}

Expand All @@ -225,8 +230,10 @@ function OxTask:scheduleTask()
return self:stop(self.debug and ('scheduled time expired %s seconds ago'):format(-sleep))
end

local timeAsString = self:getTimeAsString(runAt)

if self.debug then
print(('running task %s in %d seconds (%0.2f minutes or %0.2f hours)'):format(self.id, sleep, sleep / 60,
print(('(%s) task %s will run in %d seconds (%0.2f minutes / %0.2f hours)'):format(timeAsString, self.id, sleep, sleep / 60,
sleep / 60 / 60))
end

Expand All @@ -238,12 +245,14 @@ function OxTask:scheduleTask()
end

if self.isActive then
self:job(currentDate)

if self.debug then
print(('(%s/%s/%s %s:%s) ran task %s'):format(currentDate.year, currentDate.month, currentDate.day, currentDate.hour, currentDate.min, self.id))
print(('(%s) running task %s'):format(timeAsString, self.id))
end

Citizen.CreateThreadNow(function()
self:job(currentDate)
end)

Wait(30000)

return true
Expand Down Expand Up @@ -319,12 +328,15 @@ end
---Supports numbers, any value `*`, lists `1,2,3`, ranges `1-3`, and steps `*/4`.
---Day of the week is a range of `1-7` starting from Sunday and allows short-names (i.e. sun, mon, tue).
function lib.cron.new(expression, job, options)
if not job or type(job) ~= 'function' then return end
if not job or type(job) ~= 'function' then
error(("expected job to have type 'function' (received %s)"):format(type(job)))
end

local minute, hour, day, month, weekday = string.strsplit(' ', string.lower(expression))
---@type OxTask
local task = setmetatable(options or {}, OxTask)

task.expression = expression
task.minute = parseCron(minute, 'min')
task.hour = parseCron(hour, 'hour')
task.day = parseCron(day, 'day')
Expand Down
15 changes: 15 additions & 0 deletions server-data/resources/[ox]/ox_lib/imports/math/shared.lua
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,21 @@ function math.tovector(input, min, max, round)
error(('cannot convert %s to a vector value'):format(inputType), 2)
end

---Tries to convert a surface Normal to a Rotation.
---@param input vector3
---@return vector3
function math.normaltorotation(input)
local inputType = type(input)

if inputType == 'vector3' then
local pitch = -math.asin(input.y) * (180.0 / math.pi)
local yaw = math.atan(input.x, input.z) * (180.0 / math.pi)
return vec3(pitch, yaw, 0.0)
end

error(('cannot convert type %s to a rotation vector'):format(inputType), 2)
end

---Tries to convert its argument to a vector.
---@param input string | table
---@return number | vector2 | vector3 | vector4
Expand Down

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-6e94cd7b.js"></script>
<script type="module" crossorigin src="./assets/index-f9f66bac.js"></script>
<link rel="stylesheet" href="./assets/index-281f5198.css">
</head>
<body>
Expand Down

0 comments on commit 143602e

Please sign in to comment.