Skip to content

Commit

Permalink
refactor: use callbacks instead of netevents for setting vehicle props
Browse files Browse the repository at this point in the history
* refactor: use callback for vehicle spawns

* fix: callback in events.lua
  • Loading branch information
solareon committed Jan 13, 2024
1 parent 848b20c commit a5a1ad6
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
3 changes: 1 addition & 2 deletions client/events.lua
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,7 @@ RegisterNetEvent('QBCore:Command:GoToMarker', function()
end)

-- Vehicle Commands

RegisterNetEvent('qbx_core:client:vehicleSpawned', function(netId, props)
lib.callback.register('qbx_core:client:vehicleSpawned', function(netId, props)
local veh = NetworkGetEntityFromNetworkId(netId)

for i = -1, 0 do
Expand Down
2 changes: 1 addition & 1 deletion modules/lib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ if isServer then
end, 5000)

local netId = NetworkGetNetworkIdFromEntity(veh)
TriggerClientEvent('qbx_core:client:vehicleSpawned', owner, netId, props)
lib.callback.await('qbx_core:client:vehicleSpawned', owner, netId, props)
return netId
end
else
Expand Down
2 changes: 1 addition & 1 deletion modules/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ if isServer then
end, 5000)

local netId = NetworkGetNetworkIdFromEntity(veh)
TriggerClientEvent('qbx_core:client:vehicleSpawned', owner, netId, props)
lib.callback.await('qbx_core:client:vehicleSpawned', owner, netId, props)
return netId
end

Expand Down

0 comments on commit a5a1ad6

Please sign in to comment.