diff --git a/imports/addKeybind/client.lua b/imports/addKeybind/client.lua index 7e19b7b..8308f78 100644 --- a/imports/addKeybind/client.lua +++ b/imports/addKeybind/client.lua @@ -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 diff --git a/imports/table/shared.lua b/imports/table/shared.lua index 2918f6d..95df731 100644 --- a/imports/table/shared.lua +++ b/imports/table/shared.lua @@ -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, }) diff --git a/init.lua b/init.lua index cd05e95..7b859b0 100644 --- a/init.lua +++ b/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 diff --git a/resource/interface/client/notify.lua b/resource/interface/client/notify.lua index 5558434..e3bf629 100644 --- a/resource/interface/client/notify.lua +++ b/resource/interface/client/notify.lua @@ -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) diff --git a/resource/interface/server/txadmin.lua b/resource/interface/server/txadmin.lua index c4892f0..259efc6 100644 --- a/resource/interface/server/txadmin.lua +++ b/resource/interface/server/txadmin.lua @@ -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 diff --git a/resource/zoneCreator/client.lua b/resource/zoneCreator/client.lua index 5dfee82..11e8b43 100644 --- a/resource/zoneCreator/client.lua +++ b/resource/zoneCreator/client.lua @@ -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