PlayerEnterColshape: Difference between revisions

From RAGE Multiplayer Wiki
No edit summary
No edit summary
 
(15 intermediate revisions by 5 users not shown)
Line 1: Line 1:
This event is triggered when a player enters a colshape.
This event is triggered when a player enters a colshape.  


** This event IS NOT triggered when a player enters a colshape, neither server-side or client-side.
Default dimension for Colshapes is 0, and the player must be in the same dimension as the Colshape for them to collide.
{{ServersideCsJsEvent}}


==Parameters==
{{CSharpContainer|1=
* '''player''' - player which entered the colshape
See [[OnPlayerEnterColShape]].
* '''shape''' - the colshape the player entered
}}


==Example==
{{JSContainer|
<div class="header" style="background-color: #408DAE; color: #FFFFFF; border: 2px solid #408DAE;">
{{Parameters}}
<div style="margin: 10px 10px 10px 10px;"><b>Server-Side</b></div>
* '''player''': {{RageType|Player}} - The [[:Category:Player API|player]] which entered the colshape
<syntaxhighlight lang="javascript">
* '''shape''': {{RageType|ColShape}} - The [[:Category:ColShape API|colshape]] the player entered
 
{{Example}}
<pre>
let someColShape = mp.colshapes.newRectangle(0, 0, 100, 100);
let someColShape = mp.colshapes.newRectangle(0, 0, 100, 100);


Line 20: Line 24:


mp.events.add("playerEnterColshape", playerEnterColshapeHandler);
mp.events.add("playerEnterColshape", playerEnterColshapeHandler);
</pre>
}}
{{ClientsideCsJsEvent}}
{{CSharpContainer|
<syntaxhighlight lang="c#">
public delegate void OnPlayerEnterColshapeDelegate(Colshape colshape, CancelEventArgs cancel);
</syntaxhighlight>
</syntaxhighlight>
</div>


{{Parameters}}
* '''colshape''': colshape, expects '''RAGE.Elements.Colshape''' type.
* '''cancel''': cancel, expects '''RAGE.Events.CancelEventArgs''' type.


<div class="header" style="background-color: #AE4040; color: #FFFFFF; border: 2px solid #AE4040;">
{{Example}}
<div style="margin: 10px 10px 10px 10px;"><b>Client-Side</b></div>
<syntaxhighlight lang="csharp">
<syntaxhighlight lang="javascript">
Events.OnPlayerEnterColshape += OnPlayerEnterColshape;
</syntaxhighlight>
<syntaxhighlight lang="csharp">
public void OnPlayerEnterColshape(RAGE.Elements.Colshape colshape, RAGE.Events.CancelEventArgs cancel)
{
    RAGE.Chat.Output($"You entered colshape id:{colshape.Id}");
}
</syntaxhighlight>
}}
 
{{JSContainer|
{{Parameters}}
* '''shape''': {{RageType|ColShape}}
 
{{Example}}
<pre>
mp.events.add('playerEnterColshape', (shape) => {
mp.events.add('playerEnterColshape', (shape) => {
     mp.game.graphics.notify(`You entered a colshape with id "${shape.id}".`);
     mp.game.graphics.notify(`You entered a colshape with id "${shape.id}".`);
});
});
</syntaxhighlight>
</pre>
</div>
}}


==See also==
=See also=
{{Player_events}}
{{Player_events}}
[[Category:Player]]
[[Category:ColShape]]
[[Category:Server-side Event]]
[[Category:Client-side Event]]

Latest revision as of 12:04, 1 May 2024

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




C# Syntax


JavaScript Syntax

Parameters

  • player: Player - The player which entered the colshape
  • shape: ColShape - 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

Parameters

  • shape: ColShape

Example

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