PlayerSpawn: Difference between revisions
m (Replaced HTML with template) |
No edit summary |
||
| Line 1: | Line 1: | ||
This event is triggered when a player spawns. | This event is triggered when a player spawns. | ||
{{ServersideCsJsEvent}} | |||
{{JSContainer| | |||
{{Parameters}} | |||
* '''player''' - player, which has spawned | * '''player''' - player, which has spawned | ||
{{Example}} | |||
This example outputs a console chat message, when a player spawns. | This example outputs a console chat message, when a player spawns. | ||
<pre> | <pre> | ||
function playerSpawn(player) { | function playerSpawn(player) { | ||
| Line 16: | Line 16: | ||
}} | }} | ||
{{ClientsideCsJsEvent}} | |||
{{CSharpContainer| | |||
<syntaxhighlight lang="c#"> | |||
public delegate void OnPlayerSpawnDelegate(CancelEventArgs cancel); | |||
</syntaxhighlight> | |||
{{Parameters}} | |||
* '''cancel''': cancel, expects '''RAGE.Events.CancelEventArgs''' type. | |||
{{Example}} | |||
The example below shows a chat message to the client when they spawn. | |||
<syntaxhighlight lang="c#"> | |||
Events.OnPlayerSpawn += OnPlayerSpawn; | |||
</syntaxhighlight> | |||
<syntaxhighlight lang="c#"> | |||
public void OnPlayerSpawn(RAGE.Events.CancelEventArgs cancel) | |||
{ | |||
RAGE.Chat.Output($"You just spawned"); | |||
} | |||
</syntaxhighlight> | |||
}} | |||
==See also== | ==See also== | ||
{{Player_events}} | {{Player_events}} | ||
Revision as of 10:15, 29 November 2018
This event is triggered when a player spawns.
Server-Side Event
JavaScript Syntax
Parameters
- 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");
}
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