Skip to content

Commit

Permalink
Merge branch 'main' into tutorial-naives
Browse files Browse the repository at this point in the history
  • Loading branch information
mafewtm authored Dec 7, 2024
2 parents d006715 + 23bb76e commit 9627ac8
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 21 deletions.
18 changes: 12 additions & 6 deletions client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,19 @@ QBX.Shared = require 'shared.main'
QBX.IsLoggedIn = false

---@return table<string, Vehicle>
function GetVehiclesByName()
return QBX.Shared.Vehicles
---@overload fun(key: string): Vehicle
function GetVehiclesByName(key)
local vehicles = QBX.Shared.Vehicles
return vehicles[key] or vehicles
end

exports('GetVehiclesByName', GetVehiclesByName)

---@return table<number, Vehicle>
function GetVehiclesByHash()
return QBX.Shared.VehicleHashes
---@overload fun(key: number): Vehicle
function GetVehiclesByHash(key)
local vehicles = QBX.Shared.VehicleHashes
return vehicles[key] or vehicles
end

exports('GetVehiclesByHash', GetVehiclesByHash)
Expand All @@ -27,8 +31,10 @@ end
exports('GetVehiclesByCategory', GetVehiclesByCategory)

---@return table<number, Weapon>
function GetWeapons()
return QBX.Shared.Weapons
---@overload fun(key: number): Weapon
function GetWeapons(key)
local weapons = QBX.Shared.Weapons
return weapons[key] or weapons
end

exports('GetWeapons', GetWeapons)
Expand Down
4 changes: 2 additions & 2 deletions fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ game 'gta5'
name 'qbx_core'
description 'The core resource for the Qbox Framework'
repository 'https://github.com/Qbox-project/qbx_core'
version '1.22.0'
version '1.22.2'

ox_lib 'locale'

Expand Down Expand Up @@ -63,7 +63,7 @@ files {
}

dependencies {
'/server:7290',
'/server:10731',
'/onesync',
'ox_lib',
'oxmysql',
Expand Down
2 changes: 2 additions & 0 deletions modules/lib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,8 @@ if isServer then
error('unable to successfully spawn vehicle after 3 attempts')
end

--- prevent server from deleting a vehicle without an owner
SetEntityOrphanMode(veh, 2)
exports.qbx_core:EnablePersistence(veh)
return netId, veh
end
Expand Down
39 changes: 26 additions & 13 deletions server/player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,17 @@ function Login(source, citizenid, newData)
return false
end

local license = GetPlayerIdentifierByType(source --[[@as string]], 'license2') or GetPlayerIdentifierByType(source --[[@as string]], 'license')
local userId = storage.fetchUserByIdentifier(license)

local license, license2 = GetPlayerIdentifierByType(source --[[@as string]], 'license'), GetPlayerIdentifierByType(source --[[@as string]], 'license2')
local userId = license2 and storage.fetchUserByIdentifier(license2) or storage.fetchUserByIdentifier(license)
if not userId then
lib.print.error('User does not exist. Licenses checked:', license2, license)
return false
end
if citizenid then
local playerData = storage.fetchPlayerEntity(citizenid)
if playerData and license == playerData.license then
if playerData and (playerData.license == license2 or playerData.license == license) then
playerData.userId = userId

return not not CheckPlayerData(source, playerData)
return CheckPlayerData(source, playerData) ~= nil
else
DropPlayer(tostring(source), locale('info.exploit_dropped'))
logger.log({
Expand Down Expand Up @@ -199,9 +201,11 @@ function SetPlayerPrimaryJob(citizenid, jobName)
assert(job.grades[grade] ~= nil, ('job %s does not have grade %s'):format(jobName, grade))

player.PlayerData.job = toPlayerJob(jobName, job, grade)
Save(player.PlayerData.source)

if not player.Offline then
if player.Offline then
SaveOffline(player.PlayerData)
else
Save(player.PlayerData.source)
UpdatePlayerData(player.PlayerData.source)
TriggerEvent('QBCore:Server:OnJobUpdate', player.PlayerData.source, player.PlayerData.job)
TriggerClientEvent('QBCore:Client:OnJobUpdate', player.PlayerData.source, player.PlayerData.job)
Expand Down Expand Up @@ -314,7 +318,11 @@ function RemovePlayerFromJob(citizenid, jobName)
local job = GetJob('unemployed')
assert(job ~= nil, 'cannot find unemployed job. Does it exist in shared/jobs.lua?')
player.PlayerData.job = toPlayerJob('unemployed', job, 0)
Save(player.PlayerData.source)
if player.Offline then
SaveOffline(player.PlayerData)
else
Save(player.PlayerData.source)
end
end

if not player.Offline then
Expand Down Expand Up @@ -417,9 +425,10 @@ function SetPlayerPrimaryGang(citizenid, gangName)
}
}

Save(player.PlayerData.source)

if not player.Offline then
if player.Offline then
SaveOffline(player.PlayerData)
else
Save(player.PlayerData.source)
UpdatePlayerData(player.PlayerData.source)
TriggerEvent('QBCore:Server:OnGangUpdate', player.PlayerData.source, player.PlayerData.gang)
TriggerClientEvent('QBCore:Client:OnGangUpdate', player.PlayerData.source, player.PlayerData.gang)
Expand Down Expand Up @@ -539,7 +548,11 @@ function RemovePlayerFromGang(citizenid, gangName)
level = 0
}
}
Save(player.PlayerData.source)
if player.Offline then
SaveOffline(player.PlayerData)
else
Save(player.PlayerData.source)
end
end

if not player.Offline then
Expand Down

0 comments on commit 9627ac8

Please sign in to comment.