using AllocsFixes.PersistentData; using System; using System.Collections.Generic; using UnityEngine; namespace AllocsFixes { public class AllocsLogFunctions { public static void RequestToSpawnPlayer (GameManager manager, int _clientId, string _name, string _playerClassname, string _skinTexture, int _chunkViewDim) { try { ClientInfo ci = CommonMappingFunctions.GetClientInfoFromClientID (_clientId); int entityId = CommonMappingFunctions.GetEntityID (ci); EntityPlayer ep = CommonMappingFunctions.GetEntityPlayer (ci); string steamId = CommonMappingFunctions.GetSteamID (ci); string ip = ci.networkPlayer.ipAddress; string name = string.Empty; if (ep != null) name = ep.EntityName; Log.Out ("Player connected, clientid=" + _clientId + ", entityid=" + entityId + ", name=" + name + ", steamid=" + steamId + ", ip=" + ip ); PersistentContainer.Instance.Players [steamId].SetOnline (ci); PersistentData.PersistentContainer.Instance.Save (); } catch (Exception e) { Log.Out ("Error in AllocsLogFunctions.RequestToSpawnPlayer: " + e); } } public static void PlayerDisconnected (ConnectionManager manager, int _clientId, bool _bShutdown) { try { Player p = PersistentContainer.Instance.Players.GetPlayerByClientId (_clientId); if (p != null) { p.SetOffline (); } PersistentData.PersistentContainer.Instance.Save (); } catch (Exception e) { Log.Out ("Error in AllocsLogFunctions.PlayerDisconnected: " + e); } } } }