PlayerEnterColshape: Difference between revisions

From RAGE Multiplayer Wiki
mNo edit summary
No edit summary
Line 24: Line 24:


{{ClientsideCsJsEvent}}
{{ClientsideCsJsEvent}}
{{CSharpContainer|
<syntaxhighlight lang="c#">
public delegate void OnPlayerEnterColshapeDelegate(Colshape colshape, CancelEventArgs cancel);
</syntaxhighlight>
{{Parameters}}
* '''colshape''': colshape, expects '''RAGE.Elements.Colshape''' type.
* '''cancel''': cancel, expects '''RAGE.Events.CancelEventArgs''' type.
{{Example}}
<syntaxhighlight lang="c#">
Events.OnPlayerEnterColshape += OnPlayerEnterColshape;
</syntaxhighlight>
<syntaxhighlight lang="c#">
public void OnPlayerEnterColshape(RAGE.Elements.Colshape colshape, RAGE.Events.CancelEventArgs cancel)
{
    RAGE.Chat.Output($"You entered colshape id:{colshape.Id}");
}
</syntaxhighlight>
}}
{{JSContainer|
{{JSContainer|
<pre>
<pre>

Revision as of 14:43, 28 November 2018

This event is triggered when a player enters a colshape.

Default dimension for Colshapes is 0, and the player must be in the same dimension as the Colshape for them to collide.

Server-Side
Event

 C#  JavaScript



JavaScript Syntax

Parameters

  • player - player which entered the colshape
  • shape - the colshape the player entered

Example

let someColShape = mp.colshapes.newRectangle(0, 0, 100, 100);

function playerEnterColshapeHandler(player, shape) {
  if(shape == someColShape) {
    console.log(`${player.name} entered the colshape`);
  }
}

mp.events.add("playerEnterColshape", playerEnterColshapeHandler);


Client-Side Event

 C#  JavaScript


C# Syntax

public delegate void OnPlayerEnterColshapeDelegate(Colshape colshape, CancelEventArgs cancel);

Parameters

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

Example

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


JavaScript Syntax

mp.events.add('playerEnterColshape', (shape) => {
    mp.game.graphics.notify(`You entered a colshape with id "${shape.id}".`);
});


See also

Checkpoint

Colshape

Entity

Player

Streaming

Vehicle

Waypoint