fxdk handling + naming + duplicate license

This commit is contained in:
Kakarot
2023-11-13 03:28:14 -06:00
parent a866b1a049
commit d7323ba147
5 changed files with 39 additions and 87 deletions
+1 -1
View File
@@ -4,7 +4,7 @@
RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function() RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function()
ShutdownLoadingScreenNui() ShutdownLoadingScreenNui()
LocalPlayer.state:set('isLoggedIn', true, false) LocalPlayer.state:set('isLoggedIn', true, false)
if not QBConfig.Server.PVP then return end if not QBCore.Config.Server.PVP then return end
SetCanAttackFriendly(PlayerPedId(), true, false) SetCanAttackFriendly(PlayerPedId(), true, false)
NetworkSetFriendlyFireOption(true) NetworkSetFriendlyFireOption(true)
end) end)
+9 -9
View File
@@ -6,7 +6,7 @@ QBCore.Commands.IgnoreList = { -- Ignore old perm levels while keeping backwards
} }
CreateThread(function() -- Add ace to node for perm checking CreateThread(function() -- Add ace to node for perm checking
local permissions = QBConfig.Server.Permissions local permissions = QBCore.Config.Server.Permissions
for i = 1, #permissions do for i = 1, #permissions do
local permission = permissions[i] local permission = permissions[i]
ExecuteCommand(('add_ace qbcore.%s %s allow'):format(permission, permission)) ExecuteCommand(('add_ace qbcore.%s %s allow'):format(permission, permission))
@@ -120,8 +120,8 @@ QBCore.Commands.Add('tpm', Lang:t('command.tpm.help'), {}, false, function(sourc
end, 'admin') end, 'admin')
QBCore.Commands.Add('togglepvp', Lang:t('command.togglepvp.help'), {}, false, function() QBCore.Commands.Add('togglepvp', Lang:t('command.togglepvp.help'), {}, false, function()
QBConfig.Server.PVP = not QBConfig.Server.PVP QBCore.Config.Server.PVP = not QBCore.Config.Server.PVP
TriggerClientEvent('QBCore:Client:PvpHasToggled', -1, QBConfig.Server.PVP) TriggerClientEvent('QBCore:Client:PvpHasToggled', -1, QBCore.Config.Server.PVP)
end, 'admin') end, 'admin')
-- Permissions -- Permissions
@@ -191,7 +191,7 @@ QBCore.Commands.Add('dv', Lang:t('command.dv.help'), {}, false, function(source)
TriggerClientEvent('QBCore:Command:DeleteVehicle', source) TriggerClientEvent('QBCore:Command:DeleteVehicle', source)
end, 'admin') end, 'admin')
QBCore.Commands.Add('dvall', Lang:t('command.dvall.help'), {}, false, function(source) QBCore.Commands.Add('dvall', Lang:t('command.dvall.help'), {}, false, function()
local vehicles = GetAllVehicles() local vehicles = GetAllVehicles()
for _, vehicle in ipairs(vehicles) do for _, vehicle in ipairs(vehicles) do
DeleteEntity(vehicle) DeleteEntity(vehicle)
@@ -200,7 +200,7 @@ end, 'admin')
-- Peds -- Peds
QBCore.Commands.Add('dvp', Lang:t('command.dvp.help'), {}, false, function(source) QBCore.Commands.Add('dvp', Lang:t('command.dvp.help'), {}, false, function()
local peds = GetAllPeds() local peds = GetAllPeds()
for _, ped in ipairs(peds) do for _, ped in ipairs(peds) do
DeleteEntity(ped) DeleteEntity(ped)
@@ -209,7 +209,7 @@ end, 'admin')
-- Objects -- Objects
QBCore.Commands.Add('dvo', Lang:t('command.dvo.help'), {}, false, function(source) QBCore.Commands.Add('dvo', Lang:t('command.dvo.help'), {}, false, function()
local objects = GetAllObjects() local objects = GetAllObjects()
for _, object in ipairs(objects) do for _, object in ipairs(objects) do
DeleteEntity(object) DeleteEntity(object)
@@ -277,20 +277,20 @@ QBCore.Commands.Add('ooc', Lang:t('command.ooc.help'), {}, false, function(sourc
for _, v in pairs(Players) do for _, v in pairs(Players) do
if v == source then if v == source then
TriggerClientEvent('chat:addMessage', v, { TriggerClientEvent('chat:addMessage', v, {
color = QBConfig.Commands.OOCColor, color = QBCore.Config.Commands.OOCColor,
multiline = true, multiline = true,
args = { 'OOC | ' .. GetPlayerName(source), message } args = { 'OOC | ' .. GetPlayerName(source), message }
}) })
elseif #(playerCoords - GetEntityCoords(GetPlayerPed(v))) < 20.0 then elseif #(playerCoords - GetEntityCoords(GetPlayerPed(v))) < 20.0 then
TriggerClientEvent('chat:addMessage', v, { TriggerClientEvent('chat:addMessage', v, {
color = QBConfig.Commands.OOCColor, color = QBCore.Config.Commands.OOCColor,
multiline = true, multiline = true,
args = { 'OOC | ' .. GetPlayerName(source), message } args = { 'OOC | ' .. GetPlayerName(source), message }
}) })
elseif QBCore.Functions.HasPermission(v, 'admin') then elseif QBCore.Functions.HasPermission(v, 'admin') then
if QBCore.Functions.IsOptin(v) then if QBCore.Functions.IsOptin(v) then
TriggerClientEvent('chat:addMessage', v, { TriggerClientEvent('chat:addMessage', v, {
color = QBConfig.Commands.OOCColor, color = QBCore.Config.Commands.OOCColor,
multiline = true, multiline = true,
args = { 'Proximity OOC | ' .. GetPlayerName(source), message } args = { 'Proximity OOC | ' .. GetPlayerName(source), message }
}) })
+24 -67
View File
@@ -21,84 +21,41 @@ end)
local function onPlayerConnecting(name, _, deferrals) local function onPlayerConnecting(name, _, deferrals)
local src = source local src = source
local license
local identifiers = GetPlayerIdentifiers(src)
deferrals.defer() deferrals.defer()
-- Mandatory wait if QBCore.Config.Server.Closed and not IsPlayerAceAllowed(src, 'qbadmin.join') then
return deferrals.done(QBCore.Config.Server.ClosedReason)
end
if QBCore.Config.Server.Whitelist then
Wait(0)
deferrals.update(string.format(Lang:t('info.checking_whitelist'), name))
if not QBCore.Functions.IsWhitelisted(src) then
return deferrals.done(Lang:t('error.not_whitelisted'))
end
end
Wait(0) Wait(0)
deferrals.update(string.format('Hello %s. Your license is being checked', name))
if QBCore.Config.Server.Closed then local license = QBCore.Functions.GetIdentifier(src, 'license')
if not IsPlayerAceAllowed(src, 'qbadmin.join') then
deferrals.done(QBCore.Config.Server.ClosedReason)
end
end
for _, v in pairs(identifiers) do
if string.find(v, 'license') then
license = v
break
end
end
if GetConvarInt('sv_fxdkMode', false) then
license = 'license:AAAAAAAAAAAAAAAA' -- Dummy License
end
if not license then if not license then
deferrals.done(Lang:t('error.no_valid_license')) return deferrals.done(Lang:t('error.no_valid_license'))
elseif QBCore.Config.Server.CheckDuplicateLicense and QBCore.Functions.IsLicenseInUse(license) then elseif QBCore.Config.Server.CheckDuplicateLicense and QBCore.Functions.IsLicenseInUse(license) then
deferrals.done(Lang:t('error.duplicate_license')) return deferrals.done(Lang:t('error.duplicate_license'))
end end
local databaseTime = os.clock() Wait(0)
local databasePromise = promise.new() deferrals.update(string.format(Lang:t('info.checking_ban'), name))
-- conduct database-dependant checks local success, isBanned, reason = pcall(QBCore.Functions.IsPlayerBanned, src)
CreateThread(function() if not success then return deferrals.done(Lang:t('error.connecting_database_error')) end
deferrals.update(string.format(Lang:t('info.checking_ban'), name)) if isBanned then return deferrals.done(reason) end
local databaseSuccess, databaseError = pcall(function()
local isBanned, Reason = QBCore.Functions.IsPlayerBanned(src)
if isBanned then
deferrals.done(Reason)
end
end)
if QBCore.Config.Server.Whitelist then Wait(0)
deferrals.update(string.format(Lang:t('info.checking_whitelisted'), name)) deferrals.update(string.format(Lang:t('info.join_server'), name))
databaseSuccess, databaseError = pcall(function() deferrals.done()
if not QBCore.Functions.IsWhitelisted(src) then
deferrals.done(Lang:t('error.not_whitelisted'))
end
end)
end
if not databaseSuccess then
databasePromise:reject(databaseError)
end
databasePromise:resolve()
end)
-- wait for database to finish
databasePromise:next(function()
deferrals.update(string.format(Lang:t('info.join_server'), name))
deferrals.done()
end, function(databaseError)
deferrals.done(Lang:t('error.connecting_database_error'))
print('^1' .. databaseError)
end)
-- if conducting checks for too long then raise error
while databasePromise.state == 0 do
if os.clock() - databaseTime > 30 then
deferrals.done(Lang:t('error.connecting_database_timeout'))
error(Lang:t('error.connecting_database_timeout'))
break
end
Wait(1000)
end
-- Add any additional defferals you may need!
TriggerClientEvent('QBCore:Client:SharedUpdate', src, QBCore.Shared) TriggerClientEvent('QBCore:Client:SharedUpdate', src, QBCore.Shared)
end end
+4 -9
View File
@@ -22,7 +22,8 @@ end
---@param idtype string ---@param idtype string
---@return string? ---@return string?
function QBCore.Functions.GetIdentifier(source, idtype) function QBCore.Functions.GetIdentifier(source, idtype)
return GetPlayerIdentifierByType(source, idtype or "license") if GetConvarInt('sv_fxdkMode', 0) == 1 then return 'license:fxdk' end
return GetPlayerIdentifierByType(source, idtype or 'license')
end end
---Gets a players server id (source). Returns 0 if no player is found. ---Gets a players server id (source). Returns 0 if no player is found.
@@ -537,14 +538,8 @@ end
function QBCore.Functions.IsLicenseInUse(license) function QBCore.Functions.IsLicenseInUse(license)
local players = GetPlayers() local players = GetPlayers()
for _, player in pairs(players) do for _, player in pairs(players) do
local identifiers = GetPlayerIdentifiers(player) local playerLicense = QBCore.Functions.GetIdentifier(player, 'license')
for _, id in pairs(identifiers) do if playerLicense == license then return true end
if string.find(id, 'license') then
if id == license then
return true
end
end
end
end end
return false return false
end end
+1 -1
View File
@@ -178,7 +178,7 @@ function QBCore.Player.CheckPlayerData(source, PlayerData)
PlayerData.gang.grade.name = PlayerData.gang.grade.name or 'none' PlayerData.gang.grade.name = PlayerData.gang.grade.name or 'none'
PlayerData.gang.grade.level = PlayerData.gang.grade.level or 0 PlayerData.gang.grade.level = PlayerData.gang.grade.level or 0
-- Other -- Other
PlayerData.position = PlayerData.position or QBConfig.DefaultSpawn PlayerData.position = PlayerData.position or QBCore.Config.DefaultSpawn
PlayerData.items = GetResourceState('qb-inventory') ~= 'missing' and exports['qb-inventory']:LoadInventory(PlayerData.source, PlayerData.citizenid) or {} PlayerData.items = GetResourceState('qb-inventory') ~= 'missing' and exports['qb-inventory']:LoadInventory(PlayerData.source, PlayerData.citizenid) or {}
return QBCore.Player.CreatePlayer(PlayerData, Offline) return QBCore.Player.CreatePlayer(PlayerData, Offline)
end end