PlayerEnterColshape: Difference between revisions
m (Replaced HTML with template) |
|||
| Line 8: | Line 8: | ||
==Example== | ==Example== | ||
{{ServersideCode| | |||
<pre> | |||
< | |||
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); | ||
</ | </pre> | ||
}} | |||
{{ClientsideCode| | |||
<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}".`); | ||
}); | }); | ||
</ | </pre> | ||
}} | |||
==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
- playerChat
- playerCommand
- playerDamage
- playerDeath
- playerJoin
- playerQuit
- playerReady
- playerSpawn
- playerWeaponChange
Streaming
Vehicle
- playerStartEnterVehicle
- playerEnterVehicle
- playerStartExitVehicle
- playerExitVehicle
- trailerAttached
- vehicleDamage
- vehicleDeath
- vehicleHornToggle
- vehicleSirenToggle