OnPlayerJoin

From Wiki G1R-MP G1 Remake Multiplayer
Jump to navigation Jump to search

onPlayerJoin

IMPROVED FROM UPDATE 0.1.2
This event is available in earlier releases and has corrected or expanded behavior in G1R:MP 0.1.2 and later. The contract below describes the updated behavior.

Triggered after a client is authenticated and has received its authoritative player ID.

Availability

This event is available in server-side scripts.

Callback signature

onPlayerJoin(playerId)

Parameters

Name Type Description
playerId int The authoritative ID assigned to the joining player.

Examples

Handle the event:

addEventHandler("onPlayerJoin", root, function(playerId)
    outputChatBox("Welcome to the server!", playerId, 225, 195, 110)
end)

Notes

  • This callback runs before the client is required to send its first valid pawn snapshot. The player may therefore still be loading the game world; use onPlayerChatReady for chat UI readiness.
  • Calling spawnPlayer, teleportPlayer, or setPlayerPosition here may return true and queue the authoritative position request until the first valid snapshot proves that the pawn is ready.
  • A successful queue operation is not completion: onPlayerSpawn or onPlayerTeleport is emitted only after the client applies the reliable position-control command and the server accepts its acknowledgement.