mirror of
https://github.com/qbcore-fivem/qb-core.git
synced 2026-08-28 17:01:16 +00:00
fxdk handling + naming + duplicate license
This commit is contained in:
+1
-1
@@ -4,7 +4,7 @@
|
||||
RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function()
|
||||
ShutdownLoadingScreenNui()
|
||||
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)
|
||||
NetworkSetFriendlyFireOption(true)
|
||||
end)
|
||||
|
||||
+9
-9
@@ -6,7 +6,7 @@ QBCore.Commands.IgnoreList = { -- Ignore old perm levels while keeping backwards
|
||||
}
|
||||
|
||||
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
|
||||
local permission = permissions[i]
|
||||
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')
|
||||
|
||||
QBCore.Commands.Add('togglepvp', Lang:t('command.togglepvp.help'), {}, false, function()
|
||||
QBConfig.Server.PVP = not QBConfig.Server.PVP
|
||||
TriggerClientEvent('QBCore:Client:PvpHasToggled', -1, QBConfig.Server.PVP)
|
||||
QBCore.Config.Server.PVP = not QBCore.Config.Server.PVP
|
||||
TriggerClientEvent('QBCore:Client:PvpHasToggled', -1, QBCore.Config.Server.PVP)
|
||||
end, 'admin')
|
||||
|
||||
-- Permissions
|
||||
@@ -191,7 +191,7 @@ QBCore.Commands.Add('dv', Lang:t('command.dv.help'), {}, false, function(source)
|
||||
TriggerClientEvent('QBCore:Command:DeleteVehicle', source)
|
||||
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()
|
||||
for _, vehicle in ipairs(vehicles) do
|
||||
DeleteEntity(vehicle)
|
||||
@@ -200,7 +200,7 @@ end, 'admin')
|
||||
|
||||
-- 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()
|
||||
for _, ped in ipairs(peds) do
|
||||
DeleteEntity(ped)
|
||||
@@ -209,7 +209,7 @@ end, 'admin')
|
||||
|
||||
-- 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()
|
||||
for _, object in ipairs(objects) do
|
||||
DeleteEntity(object)
|
||||
@@ -277,20 +277,20 @@ QBCore.Commands.Add('ooc', Lang:t('command.ooc.help'), {}, false, function(sourc
|
||||
for _, v in pairs(Players) do
|
||||
if v == source then
|
||||
TriggerClientEvent('chat:addMessage', v, {
|
||||
color = QBConfig.Commands.OOCColor,
|
||||
color = QBCore.Config.Commands.OOCColor,
|
||||
multiline = true,
|
||||
args = { 'OOC | ' .. GetPlayerName(source), message }
|
||||
})
|
||||
elseif #(playerCoords - GetEntityCoords(GetPlayerPed(v))) < 20.0 then
|
||||
TriggerClientEvent('chat:addMessage', v, {
|
||||
color = QBConfig.Commands.OOCColor,
|
||||
color = QBCore.Config.Commands.OOCColor,
|
||||
multiline = true,
|
||||
args = { 'OOC | ' .. GetPlayerName(source), message }
|
||||
})
|
||||
elseif QBCore.Functions.HasPermission(v, 'admin') then
|
||||
if QBCore.Functions.IsOptin(v) then
|
||||
TriggerClientEvent('chat:addMessage', v, {
|
||||
color = QBConfig.Commands.OOCColor,
|
||||
color = QBCore.Config.Commands.OOCColor,
|
||||
multiline = true,
|
||||
args = { 'Proximity OOC | ' .. GetPlayerName(source), message }
|
||||
})
|
||||
|
||||
+24
-67
@@ -21,84 +21,41 @@ end)
|
||||
|
||||
local function onPlayerConnecting(name, _, deferrals)
|
||||
local src = source
|
||||
local license
|
||||
local identifiers = GetPlayerIdentifiers(src)
|
||||
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)
|
||||
|
||||
if QBCore.Config.Server.Closed then
|
||||
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
|
||||
deferrals.update(string.format('Hello %s. Your license is being checked', name))
|
||||
local license = QBCore.Functions.GetIdentifier(src, 'license')
|
||||
|
||||
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
|
||||
deferrals.done(Lang:t('error.duplicate_license'))
|
||||
return deferrals.done(Lang:t('error.duplicate_license'))
|
||||
end
|
||||
|
||||
local databaseTime = os.clock()
|
||||
local databasePromise = promise.new()
|
||||
Wait(0)
|
||||
deferrals.update(string.format(Lang:t('info.checking_ban'), name))
|
||||
|
||||
-- conduct database-dependant checks
|
||||
CreateThread(function()
|
||||
deferrals.update(string.format(Lang:t('info.checking_ban'), name))
|
||||
local databaseSuccess, databaseError = pcall(function()
|
||||
local isBanned, Reason = QBCore.Functions.IsPlayerBanned(src)
|
||||
if isBanned then
|
||||
deferrals.done(Reason)
|
||||
end
|
||||
end)
|
||||
local success, isBanned, reason = pcall(QBCore.Functions.IsPlayerBanned, src)
|
||||
if not success then return deferrals.done(Lang:t('error.connecting_database_error')) end
|
||||
if isBanned then return deferrals.done(reason) end
|
||||
|
||||
if QBCore.Config.Server.Whitelist then
|
||||
deferrals.update(string.format(Lang:t('info.checking_whitelisted'), name))
|
||||
databaseSuccess, databaseError = pcall(function()
|
||||
if not QBCore.Functions.IsWhitelisted(src) then
|
||||
deferrals.done(Lang:t('error.not_whitelisted'))
|
||||
end
|
||||
end)
|
||||
end
|
||||
Wait(0)
|
||||
deferrals.update(string.format(Lang:t('info.join_server'), name))
|
||||
deferrals.done()
|
||||
|
||||
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)
|
||||
end
|
||||
|
||||
|
||||
@@ -22,7 +22,8 @@ end
|
||||
---@param idtype string
|
||||
---@return string?
|
||||
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
|
||||
|
||||
---Gets a players server id (source). Returns 0 if no player is found.
|
||||
@@ -537,14 +538,8 @@ end
|
||||
function QBCore.Functions.IsLicenseInUse(license)
|
||||
local players = GetPlayers()
|
||||
for _, player in pairs(players) do
|
||||
local identifiers = GetPlayerIdentifiers(player)
|
||||
for _, id in pairs(identifiers) do
|
||||
if string.find(id, 'license') then
|
||||
if id == license then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
local playerLicense = QBCore.Functions.GetIdentifier(player, 'license')
|
||||
if playerLicense == license then return true end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
+1
-1
@@ -178,7 +178,7 @@ function QBCore.Player.CheckPlayerData(source, PlayerData)
|
||||
PlayerData.gang.grade.name = PlayerData.gang.grade.name or 'none'
|
||||
PlayerData.gang.grade.level = PlayerData.gang.grade.level or 0
|
||||
-- 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 {}
|
||||
return QBCore.Player.CreatePlayer(PlayerData, Offline)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user