Skip to content

Commit

Permalink
refactor(character): Use tutorial natives instead of manual bucket se…
Browse files Browse the repository at this point in the history
…tting
  • Loading branch information
googleoblivion authored and solareon committed Aug 14, 2024
1 parent 75fe6aa commit e2e5810
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 11 deletions.
3 changes: 1 addition & 2 deletions client/character.lua
Original file line number Diff line number Diff line change
Expand Up @@ -367,8 +367,7 @@ local function chooseCharacter()
Wait(1000)
SetEntityCoords(cache.ped, randomLocation.pedCoords.x, randomLocation.pedCoords.y, randomLocation.pedCoords.z, false, false, false, false)
SetEntityHeading(cache.ped, randomLocation.pedCoords.w)
---@diagnostic disable-next-line: missing-parameter
lib.callback.await('qbx_core:server:setCharBucket')
if not NetworkIsInTutorialSession() then NetworkStartSoloTutorialSession() end
Wait(1500)
ShutdownLoadingScreen()
ShutdownLoadingScreenNui()
Expand Down
1 change: 1 addition & 0 deletions client/events.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function()
SetCanAttackFriendly(cache.ped, true, false)
NetworkSetFriendlyFireOption(true)
end
if NetworkIsInTutorialSession() then NetworkEndTutorialSession() end
end)

---@param val PlayerData
Expand Down
9 changes: 0 additions & 9 deletions server/character.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ lib.callback.register('qbx_core:server:loadCharacter', function(source, citizenI
local success = Login(source, citizenId)
if not success then return end

SetPlayerBucket(source, 0)
logger.log({
source = 'qbx_core',
webhook = config.logging.webhook['joinleave'],
Expand All @@ -62,19 +61,11 @@ lib.callback.register('qbx_core:server:createCharacter', function(source, data)
if not success then return end

giveStarterItems(source)
if GetResourceState('qbx_spawn') == 'missing' then
SetPlayerBucket(source, 0)
end

lib.print.info(('%s has created a character'):format(GetPlayerName(source)))
return newData
end)

lib.callback.register('qbx_core:server:setCharBucket', function(source)
SetPlayerBucket(source, source)
assert(GetPlayerRoutingBucket(source) == source, 'Multicharacter bucket not set.')
end)

RegisterNetEvent('qbx_core:server:deleteCharacter', function(citizenId)
local src = source
DeleteCharacter(src --[[@as number]], citizenId)
Expand Down

0 comments on commit e2e5810

Please sign in to comment.