Skip to content

Commit

Permalink
feat(modules/lib): add veh spawn routing buckets
Browse files Browse the repository at this point in the history
* feat(modules/lib): add veh spawn routing buckets

vehicle server side spawns aren't routing bucket aware. this adds two options for setting the routing bucket of the resultant spawned vehicle before returning.

* refactor(modules/lib): only set bucket if needed

* refactor(modules/lib): use internal function

* refactor(modules/lib): remove unneeded nil

---------

Co-authored-by: BerkieBb <82737367+BerkieBb@users.noreply.github.com>
Co-authored-by: Manason <clanerp@gmail.com>
  • Loading branch information
3 people committed May 23, 2024
1 parent 5695277 commit 83616f4
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions modules/lib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ if isServer then
---@field spawnSource integer | vector3 | vector4 ped id or coords
---@field warp? boolean | integer a ped id to warp inside the vehicle, or additionally a boolean if `spawnSource` is a ped
---@field props? table https://overextended.dev/ox_lib/Modules/VehicleProperties/Client#vehicle-properties
---@field bucket? integer routing bucket to move spawned entity to.

---Creates a vehicle on the server-side and returns its `netId`.
---
Expand All @@ -235,6 +236,7 @@ if isServer then
local warp = params.warp
local ped = type(warp) == 'number' and warp or (sourceType == 'number' and warp and source or nil)
local props = params.props
local bucket = params.bucket

---@type vector4
local coords
Expand Down Expand Up @@ -268,6 +270,11 @@ if isServer then

if ped then
SetPedIntoVehicle(ped, veh, -1)
bucket = GetEntityRoutingBucket(ped) or nil
end

if bucket and bucket > 0 then
SetEntityBucket(veh, bucket)
end
local netId = NetworkGetNetworkIdFromEntity(veh)

Expand Down

0 comments on commit 83616f4

Please sign in to comment.