OnPlayerExitVehicle

From GTA Network Wiki
Jump to: navigation, search

OnPlayerExitVehicle
Shared Function

utilities-terminal.png Server-Side system-users.png Client-Side csharp.png C#

This type of event is used for handling code when the player exits any type of vehicle.



Server-side

Subscribing

Note: the Attribute should be declared above the method to be invoked, it's alternative to subscribing the method to a delegate, introduced for performance reasons.

[ServerEvent(Event.PlayerExitVehicle)]

Method Syntax

void OnPlayerExitVehicle(Client player, Vehicle vehicle)

Required Parameters

  • Client: the player.
  • Vehicle: the vehicle.

Example

Before we start, myAwesomeVeh variable is of NetHandle type defined somewhere in the script, if missing, it will output an error

[ServerEvent(Event.PlayerExitVehicle)]
public void OnPlayerExitVehicle(Client player, Vehicle vehicle)
{
    if (vehicle == myAwesomeVeh)
    {
        NAPI.Chat.SendChatMessageToPlayer(player, "You've left that awesome vehicle!");
    }
}


Client-side

Subscribing

Note: the method should be subscribed to the respective event delegate in your Main constructor/Entry point for it to be invoked.

public Main() 
{
    Events.OnPlayerLeaveVehicle += OnPlayerLeaveVehicle;
}

Method Syntax

void OnPlayerLeaveVehicle()

Example

The example below sends a chat message to play when they leave a vehicle.

public void OnPlayerLeaveVehicle()
{
    RAGE.Chat.Output("You exited a vehicle");
}

References