YaGame¶
YaGame
controls the players of a game.Functions¶
void WaitUntilConnected(function callback)¶
Use this API to delay the logic until this endpoint is connected to the network.
If this endpoint is already connected, the callback will be invoked immediately.
Otherwise, the callback will be invoked just before the first joining event.
callback
the callback function to be executed when connected
YaPlayerComponent GetLocalPlayer()¶
CLIENT ONLY
Returnsnull if local player does not exist (the client has not join a game)
Gets the local player.
Because a server does not represent a player, this API only works for the client and not a dedicated server.
number GetSteamAppId()¶
Returns0 if steamwork initial fail
Gets the SteamAppId.
number GetSteamUserId()¶
Returns0 if steamwork initial fail
Gets the SteamUserId.
YaPlayerComponent GetPlayer(number playerId)¶
Returnsnull if the player does not exist
Gets the player using the player ID provided.
playerId
The unique identifier of the player
Array<YaPlayerComponent> GetPlayers()¶
ReturnsA list of players in the current game
Gets a list of players in the current game.
YaEntity GetLocalPlayerEntity()¶
CLIENT ONLY
ReturnsLocal player entity
Gets the local player.
Because a server does not represent a player, this API only works for the client and not a dedicated server.
YaEntity GetPlayerEntity(number playerId)¶
ReturnsThe player entity
Gets the player entity using the player ID provided.
playerId
The unique identifier of the player
Array<YaEntity> GetPlayerEntities()¶
ReturnsA list of player entities in the current game
Gets a list of player entities in the current game.
Events¶
PlayerJoinedEvent<number>¶
Fired when a player joins the game.
playerId
The unique identifier of the player that joins the game
1 2 3 4 5 |
|
PlayerLeftEvent<number>¶
Fired when a player leaves the game.
To get the player, call
YaGame:GetPlayer(playerId)
instead of YaGame:GetPlayers()
.
playerId
The unique identifier of the player that leaves the game
1 2 3 4 5 6 7 |
|