PlayerSync
Sync additional player information across clients.
About this mod Author’s original text
PlayerSync
Synchronizes additional player information like ammo clip and stamina
For feedback and issues, DM @uwufood on the GTFO Modding Discord Server
Why?
The vanilla game doesn't perform synchronization for information such as stamina and weapon clip ammo count (only total ammo count is synced).
This mod adds synchronization for these values. It also performs these updates at a higher frequency than the vanilla game. For the mod to function, both ends needs to have the mod installed.
Synchronized Values
Weapon Ammo / Clip
Synchronization is done on every shot and reload by hooking BulletWeapon.Fire, Shotgun.Fire,
and PlayerInventoryLocal.DoReload. This is then capped at maximum frequency as defined in the config.
Clip information is written directly into all items and can be accessed via
ItemEquippable.GetCurrentClip for the respective item.
AmmoInPack information is simply updated at the same tigher frequency as clip information and can be access via PlayerAmmoStorage just like in the vanilla game.
Note on Reserve Ammo
The ammo information for non-local players/bots will include the clip count in the reserve count. This is to ensure
correct display in vanilla inventory UI. To obtain the actual reserve count for non-local players/bots, subtract
their clip count from the reserve count.
There is a convenience function AmmoSync.ReserveIncludesClip for determining if clip should be subtracted from reserve count to get actual reserve count, the logic is rather simple.
///
/// Returns whether a given player's reserve ammo count includes the clip
/// ammo count, which means whether if the player is not local.
/// For bots this means checking if master is remote.
///
///
/// true if clip ammo count should be subtracted from
/// reserve ammo count to obtain the actual reserve ammo count.
/// For non-supporting clients, this has no side effects in interpretation
/// since clip would always be 0 for them.
///
public static bool ReserveIncludesClip(SNet_Player player) {
if (player.IsBot) player = SNet.Master;
return!player.IsLocal;
}
Stamina
Stamina information is synced and managed by PlayerSync since the vanilla game does not provide a mechanism to track it for other players. The values can be queried via:
namespace PlayerSync.Sync.Stamina;
class StaminaSync {
///
/// Tries to get the stamina info for a given player, returns false if
/// player doesn't exist or unsupported (i.e. not synced).
///
/// player to query
/// stamina information
/// true if found
public static bool GetStaminaInfo(SNet_Player player, out StaminaInfo info) {... }
}
Advanced Configuration
In general, no configuration is needed. Clients with this mod installed will update each other with the information.
The frequency for updates, however, can be configured in the config; this is hard capped at 60Hz.
Possible Future Plans
- Synchronize modded player attributes (e.g. Oxygen)
Install & use Install: follow the bundled instructions
- Unzip the archive from playbuff and read the bundled readme / instructions first.
- Most mods rely on the game's mod loader — the usual route is a community mod manager (such as r2modman): pick this game, install, and it handles the loader and dependencies.
- For a manual install, put the mod files into the matching Mod / plugins folder inside the game directory.
- Launch the game to confirm it loaded; mods with listed dependencies need those installed as well.
Install locations vary a lot between mods — the bundled readme is the most reliable guide.
Install these first, or the mod will not work: