void StartServer() { NetPeerConfiguration config = new NetPeerConfiguration("FPSMod"); Debug.Log("Starting Server"); m_isServer = true; config.Port = ServerSettings.Port; config.SetMessageTypeEnabled(NetIncomingMessageType.UnconnectedData, true); m_server = new NetServer(config); m_server.Start(); SpawnLocalPlayer(); Debug.Log("wID: " + m_saveWorkshopID); Debug.Log("p: " + ServerSettings.Private); if (MultiplayerLoading.UseVehiclesAndCitizens) { m_vNetworkManager = gameObject.AddComponent <VehicleNetworkManager>(); m_cNetworkManager = gameObject.AddComponent <CitizenNetworkManager>(); } if (m_saveWorkshopID != UInt64.MaxValue && !ServerSettings.Private) { try { using (var client = new WebClient()) { var values = new NameValueCollection { { "name", ServerSettings.Name.IsNullOrWhiteSpace() ? "No name" : ServerSettings.Name }, { "port", ServerSettings.Port.ToString() }, { "mapId", m_saveWorkshopID.ToString() }, { "modVersion", Settings.ModVersion.ToString() } }; var result = client.UploadValues(Settings.ServerUrl + "/create", "POST", values); string responsebody = Encoding.UTF8.GetString(result); Debug.Log("Sending to masterserver: " + responsebody); } } catch (Exception) { throw; } } }
void ConnectToServer() { NetPeerConfiguration config = new NetPeerConfiguration("FPSMod"); Debug.Log("Joining Server " + ConnectSettings.Ip + ": " + ConnectSettings.Port); m_client = new NetClient(config); m_client.Start(); NetOutgoingMessage hail = m_client.CreateMessage("This is the hail message"); m_client.Connect(ConnectSettings.Ip, ConnectSettings.Port, hail); if (MultiplayerLoading.UseVehiclesAndCitizens) { m_vNetworkManager = gameObject.AddComponent <VehicleNetworkManager>(); m_cNetworkManager = gameObject.AddComponent <CitizenNetworkManager>(); } }
void StartServer() { NetPeerConfiguration config = new NetPeerConfiguration("FPSMod"); Debug.Log("Starting Server"); m_isServer = true; config.Port = ServerSettings.Port; config.SetMessageTypeEnabled(NetIncomingMessageType.UnconnectedData, true); m_server = new NetServer(config); m_server.Start(); SpawnLocalPlayer(); Debug.Log("wID: " + m_saveWorkshopID); Debug.Log("p: " + ServerSettings.Private); if (MultiplayerLoading.UseVehiclesAndCitizens) { m_vNetworkManager = gameObject.AddComponent<VehicleNetworkManager>(); m_cNetworkManager = gameObject.AddComponent<CitizenNetworkManager>(); } if (m_saveWorkshopID != UInt64.MaxValue && !ServerSettings.Private) { try { using (var client = new WebClient()) { var values = new NameValueCollection { {"name", ServerSettings.Name.IsNullOrWhiteSpace() ? "No name" : ServerSettings.Name}, {"port", ServerSettings.Port.ToString()}, {"mapId", m_saveWorkshopID.ToString()}, {"modVersion", Settings.ModVersion.ToString()} }; var result = client.UploadValues(Settings.ServerUrl + "/create", "POST", values); string responsebody = Encoding.UTF8.GetString(result); Debug.Log("Sending to masterserver: " + responsebody); } } catch (Exception) { throw; } } }
void ConnectToServer() { NetPeerConfiguration config = new NetPeerConfiguration("FPSMod"); Debug.Log("Joining Server " + ConnectSettings.Ip + ": " + ConnectSettings.Port); m_client = new NetClient(config); m_client.Start(); NetOutgoingMessage hail = m_client.CreateMessage("This is the hail message"); m_client.Connect(ConnectSettings.Ip, ConnectSettings.Port, hail); if (MultiplayerLoading.UseVehiclesAndCitizens) { m_vNetworkManager = gameObject.AddComponent<VehicleNetworkManager>(); m_cNetworkManager = gameObject.AddComponent<CitizenNetworkManager>(); } }