forked from Simnation/Main
update
This commit is contained in:
parent
91f5e9d0a3
commit
dda325f5ba
14 changed files with 938 additions and 127 deletions
|
@ -2,10 +2,10 @@
|
||||||
|
|
||||||
A FiveM library and resource implementing reusable modules, methods, and UI elements.
|
A FiveM library and resource implementing reusable modules, methods, and UI elements.
|
||||||
|
|
||||||

|

|
||||||

|

|
||||||

|

|
||||||

|

|
||||||
|
|
||||||
For guidelines to contributing to the project, and to see our Contributor License Agreement, see [CONTRIBUTING.md](./CONTRIBUTING.md)
|
For guidelines to contributing to the project, and to see our Contributor License Agreement, see [CONTRIBUTING.md](./CONTRIBUTING.md)
|
||||||
|
|
||||||
|
@ -14,19 +14,19 @@ For additional legal notices, refer to [NOTICE.md](./NOTICE.md).
|
||||||
|
|
||||||
## 📚 Documentation
|
## 📚 Documentation
|
||||||
|
|
||||||
https://overextended.dev/ox_lib
|
https://coxdocs.dev/ox_lib
|
||||||
|
|
||||||
## 💾 Download
|
## 💾 Download
|
||||||
|
|
||||||
https://github.com/overextended/ox_lib/releases/latest/download/ox_lib.zip
|
https://github.com/communityox/ox_lib/releases/latest/download/ox_lib.zip
|
||||||
|
|
||||||
## 📦 npm package
|
## 📦 npm package
|
||||||
|
|
||||||
https://www.npmjs.com/package/@overextended/ox_lib
|
https://www.npmjs.com/package/@communityox/ox_lib
|
||||||
|
|
||||||
## 🖥️ Lua Language Server
|
## 🖥️ Lua Language Server
|
||||||
|
|
||||||
- Install [Lua Language Server](https://marketplace.visualstudio.com/items?itemName=sumneko.lua) to ease development with annotations, type checking, diagnostics, and more.
|
- Install [Lua Language Server](https://marketplace.visualstudio.com/items?itemName=sumneko.lua) to ease development with annotations, type checking, diagnostics, and more.
|
||||||
- Install [cfxlua-vscode](https://marketplace.visualstudio.com/items?itemName=overextended.cfxlua-vscode) to add natives and cfxlua runtime declarations to LLS.
|
- Install [CfxLua IntelliSense](https://marketplace.visualstudio.com/items?itemName=communityox.cfxlua-vscode-cox) to add natives and cfxlua runtime declarations to LLS.
|
||||||
- You can load ox_lib into your global development environment by modifying workspace/user settings "Lua.workspace.library" with the resource path.
|
- You can load ox_lib into your global development environment by modifying workspace/user settings "Lua.workspace.library" with the resource path.
|
||||||
- e.g. "c:/fxserver/resources/ox_lib"
|
- e.g. "c:/fxserver/resources/ox_lib"
|
||||||
|
|
|
@ -6,9 +6,9 @@ rdr3_warning 'I acknowledge that this is a prerelease build of RedM, and I am aw
|
||||||
|
|
||||||
name 'ox_lib'
|
name 'ox_lib'
|
||||||
author 'Overextended'
|
author 'Overextended'
|
||||||
version '3.30.6'
|
version '3.30.10'
|
||||||
license 'LGPL-3.0-or-later'
|
license 'LGPL-3.0-or-later'
|
||||||
repository 'https://github.com/overextended/ox_lib'
|
repository 'https://github.com/communityox/ox_lib'
|
||||||
description 'A library of shared functions to utilise in other resources.'
|
description 'A library of shared functions to utilise in other resources.'
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
|
|
@ -8,16 +8,19 @@
|
||||||
|
|
||||||
---@param coords vector3 The coords to check from.
|
---@param coords vector3 The coords to check from.
|
||||||
---@param maxDistance? number The max distance to check.
|
---@param maxDistance? number The max distance to check.
|
||||||
|
---@param ignorePlayerId? number|false The player server ID to ignore.
|
||||||
---@return number? playerId
|
---@return number? playerId
|
||||||
---@return number? playerPed
|
---@return number? playerPed
|
||||||
---@return vector3? playerCoords
|
---@return vector3? playerCoords
|
||||||
function lib.getClosestPlayer(coords, maxDistance)
|
function lib.getClosestPlayer(coords, maxDistance, ignorePlayerId)
|
||||||
local players = GetActivePlayers()
|
local players = GetActivePlayers()
|
||||||
local closestId, closestPed, closestCoords
|
local closestId, closestPed, closestCoords
|
||||||
maxDistance = maxDistance or 2.0
|
maxDistance = maxDistance or 2.0
|
||||||
|
|
||||||
for i = 1, #players do
|
for i = 1, #players do
|
||||||
local playerId = players[i]
|
local playerId = players[i]
|
||||||
|
|
||||||
|
if not ignorePlayerId or playerId ~= ignorePlayerId then
|
||||||
local playerPed = GetPlayerPed(playerId)
|
local playerPed = GetPlayerPed(playerId)
|
||||||
local playerCoords = GetEntityCoords(playerPed)
|
local playerCoords = GetEntityCoords(playerPed)
|
||||||
local distance = #(coords - playerCoords)
|
local distance = #(coords - playerCoords)
|
||||||
|
@ -29,6 +32,7 @@ function lib.getClosestPlayer(coords, maxDistance)
|
||||||
closestCoords = playerCoords
|
closestCoords = playerCoords
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return closestId, closestPed, closestCoords
|
return closestId, closestPed, closestCoords
|
||||||
end
|
end
|
||||||
|
|
|
@ -59,7 +59,7 @@ end
|
||||||
|
|
||||||
local table = lib.table
|
local table = lib.table
|
||||||
|
|
||||||
---Loads the ox_lib locale module. Prefer using fxmanifest instead (see [docs](https://overextended.dev/ox_lib#usage)).
|
---Loads the ox_lib locale module. Prefer using fxmanifest instead (see [docs](https://coxdocs.dev/ox_lib#usage)).
|
||||||
---@param key? string
|
---@param key? string
|
||||||
function lib.locale(key)
|
function lib.locale(key)
|
||||||
local lang = key or lib.getLocaleKey()
|
local lang = key or lib.getLocaleKey()
|
||||||
|
|
|
@ -9,14 +9,8 @@
|
||||||
---@diagnostic disable: param-type-mismatch
|
---@diagnostic disable: param-type-mismatch
|
||||||
lib.marker = {}
|
lib.marker = {}
|
||||||
|
|
||||||
local defaultRotation = vector3(0, 0, 0)
|
---@enum (key) MarkerType
|
||||||
local defaultDirection = vector3(0, 0, 0)
|
local markerTypes = {
|
||||||
local defaultColor = { r = 255, g = 255, b = 255, a = 100 }
|
|
||||||
local defaultSize = { width = 2, height = 1 }
|
|
||||||
local defaultTextureDict = nil
|
|
||||||
local defaultTextureName = nil
|
|
||||||
|
|
||||||
local markerTypesMap = {
|
|
||||||
UpsideDownCone = 0,
|
UpsideDownCone = 0,
|
||||||
VerticalCylinder = 1,
|
VerticalCylinder = 1,
|
||||||
ThickChevronUp = 2,
|
ThickChevronUp = 2,
|
||||||
|
@ -63,58 +57,12 @@ local markerTypesMap = {
|
||||||
Unknown43 = 43,
|
Unknown43 = 43,
|
||||||
}
|
}
|
||||||
|
|
||||||
---@alias MarkerType
|
|
||||||
---| "UpsideDownCone"
|
|
||||||
---| "VerticalCylinder"
|
|
||||||
---| "ThickChevronUp"
|
|
||||||
---| "ThinChevronUp"
|
|
||||||
---| "CheckeredFlagRect"
|
|
||||||
---| "CheckeredFlagCircle"
|
|
||||||
---| "VerticleCircle"
|
|
||||||
---| "PlaneModel"
|
|
||||||
---| "LostMCTransparent"
|
|
||||||
---| "LostMC"
|
|
||||||
---| "Number0"
|
|
||||||
---| "Number1"
|
|
||||||
---| "Number2"
|
|
||||||
---| "Number3"
|
|
||||||
---| "Number4"
|
|
||||||
---| "Number5"
|
|
||||||
---| "Number6"
|
|
||||||
---| "Number7"
|
|
||||||
---| "Number8"
|
|
||||||
---| "Number9"
|
|
||||||
---| "ChevronUpx1"
|
|
||||||
---| "ChevronUpx2"
|
|
||||||
---| "ChevronUpx3"
|
|
||||||
---| "HorizontalCircleFat"
|
|
||||||
---| "ReplayIcon"
|
|
||||||
---| "HorizontalCircleSkinny"
|
|
||||||
---| "HorizontalCircleSkinny_Arrow"
|
|
||||||
---| "HorizontalSplitArrowCircle"
|
|
||||||
---| "DebugSphere"
|
|
||||||
---| "DollarSign"
|
|
||||||
---| "HorizontalBars"
|
|
||||||
---| "WolfHead"
|
|
||||||
---| "QuestionMark"
|
|
||||||
---| "PlaneSymbol"
|
|
||||||
---| "HelicopterSymbol"
|
|
||||||
---| "BoatSymbol"
|
|
||||||
---| "CarSymbol"
|
|
||||||
---| "MotorcycleSymbol"
|
|
||||||
---| "BikeSymbol"
|
|
||||||
---| "TruckSymbol"
|
|
||||||
---| "ParachuteSymbol"
|
|
||||||
---| "Unknown41"
|
|
||||||
---| "SawbladeSymbol"
|
|
||||||
---| "Unknown43"
|
|
||||||
|
|
||||||
---@class MarkerProps
|
---@class MarkerProps
|
||||||
---@field type MarkerType | number
|
---@field type? MarkerType | integer
|
||||||
---@field coords { x: number, y: number, z: number }
|
---@field coords { x: number, y: number, z: number }
|
||||||
---@field width? number
|
---@field width? number
|
||||||
---@field height? number
|
---@field height? number
|
||||||
---@field color? { r: number, g: number, b: number, a: number }
|
---@field color? { r: integer, g: integer, b: integer, a: integer }
|
||||||
---@field rotation? { x: number, y: number, z: number }
|
---@field rotation? { x: number, y: number, z: number }
|
||||||
---@field direction? { x: number, y: number, z: number }
|
---@field direction? { x: number, y: number, z: number }
|
||||||
---@field bobUpAndDown? boolean
|
---@field bobUpAndDown? boolean
|
||||||
|
@ -122,9 +70,25 @@ local markerTypesMap = {
|
||||||
---@field rotate? boolean
|
---@field rotate? boolean
|
||||||
---@field textureDict? string
|
---@field textureDict? string
|
||||||
---@field textureName? string
|
---@field textureName? string
|
||||||
|
---@field invert? boolean
|
||||||
|
|
||||||
---@param self MarkerProps
|
local vector3_zero = vector3(0, 0, 0)
|
||||||
local function drawMarker(self)
|
|
||||||
|
local marker_mt = {
|
||||||
|
type = 0,
|
||||||
|
width = 2.,
|
||||||
|
height = 1.,
|
||||||
|
color = {r = 255, g = 100, b = 0, a = 100},
|
||||||
|
rotation = vector3_zero,
|
||||||
|
direction = vector3_zero,
|
||||||
|
bobUpAndDown = false,
|
||||||
|
faceCamera = false,
|
||||||
|
rotate = false,
|
||||||
|
invert = false,
|
||||||
|
}
|
||||||
|
marker_mt.__index = marker_mt
|
||||||
|
|
||||||
|
function marker_mt:draw()
|
||||||
DrawMarker(
|
DrawMarker(
|
||||||
self.type,
|
self.type,
|
||||||
self.coords.x, self.coords.y, self.coords.z,
|
self.coords.x, self.coords.y, self.coords.z,
|
||||||
|
@ -132,40 +96,19 @@ local function drawMarker(self)
|
||||||
self.rotation.x, self.rotation.y, self.rotation.z,
|
self.rotation.x, self.rotation.y, self.rotation.z,
|
||||||
self.width, self.width, self.height,
|
self.width, self.width, self.height,
|
||||||
self.color.r, self.color.g, self.color.b, self.color.a,
|
self.color.r, self.color.g, self.color.b, self.color.a,
|
||||||
self.bobUpAndDown, self.faceCamera, 2, self.rotate, self.textureDict, self.textureName, false)
|
self.bobUpAndDown, self.faceCamera, 2, self.rotate, self.textureDict, self.textureName, self.invert)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param options MarkerProps
|
---@param options MarkerProps
|
||||||
function lib.marker.new(options)
|
function lib.marker.new(options)
|
||||||
local markerType
|
options.type =
|
||||||
if type(options.type) == "string" then
|
type(options.type) == 'string' and markerTypes[options.type]
|
||||||
markerType = markerTypesMap[options.type]
|
or type(options.type) == 'number' and options.type or nil
|
||||||
if markerType == nil then
|
|
||||||
error(("unknown marker type '%s'"):format(options.type))
|
|
||||||
end
|
|
||||||
elseif type(options.type) == "number" then
|
|
||||||
markerType = options.type
|
|
||||||
else
|
|
||||||
error(("expected marker type to have type 'string' or 'number' (received %s)"):format(type(options.type)))
|
|
||||||
end
|
|
||||||
|
|
||||||
local self = {}
|
local self = setmetatable(options, marker_mt)
|
||||||
self.type = markerType
|
|
||||||
self.coords = options.coords
|
|
||||||
self.color = options.color or defaultColor
|
|
||||||
self.width = options.width or defaultSize.width
|
|
||||||
self.height = options.height or defaultSize.height
|
|
||||||
self.rotation = options.rotation or defaultRotation
|
|
||||||
self.direction = options.direction or defaultDirection
|
|
||||||
self.bobUpAndDown = type(options.bobUpAndDown) == 'boolean' and options.bobUpAndDown
|
|
||||||
self.faceCamera = type(options.faceCamera) ~= 'boolean' or options.faceCamera
|
|
||||||
self.rotate = type(options.rotate) == 'boolean' and options.rotate
|
|
||||||
self.textureDict = options.textureDict or defaultTextureDict
|
|
||||||
self.textureName = options.textureName or defaultTextureName
|
|
||||||
self.draw = drawMarker
|
|
||||||
|
|
||||||
self.width += 0.0
|
self.width += .0
|
||||||
self.height += 0.0
|
self.height += .0
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
|
@ -122,8 +122,15 @@ local function removeZone(zone)
|
||||||
|
|
||||||
insideZones[zone.id] = nil
|
insideZones[zone.id] = nil
|
||||||
|
|
||||||
table.remove(exitingZones, exitingZones:indexOf(zone))
|
local exitingIndex = exitingZones:indexOf(zone)
|
||||||
table.remove(enteringZones, enteringZones:indexOf(zone))
|
if exitingIndex then
|
||||||
|
table.remove(exitingZones, exitingIndex)
|
||||||
|
end
|
||||||
|
|
||||||
|
local enteringIndex = enteringZones:indexOf(zone)
|
||||||
|
if enteringIndex then
|
||||||
|
table.remove(enteringZones, enteringIndex)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
CreateThread(function()
|
CreateThread(function()
|
||||||
|
|
|
@ -139,8 +139,10 @@ function SetInterval(callback, interval, ...)
|
||||||
repeat
|
repeat
|
||||||
interval = intervals[id]
|
interval = intervals[id]
|
||||||
Wait(interval)
|
Wait(interval)
|
||||||
|
|
||||||
|
if interval < 0 then break end
|
||||||
callback(table.unpack(args))
|
callback(table.unpack(args))
|
||||||
until interval < 0
|
until false
|
||||||
intervals[id] = nil
|
intervals[id] = nil
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
"locale": "Sprache ändern",
|
"locale": "Sprache ändern",
|
||||||
"locale_description": "Aktuelle Sprache: ${language} (%s)",
|
"locale_description": "Aktuelle Sprache: ${language} (%s)",
|
||||||
"notification_audio": "Benachrichtigungs-Sound",
|
"notification_audio": "Benachrichtigungs-Sound",
|
||||||
"notification_position": "Notification position"
|
"notification_position": "Benachrichtigungs-Position"
|
||||||
},
|
},
|
||||||
"position": {
|
"position": {
|
||||||
"bottom": "Unten",
|
"bottom": "Unten",
|
||||||
|
|
|
@ -13,14 +13,14 @@
|
||||||
"notification_position": "Varslingsposisjon"
|
"notification_position": "Varslingsposisjon"
|
||||||
},
|
},
|
||||||
"position": {
|
"position": {
|
||||||
"bottom": "Bunn",
|
"bottom": "Nederst",
|
||||||
"bottom-left": "Bunn-venstre",
|
"bottom-left": "Nederst til venstre",
|
||||||
"bottom-right": "Bunn-høyre",
|
"bottom-right": "Nederst til høyre",
|
||||||
"center-left": "Senter-venstre",
|
"center-left": "Midten venstre",
|
||||||
"center-right": "Senter-høyre",
|
"center-right": "Midten høyre",
|
||||||
"top": "Top",
|
"top": "Øverst",
|
||||||
"top-left": "Top-venstre",
|
"top-left": "Øverst til venstre",
|
||||||
"top-right": "Top-høyre"
|
"top-right": "Øverst til høyre"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"open_radial_menu": "Åpne radialmenyen",
|
"open_radial_menu": "Åpne radialmenyen",
|
||||||
|
@ -29,5 +29,5 @@
|
||||||
"txadmin_dm": "Direktemelding fra %s",
|
"txadmin_dm": "Direktemelding fra %s",
|
||||||
"txadmin_warn": "Du har fått en advarsel fra %s",
|
"txadmin_warn": "Du har fått en advarsel fra %s",
|
||||||
"txadmin_warn_content": "%s \nAction ID: %s",
|
"txadmin_warn_content": "%s \nAction ID: %s",
|
||||||
"txadmin_scheduledrestart": "Planlagt Omstart"
|
"txadmin_scheduledrestart": "Planlagt omstart"
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ cache = {
|
||||||
|
|
||||||
if not LoadResourceFile(lib.name, 'web/build/index.html') then
|
if not LoadResourceFile(lib.name, 'web/build/index.html') then
|
||||||
local err =
|
local err =
|
||||||
'^1Unable to load UI. Build ox_lib or download the latest release.\n ^3https://github.com/overextended/ox_lib/releases/latest/download/ox_lib.zip^0'
|
'^1Unable to load UI. Build ox_lib or download the latest release.\n ^3https://github.com/communityox/ox_lib/releases/latest/download/ox_lib.zip^0'
|
||||||
function lib.hasLoaded() return err end
|
function lib.hasLoaded() return err end
|
||||||
|
|
||||||
error(err)
|
error(err)
|
||||||
|
|
|
@ -43,4 +43,4 @@ function lib.versionCheck(repository)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
lib.versionCheck('overextended/ox_lib')
|
lib.versionCheck('communityox/ox_lib')
|
||||||
|
|
854
resources/[standalone]/ox_lib/web/build/assets/index-Bxswoo_8.js
Normal file
854
resources/[standalone]/ox_lib/web/build/assets/index-Bxswoo_8.js
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -5,8 +5,8 @@
|
||||||
<link rel="icon" type="image/svg+xml" href="/src/favicon.svg" />
|
<link rel="icon" type="image/svg+xml" href="/src/favicon.svg" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>NUI React Boilerplate</title>
|
<title>NUI React Boilerplate</title>
|
||||||
<script type="module" crossorigin src="./assets/index-Dk9MkoH6.js"></script>
|
<script type="module" crossorigin src="./assets/index-Bxswoo_8.js"></script>
|
||||||
<link rel="stylesheet" crossorigin href="./assets/index-BgkLwDpx.css">
|
<link rel="stylesheet" crossorigin href="./assets/index-SonfJNby.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="root"></div>
|
<div id="root"></div>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue