PlayerSpawn: Difference between revisions
No edit summary |
No edit summary |
||
| (2 intermediate revisions by one other user not shown) | |||
| Line 4: | Line 4: | ||
{{CSharpContainer|1= | {{CSharpContainer|1= | ||
See [ | See [[OnPlayerSpawn]]. | ||
}} | }} | ||
| Line 47: | Line 47: | ||
{{JSContainer| | {{JSContainer| | ||
{{Parameters}} | |||
* '''player''': {{RageType|Player}} - player, which has spawned (always the same as mp.players.local, only works with local player) | |||
{{Example}} | {{Example}} | ||
This example outputs a console chat message to the client when they spawns. | This example outputs a console chat message to the client when they spawns. | ||
<pre> | <pre> | ||
mp.events.add("playerSpawn", () => { | mp.events.add("playerSpawn", (player) => { | ||
mp.gui.chat.push(" | mp.gui.chat.push("Hey " + player.name + ", you just spawned"); | ||
}); | }); | ||
</pre> | </pre> | ||
Latest revision as of 19:02, 15 May 2024
This event is triggered when a player spawns.
Server-Side Event
C# Syntax
See OnPlayerSpawn.
JavaScript Syntax
Parameters
- player: Player - player, which has spawned
Example
This example outputs a console chat message, when a player spawns.
function playerSpawn(player) {
console.log(`${player.name} has spawned`);
}
mp.events.add("playerSpawn", playerSpawn);
Client-Side Event
C# Syntax
public delegate void OnPlayerSpawnDelegate(CancelEventArgs cancel);
Parameters
- cancel: cancel, expects RAGE.Events.CancelEventArgs type.
Example
The example below shows a chat message to the client when they spawn.
Events.OnPlayerSpawn += OnPlayerSpawn;
public void OnPlayerSpawn(RAGE.Events.CancelEventArgs cancel)
{
RAGE.Chat.Output($"You just spawned");
}
JavaScript Syntax
Parameters
- player: Player - player, which has spawned (always the same as mp.players.local, only works with local player)
Example
This example outputs a console chat message to the client when they spawns.
mp.events.add("playerSpawn", (player) => {
mp.gui.chat.push("Hey " + player.name + ", you just spawned");
});
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