Skip to content

Commit

Permalink
fixed stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Bluscream committed Jul 28, 2016
1 parent ff273f8 commit 623f7f1
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 22 deletions.
12 changes: 12 additions & 0 deletions AdminTools/AdminSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ public class AdminSettings
public bool OnlyAsciiNickName { get; set; }
public bool OnlyAsciiUserName { get; set; }
public bool LimitNickNames { get; set; }
public string CountryRestriction { get; set; }
/*public bool WhiteListEnabled { get; set; }
public string[] WhiteList { get; set; }
public bool BlackListEnabled { get; set; }
public string[] BlackList { get; set; }*/

public AdminSettings()
{
Expand All @@ -35,6 +40,13 @@ public AdminSettings()
OnlyAsciiNickName = true;
OnlyAsciiUserName = false;
LimitNickNames = true;
CountryRestriction = "";
/*WhiteListEnabled = false;
WhiteList[0] = "Bluscream";
WhiteList[1] = "Redscream";
BlackListEnabled = false;
BlackList[0] = "Faggot";
BlackList[1] = "Bastard";*/
}
}
}
18 changes: 12 additions & 6 deletions AdminTools/MainFilterscript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
//using Lidgren.Network;
using Console = Colorful.Console;
using System.Drawing;
using MaxMind.GeoIP2;

namespace AdminTools
{
Expand Down Expand Up @@ -77,8 +76,6 @@ public override void Start()
LogToConsole(2, false, null, "Accounts loaded.");
LoadBanlist(Location + "Banlist.xml");
LogToConsole(2, false, null, "Bans loaded.");
//Settings.MaxPing
//Settings.MaxPing

ServerWeather = 0;
ServerTime = new TimeSpan(12, 0, 0);
Expand All @@ -103,8 +100,8 @@ public override void OnTick()
Console.WriteLine(string.Format("{0} Current Ping: \"{1}\" / Max Ping: \"{2}\"",Program.ServerInstance.Clients[i].DisplayName, Math.Round(Program.ServerInstance.Clients[i].Latency * 1000, MidpointRounding.AwayFromZero).ToString(), Settings.MaxPing));
if (Math.Round(Program.ServerInstance.Clients[i].Latency * 1000, MidpointRounding.AwayFromZero) > Settings.MaxPing)
{
Program.ServerInstance.SendChatMessageToAll("SERVER", string.Format("Kicking {0} for Ping {1} too high! Max: {2}", Program.ServerInstance.Clients[i].DisplayName.ToString(), (Program.ServerInstance.Clients[i].Latency * 1000).ToString(), Settings.MaxPing.ToString()));
Program.ServerInstance.KickPlayer(Program.ServerInstance.Clients[i], string.Format("Ping {0} too high! Max: {1}", (Program.ServerInstance.Clients[i].Latency * 1000).ToString(), Settings.MaxPing.ToString()));
Program.ServerInstance.SendChatMessageToAll("SERVER", string.Format("Kicking {0} for Ping {1} too high! Max: {2}", Program.ServerInstance.Clients[i].DisplayName.ToString(), Math.Round(Program.ServerInstance.Clients[i].Latency * 1000, MidpointRounding.AwayFromZero).ToString(), Settings.MaxPing.ToString()));
Program.ServerInstance.KickPlayer(Program.ServerInstance.Clients[i], string.Format("Ping {0} too high! Max: {1}", Math.Round(Program.ServerInstance.Clients[i].Latency * 1000, MidpointRounding.AwayFromZero).ToString(), Settings.MaxPing.ToString()));
}
}

Expand All @@ -124,7 +121,7 @@ public override void OnIncomingConnection(Client player)
}
if (Settings.KickOnDefaultNickName)
{
if (player.DisplayName.StartsWith("RLD!") || player.DisplayName.StartsWith("Player") || player.DisplayName.StartsWith("nosTEAM") || player.DisplayName.ToString() == "3dmgame1")
if (player.DisplayName.ToLower().StartsWith("rld!") || player.DisplayName.ToLower().StartsWith("player") || player.DisplayName.ToLower().StartsWith("nosteam") || player.DisplayName.ToLower().StartsWith("3dmgame1") || player.DisplayName.StartsWith("3dm") || player.DisplayName.ToLower().StartsWith("your name"))
{
//Program.ServerInstance.SendChatMessageToAll("SERVER", string.Format("Kicking {0} for default nickname.", player.DisplayName.ToString()));
Program.ServerInstance.DenyPlayer(player, "~r~Change your nickname!~w~ (~h~F9~h~->~h~Settings~h~->~h~Nickname~h~)", true, null, 10); return;
Expand Down Expand Up @@ -220,6 +217,15 @@ public override void OnIncomingConnection(Client player)
Program.ServerInstance.SendChatMessageToAll("SERVER", string.Format("Kicking {0} for impersonating.", player.DisplayName.ToString()));
Program.ServerInstance.DenyPlayer(player, "Remove the () and [] from your nickname.", false, null, 15); return;
}
try {
if (!string.IsNullOrEmpty(Settings.CountryRestriction) && !string.IsNullOrEmpty(player.geoIP.Country.Name))
{
if (!Settings.CountryRestriction.Equals(player.geoIP.Country.Name))
{
Program.ServerInstance.DenyPlayer(player, "Sorry, but only players from " + Settings.CountryRestriction + " allowed here.", false, null); return;
}
}
} catch { }
}
public override bool OnPlayerConnect(Client player)
{
Expand Down
6 changes: 4 additions & 2 deletions Client/Chat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,14 @@ public void AddMessage(string sender, string msg)
if (string.IsNullOrEmpty(sender))
{
_mainScaleform.CallFunction("ADD_MESSAGE", "", SanitizeString(msg));
System.IO.File.AppendAllText("scripts\\GTACOOP_chat.log", "[" + DateTime.UtcNow + "] " + msg + "\n");
if(Main.PlayerSettings.ChatLog)
System.IO.File.AppendAllText("scripts\\GTACOOP_chat.log", "[" + DateTime.UtcNow + "] " + msg + "\n");
}
else
{
_mainScaleform.CallFunction("ADD_MESSAGE", SanitizeString(sender) + ":", SanitizeString(msg));
System.IO.File.AppendAllText("scripts\\GTACOOP_chat.log", "[" + DateTime.UtcNow + "] " + sender + ": " + msg + "\n");
if (Main.PlayerSettings.ChatLog)
System.IO.File.AppendAllText("scripts\\GTACOOP_chat.log", "[" + DateTime.UtcNow + "] " + sender + ": " + msg + "\n");
}
}

Expand Down
35 changes: 23 additions & 12 deletions Client/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,13 @@ public Main()
Util.SaveSettings(Program.Location + "ClientSettings.xml");
};

var chatLogItem = new UIMenuCheckboxItem("Log Chats", PlayerSettings.ChatLog);
chatLogItem.CheckboxEvent += (item, check) =>
{
PlayerSettings.ChatLog = check;
Util.SaveSettings(Program.Location + "ClientSettings.xml");
};

var hidePasswordsItem = new UIMenuCheckboxItem("Hide Passwords (Restart required)", PlayerSettings.HidePasswords);
hidePasswordsItem.CheckboxEvent += (item, check) =>
{
Expand Down Expand Up @@ -603,16 +610,19 @@ private void RebuildServerBrowser()
catch (Exception e)
{
UI.Notify("~r~~h~ERROR~h~~w~~n~Could not contact master server. Try again later.");
var logOutput = "===== EXCEPTION CONTACTING MASTER SERVER @ " + DateTime.UtcNow + " ======\n";
logOutput += "Message: " + e.Message;
logOutput += "\nData: " + e.Data;
logOutput += "\nStack: " + e.StackTrace;
logOutput += "\nSource: " + e.Source;
logOutput += "\nTarget: " + e.TargetSite;
if (e.InnerException != null)
logOutput += "\nInnerException: " + e.InnerException.Message;
logOutput += "\n";
File.AppendAllText("scripts\\GTACOOP.log", logOutput);
if (Main.PlayerSettings.Logging)
{
var logOutput = "===== EXCEPTION CONTACTING MASTER SERVER @ " + DateTime.UtcNow + " ======\n";
logOutput += "Message: " + e.Message;
logOutput += "\nData: " + e.Data;
logOutput += "\nStack: " + e.StackTrace;
logOutput += "\nSource: " + e.Source;
logOutput += "\nTarget: " + e.TargetSite;
if (e.InnerException != null)
logOutput += "\nInnerException: " + e.InnerException.Message;
logOutput += "\n";
File.AppendAllText("scripts\\GTACOOP.log", logOutput);
}
return;
}

Expand All @@ -624,7 +634,7 @@ private void RebuildServerBrowser()
if (dejson == null) return;

Console.WriteLine("Servers returned by master server: " + dejson.list.Count().ToString());
_serverBrowserMenu.Subtitle.Caption = dejson.list.Count().ToString();
_serverBrowserMenu.Subtitle.Caption = "Servers listed: ~g~~h~" + dejson.list.Count().ToString();
var item = new UIMenuItem(dejson.list.Count().ToString() + " Servers listed.");
item.SetLeftBadge(UIMenuItem.BadgeStyle.Star);
if (_client == null)
Expand Down Expand Up @@ -986,7 +996,8 @@ public void OnTick(object sender, EventArgs e)
for (int i = 0; i < tickNatives.Count; i++) DecodeNativeCall(tickNatives.ElementAt(i).Value);
}catch(Exception ex) {
UI.Notify("<ERROR> Could not handle this tick:"); UI.Notify(ex.Message);
File.AppendAllText("scripts\\GTACOOP.log", "[" + DateTime.UtcNow + "] <ERROR> Could not handle this tick: " + ex.Message+"\n");
if(Main.PlayerSettings.Logging)
File.AppendAllText("scripts\\GTACOOP.log", "[" + DateTime.UtcNow + "] <ERROR> Could not handle this tick: " + ex.Message+"\n");
}
}

Expand Down
4 changes: 4 additions & 0 deletions Client/PlayerSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ public class PlayerSettings
public string LastPassword { get; set; }
public bool SyncWorld { get; set; }
public bool SyncTraffic { get; set; }
public bool Logging { get; set; }
public bool OldChat { get; set; }
public bool ChatLog { get; set; }
public int MaxStreamedNpcs { get; set; }
public string MasterServerAddress { get; set; }
public Keys ActivationKey { get; set; }
Expand All @@ -31,7 +33,9 @@ public PlayerSettings()
LastIP = "127.0.0.1";
LastPort = 4499;
LastPassword = "changeme";
Logging = false;
OldChat = false;
ChatLog = false;
SyncWorld = true;
SyncTraffic = false;
AutoConnect = false;
Expand Down
1 change: 1 addition & 0 deletions Client/SyncPed.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class SyncPed
{
public SynchronizationMode SyncMode;
public long Host;
public MaxMind.GeoIP2.Responses.CountryResponse geoIP;
public Ped Character;
public Vector3 Position;
public Quaternion Rotation;
Expand Down
4 changes: 2 additions & 2 deletions Server/GameServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ public void Tick()
try { Console.Write("Password: " + connReq.Password.ToString() + " | "); } catch (Exception) { }
#endif
try { Console.Write("Game Version: " + connReq.GameVersion.ToString() + " | "); } catch (Exception) { }
try { Console.Write("Script Version: ["+connReq.ScriptVersion.ToString()+ "] "+(ScriptVersion)connReq.ScriptVersion + "("+(byte)connReq.ScriptVersion + ") | "); } catch (Exception) { }
try { Console.Write("Script Version: ["+connReq.ScriptVersion.ToString()+ "] "+(ScriptVersion)connReq.ScriptVersion+" | "); } catch (Exception) { }
try { Console.Write("IP: " + msg.SenderEndPoint.Address.ToString() + ":" + msg.SenderEndPoint.Port.ToString() + " | "); } catch (Exception) { }
Console.Write("\n");
if (!AllowOutdatedClients && (ScriptVersion)connReq.ScriptVersion != Enum.GetValues(typeof(ScriptVersion)).Cast<ScriptVersion>().Last())
Expand Down Expand Up @@ -751,7 +751,7 @@ public void Tick()
}
if (_gamemode != null) _gamemode.OnTick();
if (_filterscripts != null) _filterscripts.ForEach(fs => fs.OnTick());
}catch(Exception ex) { LogToConsole(4, false, "", "Can't handle tick: "+ex.Message); }
}catch(Exception ex) { LogToConsole(4, false, "", "Can't handle tick: "+ex.ToString()); }
}
public void Infoscreen()
{
Expand Down

0 comments on commit 623f7f1

Please sign in to comment.