OnPlayerExitCheckpoint

From GTA Network Wiki
Jump to: navigation, search

OnPlayerExitCheckpoint
Shared Function

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

Event triggered when a player leaves a checkpoint



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.PlayerExitCheckpoint)]

Method Syntax

void OnPlayerExitCheckpoint(Checkpoint checkpoint, Client player)

Required Parameters

  • Checkpoint: the checkpoint which got exited by the player.
  • Client: the player.

Usage example(s)

[ServerEvent(Event.PlayerExitCheckpoint)]
public void OnPlayerExitCheckpoint(Checkpoint checkpoint, Client player)
{
    // Some code..
}


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.OnPlayerExitCheckpoint += OnPlayerExitCheckpoint;
}

Method Syntax

void OnPlayerExitCheckpoint(Checkpoint checkpoint, CancelEventArgs cancel)

Required Parameters

  • checkpoint: checkpoint, expects RAGE.Elements.Checkpoint type.
  • cancel: cancel, expects RAGE.Events.CancelEventArgs type.

Example

The example below shows a message to player with the position of the checkpoint they just exited.

public void OnPlayerExitCheckpoint(RAGE.Elements.Checkpoint checkpoint, RAGE.Events.CancelEventArgs cancel)
{
    Vector3 pos = checkpoint.Position;
    RAGE.Chat.Output($"Player just left the checkpoint at X{pos.X} Y{pos.Y} Z{pos.Z}");
}

References