List of Players in Vehicle

So I’m attempting to get a list of other Players in a vehicle with the main player, more so the IDs of the players.

Here is the code I use to get all the Peds currently in the players vehicle. I know there is an IS_PED_A_PLAYER native function but I dont know how to get the ID of the player from the Ped object. I’m trying to trigger a client event on the player clients in the car. Maybe I missed the function in the native db but I did scour it.

  local ped = GetPlayerPed(-1)
  
  if IsPedSittingInVehicle(ped) then
    local veh = GetVehiclePedIsUsing(ped)
    local numPas = GetVehicleMaxNumberOfPassengers(veh)
    
    pedsincar = {}
    
    for i = 1, numPas do
      if not IsVehicleSeatFree(veh, i) then
        local pasInSeat = GetPedInVehicleSeat(veh, i)
        table.insert(pedsincar, 1, pasInSeat)
      end
    end
    
    -- do something with all the peds
    for i = 1, #pedsincar do
      TriggerClientEvent('message', --[[ Get player id from ped ]], args)
    end
  end

This is just pseudocode to help illustrate what I am trying to get. Thanks.

Seats range from -1 to 3 if I remember right off the top of my head

NETWORK::NETWORK_GET_PLAYER_INDEX_FROM_PED is possibly what you are looking for. Alternatively, you could look through all online players and check what cars they are in. If its the same vehicle id, then do whatever.

Cool thanks @TylerMcGruber and @Briglair. Both good information. I didn’t think the NETWORK functions worked (I thought they were native for GTAO). Thanks again.