OnPlayerSpawn

From GTA Network Wiki
Jump to: navigation, search

OnPlayerSpawn
Shared Function

utilities-terminal.png Server-Side system-users.png Client-Side csharp.png C#

This type of event is used for handling your code when you spawn.



Server-side

Subscribing

Note: the Attribute should be declared above the method to be invoked, it's alternative to subscribing the method to a delegate, introduced for performance reasons.

[ServerEvent(Event.PlayerSpawn)]

Method Syntax

void OnPlayerSpawn(Client player)

Required Parameters

  • Client: player who spawned.

Usage example(s)

[ServerEvent(Event.PlayerSpawn)]
public void OnPlayerSpawn(Client player)
{
    // Some code
}


Client-side

Subscribing

Note: the method should be subscribed to the respective event delegate in your Main constructor/Entry point for it to be invoked.

public Main() 
{
    Events.OnPlayerSpawn += OnPlayerSpawn;
}

Method Syntax

void OnPlayerSpawn(RAGE.Events.CancelEventArgs cancel)

Required Parameters

  • cancel: cancel, expects RAGE.Events.CancelEventArgs type.

Example

public void OnPlayerSpawn(RAGE.Events.CancelEventArgs cancel)
{
    RAGE.Chat.Output($"You've spawned");
}

References