Skip to content
This repository was archived by the owner on Jun 21, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 31 additions & 2 deletions NwPluginAPI/Core/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,37 @@ public string DisplayNickname
/// </summary>
public string IpAddress => ReferenceHub.characterClassManager.connectionToClient.address;

/// <summary>
/// Gets or sets player's scale.
/// </summary>
public Vector3 Scale
{
get => GameObject.transform.localScale;
set
{
if (value == Scale)
return;

try
{
GameObject.transform.localScale = value;
foreach(var player in GetPlayers())
{
Server.SpawnMessage?.Invoke(null, new object[] { NetworkIdentity, player.Connection });
}
}
catch (Exception e)
{
Log.Error($"Error on {nameof(Scale)}: {e}");
}
}
}

/// <summary>
/// Gets player's <see cref="Mirror.NetworkIdentity"/>.
/// </summary>
public NetworkIdentity NetworkIdentity => ReferenceHub.networkIdentity;

/// <summary>
/// Gets or sets the player's current role.
/// </summary>
Expand Down Expand Up @@ -679,7 +710,6 @@ public ItemBase CurrentItem
/// </summary>
public RoomIdentifier Room => RoomIdUtils.RoomAtPosition(GameObject.transform.position);


/// <summary>
/// Get player current zone.
/// </summary>
Expand Down Expand Up @@ -713,7 +743,6 @@ public string RoleName
set => ReferenceHub.serverRoles.SetText(value);
}


/// <summary>
/// Gets the player unit name.
/// </summary>
Expand Down
7 changes: 7 additions & 0 deletions NwPluginAPI/Core/Server.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ namespace PluginAPI.Core
using RoundRestarting;
using static BanHandler;
using static Broadcast;
using System.Reflection;

/// <summary>
/// Represents the server.
/// </summary>
public class Server : Player
{
private static Server _instance;
private static MethodInfo _sendSpawnMessage;

/// <summary>
/// The <see cref="Server"/> instance.
Expand Down Expand Up @@ -104,6 +106,11 @@ public static int ReservedSlots
/// </summary>
public static PermissionsHandler PermissionsHandler => ServerStatic.GetPermissionsHandler();

/// <summary>
/// Gets cached <see cref="NetworkServer"/>.SendSpawnMessage private method.
/// </summary>
public static MethodInfo SpawnMessage => _sendSpawnMessage ??= typeof(NetworkServer).GetMethod("SendSpawnMessage", BindingFlags.NonPublic | BindingFlags.Static);

/// <summary>
/// Get actual ticks per second of the server.
/// </summary>
Expand Down