PlayerSpawn: Difference between revisions
m (Replaced HTML with template) |
No edit summary |
||
| (6 intermediate revisions by 3 users not shown) | |||
| Line 1: | Line 1: | ||
This event is triggered when a player spawns. | This event is triggered when a player spawns. | ||
{{ServersideCsJsEvent}} | |||
= | {{CSharpContainer|1= | ||
See [[OnPlayerSpawn]]. | |||
}} | |||
{{JSContainer| | |||
{{Parameters}} | |||
* '''player''': {{RageType|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 13: | Line 19: | ||
mp.events.add("playerSpawn", playerSpawn); | mp.events.add("playerSpawn", playerSpawn); | ||
</pre> | |||
}} | |||
{{ClientsideCsJsEvent}} | |||
{{CSharpContainer| | |||
<syntaxhighlight lang="csharp"> | |||
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="csharp"> | |||
Events.OnPlayerSpawn += OnPlayerSpawn; | |||
</syntaxhighlight> | |||
<syntaxhighlight lang="csharp"> | |||
public void OnPlayerSpawn(RAGE.Events.CancelEventArgs cancel) | |||
{ | |||
RAGE.Chat.Output($"You just spawned"); | |||
} | |||
</syntaxhighlight> | |||
}} | |||
{{JSContainer| | |||
{{Parameters}} | |||
* '''player''': {{RageType|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. | |||
<pre> | |||
mp.events.add("playerSpawn", (player) => { | |||
mp.gui.chat.push("Hey " + player.name + ", you just spawned"); | |||
}); | |||
</pre> | </pre> | ||
}} | }} | ||
| Line 18: | Line 60: | ||
==See also== | ==See also== | ||
{{Player_events}} | {{Player_events}} | ||
[[Category:Player]] | |||
[[Category:Server-side Event]] | |||
[[Category:Client-side Event]] | |||
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