diff --git a/source/BP-Essentials/BP-Essentials.csproj b/source/BP-Essentials/BP-Essentials.csproj index c0753dff..95fb4ab2 100644 --- a/source/BP-Essentials/BP-Essentials.csproj +++ b/source/BP-Essentials/BP-Essentials.csproj @@ -89,6 +89,7 @@ + diff --git a/source/BP-Essentials/Chat/Announce.cs b/source/BP-Essentials/Chat/Announce.cs index 07841c37..7c3af4bd 100644 --- a/source/BP-Essentials/Chat/Announce.cs +++ b/source/BP-Essentials/Chat/Announce.cs @@ -31,7 +31,6 @@ public static void Run(object man) private static void OnTime(object onetMan) { var svManager = (SvManager)onetMan; - foreach (var player in svManager.players) player.svPlayer.SendToSelf(Channel.Reliable, ClPacket.GameMessage, Announcements[AnnounceIndex]); Debug.Log(SetTimeStamp.Run() + "[INFO] Announcement made..."); diff --git a/source/BP-Essentials/Chat/Commands/Admin/Arrest.cs b/source/BP-Essentials/Chat/Commands/Admin/Arrest.cs index b0c1dbcc..ac77cf54 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/Arrest.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/Arrest.cs @@ -21,10 +21,10 @@ public static bool Run(object oPlayer, string message) if (!string.IsNullOrEmpty(arg1)) ExecuteOnPlayer.Run(player, message, arg1); else - player.SendToSelf(Channel.Unsequenced, 10, ArgRequired); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, ArgRequired); } else - player.SendToSelf(Channel.Unsequenced, 10, MsgNoPerm); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, MsgNoPerm); } catch (Exception ex) { diff --git a/source/BP-Essentials/Chat/Commands/Admin/Ban.cs b/source/BP-Essentials/Chat/Commands/Admin/Ban.cs index 8e03a751..a38cc517 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/Ban.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/Ban.cs @@ -12,10 +12,10 @@ public static bool Run(object oPlayer, string message) { if (!string.IsNullOrEmpty(arg1)) ExecuteOnPlayer.Run(player, message, arg1); else - player.SendToSelf(Channel.Unsequenced, 10, ArgRequired); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, ArgRequired); } else - player.SendToSelf(Channel.Unsequenced, 10, MsgNoPerm); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, MsgNoPerm); } catch (Exception ex) { diff --git a/source/BP-Essentials/Chat/Commands/Admin/CheckAlts.cs b/source/BP-Essentials/Chat/Commands/Admin/CheckAlts.cs index 021fd404..44adcbf9 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/CheckAlts.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/CheckAlts.cs @@ -40,7 +40,7 @@ public static bool Run(object oPlayer, string message) } content = builder.ToString(); content += "\r\n\r\n" + arg2 + " occurred " + found + " times in the iplog file." + "\r\n"; - player.SendToSelf(Channel.Reliable, 50, content); + player.SendToSelf(Channel.Reliable, ClPacket.ServerInfo, content); } else if (arg1.Equals("ign", StringComparison.InvariantCultureIgnoreCase) || (arg1.Equals("player", StringComparison.InvariantCultureIgnoreCase))) { @@ -57,15 +57,15 @@ public static bool Run(object oPlayer, string message) } content = builder.ToString(); content = content + "\r\n\r\n" + arg2 + " occurred " + found + " times in the iplog file." + "\r\n"; - player.SendToSelf(Channel.Reliable, 50, content); + player.SendToSelf(Channel.Reliable, ClPacket.ServerInfo, content); } } else - player.SendToSelf(Channel.Reliable, 10, CmdCheckAlts + "[IP/IGN] [Arg2] Eg " + CmdCheckAlts + " ip 127.0.0.1"); + player.SendToSelf(Channel.Reliable, ClPacket.GameMessage, CmdCheckAlts + "[IP/IGN] [Arg2] Eg " + CmdCheckAlts + " ip 127.0.0.1"); } else - player.SendToSelf(Channel.Unsequenced, 10, MsgNoPerm); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, MsgNoPerm); } catch (Exception ex) { diff --git a/source/BP-Essentials/Chat/Commands/Admin/ClearWanted.cs b/source/BP-Essentials/Chat/Commands/Admin/ClearWanted.cs index 7a29dc8a..1d2a16f4 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/ClearWanted.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/ClearWanted.cs @@ -32,14 +32,14 @@ public static bool Run(object oPlayer, string message) msg = shPlayer.username; shPlayer.ClearCrimes(); shPlayer.svPlayer.SendToSelf(Channel.Reliable, 33, shPlayer.ID); - player.SendToSelf(Channel.Unsequenced, 10, $"Cleared crimes of '" + msg + "'."); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Cleared crimes of '" + msg + "'."); found = true; } if (!found) - player.SendToSelf(Channel.Unsequenced, 10, NotFoundOnline); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, NotFoundOnline); } else - player.SendToSelf(Channel.Unsequenced, 10, MsgNoPerm); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, MsgNoPerm); } catch (Exception ex) { diff --git a/source/BP-Essentials/Chat/Commands/Admin/DebugCommands.cs b/source/BP-Essentials/Chat/Commands/Admin/DebugCommands.cs index aa4a372a..3b2bbfef 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/DebugCommands.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/DebugCommands.cs @@ -20,14 +20,14 @@ public static bool Run(object oPlayer, string message) { string arg = GetArgument.Run(1, false, false, message).Trim().ToLower(); if (arg == "location" || arg == "getlocation") - player.SendToSelf(Channel.Unsequenced, 10, "Your location: " + shPlayer.GetPosition()); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, "Your location: " + shPlayer.GetPosition()); else if (arg == "getplayerhash" || arg == "gethash") { string arg2 = GetArgument.Run(2, false, true, message); if (!String.IsNullOrEmpty(arg2)) - player.SendToSelf(Channel.Unsequenced, 10, "Hash of " + arg2 + " : " + Animator.StringToHash(arg2).ToString()); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, "Hash of " + arg2 + " : " + Animator.StringToHash(arg2).ToString()); else - player.SendToSelf(Channel.Unsequenced, 10, "Invalid arguments. /debug get(player)hash [username]"); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, "Invalid arguments. /debug get(player)hash [username]"); } else if (arg == "spaceindex" || arg == "getspaceindex") { @@ -40,18 +40,18 @@ public static bool Run(object oPlayer, string message) if (shPlayer2.IsRealPlayer()) { found = true; - player.SendToSelf(Channel.Unsequenced, 10, "SpaceIndex of '" + shPlayer2.svPlayer.playerData.username + "': " + shPlayer2.GetPlaceIndex()); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, "SpaceIndex of '" + shPlayer2.svPlayer.playerData.username + "': " + shPlayer2.GetPlaceIndex()); } if (!found) - player.SendToSelf(Channel.Unsequenced, 10, "Invalid arguments (Or user is not found online.) /debug (get)spaceindex [username] "); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, "Invalid arguments (Or user is not found online.) /debug (get)spaceindex [username] "); } else - player.SendToSelf(Channel.Unsequenced, 10, "Your SpaceIndex: " + shPlayer.GetPlaceIndex()); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, "Your SpaceIndex: " + shPlayer.GetPlaceIndex()); } } } else - player.SendToSelf(Channel.Unsequenced, 10, MsgNoPerm); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, MsgNoPerm); } catch (Exception ex) { diff --git a/source/BP-Essentials/Chat/Commands/Admin/ExecuteOnPlayer.cs b/source/BP-Essentials/Chat/Commands/Admin/ExecuteOnPlayer.cs index 8ff920cc..7d451f4c 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/ExecuteOnPlayer.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/ExecuteOnPlayer.cs @@ -22,7 +22,7 @@ public static bool Run(object oPlayer, string message, string arg1) if (message.StartsWith(CmdKnockout) || message.StartsWith(CmdKnockout2)) { shPlayer.svPlayer.SvForceStance(StanceIndex.KnockedOut); - player.SendToSelf(Channel.Unsequenced, 10, $"Knocked out {shPlayer.username}."); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Knocked out {shPlayer.username}."); } else if (message.StartsWith(CmdJail) || message.StartsWith(CmdJail2)) { @@ -31,66 +31,66 @@ public static bool Run(object oPlayer, string message, string arg1) { if (SendToJail.Run(shPlayer, t)) { - shPlayer.svPlayer.SendToSelf(Channel.Unsequenced, 10, $"{shPlayer1.username} sent you to jail."); - player.SendToSelf(Channel.Unsequenced, 10, $"Sent {shPlayer.username} To jail."); + shPlayer.svPlayer.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"{shPlayer1.username} sent you to jail."); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Sent {shPlayer.username} To jail."); } else - player.SendToSelf(Channel.Unsequenced, 10, $"Cannot send {shPlayer.username} To jail."); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Cannot send {shPlayer.username} To jail."); } else - player.SendToSelf(Channel.Unsequenced, 10, ArgRequired); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, ArgRequired); } else if (message.StartsWith(CmdTpHere) || message.StartsWith(CmdTpHere2)) { shPlayer.svPlayer.SvReset(shPlayer1.GetPosition(), shPlayer1.GetRotation(), shPlayer1.GetPlaceIndex()); - shPlayer.svPlayer.SendToSelf(Channel.Unsequenced, 10, $"" + shPlayer1.username + $" Teleported you to him."); - player.SendToSelf(Channel.Unsequenced, 10, $"Teleported " + shPlayer.username + $" To you."); + shPlayer.svPlayer.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"" + shPlayer1.username + $" Teleported you to him."); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Teleported " + shPlayer.username + $" To you."); } else if (message.StartsWith(CmdTp)) { player.SvReset(shPlayer.GetPosition(), shPlayer.GetRotation(), shPlayer.GetPlaceIndex()); - player.SendToSelf(Channel.Unsequenced, 10, $"Teleported to " + shPlayer.username + $"."); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Teleported to " + shPlayer.username + $"."); } else if (message.Contains(CmdBan)) { player.svManager.AddBanned(shPlayer); player.svManager.Disconnect(shPlayer.svPlayer.connection); - player.SendToSelf(Channel.Unsequenced, 10, $"Banned " + shPlayer.username + $"."); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Banned " + shPlayer.username + $"."); } else if (message.Contains(CmdKick)) { player.svManager.Kick(shPlayer.svPlayer.connection); - player.SendToSelf(Channel.Unsequenced, 10, $"Kicked " + shPlayer.username + $"."); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Kicked " + shPlayer.username + $"."); } else if (message.Contains(CmdArrest)) { shPlayer.svPlayer.Arrest(); - player.SendToSelf(Channel.Unsequenced, 10, $"Arrested " + shPlayer.username + $"."); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Arrested " + shPlayer.username + $"."); } else if (message.Contains(CmdRestrain)) { shPlayer.svPlayer.Arrest(); shPlayer.svPlayer.SvSetEquipable(shPlayer.manager.restrained.index); if (!shPlayer.svPlayer.IsServerside()) - shPlayer.svPlayer.SendToSelf(Channel.Unsequenced, 10, "You've been restrained"); - player.SendToSelf(Channel.Unsequenced, 10, $"Restrained " + shPlayer.username + $"."); + shPlayer.svPlayer.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, "You've been restrained"); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Restrained " + shPlayer.username + $"."); } else if (message.Contains(CmdKill)) { shPlayer.svPlayer.SvSuicide(); - player.SendToSelf(Channel.Unsequenced, 10, $"Killed " + shPlayer.username + $"."); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Killed " + shPlayer.username + $"."); } else if (message.Contains(CmdFree)) { shPlayer.svPlayer.Unhandcuff(); - player.SendToSelf(Channel.Unsequenced, 10, $"Freed " + shPlayer.username + $"."); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Freed " + shPlayer.username + $"."); } found = true; } else - player.SendToSelf(Channel.Unsequenced, 10, $"" + arg1 + $" Is not a real player."); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"" + arg1 + $" Is not a real player."); if (!(found)) - player.SendToSelf(Channel.Unsequenced, 10, $"" + arg1 + $" Is not online."); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"" + arg1 + $" Is not online."); } catch (Exception ex) { diff --git a/source/BP-Essentials/Chat/Commands/Admin/FakeJoin.cs b/source/BP-Essentials/Chat/Commands/Admin/FakeJoin.cs index 537b4e88..17c2f21b 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/FakeJoin.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/FakeJoin.cs @@ -20,13 +20,13 @@ public static bool Run(object oPlayer, string message) string arg1 = GetArgument.Run(1, false, true, message); if (!String.IsNullOrEmpty(arg1)) { - player.SendToAll(Channel.Unsequenced, 10, arg1 + " connected"); + player.SendToAll(Channel.Unsequenced, ClPacket.GameMessage, arg1 + " connected"); } else - player.SendToSelf(Channel.Unsequenced, 10, ArgRequired); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, ArgRequired); } else - player.SendToSelf(Channel.Unsequenced, 10, MsgNoPerm); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, MsgNoPerm); } catch (Exception ex) { diff --git a/source/BP-Essentials/Chat/Commands/Admin/FakeLeave.cs b/source/BP-Essentials/Chat/Commands/Admin/FakeLeave.cs index 6bfb3610..5929c565 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/FakeLeave.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/FakeLeave.cs @@ -20,13 +20,13 @@ public static bool Run(object oPlayer, string message) string arg1 = GetArgument.Run(1, false, true, message); if (!String.IsNullOrEmpty(arg1)) { - player.SendToAll(Channel.Unsequenced, 10, arg1 + " disconnected"); + player.SendToAll(Channel.Unsequenced, ClPacket.GameMessage, arg1 + " disconnected"); } else - player.SendToSelf(Channel.Unsequenced, 10, ArgRequired); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, ArgRequired); } else - player.SendToSelf(Channel.Unsequenced, 10, MsgNoPerm); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, MsgNoPerm); } catch (Exception ex) { diff --git a/source/BP-Essentials/Chat/Commands/Admin/Feed.cs b/source/BP-Essentials/Chat/Commands/Admin/Feed.cs index 867e7909..f899a3e1 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/Feed.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/Feed.cs @@ -23,7 +23,7 @@ public static bool Run(object oPlayer, string message) { for (byte i = 0; i < 4; i++) player.UpdateStat(i, 100); - player.SendToSelf(Channel.Unsequenced, 10, String.Format(msg, "yourself")); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, String.Format(msg, "yourself")); } else { @@ -34,15 +34,15 @@ public static bool Run(object oPlayer, string message) { for (byte i = 0; i < 4; i++) shPlayer.svPlayer.UpdateStat(i, 100); - player.SendToSelf(Channel.Unsequenced, 10, String.Format(msg, shPlayer.username)); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, String.Format(msg, shPlayer.username)); found = true; } if (!found) - player.SendToSelf(Channel.Unsequenced, 10, NotFoundOnline); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, NotFoundOnline); } } else - player.SendToSelf(Channel.Unsequenced, 10, MsgNoPerm); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, MsgNoPerm); } catch (Exception ex) { diff --git a/source/BP-Essentials/Chat/Commands/Admin/Free.cs b/source/BP-Essentials/Chat/Commands/Admin/Free.cs index 89200fb2..701ece9a 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/Free.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/Free.cs @@ -21,10 +21,10 @@ public static bool Run(object oPlayer, string message) if (!string.IsNullOrEmpty(arg1)) ExecuteOnPlayer.Run(player, message, arg1); else - player.SendToSelf(Channel.Unsequenced, 10, ArgRequired); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, ArgRequired); } else - player.SendToSelf(Channel.Unsequenced, 10, MsgNoPerm); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, MsgNoPerm); } catch (Exception ex) { diff --git a/source/BP-Essentials/Chat/Commands/Admin/GetLogs.cs b/source/BP-Essentials/Chat/Commands/Admin/GetLogs.cs index 124383ad..887f13d3 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/GetLogs.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/GetLogs.cs @@ -47,12 +47,12 @@ public static bool Run(object oPlayer, string logFile) {"<", "<"/* Escape Rich Text tags*/ } }; content = "" + new Regex(string.Join("|", replace.Keys.Select(k => Regex.Escape(k)))).Replace(content, m => replace[m.Value]) + ""; - player.SendToSelf(Channel.Unsequenced, 10, $"WARNING: This is a very unstable command and doesn't work all of the times."); - player.SendToSelf(Channel.Unsequenced, 10, $"Limited to last 100 messages."); - player.SendToSelf(Channel.Fragmented, 50, content); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"WARNING: This is a very unstable command and doesn't work all of the times."); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Limited to last 100 messages."); + player.SendToSelf(Channel.Fragmented, ClPacket.ServerInfo, content); } else - player.SendToSelf(Channel.Unsequenced, 10, MsgNoPerm); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, MsgNoPerm); } catch (Exception ex) { diff --git a/source/BP-Essentials/Chat/Commands/Admin/Give.cs b/source/BP-Essentials/Chat/Commands/Admin/Give.cs index c02d3e4a..5bd2040e 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/Give.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/Give.cs @@ -21,7 +21,7 @@ public static bool Run(object oPlayer, string message) string arg2 = GetArgument.Run(2, false, false, message); if (String.IsNullOrEmpty(arg1) || String.IsNullOrEmpty(arg2)) { - player.SendToSelf(Channel.Unsequenced, 10, ArgRequired); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, ArgRequired); return true; } int arg1int, arg2int; @@ -33,14 +33,14 @@ public static bool Run(object oPlayer, string message) if (shPlayer.svPlayer == player && shPlayer.IsRealPlayer()) { shPlayer.TransferItem(1, IDs[arg1int], arg2int, true); - player.SendToSelf(Channel.Unsequenced, 10, $"Giving you item ID: " + arg1 + ""); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Giving you item ID: " + arg1 + ""); } } else - player.SendToSelf(Channel.Unsequenced, 10, $"Error: Is that a valid number you provided as argument?"); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Error: Is that a valid number you provided as argument?"); } else - player.SendToSelf(Channel.Unsequenced, 10, MsgNoPerm); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, MsgNoPerm); } catch (Exception ex) { diff --git a/source/BP-Essentials/Chat/Commands/Admin/GodMode.cs b/source/BP-Essentials/Chat/Commands/Admin/GodMode.cs index b6deeab1..91f4f58f 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/GodMode.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/GodMode.cs @@ -35,17 +35,17 @@ public static bool Run(object oPlayer, string message) { { RemoveStringFromFile.Run(GodListFile, name); ReadFile.Run(GodListFile); - player.SendToSelf(Channel.Unsequenced, 10, String.Format(msg, "disabled")); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, String.Format(msg, "disabled")); } else { File.AppendAllText(GodListFile, name + Environment.NewLine); GodListPlayers.Add(name); - player.SendToSelf(Channel.Unsequenced, 10, String.Format(msg, "enabled")); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, String.Format(msg, "enabled")); } } else - player.SendToSelf(Channel.Unsequenced, 10, MsgNoPerm); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, MsgNoPerm); } catch (Exception ex) diff --git a/source/BP-Essentials/Chat/Commands/Admin/Heal.cs b/source/BP-Essentials/Chat/Commands/Admin/Heal.cs index 6f7e7860..d9f4ecbc 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/Heal.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/Heal.cs @@ -22,7 +22,7 @@ public static bool Run(object oPlayer, string message) if (String.IsNullOrEmpty(arg1)) { player.Heal(100); - player.SendToSelf(Channel.Unsequenced, 10, String.Format(msg, "yourself")); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, String.Format(msg, "yourself")); } else { @@ -32,15 +32,15 @@ public static bool Run(object oPlayer, string message) if (shPlayer.IsRealPlayer()) { shPlayer.svPlayer.Heal(100); - player.SendToSelf(Channel.Unsequenced, 10, String.Format(msg, shPlayer.username)); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, String.Format(msg, shPlayer.username)); found = true; } if (!found) - player.SendToSelf(Channel.Unsequenced, 10, NotFoundOnline); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, NotFoundOnline); } } else - player.SendToSelf(Channel.Unsequenced, 10, MsgNoPerm); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, MsgNoPerm); } catch (Exception ex) { diff --git a/source/BP-Essentials/Chat/Commands/Admin/Info.cs b/source/BP-Essentials/Chat/Commands/Admin/Info.cs index c0b4b751..9d7f2697 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/Info.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/Info.cs @@ -25,7 +25,7 @@ public static bool Run(object oPlayer, string message) if (shPlayer.username == arg1 || shPlayer.ID.ToString() == arg1.ToString()) if (shPlayer.IsRealPlayer()) { - player.SendToSelf(Channel.Unsequenced, 10, "Info about: '" + shPlayer.username + "'."); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, "Info about: '" + shPlayer.username + "'."); string[] contentarray = { "Username: " + shPlayer.username, "", @@ -42,18 +42,18 @@ public static bool Run(object oPlayer, string message) var content = string.Join("\r\n", contentarray); - player.SendToSelf(Channel.Reliable, 50, content); + player.SendToSelf(Channel.Reliable, ClPacket.ServerInfo, content); found = true; } if (!(found)) - player.SendToSelf(Channel.Unsequenced, 10, NotFoundOnline); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, NotFoundOnline); } else - player.SendToSelf(Channel.Reliable, 10, ArgRequired); + player.SendToSelf(Channel.Reliable, ClPacket.GameMessage, ArgRequired); } else - player.SendToSelf(Channel.Unsequenced, 10, MsgNoPerm); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, MsgNoPerm); } catch (Exception ex) { diff --git a/source/BP-Essentials/Chat/Commands/Admin/Jail.cs b/source/BP-Essentials/Chat/Commands/Admin/Jail.cs index 4fd2f1b3..4f099b3d 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/Jail.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/Jail.cs @@ -26,10 +26,10 @@ public static bool Run(object oPlayer, string message) ExecuteOnPlayer.Run(player, message, arg1); } else - player.SendToSelf(Channel.Unsequenced, 10, ArgRequired); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, ArgRequired); } else - player.SendToSelf(Channel.Unsequenced, 10, MsgNoPerm); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, MsgNoPerm); } catch (Exception ex) { diff --git a/source/BP-Essentials/Chat/Commands/Admin/Kick.cs b/source/BP-Essentials/Chat/Commands/Admin/Kick.cs index 8139f169..5f2f9537 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/Kick.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/Kick.cs @@ -21,10 +21,10 @@ public static bool Run(object oPlayer, string message) if (!string.IsNullOrEmpty(arg1)) ExecuteOnPlayer.Run(player, message, arg1); else - player.SendToSelf(Channel.Unsequenced, 10, ArgRequired); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, ArgRequired); } else - player.SendToSelf(Channel.Unsequenced, 10, MsgNoPerm); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, MsgNoPerm); } catch (Exception ex) { diff --git a/source/BP-Essentials/Chat/Commands/Admin/Kill.cs b/source/BP-Essentials/Chat/Commands/Admin/Kill.cs index 705ae90e..1d60cd7e 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/Kill.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/Kill.cs @@ -21,10 +21,10 @@ public static bool Run(object oPlayer, string message) if (!string.IsNullOrEmpty(arg1)) ExecuteOnPlayer.Run(player, message, arg1); else - player.SendToSelf(Channel.Unsequenced, 10, ArgRequired); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, ArgRequired); } else - player.SendToSelf(Channel.Unsequenced, 10, MsgNoPerm); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, MsgNoPerm); } catch (Exception ex) { diff --git a/source/BP-Essentials/Chat/Commands/Admin/Knockout.cs b/source/BP-Essentials/Chat/Commands/Admin/Knockout.cs index d417101f..2c6454ea 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/Knockout.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/Knockout.cs @@ -21,10 +21,10 @@ public static bool Run(object oPlayer, string message) if (!string.IsNullOrEmpty(arg1)) ExecuteOnPlayer.Run(player, message, arg1); else - player.SendToSelf(Channel.Unsequenced, 10, ArgRequired); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, ArgRequired); } else - player.SendToSelf(Channel.Unsequenced, 10, MsgNoPerm); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, MsgNoPerm); } catch (Exception ex) { diff --git a/source/BP-Essentials/Chat/Commands/Admin/LatestVoteResults.cs b/source/BP-Essentials/Chat/Commands/Admin/LatestVoteResults.cs index 113df312..5c636fde 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/LatestVoteResults.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/LatestVoteResults.cs @@ -18,15 +18,15 @@ public static bool Run(object oPlayer) if (HasPermission.Run(player, CmdLatestVoteResultsExecutableBy)) { if (!LatestVotePeople.Any()) - player.SendToSelf(Channel.Unsequenced, 10, $"The list seems empty."); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"The list seems empty."); else { string content = string.Join("\r\n", LatestVotePeople.ToArray()); - player.SendToSelf(Channel.Unsequenced, 50, "\r\nPlayers that voted 'yes' on the latest votekick: \r\n\r\n" + content); + player.SendToSelf(Channel.Unsequenced, ClPacket.ServerInfo, "\r\nPlayers that voted 'yes' on the latest votekick: \r\n\r\n" + content); } } else - player.SendToSelf(Channel.Unsequenced, 10, MsgNoPerm); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, MsgNoPerm); } catch (Exception ex) { diff --git a/source/BP-Essentials/Chat/Commands/Admin/Launch.cs b/source/BP-Essentials/Chat/Commands/Admin/Launch.cs index 01d1bcfd..f74cc9e9 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/Launch.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/Launch.cs @@ -19,7 +19,7 @@ public static bool Run(object oPlayer, string message) { string arg1 = GetArgument.Run(1, false, true, message); if (String.IsNullOrEmpty(arg1)) - player.SendToSelf(Channel.Unsequenced, 10, ArgRequired); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, ArgRequired); else { bool playerfound = false; @@ -27,17 +27,17 @@ public static bool Run(object oPlayer, string message) if (shPlayer.username == arg1 && shPlayer.IsRealPlayer() || shPlayer.ID.ToString() == arg1 && shPlayer.IsRealPlayer()) { shPlayer.svPlayer.SvForce(new Vector3(0f, 6500f, 0f)); - shPlayer.svPlayer.SendToSelf(Channel.Unsequenced, 10, $"Off you go!"); - player.SendToSelf(Channel.Unsequenced, 10, $"You've launched {shPlayer.username} into space!"); + shPlayer.svPlayer.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Off you go!"); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"You've launched {shPlayer.username} into space!"); playerfound = true; } if (!playerfound) - player.SendToSelf(Channel.Reliable, 10, NotFoundOnline); + player.SendToSelf(Channel.Reliable, ClPacket.GameMessage, NotFoundOnline); } } else - player.SendToSelf(Channel.Unsequenced, 10, MsgNoPerm); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, MsgNoPerm); } catch (Exception ex) { diff --git a/source/BP-Essentials/Chat/Commands/Admin/Money.cs b/source/BP-Essentials/Chat/Commands/Admin/Money.cs index c0939e88..da47ad04 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/Money.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/Money.cs @@ -22,7 +22,7 @@ public static bool Run(object oPlayer, string message) string arg2 = message.Split(' ').Last().Trim(); if (String.IsNullOrEmpty(GetArgument.Run(1, false, false, message)) || String.IsNullOrEmpty(arg2)) { - player.SendToSelf(Channel.Unsequenced, 10, CorrSyntax); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, CorrSyntax); return true; } else @@ -40,18 +40,18 @@ public static bool Run(object oPlayer, string message) if (shPlayer.username == arg1 && shPlayer.IsRealPlayer() || shPlayer.ID.ToString() == arg1 && shPlayer.IsRealPlayer()) { shPlayer.TransferMoney(1, arg2int, true); - player.SendToSelf(Channel.Unsequenced, 10, $"Successfully gave " + shPlayer.username + " " + arg2int + $"$"); - shPlayer.svPlayer.SendToSelf(Channel.Unsequenced, 10, $"" + player.playerData.username + $" gave you " + arg2int + $"$!"); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Successfully gave " + shPlayer.username + " " + arg2int + $"$"); + shPlayer.svPlayer.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"" + player.playerData.username + $" gave you " + arg2int + $"$!"); found = true; } if (!found) - player.SendToSelf(Channel.Unsequenced, 10, NotFoundOnline); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, NotFoundOnline); } else - player.SendToSelf(Channel.Unsequenced, 10, CorrSyntax); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, CorrSyntax); } else - player.SendToSelf(Channel.Unsequenced, 10, MsgNoPerm); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, MsgNoPerm); } catch (Exception ex) { diff --git a/source/BP-Essentials/Chat/Commands/Admin/Mute.cs b/source/BP-Essentials/Chat/Commands/Admin/Mute.cs index d15f00bd..6103bf3d 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/Mute.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/Mute.cs @@ -30,7 +30,7 @@ public static bool Run(object oPlayer, string message) } if (!found) { - player.SendToSelf(Channel.Unsequenced, 10, NotFoundOnline); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, NotFoundOnline); return true; } ReadFile.Run(MuteListFile); @@ -38,18 +38,18 @@ public static bool Run(object oPlayer, string message) { MutePlayers.Add(muteuser); File.AppendAllText(MuteListFile, muteuser + Environment.NewLine); - player.SendToSelf(Channel.Unsequenced, 10, $"Muted " + muteuser + ""); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Muted " + muteuser + ""); } else { RemoveStringFromFile.Run(MuteListFile, muteuser); ReadFile.Run(MuteListFile); - player.SendToSelf(Channel.Unsequenced, 10, $"Unmuted " + muteuser + ""); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Unmuted " + muteuser + ""); } } else - player.SendToSelf(Channel.Unsequenced, 10, MsgNoPerm); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, MsgNoPerm); } catch (Exception ex) { diff --git a/source/BP-Essentials/Chat/Commands/Admin/Reload.cs b/source/BP-Essentials/Chat/Commands/Admin/Reload.cs index 3e0dac5d..ac3ae010 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/Reload.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/Reload.cs @@ -18,7 +18,7 @@ public static bool Run(object oPlayer) if (AdminsListPlayers.Contains(player.playerData.username)) BP_Essentials.Reload.Run(false, player); else - player.SendToSelf(Channel.Unsequenced, 10, MsgNoPerm); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, MsgNoPerm); } catch (Exception ex) { diff --git a/source/BP-Essentials/Chat/Commands/Admin/Restrain.cs b/source/BP-Essentials/Chat/Commands/Admin/Restrain.cs index c4907e7e..54f01600 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/Restrain.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/Restrain.cs @@ -21,10 +21,10 @@ public static bool Run(object oPlayer, string message) if (!string.IsNullOrEmpty(arg1)) ExecuteOnPlayer.Run(player, message, arg1); else - player.SendToSelf(Channel.Unsequenced, 10, ArgRequired); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, ArgRequired); } else - player.SendToSelf(Channel.Unsequenced, 10, MsgNoPerm); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, MsgNoPerm); } catch (Exception ex) { diff --git a/source/BP-Essentials/Chat/Commands/Admin/Save.cs b/source/BP-Essentials/Chat/Commands/Admin/Save.cs index 36352561..f84c65b9 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/Save.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/Save.cs @@ -16,7 +16,7 @@ public static bool Run(object oPlayer) thread.Start(); } else - player.SendToSelf(Channel.Unsequenced, 10, MsgNoPerm); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, MsgNoPerm); } catch (Exception ex) { diff --git a/source/BP-Essentials/Chat/Commands/Admin/Say.cs b/source/BP-Essentials/Chat/Commands/Admin/Say.cs index 51bfb67f..a57e0712 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/Say.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/Say.cs @@ -20,15 +20,15 @@ public static bool Run(object oPlayer, string message) { string arg1 = GetArgument.Run(1, false, true, message); if (String.IsNullOrEmpty(arg1)) - player.SendToSelf(Channel.Unsequenced, 10, ArgRequired); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, ArgRequired); else { arg1 = new Regex("(<)").Replace(arg1, "<"); - player.SendToAll(Channel.Unsequenced, 10, $"{MsgSayPrefix} {player.playerData.username}: {arg1}"); + player.SendToAll(Channel.Unsequenced, ClPacket.GameMessage, $"{MsgSayPrefix} {player.playerData.username}: {arg1}"); } } else - player.SendToSelf(Channel.Unsequenced, 10, MsgNoPerm); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, MsgNoPerm); } catch (Exception ex) { diff --git a/source/BP-Essentials/Chat/Commands/Admin/Search.cs b/source/BP-Essentials/Chat/Commands/Admin/Search.cs index 4ce36db2..8436dc60 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/Search.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/Search.cs @@ -19,7 +19,7 @@ public static bool Run(object oPlayer, string message) { string arg1 = GetArgument.Run(1, false, true, message); if (String.IsNullOrEmpty(arg1)) - player.SendToSelf(Channel.Unsequenced, 10, ArgRequired); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, ArgRequired); else { foreach (var shPlayer2 in FindObjectsOfType()) @@ -37,17 +37,17 @@ public static bool Run(object oPlayer, string message) player.SendToSelf(Channel.Fragmented, 13, shPlayer.otherEntity.ID, shPlayer.otherEntity.SerializeMyItems()); if (!shPlayer2.svPlayer.IsServerside() && shPlayer2.viewers.Count == 1) shPlayer2.svPlayer.SendToSelf(Channel.Reliable, 16, new System.Object[] { }); - player.SendToSelf(Channel.Unsequenced, 10, $"Viewing inventory of {shPlayer2.username}"); - shPlayer2.svPlayer.SendToSelf(Channel.Unsequenced, 10, $"{AdminSearchingInv}"); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Viewing inventory of {shPlayer2.username}"); + shPlayer2.svPlayer.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"{AdminSearchingInv}"); } else - player.SendToSelf(Channel.Unsequenced, 10, $"Player is dead."); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Player is dead."); } } } } else - player.SendToSelf(Channel.Unsequenced, 10, MsgNoPerm); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, MsgNoPerm); } catch (Exception ex) { diff --git a/source/BP-Essentials/Chat/Commands/Admin/Slap.cs b/source/BP-Essentials/Chat/Commands/Admin/Slap.cs index bc123118..a9bb9e79 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/Slap.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/Slap.cs @@ -19,7 +19,7 @@ public static bool Run(object oPlayer, string message) { string arg1 = GetArgument.Run(1, false, true, message); if (String.IsNullOrEmpty(arg1)) - player.SendToSelf(Channel.Unsequenced, 10, ArgRequired); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, ArgRequired); else { bool playerfound = false; @@ -32,18 +32,18 @@ public static bool Run(object oPlayer, string message) int amount = new System.Random().Next(4, 15); shPlayer.svPlayer.Damage(DamageIndex.Null, amount, null, null); shPlayer.svPlayer.SvForce(new Vector3(500f, 0f, 500f)); - shPlayer.svPlayer.SendToSelf(Channel.Unsequenced, 10, $"You got slapped by {shPlayer2.username}! [-{amount} HP]"); - player.SendToSelf(Channel.Unsequenced, 10, $"You've slapped {shPlayer.username}. [-{amount} HP]"); + shPlayer.svPlayer.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"You got slapped by {shPlayer2.username}! [-{amount} HP]"); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"You've slapped {shPlayer.username}. [-{amount} HP]"); playerfound = true; } } if (!playerfound) - player.SendToSelf(Channel.Reliable, 10, NotFoundOnline); + player.SendToSelf(Channel.Reliable, ClPacket.GameMessage, NotFoundOnline); } } else - player.SendToSelf(Channel.Unsequenced, 10, MsgNoPerm); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, MsgNoPerm); } catch (Exception ex) { diff --git a/source/BP-Essentials/Chat/Commands/Admin/Strip.cs b/source/BP-Essentials/Chat/Commands/Admin/Strip.cs index 58438a91..f0e80efa 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/Strip.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/Strip.cs @@ -19,7 +19,7 @@ public static bool Run(object oPlayer, string message) { string arg1 = GetArgument.Run(1, false, true, message); if (String.IsNullOrEmpty(arg1)) - player.SendToSelf(Channel.Unsequenced, 10, ArgRequired); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, ArgRequired); else { bool playerfound = false; @@ -36,20 +36,20 @@ public static bool Run(object oPlayer, string message) shPlayer.svPlayer.SvSetWearable(-501996567); //NullHead shPlayer.svPlayer.SvSetWearable(-1191209217); //NullLegs // --- - foreach (ShInventoryItem item in shPlayer.myItems.Values.ToList()) + foreach (var item in shPlayer.myItems.Values.ToList()) if (item.item.GetType() == typeof(ShWearable)) shPlayer.TransferItem(2, item.item.index, shPlayer.MyItemCount(item.item.index), true); - shPlayer.svPlayer.SendToSelf(Channel.Unsequenced, 10, $"{player.playerData.username} Removed your clothes."); - player.SendToSelf(Channel.Unsequenced, 10, $"Removed {shPlayer.username}'s clothes."); + shPlayer.svPlayer.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"{player.playerData.username} Removed your clothes."); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Removed {shPlayer.username}'s clothes."); playerfound = true; } if (!playerfound) - player.SendToSelf(Channel.Reliable, 10, NotFoundOnline); + player.SendToSelf(Channel.Reliable, ClPacket.GameMessage, NotFoundOnline); } } else - player.SendToSelf(Channel.Unsequenced, 10, MsgNoPerm); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, MsgNoPerm); } catch (Exception ex) { diff --git a/source/BP-Essentials/Chat/Commands/Admin/Tp.cs b/source/BP-Essentials/Chat/Commands/Admin/Tp.cs index 8929bbbb..216b78da 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/Tp.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/Tp.cs @@ -15,10 +15,10 @@ public static bool TpHere(object oPlayer, string message) if (!string.IsNullOrEmpty(arg1)) ExecuteOnPlayer.Run(player, message, arg1); else - player.SendToSelf(Channel.Unsequenced, 10, ArgRequired); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, ArgRequired); } else - player.SendToSelf(Channel.Unsequenced, 10, MsgNoPerm); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, MsgNoPerm); } catch (Exception ex) { @@ -37,10 +37,10 @@ public static bool Run(object oPlayer, string message) { if (!string.IsNullOrEmpty(arg1)) ExecuteOnPlayer.Run(player, message, arg1); else - player.SendToSelf(Channel.Unsequenced, 10, ArgRequired); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, ArgRequired); } else - player.SendToSelf(Channel.Unsequenced, 10, MsgNoPerm); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, MsgNoPerm); } catch (Exception ex) { diff --git a/source/BP-Essentials/Chat/Commands/Admin/_SetJob.cs b/source/BP-Essentials/Chat/Commands/Admin/_SetJob.cs index 27b4a551..e1d9b778 100644 --- a/source/BP-Essentials/Chat/Commands/Admin/_SetJob.cs +++ b/source/BP-Essentials/Chat/Commands/Admin/_SetJob.cs @@ -38,21 +38,21 @@ public static bool Run(object oPlayer, string message) if (shPlayer.username == arg2 || shPlayer.ID.ToString() == arg2.ToString()) if (arg1int <= Jobs.Length && arg1int >= 0) { - player.SendToSelf(Channel.Unsequenced, 10, String.Format(msg, arg2, Jobs[arg1int])); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, String.Format(msg, arg2, Jobs[arg1int])); SetJob.Run(shPlayer, arg1int, true, false); } else - player.SendToSelf(Channel.Unsequenced, 10, $"Error: The value must be between 0 and {Jobs.Length}."); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Error: The value must be between 0 and {Jobs.Length}."); } else - player.SendToSelf(Channel.Unsequenced, 10, NotValidArg); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, NotValidArg); } else - player.SendToSelf(Channel.Unsequenced, 10, NotValidArg); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, NotValidArg); } else - player.SendToSelf(Channel.Unsequenced, 10, MsgNoPerm); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, MsgNoPerm); } catch (Exception ex) { diff --git a/source/BP-Essentials/Chat/Commands/Everyone/Afk.cs b/source/BP-Essentials/Chat/Commands/Everyone/Afk.cs index ad888c82..baeb14d3 100644 --- a/source/BP-Essentials/Chat/Commands/Everyone/Afk.cs +++ b/source/BP-Essentials/Chat/Commands/Everyone/Afk.cs @@ -15,17 +15,17 @@ public static bool Run(object oPlayer) { RemoveStringFromFile.Run(AfkListFile, player.playerData.username); ReadFile.Run(AfkListFile); - player.SendToSelf(Channel.Unsequenced, 10, $"You are no longer AFK."); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"You are no longer AFK."); } else { File.AppendAllText(AfkListFile, player.playerData.username + Environment.NewLine); AfkPlayers.Add(player.playerData.username); - player.SendToSelf(Channel.Unsequenced, 10, $"You are now AFK."); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"You are now AFK."); } } else - player.SendToSelf(Channel.Unsequenced, 10, MsgNoPerm); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, MsgNoPerm); } catch (Exception ex) { diff --git a/source/BP-Essentials/Chat/Commands/Everyone/Atm.cs b/source/BP-Essentials/Chat/Commands/Everyone/Atm.cs index cf66f663..a49969ef 100644 --- a/source/BP-Essentials/Chat/Commands/Everyone/Atm.cs +++ b/source/BP-Essentials/Chat/Commands/Everyone/Atm.cs @@ -22,14 +22,14 @@ public static bool Run(object oPlayer) if (shPlayer.IsRealPlayer()) if (shPlayer.wantedLevel == 0) { - player.SendToSelf(Channel.Unsequenced, 10, $"Opening ATM menu.."); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Opening ATM menu.."); player.SendToSelf(Channel.Reliable, 40, player.bankBalance); } else if (shPlayer.wantedLevel != 0) - player.SendToSelf(Channel.Unsequenced, 10, $"Criminal Activity: Account Locked"); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Criminal Activity: Account Locked"); } else - player.SendToSelf(Channel.Unsequenced, 10, MsgNoPerm); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, MsgNoPerm); } catch (Exception ex) { diff --git a/source/BP-Essentials/Chat/Commands/Everyone/Essentials.cs b/source/BP-Essentials/Chat/Commands/Everyone/Essentials.cs index 0e9d8597..1245aedf 100644 --- a/source/BP-Essentials/Chat/Commands/Everyone/Essentials.cs +++ b/source/BP-Essentials/Chat/Commands/Everyone/Essentials.cs @@ -8,28 +8,28 @@ public static bool Run(object oPlayer, string message) { var player = (SvPlayer)oPlayer; string arg = GetArgument.Run(1, false, false, message).Trim().ToLower(); if (arg == "ver" || arg == "version") - player.SendToSelf(Channel.Unsequenced, 10, "Version: " + EssentialsVariablesPlugin.Version); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, "Version: " + EssentialsVariablesPlugin.Version); else if (arg == "info") { - player.SendToSelf(Channel.Unsequenced, 10, "Essentials Created by UserR00T & DeathByKorea & BP"); - player.SendToSelf(Channel.Unsequenced, 10, "Version " + EssentialsVariablesPlugin.Version); - player.SendToSelf(Channel.Unsequenced, 10, "Type '/essentials help' for more info. "); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, "Essentials Created by UserR00T & DeathByKorea & BP"); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, "Version " + EssentialsVariablesPlugin.Version); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, "Type '/essentials help' for more info. "); } else if (arg == "help") { - player.SendToSelf(Channel.Unsequenced, 10, "Subcommands for /essentials:"); - player.SendToSelf(Channel.Unsequenced, 10, " - help : Shows this menu."); - player.SendToSelf(Channel.Unsequenced, 10, " - info : Shows infomation about the developer."); - player.SendToSelf(Channel.Unsequenced, 10, " - ver/version : Shows version number."); - player.SendToSelf(Channel.Unsequenced, 10, " - cmd/command : Gives a link to the website of BP-Essentials."); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, "Subcommands for /essentials:"); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, " - help : Shows this menu."); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, " - info : Shows infomation about the developer."); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, " - ver/version : Shows version number."); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, " - cmd/command : Gives a link to the website of BP-Essentials."); } else if (arg == "cmd" || arg == "cmds" || arg == "command" || arg == "commands") - player.SendToSelf(Channel.Unsequenced, 10, "Up to date help can be found at http://bit.do/BPEssentials"); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, "Up to date help can be found at http://bit.do/BPEssentials"); else { - player.SendToSelf(Channel.Unsequenced, 10, "Essentials Created by UserR00T & DeathByKorea & BP."); - player.SendToSelf(Channel.Unsequenced, 10, "Version " + EssentialsVariablesPlugin.Version); - player.SendToSelf(Channel.Unsequenced, 10, "Type '/essentials help' for more info. "); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, "Essentials Created by UserR00T & DeathByKorea & BP."); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, "Version " + EssentialsVariablesPlugin.Version); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, "Type '/essentials help' for more info. "); } } catch (Exception ex) diff --git a/source/BP-Essentials/Chat/Commands/Everyone/OnlinePlayers.cs b/source/BP-Essentials/Chat/Commands/Everyone/OnlinePlayers.cs index 79fad819..ccde1399 100644 --- a/source/BP-Essentials/Chat/Commands/Everyone/OnlinePlayers.cs +++ b/source/BP-Essentials/Chat/Commands/Everyone/OnlinePlayers.cs @@ -22,15 +22,15 @@ public static bool Run(object oPlayer) switch (realPlayers) { case 1: - player.SendToSelf(Channel.Unsequenced, 10, $"There is {realPlayers} player online"); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"There is {realPlayers} player online"); break; default: - player.SendToSelf(Channel.Unsequenced, 10, $"There are {realPlayers} players online"); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"There are {realPlayers} players online"); break; } } else - player.SendToSelf(Channel.Unsequenced, 10, MsgNoPerm); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, MsgNoPerm); } catch (Exception ex) { diff --git a/source/BP-Essentials/Chat/Commands/Everyone/Pay.cs b/source/BP-Essentials/Chat/Commands/Everyone/Pay.cs index 656d5387..a8c44811 100644 --- a/source/BP-Essentials/Chat/Commands/Everyone/Pay.cs +++ b/source/BP-Essentials/Chat/Commands/Everyone/Pay.cs @@ -19,7 +19,7 @@ public static bool Run(object oPlayer, string message) string arg2 = message.Split(' ').Last().Trim(); if (String.IsNullOrEmpty(GetArgument.Run(1, false, false, message)) || String.IsNullOrEmpty(arg2)) { - player.SendToSelf(Channel.Unsequenced, 10, CorrSyntax); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, CorrSyntax); return true; } else @@ -34,7 +34,7 @@ public static bool Run(object oPlayer, string message) { if (arg2Int <= 0) { - player.SendToSelf(Channel.Unsequenced, 10, $"Cannot transfer 0$."); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Cannot transfer 0$."); return true; } foreach (var shPlayer in UnityEngine.Object.FindObjectsOfType()) @@ -46,21 +46,21 @@ public static bool Run(object oPlayer, string message) { _shPlayer.TransferMoney(2, arg2Int, true); shPlayer.TransferMoney(1, arg2Int, true); - player.SendToSelf(Channel.Unsequenced, 10, $"Successfully transfered {arg2Int}$ to {shPlayer.username}!"); - shPlayer.svPlayer.SendToSelf(Channel.Unsequenced, 10, $"{player.playerData.username} gave you {arg2Int}$!"); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Successfully transfered {arg2Int}$ to {shPlayer.username}!"); + shPlayer.svPlayer.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"{player.playerData.username} gave you {arg2Int}$!"); } else - player.SendToSelf(Channel.Unsequenced, 10, $"Cannot transfer money, do you have " + arg2Int + $"$ in your inventory?"); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Cannot transfer money, do you have " + arg2Int + $"$ in your inventory?"); return true; } - player.SendToSelf(Channel.Unsequenced, 10, NotFoundOnline); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, NotFoundOnline); } else - player.SendToSelf(Channel.Unsequenced, 10, CorrSyntax); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, CorrSyntax); } else - player.SendToSelf(Channel.Unsequenced, 10, MsgNoPerm); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, MsgNoPerm); } catch (Exception ex) { diff --git a/source/BP-Essentials/Chat/Commands/Everyone/Report.cs b/source/BP-Essentials/Chat/Commands/Everyone/Report.cs index d9378f49..aa2ee750 100644 --- a/source/BP-Essentials/Chat/Commands/Everyone/Report.cs +++ b/source/BP-Essentials/Chat/Commands/Everyone/Report.cs @@ -42,22 +42,22 @@ public static bool Run(object oPlayer, string message) item.Key.reportedPlayer = shPlayer; } else - player.SendToSelf(Channel.Reliable, 10, $"Hey! You cannot report an admin."); + player.SendToSelf(Channel.Reliable, ClPacket.GameMessage, $"Hey! You cannot report an admin."); break; } if (!playerfound) - player.SendToSelf(Channel.Reliable, 10, NotFoundOnline); + player.SendToSelf(Channel.Reliable, ClPacket.GameMessage, NotFoundOnline); } else - player.SendToSelf(Channel.Reliable, 10, $"Hey! You cannot report as admin."); + player.SendToSelf(Channel.Reliable, ClPacket.GameMessage, $"Hey! You cannot report as admin."); } else - player.SendToSelf(Channel.Reliable, 10, $"Hey! You cannot report yourself, dummy."); + player.SendToSelf(Channel.Reliable, ClPacket.GameMessage, $"Hey! You cannot report yourself, dummy."); } } else { - player.SendToSelf(Channel.Reliable, 10, $"Missing argument! Correct syntax: {GetArgument.Run(0, false, false, message)} [player]"); + player.SendToSelf(Channel.Reliable, ClPacket.GameMessage, $"Missing argument! Correct syntax: {GetArgument.Run(0, false, false, message)} [player]"); } } catch (Exception ex) diff --git a/source/BP-Essentials/EssentialsChat.cs b/source/BP-Essentials/EssentialsChat.cs index 9dc5514b..b5985c51 100644 --- a/source/BP-Essentials/EssentialsChat.cs +++ b/source/BP-Essentials/EssentialsChat.cs @@ -28,7 +28,7 @@ public static bool SvGlobalChatMessage(SvPlayer player, ref string message) if (!CmdAfkDisabled) return Commands.Afk.Run(player); else - { player.SendToSelf(Channel.Unsequenced, 10, DisabledCommand); return true; } + { player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, DisabledCommand); return true; } } else if (AfkPlayers.Contains(player.playerData.username)) Commands.Afk.Run(player); @@ -43,7 +43,7 @@ public static bool SvGlobalChatMessage(SvPlayer player, ref string message) i = CustomCommands.IndexOf(command); string[] lines = Responses[i].Split(new[] { "\r\n", "\n" }, StringSplitOptions.None); foreach (string line in lines) - player.SendToSelf(Channel.Unsequenced, 10, GetPlaceHolders.Run(line, player)); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, GetPlaceHolders.Run(line, player)); return true; } @@ -51,7 +51,7 @@ public static bool SvGlobalChatMessage(SvPlayer player, ref string message) if (!CmdClearChatDisabled) return Commands.ClearChat.Run(player, message); else - { player.SendToSelf(Channel.Unsequenced, 10, DisabledCommand); return true; } + { player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, DisabledCommand); return true; } else if (message.StartsWith("/essentials") || message.StartsWith("/ess")) return Commands.Essentials.Run(player, message); else if (message.StartsWith(CmdDebug) || (message.StartsWith(CmdDebug2))) @@ -60,12 +60,12 @@ public static bool SvGlobalChatMessage(SvPlayer player, ref string message) if (!CmdGodmodeDisabled) return Commands.GodMode.Run(player, message); else - { player.SendToSelf(Channel.Unsequenced, 10, DisabledCommand); return true; } + { player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, DisabledCommand); return true; } else if (message.StartsWith(CmdPay) || message.StartsWith(CmdPay2)) if (!CmdPayDisabled) return Commands.Pay.Run(player, message); else - { player.SendToSelf(Channel.Unsequenced, 10, DisabledCommand); return true; } + { player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, DisabledCommand); return true; } else if (message.StartsWith(CmdSave)) return Commands.Save.Run(player); else if (message.StartsWith(CmdBan)) @@ -90,17 +90,17 @@ public static bool SvGlobalChatMessage(SvPlayer player, ref string message) if (!CmdMuteDisabled) return Commands.Mute.Run(player, message); else - { player.SendToSelf(Channel.Unsequenced, 10, DisabledCommand); return true; } + { player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, DisabledCommand); return true; } else if (message.StartsWith(CmdSay) || message.StartsWith(CmdSay2)) if (!CmdSayDisabled) return Commands.Say.Run(player, message); else - { player.SendToSelf(Channel.Unsequenced, 10, DisabledCommand); return true; } + { player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, DisabledCommand); return true; } else if (message.StartsWith(CmdInfo) || message.StartsWith(CmdInfo2)) if (!CmdInfoDisabled) return Commands.Info.Run(player, message); else - { player.SendToSelf(Channel.Unsequenced, 10, DisabledCommand); return true; } + { player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, DisabledCommand); return true; } else if (message.StartsWith(CmdLogs)) return Commands.GetLogs.Run(player, ChatLogFile); @@ -109,32 +109,32 @@ public static bool SvGlobalChatMessage(SvPlayer player, ref string message) if (!CmdPlayersDisabled) return Commands.OnlinePlayers.Run(player); else - { player.SendToSelf(Channel.Unsequenced, 10, DisabledCommand); return true; } + { player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, DisabledCommand); return true; } else if (message.StartsWith(CmdGive) || (message.StartsWith(CmdGive2))) if (!CmdGiveDisabled) return Commands.Give.Run(player, message); else - { player.SendToSelf(Channel.Unsequenced, 10, DisabledCommand); return true; } + { player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, DisabledCommand); return true; } else if (message.StartsWith(CmdFakeJoin) || (message.StartsWith(CmdFakeJoin2))) if (!CmdFakeJoinDisabled) return Commands.FakeJoin.Run(player, message); else - { player.SendToSelf(Channel.Unsequenced, 10, DisabledCommand); return true; } + { player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, DisabledCommand); return true; } else if (message.StartsWith(CmdFakeLeave) || (message.StartsWith(CmdFakeLeave2))) if (!CmdFakeLeaveDisabled) return Commands.FakeLeave.Run(player, message); else - { player.SendToSelf(Channel.Unsequenced, 10, DisabledCommand); return true; } + { player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, DisabledCommand); return true; } else if (message.StartsWith(CmdAtm) || (message.StartsWith(CmdAtm2))) if (!CmdAtmDisabled) return Commands.Atm.Run(player); else - { player.SendToSelf(Channel.Unsequenced, 10, DisabledCommand); return true; } + { player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, DisabledCommand); return true; } else if (message.StartsWith(CmdCheckAlts) || (message.StartsWith(CmdCheckAlts2))) if (!CmdCheckAltsDisabled) return Commands.CheckAlts.Run(player, message); else - { player.SendToSelf(Channel.Unsequenced, 10, DisabledCommand); return true; } + { player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, DisabledCommand); return true; } else if (message.StartsWith(CmdHeal) || message.StartsWith(CmdHeal2)) return Commands.Heal.Run(player, message); else if (message.StartsWith(CmdFeed) || message.StartsWith(CmdFeed2)) @@ -143,77 +143,77 @@ public static bool SvGlobalChatMessage(SvPlayer player, ref string message) if (!CmdLatestVoteResultsDisabled) return Commands.LatestVoteResults.Run(player); else - { player.SendToSelf(Channel.Unsequenced, 10, DisabledCommand); return true; } + { player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, DisabledCommand); return true; } else if (message.StartsWith(CmdMoney) || message.StartsWith(CmdMoney2)) if (!CmdMoneyDisabled) return Commands.Money.Run(player, message); else - { player.SendToSelf(Channel.Unsequenced, 10, DisabledCommand); return true; } + { player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, DisabledCommand); return true; } else if (message.StartsWith(CmdSetjob) || message.StartsWith(CmdSetjob2)) if (!CmdSetjobDisabled) return Commands._SetJob.Run(player, message); else - { player.SendToSelf(Channel.Unsequenced, 10, DisabledCommand); return true; } + { player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, DisabledCommand); return true; } else if (message.StartsWith(CmdClearWanted) || message.StartsWith(CmdClearWanted2)) if (!CmdClearWantedDisabled) return Commands.ClearWanted.Run(player, message); else - { player.SendToSelf(Channel.Unsequenced, 10, DisabledCommand); return true; } + { player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, DisabledCommand); return true; } else if (message.StartsWith(CmdReport) || message.StartsWith(CmdReport2)) if (!CmdReportDisabled) return Commands.Report.Run(player, message); else - { player.SendToSelf(Channel.Unsequenced, 10, DisabledCommand); return true; } + { player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, DisabledCommand); return true; } else if (message.StartsWith(CmdLaunch) || message.StartsWith(CmdLaunch2)) if (!CmdLaunchDisabled) return Commands.Launch.Run(player, message); else - { player.SendToSelf(Channel.Unsequenced, 10, DisabledCommand); return true; } + { player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, DisabledCommand); return true; } else if (message.StartsWith(CmdStrip) || message.StartsWith(CmdStrip2)) if (!CmdStripDisabled) return Commands.Strip.Run(player, message); else - { player.SendToSelf(Channel.Unsequenced, 10, DisabledCommand); return true; } + { player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, DisabledCommand); return true; } else if (message.StartsWith(CmdSlap) || message.StartsWith(CmdSlap2)) if (!CmdSlapDisabled) return Commands.Slap.Run(player, message); else - { player.SendToSelf(Channel.Unsequenced, 10, DisabledCommand); return true; } + { player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, DisabledCommand); return true; } else if (message.StartsWith(CmdSearch) || message.StartsWith(CmdSearch2)) if (!CmdSearchDisabled) return Commands.Search.Run(player, message); else - { player.SendToSelf(Channel.Unsequenced, 10, DisabledCommand); return true; } + { player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, DisabledCommand); return true; } else if (message.StartsWith(CmdConfirm) || message.StartsWith(CmdConfirm2)) return Commands.Confirm.Run(player); else if (message.StartsWith(CmdJail) || message.StartsWith(CmdJail2)) if (!CmdJailDisabled) return Commands.Jail.Run(player, message); else - { player.SendToSelf(Channel.Unsequenced, 10, DisabledCommand); return true; } + { player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, DisabledCommand); return true; } else if (message.StartsWith(CmdKnockout) || message.StartsWith(CmdKnockout2)) if (!CmdKnockoutDisabled) return Commands.Knockout.Run(player, message); else - { player.SendToSelf(Channel.Unsequenced, 10, DisabledCommand); return true; } + { player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, DisabledCommand); return true; } if (MsgUnknownCommand) { - player.SendToSelf(Channel.Unsequenced, 10, $"Unknown command. Type {CmdCommandCharacter}essentials cmds for more info."); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Unknown command. Type {CmdCommandCharacter}essentials cmds for more info."); return true; } } //Checks if the player is muted. if (MutePlayers.Contains(player.playerData.username)) { - player.SendToSelf(Channel.Unsequenced, 10, SelfIsMuted); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, SelfIsMuted); return true; } //Checks if the message contains a username that is AFK. if (AfkPlayers.Any(message.Contains)) { - player.SendToSelf(Channel.Unsequenced, 10, PlayerIsAFK); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, PlayerIsAFK); return true; } @@ -225,7 +225,7 @@ public static bool SvGlobalChatMessage(SvPlayer player, ref string message) _msg = curr.Value.Message; _msg = _msg.Replace("{username}", new Regex("(<)").Replace(player.playerData.username, "<")); _msg = _msg.Replace("{message}", new Regex("(<)").Replace(Chat.LangAndChatBlock.Run(player, message), "<")); - player.SendToAll(Channel.Unsequenced, 10, _msg); + player.SendToAll(Channel.Unsequenced, ClPacket.GameMessage, _msg); return true; } } @@ -234,13 +234,13 @@ public static bool SvGlobalChatMessage(SvPlayer player, ref string message) _msg = AdminMessage; _msg = _msg.Replace("{username}", new Regex("(<)").Replace(player.playerData.username, "<")); _msg = _msg.Replace("{message}", new Regex("(<)").Replace(Chat.LangAndChatBlock.Run(player, message), "<")); - player.SendToAll(Channel.Unsequenced, 10, _msg); + player.SendToAll(Channel.Unsequenced, ClPacket.GameMessage, _msg); return true; } _msg = PlayerMessage; _msg = _msg.Replace("{username}", new Regex("(<)").Replace(player.playerData.username, "<")); _msg = _msg.Replace("{message}", new Regex("(<)").Replace(Chat.LangAndChatBlock.Run(player, message), "<")); - player.SendToAll(Channel.Unsequenced, 10, _msg); + player.SendToAll(Channel.Unsequenced, ClPacket.GameMessage, _msg); return true; } catch (Exception ex) diff --git a/source/BP-Essentials/EssentialsCore.cs b/source/BP-Essentials/EssentialsCore.cs index a759cf1e..2b0a5fc8 100644 --- a/source/BP-Essentials/EssentialsCore.cs +++ b/source/BP-Essentials/EssentialsCore.cs @@ -24,8 +24,8 @@ namespace BP_Essentials public class EssentialsCorePlugin { //Initialization - [Hook("SvManager.StartServerNetwork")] - public static void StartServerNetwork(SvManager svManager) + [Hook("SvManager.StartServer")] + public static void StartServer(SvManager svManager) { // ShManager Manager = (ShManager)typeof(SvManager).GetField("manager", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(svManager); try @@ -46,7 +46,7 @@ public static void StartServerNetwork(SvManager svManager) Reload.Run(true); } var thread = new Thread(SavePeriodically.Run); - thread.Start(); + thread.Start(svManager); Debug.Log("-------------------------------------------------------------------------------"); Debug.Log(" "); Debug.Log("[INFO] Essentials - version: " + LocalVersion + " Loaded in successfully!"); diff --git a/source/BP-Essentials/EssentialsMethods.cs b/source/BP-Essentials/EssentialsMethods.cs index 957b6d5a..185ed923 100644 --- a/source/BP-Essentials/EssentialsMethods.cs +++ b/source/BP-Essentials/EssentialsMethods.cs @@ -13,22 +13,13 @@ namespace BP_Essentials { public class EssentialsMethodsPlugin : EssentialsCorePlugin { - - - [Hook("SvPlayer.SvSellApartment")] public static bool SvSellApartment(SvPlayer player) { + Confirmed = false; if (Confirmed) - { - Confirmed = false; return false; - } - else - { - Confirmed = false; - player.SendToSelf(Channel.Unsequenced, 10, $"Are you sure you want to sell your apartment? Type '{CmdConfirm}' to confirm."); - } + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Are you sure you want to sell your apartment? Type '{CmdConfirm}' to confirm."); return true; } @@ -76,13 +67,12 @@ public static bool SpawnBot(SvPlayer player, ref Vector3 position, ref Quaternio [Hook("ShRetainer.HitEffect")] public static bool HitEffect(ShRetainer player, ref ShEntity hitTarget, ref ShPlayer source, ref Collider collider) { - - foreach (var shPlayer in GameObject.FindObjectsOfType()) + foreach (var shPlayer in UnityEngine.Object.FindObjectsOfType()) if (shPlayer.IsRealPlayer()) { if (shPlayer != hitTarget) continue; if (!GodListPlayers.Contains(shPlayer.username)) continue; - shPlayer.svPlayer.SendToSelf(Channel.Unsequenced, 10, "Being handcuffed Blocked!"); + shPlayer.svPlayer.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, "Being handcuffed Blocked!"); return true; } return false; @@ -91,16 +81,17 @@ public static bool HitEffect(ShRetainer player, ref ShEntity hitTarget, ref ShPl [Hook("SvPlayer.SvBan")] public static void SvBan(SvPlayer player, ref int otherID) { - foreach (var shPlayer in GameObject.FindObjectsOfType()) + foreach (var shPlayer in UnityEngine.Object.FindObjectsOfType()) if (shPlayer.ID == otherID) if (shPlayer.IsRealPlayer() && !shPlayer.svPlayer.IsServerside()) - player.SendToAll(Channel.Unsequenced, 10, $"{shPlayer.username} Just got banned by {player.playerData.username}"); + player.SendToAll(Channel.Unsequenced, ClPacket.GameMessage, $"{shPlayer.username} Just got banned by {player.playerData.username}"); } [Hook("SvPlayer.SvStartVote")] public static bool SvStartVote(SvPlayer player, ref byte voteIndex, ref int ID) { if (voteIndex == 1) + { if (!VoteKickDisabled) { foreach (var shPlayer in UnityEngine.Object.FindObjectsOfType()) @@ -117,7 +108,7 @@ public static bool SvStartVote(SvPlayer player, ref byte voteIndex, ref int ID) player.SendToAll(Channel.Reliable, 60, voteIndex, ID); player.svManager.StartCoroutine(player.svManager.StartVote()); Debug.Log($"{SetTimeStamp.Run()}[INFO] {player.playerData.username} Has issued a votekick against {shPlayer.username}"); - player.SendToAll(Channel.Unsequenced, 10, $"{player.playerData.username} Has issued a vote kick against {shPlayer.username}"); + player.SendToAll(Channel.Unsequenced, ClPacket.GameMessage, $"{player.playerData.username} Has issued a vote kick against {shPlayer.username}"); LatestVotePeople.Clear(); } else @@ -125,8 +116,10 @@ public static bool SvStartVote(SvPlayer player, ref byte voteIndex, ref int ID) } } else - player.SendToSelf(Channel.Unsequenced, 10, $"Vote kicking has been disabled on this server."); - return true; + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Vote kicking has been disabled on this server."); + return true; + } + return false; } [Hook("SvPlayer.SvVoteYes", true)] @@ -152,7 +145,7 @@ public static bool SvFunctionKey(SvPlayer player, ref byte key) if (item.Key.LastMenu == CurrentMenu.Report && key > 1 && key < 11) { player.SendToSelf(Channel.Reliable, ClPacket.CloseFunctionMenu); - player.SendToSelf(Channel.Reliable, 10, $"Reported \"{item.Key.reportedPlayer.username}\" With the reason \"{ReportReasons[key - 2]}\"."); + player.SendToSelf(Channel.Reliable, ClPacket.GameMessage, $"Reported \"{item.Key.reportedPlayer.username}\" With the reason \"{ReportReasons[key - 2]}\"."); item.Key.reportedReason = ReportReasons[key - 2]; item.Key.LastMenu = CurrentMenu.Main; ReportPlayer.Run(player.playerData.username, ReportReasons[key - 2], item.Key.reportedPlayer); @@ -181,7 +174,7 @@ public static bool SvFunctionKey(SvPlayer player, ref byte key) if (item.Key.LastMenu == CurrentMenu.ServerInfo) { player.SendToSelf(Channel.Reliable, ClPacket.CloseFunctionMenu); - player.SendToSelf(Channel.Fragmented, 50, File.ReadAllText("server_info.txt")); + player.SendToSelf(Channel.Fragmented, ClPacket.ServerInfo, File.ReadAllText("server_info.txt")); item.Key.LastMenu = CurrentMenu.Main; } if (item.Key.LastMenu == CurrentMenu.Staff && HasPermission.Run(player, AccessMoneyMenu)) @@ -193,7 +186,7 @@ public static bool SvFunctionKey(SvPlayer player, ref byte key) { player.SendToSelf(Channel.Reliable, ClPacket.CloseFunctionMenu); shPlayer.TransferMoney(1, 1000, true); - player.SendToSelf(Channel.Reliable, 10, $"You have given yourself 1.000 dollars."); + player.SendToSelf(Channel.Reliable, ClPacket.GameMessage, $"You have given yourself 1.000 dollars."); Debug.Log(SetTimeStamp.Run() + "[INFO] " + player.playerData.username + " Spawned in 1.000 dollars through the functionUI"); item.Key.LastMenu = CurrentMenu.Main; } @@ -201,7 +194,7 @@ public static bool SvFunctionKey(SvPlayer player, ref byte key) { player.SendToSelf(Channel.Reliable, ClPacket.CloseFunctionMenu); shPlayer.TransferItem(1, CommonIDs[0], 500, true); - player.SendToSelf(Channel.Reliable, 10, $"You have given yourself 500 pistol ammo."); + player.SendToSelf(Channel.Reliable, ClPacket.GameMessage, $"You have given yourself 500 pistol ammo."); Debug.Log(SetTimeStamp.Run() + "[INFO] " + player.playerData.username + " Spawned in 500 pistol ammo through the functionUI"); item.Key.LastMenu = CurrentMenu.Main; } @@ -211,10 +204,10 @@ public static bool SvFunctionKey(SvPlayer player, ref byte key) if (IsOnline.Run(item.Key.reportedPlayer)) { shPlayer.SetPosition(item.Key.reportedPlayer.GetPosition()); - player.SendToSelf(Channel.Reliable, 10, $"Teleported to \"{item.Key.reportedPlayer.username}\"."); + player.SendToSelf(Channel.Reliable, ClPacket.GameMessage, $"Teleported to \"{item.Key.reportedPlayer.username}\"."); } else - player.SendToSelf(Channel.Reliable, 10, "Player not online anymore."); + player.SendToSelf(Channel.Reliable, ClPacket.GameMessage, "Player not online anymore."); item.Key.reportedPlayer = null; item.Key.LastMenu = CurrentMenu.Main; } @@ -230,7 +223,7 @@ public static bool SvFunctionKey(SvPlayer player, ref byte key) { player.SendToSelf(Channel.Reliable, ClPacket.CloseFunctionMenu); shPlayer.TransferMoney(1, 10000, true); - player.SendToSelf(Channel.Reliable, 10, $"You have given yourself 10.000 dollars."); + player.SendToSelf(Channel.Reliable, ClPacket.GameMessage, $"You have given yourself 10.000 dollars."); Debug.Log(SetTimeStamp.Run() + "[INFO] " + player.playerData.username + " Spawned in 10.000 dollars through the functionUI"); item.Key.LastMenu = CurrentMenu.Main; return true; @@ -239,7 +232,7 @@ public static bool SvFunctionKey(SvPlayer player, ref byte key) { player.SendToSelf(Channel.Reliable, ClPacket.CloseFunctionMenu); shPlayer.TransferItem(1, CommonIDs[1], 20, true); - player.SendToSelf(Channel.Reliable, 10, $"You have given yourself 20 handcuffs."); + player.SendToSelf(Channel.Reliable, ClPacket.GameMessage, $"You have given yourself 20 handcuffs."); Debug.Log(SetTimeStamp.Run() + "[INFO] " + player.playerData.username + " Spawned in 20 handcuffs through the functionUI"); item.Key.LastMenu = CurrentMenu.Main; return true; @@ -263,7 +256,7 @@ public static bool SvFunctionKey(SvPlayer player, ref byte key) foreach (var line in File.ReadAllLines("admin_list.txt")) if (line.Trim() != null && !line.Trim().StartsWith("#", StringComparison.OrdinalIgnoreCase)) builder.Append(line + "\r\n"); - player.SendToSelf(Channel.Fragmented, 50, builder.ToString()); + player.SendToSelf(Channel.Fragmented, ClPacket.ServerInfo, builder.ToString()); item.Key.LastMenu = CurrentMenu.Main; } @@ -272,22 +265,22 @@ public static bool SvFunctionKey(SvPlayer player, ref byte key) if (item.Key.LastMenu == CurrentMenu.GiveMoney) { item.Key.shplayer.TransferMoney(1, 100000, true); - player.SendToSelf(Channel.Reliable, 10, $"You have given yourself 100.000 dollars."); + player.SendToSelf(Channel.Reliable, ClPacket.GameMessage, $"You have given yourself 100.000 dollars."); Debug.Log(SetTimeStamp.Run() + "[INFO] " + player.playerData.username + " Spawned in 100.000 dollars through the functionUI"); item.Key.LastMenu = CurrentMenu.Main; } else if (item.Key.LastMenu == CurrentMenu.Staff && HasPermission.Run(player, AccessSetHPMenu)) { player.Heal(100); - player.SendToSelf(Channel.Reliable, 10, $"You've been healed."); + player.SendToSelf(Channel.Reliable, ClPacket.GameMessage, $"You've been healed."); Debug.Log(SetTimeStamp.Run() + "[INFO] " + player.playerData.username + " healed himself through the functionUI"); item.Key.LastMenu = CurrentMenu.Main; } else if (item.Key.LastMenu == CurrentMenu.GiveItems) { player.SendToSelf(Channel.Reliable, ClPacket.CloseFunctionMenu); - shPlayer.TransferItem(1, CommonIDs[2], 10, true); - player.SendToSelf(Channel.Reliable, 10, $"You have given yourself 10 Taser ammo."); + shPlayer.TransferItem(1, CommonIDs[2], ClPacket.GameMessage, true); + player.SendToSelf(Channel.Reliable, ClPacket.GameMessage, $"You have given yourself 10 Taser ammo."); Debug.Log(SetTimeStamp.Run() + "[INFO] " + player.playerData.username + " Spawned in 10 taser ammo through the functionUI"); item.Key.LastMenu = CurrentMenu.Main; } @@ -298,7 +291,7 @@ public static bool SvFunctionKey(SvPlayer player, ref byte key) { for (byte i = 0; i < 4; i++) player.UpdateStat(i, 100); - player.SendToSelf(Channel.Reliable, 10, $"Maxed out stats for yourself."); + player.SendToSelf(Channel.Reliable, ClPacket.GameMessage, $"Maxed out stats for yourself."); Debug.Log(SetTimeStamp.Run() + "[INFO] " + player.playerData.username + " Maxed out stats through the functionUI"); item.Key.LastMenu = CurrentMenu.Main; } @@ -306,7 +299,7 @@ public static bool SvFunctionKey(SvPlayer player, ref byte key) { for (int i = 3; i < 7; i++) shPlayer.TransferItem(1, CommonIDs[i], 1, true); - player.SendToSelf(Channel.Reliable, 10, $"You have given yourself all licenses."); + player.SendToSelf(Channel.Reliable, ClPacket.GameMessage, $"You have given yourself all licenses."); Debug.Log(SetTimeStamp.Run() + "[INFO] " + player.playerData.username + " Spawned in all licenses through the functionUI"); item.Key.LastMenu = CurrentMenu.Main; } @@ -318,7 +311,7 @@ public static bool SvFunctionKey(SvPlayer player, ref byte key) { shPlayer.ClearCrimes(); player.SendToSelf(Channel.Reliable, 33, shPlayer.ID); - player.SendToSelf(Channel.Reliable, 10, $"Cleared wanted level."); + player.SendToSelf(Channel.Reliable, ClPacket.GameMessage, $"Cleared wanted level."); Debug.Log(SetTimeStamp.Run() + "[INFO] " + player.playerData.username + " Removed his wantedlevel through the functionUI"); item.Key.LastMenu = CurrentMenu.Main; } @@ -361,5 +354,20 @@ public static bool SvFunctionKey(SvPlayer player, ref byte key) return true; } + + [Hook("SvPlayer.SvSuicide")] + public static bool SvSuicide(SvPlayer player) + { + if (player.IsServerside()) + return true; + var shPlayer = GetShBySv.Run(player); + if (shPlayer.IsDead()) + return true; + + + shPlayer.ShDie(); + player.SendToLocalAndSelf(Channel.Reliable, ClPacket.UpdateHealth, shPlayer.ID, shPlayer.health); + return true; + } } } \ No newline at end of file diff --git a/source/BP-Essentials/Methods/API/GetShBySv.cs b/source/BP-Essentials/Methods/API/GetShBySv.cs new file mode 100644 index 00000000..ca7d18fb --- /dev/null +++ b/source/BP-Essentials/Methods/API/GetShBySv.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; +using static BP_Essentials.EssentialsVariablesPlugin; +using static BP_Essentials.EssentialsMethodsPlugin; + +namespace BP_Essentials +{ + class GetShBySv : EssentialsCorePlugin + { + public static ShPlayer Run(SvPlayer player) + { + try + { + foreach (var shPlayer in UnityEngine.Object.FindObjectsOfType()) + if (shPlayer.svPlayer == player) + return shPlayer; + return null; + } + catch (Exception ex) + { + ErrorLogging.Run(ex); + return null; + } + } + } +} diff --git a/source/BP-Essentials/Methods/API/HasPermission.cs b/source/BP-Essentials/Methods/API/HasPermission.cs index a3056a1a..0fe41732 100644 --- a/source/BP-Essentials/Methods/API/HasPermission.cs +++ b/source/BP-Essentials/Methods/API/HasPermission.cs @@ -20,7 +20,7 @@ public static bool Run(object oPlayer, string ExeBy, bool ShowNoPermMessage = fa if (Groups.Any(curr => $"group:{curr.Value.Name}".Equals(name.Trim()) && curr.Value.Users.Contains(player.playerData.username))) return true; if (ShowNoPermMessage) - player.SendToSelf(Channel.Unsequenced, 10, $"{MsgNoPerm}"); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"{MsgNoPerm}"); return false; } } diff --git a/source/BP-Essentials/Methods/Check/CheckGodMode.cs b/source/BP-Essentials/Methods/Check/CheckGodMode.cs index af446501..bf01abb6 100644 --- a/source/BP-Essentials/Methods/Check/CheckGodMode.cs +++ b/source/BP-Essentials/Methods/Check/CheckGodMode.cs @@ -18,7 +18,7 @@ public static bool Run(object oPlayer, float amount) if (GodListPlayers.Contains(player.playerData.username)) { if (ShowDMGMessage) - player.SendToSelf(Channel.Unsequenced, 10, $"{amount} DMG Blocked!"); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"{amount} DMG Blocked!"); return true; } } diff --git a/source/BP-Essentials/Methods/GameMethods/SendToJail.cs b/source/BP-Essentials/Methods/GameMethods/SendToJail.cs index c34cc234..10d89d02 100644 --- a/source/BP-Essentials/Methods/GameMethods/SendToJail.cs +++ b/source/BP-Essentials/Methods/GameMethods/SendToJail.cs @@ -18,8 +18,9 @@ public static bool Run(ShPlayer shPlayer, float time) SetJob.Run(shPlayer, 2, true, false); shPlayer.svEntity.SvReset(jailSpawn.position, jailSpawn.rotation, 0); shPlayer.StartCoroutine(shPlayer.svPlayer.JailTimer(time)); - shPlayer.SendToJail(); - shPlayer.svPlayer.SendToSelf(Channel.Reliable, 39, time); + shPlayer.svPlayer.SvClearCrimes(); + shPlayer.RemoveItemsJail(); + shPlayer.svPlayer.SendToSelf(Channel.Reliable, ClPacket.Timer, time); return true; } } diff --git a/source/BP-Essentials/Methods/misc/Reload.cs b/source/BP-Essentials/Methods/misc/Reload.cs index de012a1c..35937e46 100644 --- a/source/BP-Essentials/Methods/misc/Reload.cs +++ b/source/BP-Essentials/Methods/misc/Reload.cs @@ -18,12 +18,12 @@ public static void Run(bool silentExecution, object oPlayer = null) var player = (SvPlayer)oPlayer; if (AdminsListPlayers.Contains(player.playerData.username)) { - player.SendToSelf(Channel.Unsequenced, 10, "Checking if file's exist..."); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, "Checking if file's exist..."); CheckFiles.Run("all"); - player.SendToSelf(Channel.Unsequenced, 10, "Reloading config files..."); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, "Reloading config files..."); ReadFile.Run(SettingsFile); - player.SendToSelf(Channel.Unsequenced, 10, "[OK] Config file reloaded"); - player.SendToSelf(Channel.Unsequenced, 10, "Reloading critical .txt files..."); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, "[OK] Config file reloaded"); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, "Reloading critical .txt files..."); ReadCustomCommands.Run(); ReadGroups.Run(); ReadStream.Run(LanguageBlockFile, LanguageBlockWords); @@ -36,11 +36,11 @@ public static void Run(bool silentExecution, object oPlayer = null) ReadFile.Run(MuteListFile); ReadFile.Run(AfkListFile); ReadFile.Run(RulesFile); - player.SendToSelf(Channel.Unsequenced, 10, "[OK] Critical .txt files reloaded"); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, "[OK] Critical .txt files reloaded"); } else { - player.SendToSelf(Channel.Unsequenced, 10, MsgNoPerm); + player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, MsgNoPerm); } } else diff --git a/source/BP-Essentials/Methods/misc/SaveNow.cs b/source/BP-Essentials/Methods/misc/SaveNow.cs index 73a44a29..c5c17061 100644 --- a/source/BP-Essentials/Methods/misc/SaveNow.cs +++ b/source/BP-Essentials/Methods/misc/SaveNow.cs @@ -19,7 +19,7 @@ public static void Run() if (shPlayer.IsRealPlayer()) { if (shPlayer.GetPlaceIndex() >= 13) continue; - shPlayer.svPlayer.SendToSelf(Channel.Unsequenced, 10, "Saving game.. This can take up to 5 seconds."); + shPlayer.svPlayer.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, "Saving game.. This can take up to 5 seconds."); shPlayer.svPlayer.Save(); } } diff --git a/source/BP-Essentials/Methods/misc/SavePeriodically.cs b/source/BP-Essentials/Methods/misc/SavePeriodically.cs index dcb1541f..cd4fcc3b 100644 --- a/source/BP-Essentials/Methods/misc/SavePeriodically.cs +++ b/source/BP-Essentials/Methods/misc/SavePeriodically.cs @@ -12,30 +12,30 @@ namespace BP_Essentials { class SavePeriodically : EssentialsChatPlugin { - public static void Run() + public static void Run(object man) { try { - using (System.Timers.Timer Tmer = new System.Timers.Timer()) - { - Tmer.Elapsed += new ElapsedEventHandler(OnTime); - Tmer.Interval = SaveTime * 1000; - Tmer.Enabled = true; - } + var svManager = (SvManager)man; + var Tmer = new System.Timers.Timer(); + Tmer.Elapsed += (sender, e) => OnTime(svManager); + Tmer.Interval = SaveTime * 1000; + Tmer.Enabled = true; } catch (Exception ex) { ErrorLogging.Run(ex); } } - private static void OnTime(object source, ElapsedEventArgs e) + static void OnTime(object onetMan) { + var svManager = (SvManager)onetMan; Debug.Log(SetTimeStamp.Run() + "[INFO] Saving game.."); - foreach (var shPlayer in FindObjectsOfType()) + foreach (var shPlayer in svManager.players) if (shPlayer.IsRealPlayer()) { if (shPlayer.GetPlaceIndex() >= 13) continue; - shPlayer.svPlayer.SendToSelf(Channel.Unsequenced, 10, "Saving game.. This can take up to 5 seconds."); + shPlayer.svPlayer.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, "Saving game.. This can take up to 5 seconds."); shPlayer.svPlayer.Save(); } }