diff --git a/locales/en.json b/locales/en.json index f907091..6140245 100644 --- a/locales/en.json +++ b/locales/en.json @@ -164,6 +164,7 @@ "blips_deactivated": "Blips deactivated", "names_deactivated": "Names deactivated", "no_report_reply": "Reply failed to send due to no message", - "no_reports": "no pending reports to load" + "no_reports": "no pending reports to load", + "not_optin": "You are not opted in." } } diff --git a/server/commands.lua b/server/commands.lua index 1357fba..96b2243 100644 --- a/server/commands.lua +++ b/server/commands.lua @@ -13,6 +13,7 @@ lib.addCommand('admin', { help = 'Opens Admin Menu', restricted = config.useMenu, }, function(source) + if not exports.qbx_core:IsOptin(source) then exports.qbx_core:Notify(source, locale('error.not_optin'), 'error') return end TriggerClientEvent('qbx_admin:client:openMenu', source) end) @@ -20,6 +21,7 @@ lib.addCommand('noclip', { help = 'Toggle NoClip', restricted = config.noclip, }, function(source) + if not exports.qbx_core:IsOptin(source) then exports.qbx_core:Notify(source, locale('error.not_optin'), 'error') return end TriggerClientEvent('qbx_admin:client:ToggleNoClip', source) end) @@ -27,6 +29,7 @@ lib.addCommand('names', { help = 'Toggle Player Names', restricted = config.names, }, function(source) + if not exports.qbx_core:IsOptin(source) then exports.qbx_core:Notify(source, locale('error.not_optin'), 'error') return end TriggerClientEvent('qbx_admin:client:names', source) end) @@ -34,6 +37,7 @@ lib.addCommand('blips', { help = 'Toggle Player Blips', restricted = config.blips, }, function(source) + if not exports.qbx_core:IsOptin(source) then exports.qbx_core:Notify(source, locale('error.not_optin'), 'error') return end TriggerClientEvent('qbx_admin:client:blips', source) end) @@ -41,6 +45,7 @@ lib.addCommand('admincar', { help = 'Buy Vehicle', restricted = config.saveVehicle, }, function(source) + if not exports.qbx_core:IsOptin(source) then exports.qbx_core:Notify(source, locale('error.not_optin'), 'error') return end local vehicle = GetVehiclePedIsIn(GetPlayerPed(source), false) if vehicle == 0 then return exports.qbx_core:Notify(source, 'You have to be in a vehicle, to use this', 'error') @@ -83,6 +88,7 @@ lib.addCommand('setmodel', { {name = 'id', help = 'Player ID', type = 'number', optional = true}, } }, function(source, args) + if not exports.qbx_core:IsOptin(source) then exports.qbx_core:Notify(source, locale('error.not_optin'), 'error') return end local Target = args.id or source if not exports.qbx_core:GetPlayer(Target) then return end @@ -94,6 +100,7 @@ lib.addCommand('vec2', { help = 'Copy vector2 to clipboard (Admin only)', restricted = config.dev, }, function(source) + if not exports.qbx_core:IsOptin(source) then exports.qbx_core:Notify(source, locale('error.not_optin'), 'error') return end TriggerClientEvent('qbx_admin:client:copyToClipboard', source, 'coords2') end) @@ -101,6 +108,7 @@ lib.addCommand('vec3', { help = 'Copy vector3 to clipboard (Admin only)', restricted = config.dev, }, function(source) + if not exports.qbx_core:IsOptin(source) then exports.qbx_core:Notify(source, locale('error.not_optin'), 'error') return end TriggerClientEvent('qbx_admin:client:copyToClipboard', source, 'coords3') end) @@ -108,6 +116,7 @@ lib.addCommand('vec4', { help = 'Copy vector4 to clipboard (Admin only)', restricted = config.dev, }, function(source) + if not exports.qbx_core:IsOptin(source) then exports.qbx_core:Notify(source, locale('error.not_optin'), 'error') return end TriggerClientEvent('qbx_admin:client:copyToClipboard', source, 'coords4') end) @@ -115,5 +124,6 @@ lib.addCommand('heading', { help = 'Copy heading to clipboard (Admin only)', restricted = config.dev, }, function(source) + if not exports.qbx_core:IsOptin(source) then exports.qbx_core:Notify(source, locale('error.not_optin'), 'error') return end TriggerClientEvent('qbx_admin:client:copyToClipboard', source, 'heading') end) \ No newline at end of file diff --git a/server/main.lua b/server/main.lua index 5f7f5e0..c3c9764 100644 --- a/server/main.lua +++ b/server/main.lua @@ -12,7 +12,9 @@ REPORTS = {} function OnAdmin(permission, cb) for k, v in pairs(exports.qbx_core:GetQBPlayers()) do if IsPlayerAceAllowed(k, permission) then - cb(v) + if exports.qbx_core:IsOptin(k) then + cb(v) + end end end end @@ -53,6 +55,7 @@ end RegisterNetEvent('qbx_admin:server:sendReply', function(report, message) if not IsPlayerAceAllowed(source, config.commandPerms.reportReply) then exports.qbx_core:Notify(source, locale('error.no_perms'), 'error') return end + if not exports.qbx_core:IsOptin(source) then exports.qbx_core:Notify(source, locale('error.not_optin'), 'error') return end for k, v in pairs(REPORTS) do if v.id == report.id then @@ -74,6 +77,7 @@ end) RegisterNetEvent('qbx_admin:server:deleteReport', function(report) if not IsPlayerAceAllowed(source, config.commandPerms.reportReply) then exports.qbx_core:Notify(source, locale('error.no_perms'), 'error') return end + if not exports.qbx_core:IsOptin(source) then exports.qbx_core:Notify(source, locale('error.not_optin'), 'error') return end for k, v in pairs(REPORTS) do if v.id == report.id then @@ -118,6 +122,7 @@ local generalOptions = { } RegisterNetEvent('qbx_admin:server:playerOptionsGeneral', function(selected, selectedPlayer, input) if not IsPlayerAceAllowed(source, config.eventPerms.playerOptionsGeneral) then exports.qbx_core:Notify(source, locale('error.no_perms'), 'error') return end + if not exports.qbx_core:IsOptin(source) then exports.qbx_core:Notify(source, locale('error.not_optin'), 'error') return end ---@diagnostic disable-next-line: redundant-parameter generalOptions[selected](selectedPlayer, source, input) @@ -126,10 +131,13 @@ end) local administrationOptions = { function(source, selectedPlayer, input) if not IsPlayerAceAllowed(source, config.eventPerms.kick) then exports.qbx_core:Notify(source, locale('error.no_perms'), 'error') return end + if not exports.qbx_core:IsOptin(source) then exports.qbx_core:Notify(source, locale('error.not_optin'), 'error') return end + DropPlayer(selectedPlayer.id, input) end, function(source, selectedPlayer, input) if not IsPlayerAceAllowed(source, config.eventPerms.ban) then exports.qbx_core:Notify(source, locale('error.no_perms'), 'error') return end + if not exports.qbx_core:IsOptin(source) then exports.qbx_core:Notify(source, locale('error.not_optin'), 'error') return end local banDuration = (input[2] or 0) * 3600 + (input[3] or 0) * 86400 + (input[4] or 0) * 2629743 DropPlayer(selectedPlayer.id, locale('player_options.administration.banreason', input[1], os.date('%c', os.time() + banDuration))) MySQL.Async.insert('INSERT INTO bans (name, license, discord, ip, reason, expire, bannedby) VALUES (?, ?, ?, ?, ?, ?, ?)', { @@ -139,6 +147,7 @@ local administrationOptions = { end, function(source, selectedPlayer, input) if not IsPlayerAceAllowed(source, config.eventPerms.changePerms) then exports.qbx_core:Notify(source, locale('error.no_perms'), 'error') return end + if not exports.qbx_core:IsOptin(source) then exports.qbx_core:Notify(source, locale('error.not_optin'), 'error') return end if input == 'remove' then exports.qbx_core:RemovePermission(selectedPlayer.id) else exports.qbx_core:AddPermission(selectedPlayer.id, input) end end, } @@ -182,6 +191,8 @@ RegisterNetEvent('qbx_admin:server:changePlayerData', function(selected, selecte local target = exports.qbx_core:GetPlayer(selectedPlayer.id) if not IsPlayerAceAllowed(source, config.eventPerms.changePlayerData) then exports.qbx_core:Notify(source, locale('error.no_perms'), 'error') return end + if not exports.qbx_core:IsOptin(source) then exports.qbx_core:Notify(source, locale('error.not_optin'), 'error') return end + if not target then return end playerDataOptions[selected](target, input) @@ -192,6 +203,7 @@ RegisterNetEvent('qbx_admin:server:giveAllWeapons', function(weaponType, playerI local target = exports.qbx_core:GetPlayer(src) if not IsPlayerAceAllowed(source, config.eventPerms.giveAllWeapons) then exports.qbx_core:Notify(source, locale('error.no_perms'), 'error') return end + if not exports.qbx_core:IsOptin(source) then exports.qbx_core:Notify(source, locale('error.not_optin'), 'error') return end for i = 1, #config.weaponList[weaponType], 1 do target.Functions.AddItem(config.weaponList[weaponType][i], 1) @@ -203,6 +215,7 @@ lib.callback.register('qbx_admin:callback:getradiolist', function(source, freque local players = {} if not IsPlayerAceAllowed(source, config.eventPerms.getRadioList) then exports.qbx_core:Notify(source, locale('error.no_perms'), 'error') return end + if not exports.qbx_core:IsOptin(source) then exports.qbx_core:Notify(source, locale('error.not_optin'), 'error') return end for targetSource, _ in pairs(list) do -- cheers Knight who shall not be named local player = exports.qbx_core:GetPlayer(targetSource) @@ -216,6 +229,7 @@ end) lib.callback.register('qbx_admin:server:getPlayers', function(source) if not IsPlayerAceAllowed(source, config.eventPerms.useMenu) then exports.qbx_core:Notify(source, locale('error.no_perms'), 'error') return end + if not exports.qbx_core:IsOptin(source) then exports.qbx_core:Notify(source, locale('error.not_optin'), 'error') return end local players = {} for k, v in pairs(exports.qbx_core:GetQBPlayers()) do @@ -245,6 +259,7 @@ end) lib.callback.register('qbx_admin:server:getPlayer', function(source, playerToGet) if not IsPlayerAceAllowed(source, config.eventPerms.useMenu) then exports.qbx_core:Notify(source, locale('error.no_perms'), 'error') return end + if not exports.qbx_core:IsOptin(source) then exports.qbx_core:Notify(source, locale('error.not_optin'), 'error') return end local playerData = exports.qbx_core:GetPlayer(playerToGet).PlayerData local player = { @@ -270,10 +285,8 @@ lib.callback.register('qbx_admin:server:getPlayer', function(source, playerToGet end) lib.callback.register('qbx_admin:server:clothingMenu', function(source, target) - if not IsPlayerAceAllowed(source, config.eventPerms.clothingMenu) then - exports.qbx_core:Notify(source, locale('error.no_perms'), 'error') - return false - end + if not IsPlayerAceAllowed(source, config.eventPerms.clothingMenu) then exports.qbx_core:Notify(source, locale('error.no_perms'), 'error') return false end + if not exports.qbx_core:IsOptin(source) then exports.qbx_core:Notify(source, locale('error.not_optin'), 'error') return false end TriggerClientEvent('qb-clothing:client:openMenu', target) @@ -281,10 +294,8 @@ lib.callback.register('qbx_admin:server:clothingMenu', function(source, target) end) lib.callback.register('qbx_admin:server:canUseMenu', function(source) - if not IsPlayerAceAllowed(source, config.eventPerms.useMenu) then - exports.qbx_core:Notify(source, locale('error.no_perms'), 'error') - return false - end + if not IsPlayerAceAllowed(source, config.eventPerms.useMenu) then exports.qbx_core:Notify(source, locale('error.no_perms'), 'error') return false end + if not exports.qbx_core:IsOptin(source) then exports.qbx_core:Notify(source, locale('error.not_optin'), 'error') return false end return true end) @@ -303,6 +314,6 @@ end) lib.callback.register('qbx_admin:server:getReports', function(source) if not IsPlayerAceAllowed(source, config.commandPerms.reportReply) then exports.qbx_core:Notify(source, locale('error.no_perms'), 'error') return end - + if not exports.qbx_core:IsOptin(source) then exports.qbx_core:Notify(source, locale('error.not_optin'), 'error') return end return REPORTS end) \ No newline at end of file