PlayerEnterColshape: Difference between revisions

From RAGE Multiplayer Wiki
(Added client-side example)
No edit summary
Line 9: Line 9:
<div style="margin: 10px 10px 10px 10px;"><b>Server-Side</b></div>
<div style="margin: 10px 10px 10px 10px;"><b>Server-Side</b></div>
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
  let someColShape = mp.colshapes.newRectangle(0, 0, 100, 100);
let someColShape = mp.colshapes.newRectangle(0, 0, 100, 100);


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


  mp.events.add("playerEnterColshape", playerEnterColshapeHandler);
mp.events.add("playerEnterColshape", playerEnterColshapeHandler);
</syntaxhighlight>
</syntaxhighlight>
</div>
</div>
Line 25: Line 25:
<div style="margin: 10px 10px 10px 10px;"><b>Client-Side</b></div>
<div style="margin: 10px 10px 10px 10px;"><b>Client-Side</b></div>
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
  let someColShape = mp.colshapes.newRectangle(0, 0, 100, 100);
let someColShape = mp.colshapes.newRectangle(0, 0, 100, 100);


  function playerEnterColshapeHandler(shape) {
function playerEnterColshapeHandler(shape) {
    if(shape == someColShape) {
  if(shape == someColShape) {
      //Local player entered the colshape
    //Local player entered the colshape
    }
   }
   }
}


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

Revision as of 20:40, 15 October 2017

This event is triggered when a player enters a colshape.

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
let someColShape = mp.colshapes.newRectangle(0, 0, 100, 100);

function playerEnterColshapeHandler(shape) {
  if(shape == someColShape) {
    //Local player entered the colshape
  }
}

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

See also

Checkpoint

Colshape

Entity

Player

Streaming

Vehicle

Waypoint