OnPlayerEnterColShape

From GTA Network Wiki
Jump to: navigation, search

OnPlayerEnterColShape
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 enters a ColShape.



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

Method Syntax

void OnPlayerEnterColshape(ColShape shape, Client player)

Required Parameteres

  • ColShape: the colshape.
  • Client: the player.

Usage example(s)

[ServerEvent(Event.PlayerEnterColshape)]
public void OnPlayerEnterColshape(ColShape shape, 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.OnPlayerEnterColshape += OnPlayerEnterColshape;
}

Method Syntax

void OnPlayerEnterColshape(Colshape colshape, CancelEventArgs cancel)

Required Parameters

  • colshape: colshape, expects RAGE.Elements.Colshape type.
  • cancel: cancel, expects RAGE.Events.CancelEventArgs type.

Example

The example below sends a chat message to play when they enter a vehicle, showing whether they are driver or passenger.

public void OnPlayerEnterColshape(RAGE.Elements.Colshape colshape, RAGE.Events.CancelEventArgs cancel)
{
    RAGE.Chat.Output($"You entered colshape id:{colshape.Id}");
}

References