From GTA Network Wiki
Jump to: navigation, search

Server-Side Function

utilities-terminal.png Server-Side csharp.png C#

A function that returns the players who are inside a vehicle.


List<Client> NAPI.Vehicle.GetVehicleOccupants(NetHandle vehicle, int maxOccupants = 4);

Required Arguments

  • vehicle: parameter input should be in NetHandle type.

Usage example

In this example, we're going to retrieve the players inside a vehicle, and we'll send a chat message.

public void CarMates(Client sender)
    // we get the players of the vehicle. We assume that sender is inside a vehicle, and by using getPlayerVehicle we get the NetHandle
    var playersInCar = NAPI.Vehicle.GetVehicleOccupants(sender.Vehicle); 
    sender.SendChatMessage("List of players in your vehicle:");
    foreach (var player in playersInCar) 
        // We'll send a message containing one of the occupant's name

Remember that if you're not in any vehicle, the vehicle doesn't exist or is empty, this function will return an empty list.


Version Description
1.0 Release.