Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(character): Use tutorial natives instead of manual bucket setting #480

Merged
merged 3 commits into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions client/character.lua
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,11 @@ 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
4 changes: 4 additions & 0 deletions client/events.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function()
NetworkSetFriendlyFireOption(true)
end

if NetworkIsInTutorialSession() then
NetworkEndTutorialSession()
end

local motd = GetConvar('qbx:motd', '')
if motd ~= '' then
exports.chat:addMessage({ template = motd })
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