Skip to content

Commit 8d6cab9

Browse files
feat: serverIds in getOtherPlayersInVehicle (#61)
1 parent 90d76b3 commit 8d6cab9

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

client/main.lua

+6-6
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ local function setVehicleDoorLock(vehicle, state, anim)
8080
TaskPlayAnim(cache.ped, 'anim@mp_player_intmenu@key_fob@', 'fob_click', 3.0, 3.0, -1, 49, 0, false, false, false)
8181
end
8282

83-
TriggerServerEvent('InteractSound_SV:PlayWithinDistance', 5, 'lock', 0.3)
83+
StartVehicleHorn(vehicle, 1, 'HELDDOWN', false)
8484
NetworkRequestControlOfEntity(vehicle)
8585

8686
local lockstate
@@ -111,14 +111,14 @@ end
111111
exports('SetVehicleDoorLock', setVehicleDoorLock)
112112

113113
local function getOtherPlayersInVehicle(vehicle)
114-
local otherPeds = {}
114+
local otherPlayers = {}
115115
for seat = -1, GetVehicleModelNumberOfSeats(GetEntityModel(vehicle)) - 2 do
116116
local pedInSeat = GetPedInVehicleSeat(vehicle, seat)
117-
if IsPedAPlayer(pedInSeat) and pedInSeat ~= cache.ped then
118-
otherPeds[#otherPeds + 1] = pedInSeat
117+
if pedInSeat ~= cache.ped and IsPedAPlayer(pedInSeat) then
118+
otherPlayers[#otherPlayers + 1] = GetPlayerServerId(NetworkGetPlayerIndexFromPed(pedInSeat))
119119
end
120120
end
121-
return otherPeds
121+
return otherPlayers
122122
end
123123

124124
local function getPedsInVehicle(vehicle)
@@ -410,7 +410,7 @@ RegisterNetEvent('qb-vehiclekeys:client:GiveKeys', function(id, plate)
410410
if IsPedSittingInVehicle(cache.ped, targetVehicle) then -- Give keys to everyone in vehicle
411411
local otherOccupants = getOtherPlayersInVehicle(targetVehicle)
412412
for p = 1, #otherOccupants do
413-
TriggerServerEvent('qb-vehiclekeys:server:GiveVehicleKeys', GetPlayerServerId(NetworkGetPlayerIndexFromPed(otherOccupants[p])), targetPlate)
413+
TriggerServerEvent('qb-vehiclekeys:server:GiveVehicleKeys', otherOccupants[p], targetPlate)
414414
end
415415
else -- Give keys to closest player
416416
local playerId = lib.getClosestPlayer(GetEntityCoords(cache.ped), 3, false)

0 commit comments

Comments
 (0)