mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-16 22:46:03 +01:00
chore: types
mostly types anyway.
This commit is contained in:
@@ -49,6 +49,7 @@ end
|
||||
---@param data KeybindProps
|
||||
---@return CKeybind
|
||||
function lib.addKeybind(data)
|
||||
---@cast data CKeybind
|
||||
if not data.defaultKey then data.defaultKey = '' end
|
||||
if not data.defaultMapper then data.defaultMapper = 'keyboard' end
|
||||
|
||||
@@ -74,7 +75,7 @@ function lib.addKeybind(data)
|
||||
data.disable = disableKeybind
|
||||
keybinds[data.name] = setmetatable(data, keybind_mt)
|
||||
|
||||
return data --[[@as CKeybind]]
|
||||
return data
|
||||
end
|
||||
|
||||
return lib.addKeybind
|
||||
|
||||
@@ -123,6 +123,7 @@ function table.freeze(tbl)
|
||||
__metatable = 'readonly',
|
||||
__newindex = frozenNewIndex,
|
||||
__len = function() return #copy end,
|
||||
---@diagnostic disable-next-line: redundant-return-value
|
||||
__pairs = function() return next, copy end,
|
||||
})
|
||||
|
||||
|
||||
3
init.lua
3
init.lua
@@ -179,11 +179,14 @@ if context == 'client' then
|
||||
cache.playerId = PlayerId()
|
||||
cache.serverId = GetPlayerServerId(cache.playerId)
|
||||
else
|
||||
---`server`\
|
||||
---Trigger a notification on the target playerId from the server.\
|
||||
---If locales are loaded, the title and description will be formatted automatically.\
|
||||
---Note: No support for locale placeholders when using this function.
|
||||
---@param playerId number
|
||||
---@param data NotifyProps
|
||||
---@deprecated
|
||||
---@diagnostic disable-next-line: duplicate-set-field
|
||||
function lib.notify(playerId, data)
|
||||
TriggerClientEvent(notify, playerId, data)
|
||||
end
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
---@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
|
||||
---@field id? string
|
||||
@@ -12,7 +12,9 @@
|
||||
---@field icon? string | {[1]: IconProp, [2]: string};
|
||||
---@field iconColor? string;
|
||||
|
||||
---`client`
|
||||
---@param data NotifyProps
|
||||
---@diagnostic disable-next-line: duplicate-set-field
|
||||
function lib.notify(data)
|
||||
SendNUIMessage({
|
||||
action = 'notify',
|
||||
@@ -33,7 +35,7 @@ function lib.defaultNotify(data)
|
||||
-- Backwards compat for v3
|
||||
data.type = data.status
|
||||
if data.type == 'inform' then data.type = 'info' end
|
||||
return lib.notify(data)
|
||||
return lib.notify(data --[[@as NotifyProps]])
|
||||
end
|
||||
|
||||
RegisterNetEvent('ox_lib:notify', lib.notify)
|
||||
|
||||
@@ -1,44 +1,44 @@
|
||||
if GetConvarInt('ox:txAdminNotifications', false) == 1 then
|
||||
if GetConvar('txAdmin-hideDefaultAnnouncement', 'false') == 'true' then
|
||||
AddEventHandler('txAdmin:events:announcement', function(eventData)
|
||||
TriggerClientEvent('ox_lib:notify', -1, {
|
||||
id = 'txAdmin:announcement',
|
||||
title = locale('txadmin_announcement', eventData.author),
|
||||
description = eventData.message,
|
||||
duration = 5000
|
||||
})
|
||||
end)
|
||||
end
|
||||
if GetConvarInt('ox:txAdminNotifications', 0) == 0 then return end
|
||||
|
||||
if GetConvar('txAdmin-hideDefaultDirectMessage', 'false') == 'true' then
|
||||
AddEventHandler('txAdmin:events:playerDirectMessage', function(eventData)
|
||||
TriggerClientEvent('ox_lib:notify', eventData.target, {
|
||||
id = 'txAdmin:playerDirectMessage',
|
||||
title = locale('txadmin_dm', eventData.author),
|
||||
description = eventData.message,
|
||||
duration = 5000
|
||||
})
|
||||
end)
|
||||
end
|
||||
|
||||
if GetConvar('txAdmin-hideDefaultWarning', 'false') == 'true' then
|
||||
AddEventHandler('txAdmin:events:playerWarned', function(eventData)
|
||||
TriggerClientEvent('ox_lib:alertDialog', eventData.target, {
|
||||
header = locale('txadmin_warn', eventData.author),
|
||||
content = locale('txadmin_warn_content', eventData.reason, eventData.actionId),
|
||||
centered = true
|
||||
})
|
||||
end)
|
||||
end
|
||||
|
||||
if GetConvar('txAdmin-hideDefaultScheduledRestartWarning', 'false') == 'true' then
|
||||
AddEventHandler('txAdmin:events:scheduledRestart', function(eventData)
|
||||
TriggerClientEvent('ox_lib:notify', -1, {
|
||||
id = 'txAdmin:scheduledRestart',
|
||||
title = locale('txadmin_scheduledrestart'),
|
||||
description = eventData.translatedMessage,
|
||||
duration = 5000
|
||||
})
|
||||
end)
|
||||
end
|
||||
if GetConvarInt('txAdmin-hideDefaultAnnouncement', 0) == 1 then
|
||||
AddEventHandler('txAdmin:events:announcement', function(eventData)
|
||||
TriggerClientEvent('ox_lib:notify', -1, {
|
||||
id = 'txAdmin:announcement',
|
||||
title = locale('txadmin_announcement', eventData.author),
|
||||
description = eventData.message,
|
||||
duration = 5000
|
||||
})
|
||||
end)
|
||||
end
|
||||
|
||||
if GetConvarInt('txAdmin-hideDefaultDirectMessage', 0) == 1 then
|
||||
AddEventHandler('txAdmin:events:playerDirectMessage', function(eventData)
|
||||
TriggerClientEvent('ox_lib:notify', eventData.target, {
|
||||
id = 'txAdmin:playerDirectMessage',
|
||||
title = locale('txadmin_dm', eventData.author),
|
||||
description = eventData.message,
|
||||
duration = 5000
|
||||
})
|
||||
end)
|
||||
end
|
||||
|
||||
if GetConvarInt('txAdmin-hideDefaultWarning', 0) == 1 then
|
||||
AddEventHandler('txAdmin:events:playerWarned', function(eventData)
|
||||
TriggerClientEvent('ox_lib:alertDialog', eventData.target, {
|
||||
header = locale('txadmin_warn', eventData.author),
|
||||
content = locale('txadmin_warn_content', eventData.reason, eventData.actionId),
|
||||
centered = true
|
||||
})
|
||||
end)
|
||||
end
|
||||
|
||||
if GetConvarInt('txAdmin-hideDefaultScheduledRestartWarning', 0) == 1 then
|
||||
AddEventHandler('txAdmin:events:scheduledRestart', function(eventData)
|
||||
TriggerClientEvent('ox_lib:notify', -1, {
|
||||
id = 'txAdmin:scheduledRestart',
|
||||
title = locale('txadmin_scheduledrestart'),
|
||||
description = eventData.translatedMessage,
|
||||
duration = 5000
|
||||
})
|
||||
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 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, forwardX, forwardY, zCoord, 0, 255, 0, 225)
|
||||
DrawLine(xCoord, yCoord, zCoord, rightX, rightY or 0, zCoord, 0, 255, 0, 225)
|
||||
DrawLine(xCoord, yCoord, zCoord, forwardX, forwardY or 0, zCoord, 0, 255, 0, 225)
|
||||
end
|
||||
|
||||
DrawLine(xCoord, yCoord, zCoord, xCoord + 2, yCoord, zCoord, 0, 0, 255, 225)
|
||||
@@ -228,6 +228,7 @@ local function startCreator(arg, useLast)
|
||||
|
||||
drawLines()
|
||||
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)
|
||||
end
|
||||
|
||||
@@ -294,7 +295,7 @@ local function startCreator(arg, useLast)
|
||||
newX = 0.0
|
||||
end
|
||||
|
||||
if math.abs(newY) < minCheck then
|
||||
if math.abs(newY or 0) < minCheck then
|
||||
newY = 0.0
|
||||
end
|
||||
|
||||
@@ -319,7 +320,7 @@ local function startCreator(arg, useLast)
|
||||
newX = 0.0
|
||||
end
|
||||
|
||||
if math.abs(newY) < minCheck then
|
||||
if math.abs(newY or 0) < minCheck then
|
||||
newY = 0.0
|
||||
end
|
||||
|
||||
@@ -344,7 +345,7 @@ local function startCreator(arg, useLast)
|
||||
newX = 0.0
|
||||
end
|
||||
|
||||
if math.abs(newY) < minCheck then
|
||||
if math.abs(newY or 0) < minCheck then
|
||||
newY = 0.0
|
||||
end
|
||||
|
||||
@@ -369,7 +370,7 @@ local function startCreator(arg, useLast)
|
||||
newX = 0.0
|
||||
end
|
||||
|
||||
if math.abs(newY) < minCheck then
|
||||
if math.abs(newY or 0) < minCheck then
|
||||
newY = 0.0
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user