Skip to content

Commit

Permalink
Add GetPlayerPosition() and GetPlayerReady() to api
Browse files Browse the repository at this point in the history
  • Loading branch information
misternebula committed Nov 12, 2023
1 parent 5f92d5d commit 8c76f4f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
13 changes: 13 additions & 0 deletions QSB/API/IQSBAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,19 @@ public interface IQSBAPI
/// <param name="playerID">The ID of the player you want the name of.</param>
string GetPlayerName(uint playerID);

/// <summary>
/// Returns the position of a given player.
/// This position is in world space, where (0, 0, 0) is roughly where the local player is located.
/// </summary>
/// <param name="playerID">The ID of the player you want the position of.</param>
Vector3 GetPlayerPosition(uint playerID);

/// <summary>
/// Returns true if a given player has fully loaded into the game. If the local player is still loading into the game, this will return false.
/// </summary>
/// <param name="playerID">The ID of the player.</param>
bool GetPlayerReady(uint playerID);

/// <summary>
/// Returns the list of IDs of all connected players.
///
Expand Down
7 changes: 7 additions & 0 deletions QSB/API/QSBAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ public void RegisterRequiredForAllPlayers(IModBehaviour mod)

public uint GetLocalPlayerID() => QSBPlayerManager.LocalPlayerId;
public string GetPlayerName(uint playerId) => QSBPlayerManager.GetPlayer(playerId).Name;
public Vector3 GetPlayerPosition(uint playerId) => QSBPlayerManager.GetPlayer(playerId).Body.transform.position;

public bool GetPlayerReady(uint playerId)
{
var player = QSBPlayerManager.GetPlayer(playerId);
return player.IsReady && player.Body != null;
}
public uint[] GetPlayerIDs() => QSBPlayerManager.PlayerList.Select(x => x.PlayerId).ToArray();

public UnityEvent<uint> OnPlayerJoin() => QSBAPIEvents.OnPlayerJoinEvent;
Expand Down

0 comments on commit 8c76f4f

Please sign in to comment.