PlayerSpawn: Difference between revisions
(clientside js) |
No edit summary |
||
| (3 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
This event is triggered when a player spawns. | This event is triggered when a player spawns. | ||
{{ServersideCsJsEvent}} | {{ServersideCsJsEvent}} | ||
{{CSharpContainer|1= | |||
See [[OnPlayerSpawn]]. | |||
}} | |||
{{JSContainer| | {{JSContainer| | ||
{{Parameters}} | {{Parameters}} | ||
* '''player''' - player, which has spawned | * '''player''': {{RageType|Player}} - player, which has spawned | ||
{{Example}} | {{Example}} | ||
| Line 17: | Line 23: | ||
{{ClientsideCsJsEvent}} | {{ClientsideCsJsEvent}} | ||
{{CSharpContainer| | {{CSharpContainer| | ||
<syntaxhighlight lang=" | <syntaxhighlight lang="csharp"> | ||
public delegate void OnPlayerSpawnDelegate(CancelEventArgs cancel); | public delegate void OnPlayerSpawnDelegate(CancelEventArgs cancel); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| Line 28: | Line 35: | ||
The example below shows a chat message to the client when they spawn. | The example below shows a chat message to the client when they spawn. | ||
<syntaxhighlight lang=" | <syntaxhighlight lang="csharp"> | ||
Events.OnPlayerSpawn += OnPlayerSpawn; | Events.OnPlayerSpawn += OnPlayerSpawn; | ||
</syntaxhighlight> | </syntaxhighlight> | ||
<syntaxhighlight lang=" | <syntaxhighlight lang="csharp"> | ||
public void OnPlayerSpawn(RAGE.Events.CancelEventArgs cancel) | public void OnPlayerSpawn(RAGE.Events.CancelEventArgs cancel) | ||
{ | { | ||
| Line 38: | Line 45: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
}} | }} | ||
{{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> | ||
}} | }} | ||
==See also== | ==See also== | ||
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