PlayerEnterColshape: Difference between revisions

From RAGE Multiplayer Wiki
m (Replaced HTML with template)
Line 8: Line 8:


==Example==
==Example==
<div class="header" style="background-color: #408DAE; color: #FFFFFF; border: 2px solid #408DAE;">
{{ServersideCode|
<div style="margin: 10px 10px 10px 10px;"><b>Server-Side</b></div>
<pre>
<syntaxhighlight lang="javascript">
let someColShape = mp.colshapes.newRectangle(0, 0, 100, 100);
let someColShape = mp.colshapes.newRectangle(0, 0, 100, 100);


Line 20: Line 19:


mp.events.add("playerEnterColshape", playerEnterColshapeHandler);
mp.events.add("playerEnterColshape", playerEnterColshapeHandler);
</syntaxhighlight>
</pre>
</div>
}}




<div class="header" style="background-color: #AE4040; color: #FFFFFF; border: 2px solid #AE4040;">
{{ClientsideCode|
<div style="margin: 10px 10px 10px 10px;"><b>Client-Side</b></div>
<pre>
<syntaxhighlight lang="javascript">
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}}

Revision as of 12:12, 26 October 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 than the Colshape for them to collide.

Parameters

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

Example

Server-Side
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
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