[BUG]: Setting Player.DisarmedBy = null skips client network synchronization (SendToAuthenticated)
Before You Report
- [x] I have searched for existing reports of this bug, and this bug report is unique.
Version
1.1.7
Description
Setting player.DisarmedBy = null uncuffs the player on the server via Inventory.SetDisarmedStatus(null), but fails to notify clients because an early return bypasses new DisarmedPlayersListMessage(DisarmedPlayers.Entries).SendToAuthenticated().
As a result:
- The server considers the player uncuffed.
- Clients never receive the updated
DisarmedPlayersListMessage, keeping the player visually and functionally cuffed from the perspective of clients (client/server desync).
To Reproduce
- Disarm a player by setting
player.DisarmedBy = disarmerPlayer;(or via standard in-game disarmer). - Uncuff the player via
player.DisarmedBy = null;. - Observe that while
player.IsDisarmedis false on the server, connected clients still render the player with hands bound behind their back and client-side interactions remain restricted.
Expected Behavior
Setting player.DisarmedBy = null should update the status on the server and broadcast DisarmedPlayersListMessage to all authenticated clients so they recognize the player as uncuffed.
Additional Information
In LabApi/Features/Wrappers/Players/Player.cs lines 1159-1170:
public Player? DisarmedBy
{
get
{
if (!IsDisarmed)
{
return null;
}
DisarmedPlayers.DisarmedEntry entry = DisarmedPlayers.Entries.Find(x => x.DisarmedPlayer == NetworkId);
return Get(entry.Disarmer);
}
set
{
Inventory.SetDisarmedStatus(null);
if (value == null)
{
return; // <--- The early return bypasses network synchronization!
}
DisarmedPlayers.Entries.Add(new DisarmedPlayers.DisarmedEntry(NetworkId, value.NetworkId));
new DisarmedPlayersListMessage(DisarmedPlayers.Entries).SendToAuthenticated();
}
}
Because Inventory.SetDisarmedStatus(Inventory disarmer) in InventorySystem.Disarming.DisarmedPlayers already handles removing existing entries and adding a new one if disarmer != null, the setter can be simplified and made fully consistent:
Proposed fix:
set
{
Inventory.SetDisarmedStatus(value?.Inventory);
new DisarmedPlayersListMessage(DisarmedPlayers.Entries).SendToAuthenticated();
}
This guarantees that:
- When
value == null,SetDisarmedStatus(null)removes the entry fromEntries, and clients receive the updated list. - When
value != null,SetDisarmedStatus(value.Inventory)removes any stale entry and registers the new disarmer without needing manualEntries.Add(...). - Network synchronization always executes.
value?.Inventory doesn't do a proper Unity lifetime check, but other than that it should be sufficient