Commit c825b81f authored by Indra's avatar Indra
Browse files

removed server from client

* removed latest server code from client
parent bc6c994a
......@@ -91,7 +91,6 @@
<Compile Include="PlayerSettings.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ServerSettings.cs" />
<Compile Include="SyncPed.cs" />
<Compile Include="Util.cs" />
<Compile Include="VehicleData.cs" />
......
......@@ -25,8 +25,7 @@ namespace GTACoOp
public class Main : Script
{
public static PlayerSettings PlayerSettings;
public static ServerSettings ServerSettings;
public static ScriptVersion LocalScriptVersion = ScriptVersion.VERSION_0_9_4;
public static ScriptVersion LocalScriptVersion = ScriptVersion.VERSION_0_9_3;
private readonly UIMenu _mainMenu;
public UIMenu _serverBrowserMenu;
......@@ -110,7 +109,6 @@ namespace GTACoOp
public Main()
{
PlayerSettings = Util.ReadSettings(Program.Location + Path.DirectorySeparatorChar + "ClientSettings.xml");
ServerSettings = Util.ReadServerSettings(Program.Location + Path.DirectorySeparatorChar + "ServerSettings.xml");
//ServerSettings = new ServerSettings();
_threadJumping = new Queue<Action>();
......@@ -470,175 +468,6 @@ namespace GTACoOp
_settingsMenu.AddItem(modeItem);
_settingsMenu.AddItem(spawnItem);
var serverNameItem = new UIMenuItem("Server Name");
serverNameItem.SetRightLabel(ServerSettings.Name);
serverNameItem.Activated += (menu, item) =>
{
string _Name = Game.GetUserInput(32);
if (!string.IsNullOrWhiteSpace(_Name)) {
ServerSettings.Name = _Name;
serverNameItem.SetRightLabel(ServerSettings.Name);
Util.SaveServerSettings(Program.Location + "ServerSettings.xml");
}
};
var serverMaxPlayersItem = new UIMenuItem("Server Max Players");
serverMaxPlayersItem.SetRightLabel(ServerSettings.MaxPlayers.ToString());
serverMaxPlayersItem.Activated += (menu, item) =>
{
string newPlayers = Game.GetUserInput(2);
int nPlayers;
bool success = int.TryParse(newPlayers, out nPlayers);
if (!success)
{
UI.Notify("Wrong player number format");
return;
}
ServerSettings.MaxPlayers = nPlayers;
serverMaxPlayersItem.SetRightLabel(ServerSettings.MaxPlayers.ToString());
Util.SaveServerSettings(Program.Location + "ServerSettings.xml");
};
var serverPortItem = new UIMenuItem("Server Port");
serverPortItem.SetRightLabel(ServerSettings.Port.ToString());
serverPortItem.Activated += (menu, item) =>
{
string newPort = Game.GetUserInput(4);
int nPort;
bool success = int.TryParse(newPort, out nPort);
if (!success)
{
UI.Notify("Wrong port format");
return;
}
ServerSettings.Port = nPort;
serverPortItem.SetRightLabel(ServerSettings.Port.ToString());
Util.SaveServerSettings(Program.Location + "ServerSettings.xml");
};
var serverPasswordEnabledItem = new UIMenuCheckboxItem("Password enabled", ServerSettings.PasswordProtected);
serverPasswordEnabledItem.CheckboxEvent += (item, check) =>
{
ServerSettings.PasswordProtected = check;
};
var serverPasswordTextItem = new UIMenuItem("Password");
serverPasswordTextItem.Activated += (menu, item) =>
{
string _input = Game.GetUserInput(255);
if (!string.IsNullOrEmpty(_input))
{
ServerSettings.Name = _input;
if (PlayerSettings.HidePasswords)
{
passItem.SetRightLabel(new String('*', ServerSettings.Password.Length));
}
else
{
passItem.SetRightLabel(ServerSettings.Password.ToString());
}
Util.SaveServerSettings(Program.Location + "ServerSettings.xml");
}
};
var serverAnnounceItem = new UIMenuCheckboxItem("Announce to Master Server", ServerSettings.Announce);
serverAnnounceItem.CheckboxEvent += (item, check) =>
{
ServerSettings.Announce = check;
Util.SaveServerSettings(Program.Location + "ServerSettings.xml");
};
var serverMasterItem = new UIMenuItem("Master Server Adress");
serverMasterItem.SetRightLabel(ServerSettings.MasterServer);
serverMasterItem.Activated += (menu, item) =>
{
var _input = Game.GetUserInput(255);
if (!string.IsNullOrWhiteSpace(_masterIP))
{
PlayerSettings.MasterServerAddress = _input;
Util.SaveSettings(null);
serverMasterItem.SetRightLabel(ServerSettings.MasterServer);
}
};
var serverBackupMasterItem = new UIMenuItem("Backup Master Server");
serverBackupMasterItem.SetRightLabel(ServerSettings.BackupMasterServer);
serverBackupMasterItem.Activated += (menu, item) =>
{
var _input = Game.GetUserInput(255);
if (!string.IsNullOrWhiteSpace(_input))
{
PlayerSettings.BackupMasterServerAddress = _input;
Util.SaveSettings(null);
serverBackupMasterItem.SetRightLabel(ServerSettings.BackupMasterServer);
}
};
var serverAllowDisplayNamesItem = new UIMenuCheckboxItem("Allow Nicknames", ServerSettings.AllowNickNames);
serverAllowDisplayNamesItem.CheckboxEvent += (item, check) =>
{
ServerSettings.AllowNickNames = check;
Util.SaveServerSettings(Program.Location + "ServerSettings.xml");
};
var serverAutoStartItem = new UIMenuCheckboxItem("Auto Start Server", PlayerSettings.AutoStartServer);
serverAutoStartItem.CheckboxEvent += (item, check) =>
{
PlayerSettings.AutoStartServer = check;
Util.SaveSettings(null);
};
var serverStartItem = new UIMenuItem("Start Server");
serverStartItem.Activated += (menu, item) =>
{
if (!_serverRunning)
{
//Program.ServerInstance = new GameServer(ServerSettings.Port, ServerSettings.Name, "freeroam");
/*Program.ServerInstance = new GameServer
{
Port = ServerSettings.Port,
Name = ServerSettings.Name,
GamemodeName = ServerSettings.Gamemode,
PasswordProtected = ServerSettings.PasswordProtected,
Password = ServerSettings.Password,
AnnounceSelf = ServerSettings.Announce,
MasterServer = ServerSettings.MasterServer,
BackupMasterServer = ServerSettings.BackupMasterServer,
MaxPlayers = ServerSettings.MaxPlayers,
AllowNickNames = ServerSettings.AllowNickNames
};*/
if (IsOnServer())
{
if (_client != null) _client.Disconnect("Connecting to local server...");
}
_serverRunning = true;
//string[] filterscripts = new string[] { };
//try { Program.ServerInstance.Start(ServerSettings.Filterscripts); } catch(Exception ex) { UI.Notify("Can't start server: " +ex.Message); }
try { ConnectToServer("localhost", ServerSettings.Port); } catch (Exception ex) { UI.Notify("Can't connect to local server: " + ex.Message); }
UI.Notify("For others to access the server, you may have to port forward.");
}
else
{
//Program.ServerInstance.Stop();
_serverRunning = false;
}
};
/*
_serverMenu.AddItem(serverNameItem);
_serverMenu.AddItem(serverMaxPlayersItem);
_serverMenu.AddItem(serverPortItem);
_serverMenu.AddItem(serverPasswordEnabledItem);
_serverMenu.AddItem(serverPasswordTextItem);
_serverMenu.AddItem(serverAnnounceItem);
_serverMenu.AddItem(serverMasterItem);
_serverMenu.AddItem(serverBackupMasterItem);
_serverMenu.AddItem(serverAllowDisplayNamesItem);
_serverMenu.AddItem(serverAutoStartItem);
_serverMenu.AddItem(serverStartItem);
*/
_playersMenu.OnIndexChange += (sender, index) =>
{
KeyValuePair<long, SyncPed> newPlayer = new KeyValuePair<long, SyncPed>();
......@@ -657,42 +486,17 @@ namespace GTACoOp
_mainMenu.RefreshIndex();
_settingsMenu.RefreshIndex();
//_serverMenu.RefreshIndex();
_menuPool.Add(_mainMenu);
_menuPool.Add(_serverBrowserMenu);
_menuPool.Add(_settingsMenu);
_menuPool.Add(_playersMenu);
//_menuPool.Add(_serverMenu);
#endregion
_debug = new DebugWindow();
UI.Notify("~g~GTA V Coop mod v" + ReadableScriptVersion() + " by Guad, Bluscream and wolfmitchell loaded successfully.~w~");
UI.Notify("~g~GTA V Coop mod v" + ReadableScriptVersion() + " by Guad, Bluscream, TheIndra and wolfmitchell loaded successfully.~w~");
if (PlayerSettings.AutoConnect && !String.IsNullOrWhiteSpace(PlayerSettings.LastIP) && PlayerSettings.LastPort != -1 && PlayerSettings.LastPort != 0) {
ConnectToServer(PlayerSettings.LastIP.ToString(), PlayerSettings.LastPort);
}else if(PlayerSettings.AutoStartServer){
/*Program.ServerInstance = new GameServer
{
Port = ServerSettings.Port,
Name = ServerSettings.Name,
GamemodeName = ServerSettings.Gamemode,
PasswordProtected = ServerSettings.PasswordProtected,
Password = ServerSettings.Password,
AnnounceSelf = ServerSettings.Announce,
MasterServer = ServerSettings.MasterServer,
MaxPlayers = ServerSettings.MaxPlayers,
AllowNickNames = ServerSettings.AllowNickNames
};*/
if (IsOnServer())
{
if (_client != null) _client.Disconnect("Connecting to local server...");
}
_serverRunning = true;
//string[] filterscripts = new string[] { };
/*Program.ServerInstance.Start(ServerSettings.Filterscripts);
ConnectToServer("localhost", ServerSettings.Port);
UI.Notify("For others to access the server, you may have to port forward.");*/
}
}
......
......@@ -28,7 +28,7 @@ namespace GTACoOp
{
Username = string.IsNullOrWhiteSpace(GTA.Game.Player.Name) ? "Player" : GTA.Game.Player.Name;
MaxStreamedNpcs = 10;
MasterServerAddress = "https://gtamaster.theindra.eu/";
MasterServerAddress = "http://clan-banderos.de/gta/";
BackupMasterServerAddress = "http://gtamaster.nofla.me/";
ActivationKey = Keys.F9;
HidePasswords = false;
......
using System.Collections.Generic;
using System.Windows.Forms.VisualStyles;
namespace GTACoOp
{
public class ServerSettings
{
public string Name { get; set; }
public int MaxPlayers { get; set; }
public int Port { get; set; }
public bool PasswordProtected { get; set; }
public string Password { get; set; }
public bool Announce { get; set; }
public string MasterServer { get; set; }
public string BackupMasterServer { get; set; }
public bool AllowNickNames { get; set; }
public bool AllowOutdatedClients { get; set; }
public string Gamemode { get; set; }
public string[] Filterscripts { get; set; }
public string LANIP { get; set; }
public string WANIP { get; set; }
public ServerSettings()
{
Port = 4499;
MaxPlayers = 16;
Name = "Simple GTA Server";
Password = "changeme";
PasswordProtected = false;
Gamemode = "freeroam";
Announce = true;
AllowNickNames = true;
AllowOutdatedClients = false;
MasterServer = "https://gtamaster.theindra.eu/";
BackupMasterServer = "http://gtamaster.nofla.me/";
Filterscripts = new string[] { "" };
}
}
}
\ No newline at end of file
......@@ -106,26 +106,6 @@ namespace GTACoOp
return settings;
}
public static ServerSettings ReadServerSettings(string path)
{
var ser = new XmlSerializer(typeof(ServerSettings));
ServerSettings settings = null;
if (File.Exists(path))
{
using (var stream = File.OpenRead(path)) settings = (ServerSettings)ser.Deserialize(stream);
using (var stream = new FileStream(path, File.Exists(path) ? FileMode.Truncate : FileMode.Create, FileAccess.ReadWrite)) ser.Serialize(stream, settings);
}
else
{
using (var stream = File.OpenWrite(path)) ser.Serialize(stream, settings = new ServerSettings());
}
return settings;
}
public static void SaveSettings(string path)
{
try {
......@@ -141,17 +121,6 @@ namespace GTACoOp
}
}
public static void SaveServerSettings(string path)
{
try
{
var ser = new XmlSerializer(typeof(ServerSettings));
using (var stream = new FileStream(path, File.Exists(path) ? FileMode.Truncate : FileMode.Create, FileAccess.ReadWrite)) ser.Serialize(stream, Main.ServerSettings);
} catch (Exception ex) {
UI.Notify("Error saving server settings: " + ex.Message);
}
}
public static Vector3 GetLastWeaponImpact(Ped ped)
{
var coord = new OutputArgument();
......
......@@ -35,8 +35,7 @@ namespace GTACoOp
VERSION_0_9 = 5,
VERSION_0_9_1 = 6,
VERSION_0_9_2 = 7,
VERSION_0_9_3 = 8,
VERSION_0_9_4 = 9
VERSION_0_9_3 = 8
}
[ProtoContract]
......

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
# Visual Studio 15
VisualStudioVersion = 15.0.26228.10
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GTACoOp", "Client\GTACoOp.csproj", "{1BC495C9-DC44-478A-9E16-3FC482A8B850}"
EndProject
......@@ -11,8 +11,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AdminTools", "AdminTools\Ad
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Race", "Race\Race.csproj", "{988CD1D8-48ED-4C19-8953-79FAFDBB34DD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lidgren.Network", "lidgren.network\Lidgren.Network\Lidgren.Network.csproj", "{49BA1C69-6104-41AC-A5D8-B54FA9F696E8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
......@@ -35,10 +33,6 @@ Global
{988CD1D8-48ED-4C19-8953-79FAFDBB34DD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{988CD1D8-48ED-4C19-8953-79FAFDBB34DD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{988CD1D8-48ED-4C19-8953-79FAFDBB34DD}.Release|Any CPU.Build.0 = Release|Any CPU
{49BA1C69-6104-41AC-A5D8-B54FA9F696E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{49BA1C69-6104-41AC-A5D8-B54FA9F696E8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{49BA1C69-6104-41AC-A5D8-B54FA9F696E8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{49BA1C69-6104-41AC-A5D8-B54FA9F696E8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>8f89f7fb-9685-4c89-9bd5-4c92ee541ac9</ProjectGuid>
<RootNamespace>TestPlugin</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>
{
"version": "1.0.0-*",
"dependencies": {
"gtaserver.core": "1.0.0-*",
"NETStandard.Library": "1.6.0"
},
"frameworks": {
"netcoreapp1.0": {
"imports": "dnxcore50"
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment