mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-18 15:36:02 +01:00
chore: types
mostly types anyway.
This commit is contained in:
@@ -49,6 +49,7 @@ end
|
|||||||
---@param data KeybindProps
|
---@param data KeybindProps
|
||||||
---@return CKeybind
|
---@return CKeybind
|
||||||
function lib.addKeybind(data)
|
function lib.addKeybind(data)
|
||||||
|
---@cast data CKeybind
|
||||||
if not data.defaultKey then data.defaultKey = '' end
|
if not data.defaultKey then data.defaultKey = '' end
|
||||||
if not data.defaultMapper then data.defaultMapper = 'keyboard' end
|
if not data.defaultMapper then data.defaultMapper = 'keyboard' end
|
||||||
|
|
||||||
@@ -74,7 +75,7 @@ function lib.addKeybind(data)
|
|||||||
data.disable = disableKeybind
|
data.disable = disableKeybind
|
||||||
keybinds[data.name] = setmetatable(data, keybind_mt)
|
keybinds[data.name] = setmetatable(data, keybind_mt)
|
||||||
|
|
||||||
return data --[[@as CKeybind]]
|
return data
|
||||||
end
|
end
|
||||||
|
|
||||||
return lib.addKeybind
|
return lib.addKeybind
|
||||||
|
|||||||
@@ -123,6 +123,7 @@ function table.freeze(tbl)
|
|||||||
__metatable = 'readonly',
|
__metatable = 'readonly',
|
||||||
__newindex = frozenNewIndex,
|
__newindex = frozenNewIndex,
|
||||||
__len = function() return #copy end,
|
__len = function() return #copy end,
|
||||||
|
---@diagnostic disable-next-line: redundant-return-value
|
||||||
__pairs = function() return next, copy end,
|
__pairs = function() return next, copy end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
3
init.lua
3
init.lua
@@ -179,11 +179,14 @@ if context == 'client' then
|
|||||||
cache.playerId = PlayerId()
|
cache.playerId = PlayerId()
|
||||||
cache.serverId = GetPlayerServerId(cache.playerId)
|
cache.serverId = GetPlayerServerId(cache.playerId)
|
||||||
else
|
else
|
||||||
|
---`server`\
|
||||||
---Trigger a notification on the target playerId from the server.\
|
---Trigger a notification on the target playerId from the server.\
|
||||||
---If locales are loaded, the title and description will be formatted automatically.\
|
---If locales are loaded, the title and description will be formatted automatically.\
|
||||||
---Note: No support for locale placeholders when using this function.
|
---Note: No support for locale placeholders when using this function.
|
||||||
---@param playerId number
|
---@param playerId number
|
||||||
---@param data NotifyProps
|
---@param data NotifyProps
|
||||||
|
---@deprecated
|
||||||
|
---@diagnostic disable-next-line: duplicate-set-field
|
||||||
function lib.notify(playerId, data)
|
function lib.notify(playerId, data)
|
||||||
TriggerClientEvent(notify, playerId, data)
|
TriggerClientEvent(notify, playerId, data)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
---@alias NotificationPosition 'top' | 'top-right' | 'top-left' | 'bottom' | 'bottom-right' | 'bottom-left' | 'center-right' | 'center-left'
|
---@alias NotificationPosition 'top' | 'top-right' | 'top-left' | 'bottom' | 'bottom-right' | 'bottom-left' | 'center-right' | 'center-left'
|
||||||
---@alias NotificationType 'inform' | 'warning' | 'success' | 'error'
|
---@alias NotificationType 'info' | 'warning' | 'success' | 'error'
|
||||||
|
|
||||||
---@class NotifyProps
|
---@class NotifyProps
|
||||||
---@field id? string
|
---@field id? string
|
||||||
@@ -12,7 +12,9 @@
|
|||||||
---@field icon? string | {[1]: IconProp, [2]: string};
|
---@field icon? string | {[1]: IconProp, [2]: string};
|
||||||
---@field iconColor? string;
|
---@field iconColor? string;
|
||||||
|
|
||||||
|
---`client`
|
||||||
---@param data NotifyProps
|
---@param data NotifyProps
|
||||||
|
---@diagnostic disable-next-line: duplicate-set-field
|
||||||
function lib.notify(data)
|
function lib.notify(data)
|
||||||
SendNUIMessage({
|
SendNUIMessage({
|
||||||
action = 'notify',
|
action = 'notify',
|
||||||
@@ -33,7 +35,7 @@ function lib.defaultNotify(data)
|
|||||||
-- Backwards compat for v3
|
-- Backwards compat for v3
|
||||||
data.type = data.status
|
data.type = data.status
|
||||||
if data.type == 'inform' then data.type = 'info' end
|
if data.type == 'inform' then data.type = 'info' end
|
||||||
return lib.notify(data)
|
return lib.notify(data --[[@as NotifyProps]])
|
||||||
end
|
end
|
||||||
|
|
||||||
RegisterNetEvent('ox_lib:notify', lib.notify)
|
RegisterNetEvent('ox_lib:notify', lib.notify)
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
if GetConvarInt('ox:txAdminNotifications', false) == 1 then
|
if GetConvarInt('ox:txAdminNotifications', 0) == 0 then return end
|
||||||
if GetConvar('txAdmin-hideDefaultAnnouncement', 'false') == 'true' then
|
|
||||||
|
if GetConvarInt('txAdmin-hideDefaultAnnouncement', 0) == 1 then
|
||||||
AddEventHandler('txAdmin:events:announcement', function(eventData)
|
AddEventHandler('txAdmin:events:announcement', function(eventData)
|
||||||
TriggerClientEvent('ox_lib:notify', -1, {
|
TriggerClientEvent('ox_lib:notify', -1, {
|
||||||
id = 'txAdmin:announcement',
|
id = 'txAdmin:announcement',
|
||||||
@@ -10,7 +11,7 @@ if GetConvarInt('ox:txAdminNotifications', false) == 1 then
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
if GetConvar('txAdmin-hideDefaultDirectMessage', 'false') == 'true' then
|
if GetConvarInt('txAdmin-hideDefaultDirectMessage', 0) == 1 then
|
||||||
AddEventHandler('txAdmin:events:playerDirectMessage', function(eventData)
|
AddEventHandler('txAdmin:events:playerDirectMessage', function(eventData)
|
||||||
TriggerClientEvent('ox_lib:notify', eventData.target, {
|
TriggerClientEvent('ox_lib:notify', eventData.target, {
|
||||||
id = 'txAdmin:playerDirectMessage',
|
id = 'txAdmin:playerDirectMessage',
|
||||||
@@ -21,7 +22,7 @@ if GetConvarInt('ox:txAdminNotifications', false) == 1 then
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
if GetConvar('txAdmin-hideDefaultWarning', 'false') == 'true' then
|
if GetConvarInt('txAdmin-hideDefaultWarning', 0) == 1 then
|
||||||
AddEventHandler('txAdmin:events:playerWarned', function(eventData)
|
AddEventHandler('txAdmin:events:playerWarned', function(eventData)
|
||||||
TriggerClientEvent('ox_lib:alertDialog', eventData.target, {
|
TriggerClientEvent('ox_lib:alertDialog', eventData.target, {
|
||||||
header = locale('txadmin_warn', eventData.author),
|
header = locale('txadmin_warn', eventData.author),
|
||||||
@@ -31,7 +32,7 @@ if GetConvarInt('ox:txAdminNotifications', false) == 1 then
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
if GetConvar('txAdmin-hideDefaultScheduledRestartWarning', 'false') == 'true' then
|
if GetConvarInt('txAdmin-hideDefaultScheduledRestartWarning', 0) == 1 then
|
||||||
AddEventHandler('txAdmin:events:scheduledRestart', function(eventData)
|
AddEventHandler('txAdmin:events:scheduledRestart', function(eventData)
|
||||||
TriggerClientEvent('ox_lib:notify', -1, {
|
TriggerClientEvent('ox_lib:notify', -1, {
|
||||||
id = 'txAdmin:scheduledRestart',
|
id = 'txAdmin:scheduledRestart',
|
||||||
@@ -41,4 +42,3 @@ if GetConvarInt('ox:txAdminNotifications', false) == 1 then
|
|||||||
})
|
})
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|||||||
@@ -202,8 +202,8 @@ local function startCreator(arg, useLast)
|
|||||||
local rightX, rightY = getRelativePos(vec2(xCoord, yCoord), vec2(xCoord + 2, yCoord), GetGameplayCamRot(2).z)
|
local rightX, rightY = getRelativePos(vec2(xCoord, yCoord), vec2(xCoord + 2, yCoord), GetGameplayCamRot(2).z)
|
||||||
local forwardX, forwardY = getRelativePos(vec2(xCoord, yCoord), vec2(xCoord, yCoord + 2), GetGameplayCamRot(2).z)
|
local forwardX, forwardY = getRelativePos(vec2(xCoord, yCoord), vec2(xCoord, yCoord + 2), GetGameplayCamRot(2).z)
|
||||||
|
|
||||||
DrawLine(xCoord, yCoord, zCoord, rightX, rightY, zCoord, 0, 255, 0, 225)
|
DrawLine(xCoord, yCoord, zCoord, rightX, rightY or 0, zCoord, 0, 255, 0, 225)
|
||||||
DrawLine(xCoord, yCoord, zCoord, forwardX, forwardY, zCoord, 0, 255, 0, 225)
|
DrawLine(xCoord, yCoord, zCoord, forwardX, forwardY or 0, zCoord, 0, 255, 0, 225)
|
||||||
end
|
end
|
||||||
|
|
||||||
DrawLine(xCoord, yCoord, zCoord, xCoord + 2, yCoord, zCoord, 0, 0, 255, 225)
|
DrawLine(xCoord, yCoord, zCoord, xCoord + 2, yCoord, zCoord, 0, 0, 255, 225)
|
||||||
@@ -228,6 +228,7 @@ local function startCreator(arg, useLast)
|
|||||||
|
|
||||||
drawLines()
|
drawLines()
|
||||||
elseif zoneType == 'sphere' then
|
elseif zoneType == 'sphere' then
|
||||||
|
---@diagnostic disable-next-line: param-type-mismatch
|
||||||
DrawMarker(28, xCoord, yCoord, zCoord, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, height, height, height, 255, 42, 24, 100, false, false, 0, false, false, false, false)
|
DrawMarker(28, xCoord, yCoord, zCoord, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, height, height, height, 255, 42, 24, 100, false, false, 0, false, false, false, false)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -294,7 +295,7 @@ local function startCreator(arg, useLast)
|
|||||||
newX = 0.0
|
newX = 0.0
|
||||||
end
|
end
|
||||||
|
|
||||||
if math.abs(newY) < minCheck then
|
if math.abs(newY or 0) < minCheck then
|
||||||
newY = 0.0
|
newY = 0.0
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -319,7 +320,7 @@ local function startCreator(arg, useLast)
|
|||||||
newX = 0.0
|
newX = 0.0
|
||||||
end
|
end
|
||||||
|
|
||||||
if math.abs(newY) < minCheck then
|
if math.abs(newY or 0) < minCheck then
|
||||||
newY = 0.0
|
newY = 0.0
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -344,7 +345,7 @@ local function startCreator(arg, useLast)
|
|||||||
newX = 0.0
|
newX = 0.0
|
||||||
end
|
end
|
||||||
|
|
||||||
if math.abs(newY) < minCheck then
|
if math.abs(newY or 0) < minCheck then
|
||||||
newY = 0.0
|
newY = 0.0
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -369,7 +370,7 @@ local function startCreator(arg, useLast)
|
|||||||
newX = 0.0
|
newX = 0.0
|
||||||
end
|
end
|
||||||
|
|
||||||
if math.abs(newY) < minCheck then
|
if math.abs(newY or 0) < minCheck then
|
||||||
newY = 0.0
|
newY = 0.0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user