diff --git a/source/BP-Essentials/BP-Essentials.csproj b/source/BP-Essentials/BP-Essentials.csproj
index b06fe164..ebeefc7e 100644
--- a/source/BP-Essentials/BP-Essentials.csproj
+++ b/source/BP-Essentials/BP-Essentials.csproj
@@ -45,6 +45,7 @@
+
@@ -63,10 +64,13 @@
+
+
+
@@ -80,6 +84,8 @@
+
+
@@ -94,23 +100,25 @@
+
-
-
+
+
+
-
+
@@ -284,6 +292,9 @@
..\..\BrokeProtocol_Data\Managed\UnityEngine.VRModule.dll
+
+ ..\..\BrokeProtocol_Data\Managed\UnityEngine.WebModule.dll
+
..\..\BrokeProtocol_Data\Managed\UnityEngine.WindModule.dll
diff --git a/source/BP-Essentials/Chat/Announce.cs b/source/BP-Essentials/Chat/Announce.cs
index ae3e4a87..168646c6 100644
--- a/source/BP-Essentials/Chat/Announce.cs
+++ b/source/BP-Essentials/Chat/Announce.cs
@@ -31,7 +31,7 @@ private static void OnTime(object onetMan)
var svManager = (SvManager)onetMan;
foreach (var player in svManager.players)
foreach (var line in Announcements[AnnounceIndex].Split(new[] { "\\r\\n", "\\r", "\\n" }, StringSplitOptions.None))
- player.Value.svPlayer.SendToSelf(Channel.Reliable, ClPacket.GameMessage, line);
+ player.Value.svPlayer.Send(SvSendType.Self, Channel.Reliable, ClPacket.GameMessage, line);
Debug.Log($"{SetTimeStamp.Run()}[INFO] Announcement made...");
AnnounceIndex += 1;
if (AnnounceIndex > Announcements.Length - 1)
diff --git a/source/BP-Essentials/Chat/Commands/Admin/Arrest.cs b/source/BP-Essentials/Chat/Commands/Admin/Arrest.cs
index 5f896ed6..3054bc72 100644
--- a/source/BP-Essentials/Chat/Commands/Admin/Arrest.cs
+++ b/source/BP-Essentials/Chat/Commands/Admin/Arrest.cs
@@ -18,15 +18,16 @@ public static void Run(SvPlayer player, string message)
var shPlayer = GetShByStr.Run(arg1);
if (shPlayer == null)
{
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, NotFoundOnline);
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, NotFoundOnline);
return;
}
shPlayer.svPlayer.Restrain(shPlayer.manager.handcuffed);
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Arrested " + shPlayer.username + $".");
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"Arrested " + shPlayer.username + $".");
}
else
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, ArgRequired);
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, ArgRequired);
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, ArgRequired);
}
}
}
diff --git a/source/BP-Essentials/Chat/Commands/Admin/Ban.cs b/source/BP-Essentials/Chat/Commands/Admin/Ban.cs
index f2443bfd..3081d908 100644
--- a/source/BP-Essentials/Chat/Commands/Admin/Ban.cs
+++ b/source/BP-Essentials/Chat/Commands/Admin/Ban.cs
@@ -7,23 +7,23 @@ public static void Run(SvPlayer player, string message)
{
var arg1 = GetArgument.Run(1, false, false, message);
var arg2 = GetArgument.Run(2, false, true, message);
- if (!string.IsNullOrEmpty(arg1) || !string.IsNullOrEmpty(arg2))
+ if (!string.IsNullOrEmpty(arg1) && !string.IsNullOrEmpty(arg2))
{
var shPlayer = GetShByStr.Run(arg1, true);
if (shPlayer == null)
{
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, NotFoundOnlineIdOnly);
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, NotFoundOnlineIdOnly);
return;
}
- LogMessage.LogOther($"{SetTimeStamp.Run()}[INFO] {shPlayer.username} Got banned by {player.playerData.username}");
- player.SendToAll(Channel.Unsequenced, ClPacket.GameMessage, $"{shPlayer.username} Just got banned by {player.playerData.username}");
+ LogMessage.LogOther($"{SetTimeStamp.Run()}[INFO] {shPlayer.username} Got banned by {player.playerData.username} (Reason: {arg2}");
+ player.Send(SvSendType.All, Channel.Unsequenced, ClPacket.GameMessage, $"{shPlayer.username} Just got banned by {player.playerData.username} (Reason: {arg2})");
SendDiscordMessage.BanMessage(shPlayer.username, player.playerData.username, arg2);
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Banned {shPlayer.username}. (Reason: {arg2})");
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"Banned {shPlayer.username}. (Reason: {arg2})");
player.svManager.AddBanned(shPlayer);
player.svManager.Disconnect(shPlayer.svPlayer.connection);
}
else
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, ArgRequired);
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, ArgRequired);
}
}
}
\ No newline at end of file
diff --git a/source/BP-Essentials/Chat/Commands/Admin/CheckAlts.cs b/source/BP-Essentials/Chat/Commands/Admin/CheckAlts.cs
index 2808fb9e..2f393b55 100644
--- a/source/BP-Essentials/Chat/Commands/Admin/CheckAlts.cs
+++ b/source/BP-Essentials/Chat/Commands/Admin/CheckAlts.cs
@@ -33,7 +33,7 @@ public static void Run(SvPlayer player, string message)
}
content = builder.ToString();
content += "\r\n\r\n" + arg2 + " occurred " + found + " times in the iplog file." + "\r\n";
- player.SendToSelf(Channel.Reliable, ClPacket.ServerInfo, content);
+ player.Send(SvSendType.Self, Channel.Reliable, ClPacket.ServerInfo, content);
}
else if (arg1.Equals("ign", StringComparison.InvariantCultureIgnoreCase) || (arg1.Equals(nameof(player), StringComparison.InvariantCultureIgnoreCase)))
{
@@ -50,11 +50,11 @@ public static void Run(SvPlayer player, 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, ClPacket.ServerInfo, content);
+ player.Send(SvSendType.Self, Channel.Reliable, ClPacket.ServerInfo, content);
}
}
else
- player.SendToSelf(Channel.Reliable, ClPacket.GameMessage, GetArgument.Run(0, false,false,message) + "[IP/IGN] [Arg2] Eg " + GetArgument.Run(0,false,false,message) + " ip 127.0.0.1");
+ player.Send(SvSendType.Self, Channel.Reliable, ClPacket.GameMessage, GetArgument.Run(0, false,false,message) + "[IP/IGN] [Arg2] Eg " + GetArgument.Run(0,false,false,message) + " ip 127.0.0.1");
}
}
}
diff --git a/source/BP-Essentials/Chat/Commands/Admin/Clear.cs b/source/BP-Essentials/Chat/Commands/Admin/Clear.cs
index f2feaede..d6b07075 100644
--- a/source/BP-Essentials/Chat/Commands/Admin/Clear.cs
+++ b/source/BP-Essentials/Chat/Commands/Admin/Clear.cs
@@ -13,7 +13,7 @@ public static void Run(SvPlayer player, string message)
var shPlayer = GetShByStr.Run(arg1);
if (shPlayer == null)
{
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, NotFoundOnline);
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, NotFoundOnline);
return;
}
var tempList = new List();
@@ -21,11 +21,11 @@ public static void Run(SvPlayer player, string message)
tempList.Add(item);
for (int i = 0; i < tempList.Count; i++)
shPlayer.TransferItem(2, tempList[i].item.index, shPlayer.MyItemCount(tempList[i].item.index), true);
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"You cleared the inventory of {shPlayer.username}.");
- shPlayer.svPlayer.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Your inventory has been cleared by {player.playerData.username}.");
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"You cleared the inventory of {shPlayer.username}.");
+ shPlayer.svPlayer.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"Your inventory has been cleared by {player.playerData.username}.");
}
else
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, ArgRequired);
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, ArgRequired);
}
}
}
\ No newline at end of file
diff --git a/source/BP-Essentials/Chat/Commands/Admin/ClearWanted.cs b/source/BP-Essentials/Chat/Commands/Admin/ClearWanted.cs
index 4185b27c..14289d54 100644
--- a/source/BP-Essentials/Chat/Commands/Admin/ClearWanted.cs
+++ b/source/BP-Essentials/Chat/Commands/Admin/ClearWanted.cs
@@ -25,12 +25,12 @@ public static void Run(SvPlayer player, string message)
{
msg = shPlayer.username;
shPlayer.ClearCrimes();
- shPlayer.svPlayer.SendToSelf(Channel.Reliable, 33, shPlayer.ID);
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Cleared crimes of '" + msg + "'.");
+ shPlayer.svPlayer.Send(SvSendType.Self, Channel.Reliable, 33, shPlayer.ID);
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"Cleared crimes of '" + msg + "'.");
found = true;
}
if (!found)
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, NotFoundOnline);
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, NotFoundOnline);
}
}
}
diff --git a/source/BP-Essentials/Chat/Commands/Admin/CreateKit.cs b/source/BP-Essentials/Chat/Commands/Admin/CreateKit.cs
new file mode 100644
index 00000000..0c094c59
--- /dev/null
+++ b/source/BP-Essentials/Chat/Commands/Admin/CreateKit.cs
@@ -0,0 +1,36 @@
+using static BP_Essentials.EssentialsVariablesPlugin;
+using System;
+using static BP_Essentials.EssentialsMethodsPlugin;
+using System.IO;
+using System.Collections.Generic;
+using Newtonsoft.Json;
+
+namespace BP_Essentials.Commands
+{
+ public class CreateKit : EssentialsChatPlugin
+ {
+ public static void Run(SvPlayer player, string message)
+ {
+ var arg1 = GetArgument.Run(1, false, false, message);
+ var arg2 = GetArgument.Run(2, false, true, message);
+ if (string.IsNullOrEmpty(arg1.Trim()) || string.IsNullOrEmpty(arg2.Trim()))
+ {
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, ArgRequired);
+ return;
+ }
+ if (!int.TryParse(arg1, out int arg1i))
+ {
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"Cannot convert {arg1} to a integer.");
+ return;
+ }
+ var file = Path.Combine(KitDirectory, $"{arg2}.json");
+ if (File.Exists(file))
+ {
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"A kit already exists with that name.");
+ return;
+ }
+ Kits.CreateKit(player, arg2, arg1i, file);
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"Kit created. Please edit {file} to add ExecuteableBy.");
+ }
+ }
+}
\ No newline at end of file
diff --git a/source/BP-Essentials/Chat/Commands/Admin/DebugCommands.cs b/source/BP-Essentials/Chat/Commands/Admin/DebugCommands.cs
index b512a63f..a8b0c516 100644
--- a/source/BP-Essentials/Chat/Commands/Admin/DebugCommands.cs
+++ b/source/BP-Essentials/Chat/Commands/Admin/DebugCommands.cs
@@ -11,79 +11,91 @@ public class DebugCommands : EssentialsChatPlugin
{
public static void Run(SvPlayer player, string message)
{
- foreach (var shPlayer in FindObjectsOfType())
- if (shPlayer.svPlayer == player)
- if (!shPlayer.svPlayer.IsServerside())
+ var shPlayer = player.player;
+ string arg = GetArgument.Run(1, false, false, message).Trim().ToLower();
+
+ if (arg == "location" || arg == "getlocation")
+ player.Send(SvSendType.Self, 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.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, "Hash of " + arg2 + " : " + Animator.StringToHash(arg2));
+ else
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, "Invalid arguments. /debug get(player)hash [username]");
+ }
+ else if (arg == "spaceindex" || arg == "getspaceindex")
+ {
+ string arg2 = GetArgument.Run(2, false, true, message);
+ if (!String.IsNullOrEmpty(arg2))
+ {
+ bool found = false;
+ foreach (var shPlayer2 in UnityEngine.Object.FindObjectsOfType())
+ if (shPlayer2.svPlayer.playerData.username == arg2 || shPlayer2.ID.ToString() == arg2)
+ if (!shPlayer2.svPlayer.IsServerside())
+ {
+ found = true;
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, "SpaceIndex of '" + shPlayer2.svPlayer.playerData.username + "': " + shPlayer2.GetPlaceIndex());
+ }
+ if (!found)
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, "Invalid arguments (Or user is not found online.) /debug (get)spaceindex [username] ");
+ }
+ else
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, "Your SpaceIndex: " + shPlayer.GetPlaceIndex());
+ }
+ else if (arg == "createidlist")
+ {
+ string arg2 = GetArgument.Run(2, false, true, message).Trim().ToLower();
+ if (!String.IsNullOrEmpty(arg2) && (arg2 == "item" || arg2 == "vehicle"))
+ {
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, "Creating ID list.. please wait");
+ var location = $"{FileDirectory}IDLists/{arg2}/IDLIST_{DateTime.Now.ToString("yyyy_mm_dd_hh_mm_ss")}.txt";
+ if (!Directory.Exists($"{FileDirectory}IDLists/{arg2}"))
+ Directory.CreateDirectory($"{FileDirectory}IDLists/{arg2}");
+ var sb = new StringBuilder();
+ int currIndex = 1;
+ sb.Append("{\"items\": [");
+ IndexCollection ECol = (IndexCollection)typeof(ShManager).GetField("entityCollection", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(shPlayer.manager);
+ foreach (ShEntity v in ECol)
{
- string arg = GetArgument.Run(1, false, false, message).Trim().ToLower();
- if (arg == "location" || arg == "getlocation")
- 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, ClPacket.GameMessage, "Hash of " + arg2 + " : " + Animator.StringToHash(arg2));
- else
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, "Invalid arguments. /debug get(player)hash [username]");
- }
- else if (arg == "spaceindex" || arg == "getspaceindex")
+ // dry coding, improve
+ if (arg2 == "item")
{
- string arg2 = GetArgument.Run(2, false, true, message);
- if (!String.IsNullOrEmpty(arg2))
+ // Jesus o.O
+ if (v.GetType() == typeof(ShPlaceable) || v.GetType() == typeof(ShPlaceable) || v.GetType() == typeof(ShGun) || v.GetType() == typeof(ShWeapon) || v.GetType() == typeof(ShFurniture) || v.GetType() == typeof(ShWearable) || v.GetType() == typeof(ShConsumable) || v.GetType() == typeof(ShDrugMaterial) || v.GetType() == typeof(ShExtinguisher) || v.GetType() == typeof(ShHealer) || v.GetType() == typeof(ShRestraint) || v.GetType() == typeof(ShSeed) || v.GetType() == typeof(ShProjectile))
{
- bool found = false;
- foreach (var shPlayer2 in UnityEngine.Object.FindObjectsOfType())
- if (shPlayer2.svPlayer.playerData.username == arg2 || shPlayer2.ID.ToString() == arg2)
- if (!shPlayer2.svPlayer.IsServerside())
- {
- found = true;
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, "SpaceIndex of '" + shPlayer2.svPlayer.playerData.username + "': " + shPlayer2.GetPlaceIndex());
- }
- if (!found)
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, "Invalid arguments (Or user is not found online.) /debug (get)spaceindex [username] ");
+ sb.Append($"{{\"name\": \"{v.name}\",\"id\": {currIndex},\"gameid\": {v.index}}},\n");
+ ++currIndex;
}
- else
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, "Your SpaceIndex: " + shPlayer.GetPlaceIndex());
}
- else if (arg == "createidlist")
+ else if (arg2 == "vehicle")
{
- string arg2 = GetArgument.Run(2, false, true, message).ToLower();
- if (!String.IsNullOrEmpty(arg2) && arg2 == "json" || arg2 == "array")
+ if (v.GetType() == typeof(ShVehicle) || v.GetType() == typeof(ShBoat) || v.GetType() == typeof(ShHelo) || v.GetType() == typeof(ShTransport))
{
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, "Creating ID list.. please wait");
- var shm = shPlayer.manager;
- var location = $"{FileDirectory}IDLists/IDLIST_{DateTime.Now.ToString("yyyy_mm_dd_hh_mm_ss")}.txt";
- if (!Directory.Exists($"{FileDirectory}IDLists/"))
- Directory.CreateDirectory($"{FileDirectory}IDLists/");
- var sb = new StringBuilder();
- int currIndex = 1;
- if (arg2 == "array")
- sb.Append("public static int[] IDs = {\n0, // you don't want to use ID 0\n");
- else
- sb.Append("{\"items\": [");
- IndexCollection ECol = (IndexCollection)typeof(ShManager).GetField("entityCollection", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(shm);
- foreach (ShEntity v in ECol)
- {
- if (v.GetType() == typeof(ShPlaceable) || v.GetType() == typeof(ShPlaceable) || v.GetType() == typeof(ShGun) || v.GetType() == typeof(ShWeapon) || v.GetType() == typeof(ShFurniture) || v.GetType() == typeof(ShWearable) || v.GetType() == typeof(ShConsumable) || v.GetType() == typeof(ShDrugMaterial) || v.GetType() == typeof(ShExtinguisher) || v.GetType() == typeof(ShHealer) || v.GetType() == typeof(ShRestraint) || v.GetType() == typeof(ShSeed) || v.GetType() == typeof(ShProjectile))
- if (arg2 == "array")
- sb.Append($"{v.index}, //{v.name}\n");
- else
- {
- sb.Append($"{{\"name\": \"{v.name}\",\"id\": {currIndex},\"gameid\": {v.index}}},\n");
- ++currIndex;
- }
- }
- if (arg2 == "array")
- File.WriteAllText(location, $"{sb}}};");
- else
- File.WriteAllText(location, $"{sb.Remove(sb.Length - 2, 1)}]}}");
-
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Success! ID List has been saved in {location}. ({currIndex} entries.)");
+ sb.Append($"{{\"name\": \"{v.name}\",\"id\": {currIndex},\"gameid\": {v.index}}},\n");
+ ++currIndex;
}
- else
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, "Please select file type /debug createidlist json/array");
}
}
+ File.WriteAllText(location, $"{sb.Remove(sb.Length - 2, 1)}]}}");
+
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"Success! ID List has been saved in {location}. ({currIndex} entries.)");
+ }
+ else
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, "Please select idlist type: /debug createidlist item/vehicle");
+ }
+ else if (arg == "jobarray")
+ {
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"Jobs array: (Length: {Jobs.Length}) {string.Join(", ", Jobs)}");
+ }
+ else if (arg == "tpall")
+ {
+ foreach (var currPlayer in FindObjectsOfType())
+ currPlayer.SvReset(shPlayer.GetPosition(), shPlayer.GetRotation(), shPlayer.GetPlaceIndex());
+ }
+ else
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, "/debug location/getplayerhash/getspaceindex/createidlist/jobarray");
}
+
}
}
\ No newline at end of file
diff --git a/source/BP-Essentials/Chat/Commands/Admin/FakeJoin.cs b/source/BP-Essentials/Chat/Commands/Admin/FakeJoin.cs
index 3366c583..ed740f44 100644
--- a/source/BP-Essentials/Chat/Commands/Admin/FakeJoin.cs
+++ b/source/BP-Essentials/Chat/Commands/Admin/FakeJoin.cs
@@ -14,9 +14,9 @@ public static void Run(SvPlayer player, string message)
{
string arg1 = GetArgument.Run(1, false, true, message);
if (!String.IsNullOrEmpty(arg1))
- player.SendToAll(Channel.Unsequenced, ClPacket.GameMessage, arg1 + " connected");
+ player.Send(SvSendType.All, Channel.Unsequenced, ClPacket.GameMessage, arg1 + " connected");
else
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, ArgRequired);
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, ArgRequired);
}
}
}
diff --git a/source/BP-Essentials/Chat/Commands/Admin/FakeLeave.cs b/source/BP-Essentials/Chat/Commands/Admin/FakeLeave.cs
index 9c409d6e..9d2134f6 100644
--- a/source/BP-Essentials/Chat/Commands/Admin/FakeLeave.cs
+++ b/source/BP-Essentials/Chat/Commands/Admin/FakeLeave.cs
@@ -14,9 +14,9 @@ public static void Run(SvPlayer player, string message)
{
string arg1 = GetArgument.Run(1, false, true, message);
if (!String.IsNullOrEmpty(arg1))
- player.SendToAll(Channel.Unsequenced, ClPacket.GameMessage, arg1 + " disconnected");
+ player.Send(SvSendType.All, Channel.Unsequenced, ClPacket.GameMessage, arg1 + " disconnected");
else
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, ArgRequired);
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, ArgRequired);
}
}
}
diff --git a/source/BP-Essentials/Chat/Commands/Admin/Feed.cs b/source/BP-Essentials/Chat/Commands/Admin/Feed.cs
index 729694f5..77475111 100644
--- a/source/BP-Essentials/Chat/Commands/Admin/Feed.cs
+++ b/source/BP-Essentials/Chat/Commands/Admin/Feed.cs
@@ -12,26 +12,26 @@ class Feed : EssentialsChatPlugin
{
public static void Run(SvPlayer player, string message)
{
- string arg1 = GetArgument.Run(1, false, true, message).Trim();
+ string arg1 = GetArgument.Run(1, false, true, message);
string msg = $"Maxed stats for " + "{0}" + $".";
if (String.IsNullOrEmpty(arg1))
{
- player.UpdateStats(100f, 100f, 100f, 100f);
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, String.Format(msg, "yourself"));
+ player.UpdateStats(100F, 100F, 100F, 100F);
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, String.Format(msg, "yourself"));
}
else
{
bool found = false;
- foreach (var shPlayer in UnityEngine.Object.FindObjectsOfType())
+ foreach (var shPlayer in FindObjectsOfType())
if (shPlayer.username == arg1 || shPlayer.ID.ToString() == arg1.ToString())
if (!shPlayer.svPlayer.IsServerside())
{
- player.UpdateStats(100f, 100f, 100f, 100f);
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, String.Format(msg, shPlayer.username));
+ shPlayer.svPlayer.UpdateStats(100F, 100F, 100F, 100F);
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, String.Format(msg, shPlayer.username));
found = true;
}
if (!found)
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, NotFoundOnline);
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, NotFoundOnline);
}
}
}
diff --git a/source/BP-Essentials/Chat/Commands/Admin/Free.cs b/source/BP-Essentials/Chat/Commands/Admin/Free.cs
index 7f818c97..df7b93f1 100644
--- a/source/BP-Essentials/Chat/Commands/Admin/Free.cs
+++ b/source/BP-Essentials/Chat/Commands/Admin/Free.cs
@@ -18,14 +18,14 @@ public static void Run(SvPlayer player, string message)
var shPlayer = GetShByStr.Run(arg1);
if (shPlayer == null)
{
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, NotFoundOnline);
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, NotFoundOnline);
return;
}
- UnRetain.Run(shPlayer.svPlayer);
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Freed " + shPlayer.username + $".");
+ UnRestrain.Run(shPlayer.svPlayer);
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"Freed " + shPlayer.username + $".");
}
else
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, ArgRequired);
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, ArgRequired);
}
}
}
diff --git a/source/BP-Essentials/Chat/Commands/Admin/GetLogs.cs b/source/BP-Essentials/Chat/Commands/Admin/GetLogs.cs
index 44645c5c..2415d1e9 100644
--- a/source/BP-Essentials/Chat/Commands/Admin/GetLogs.cs
+++ b/source/BP-Essentials/Chat/Commands/Admin/GetLogs.cs
@@ -39,10 +39,10 @@ public static void Run(SvPlayer player, string logFile)
{"[MESSAGE]",""},
{"<", "<"/* 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, 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);
+ content = "" + new Regex(string.Join("|", replace.Keys.Select(k => Regex.Escape(k)))).Replace(content, m => replace[m.Value]) + "";
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"WARNING: This is a very unstable command and doesn't work all of the times.");
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"Limited to last 100 messages.");
+ player.Send(SvSendType.Self, Channel.Fragmented, ClPacket.ServerInfo, content);
}
}
}
diff --git a/source/BP-Essentials/Chat/Commands/Admin/Give.cs b/source/BP-Essentials/Chat/Commands/Admin/Give.cs
index 9f825e10..c77b7344 100644
--- a/source/BP-Essentials/Chat/Commands/Admin/Give.cs
+++ b/source/BP-Essentials/Chat/Commands/Admin/Give.cs
@@ -16,30 +16,27 @@ public static void Run(SvPlayer player, string message)
string arg2 = GetArgument.Run(2, false, false, message);
if (String.IsNullOrEmpty(arg1) || String.IsNullOrEmpty(arg2))
{
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, ArgRequired);
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, ArgRequired);
return;
}
bool Parsed = int.TryParse(arg1, out int arg1int);
Parsed = int.TryParse(arg2, out int arg2int);
if (Parsed)
{
- if (arg1int > 0 && arg1int <= IDs.Length)
+ if (arg1int > 0 && arg1int <= IDs_Items.Length)
{
- foreach (var shPlayer in FindObjectsOfType())
- if (shPlayer.svPlayer == player && !shPlayer.svPlayer.IsServerside())
- {
- if (arg1.Length > 4)
- shPlayer.TransferItem(1, arg1int, arg2int, true);
- else
- shPlayer.TransferItem(1, IDs[arg1int - 1], arg2int, true);
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Giving you item ID: {arg1}");
- }
+ var shPlayer = player.player;
+ if (arg1.Length > 4)
+ shPlayer.TransferItem(1, arg1int, arg2int, true);
+ else
+ shPlayer.TransferItem(1, IDs_Items[arg1int - 1], arg2int, true);
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"Giving you item ID: {arg1}");
}
else
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Error: The ID must be between 1 and {IDs.Length}.");
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"Error: The ID must be between 1 and {IDs_Items.Length}.");
}
else
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Error: Is that a valid number you provided as argument?");
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"Error: Is that a valid number you provided as argument?");
}
}
}
diff --git a/source/BP-Essentials/Chat/Commands/Admin/GodMode.cs b/source/BP-Essentials/Chat/Commands/Admin/GodMode.cs
index 28aaa8ac..81469e11 100644
--- a/source/BP-Essentials/Chat/Commands/Admin/GodMode.cs
+++ b/source/BP-Essentials/Chat/Commands/Admin/GodMode.cs
@@ -10,7 +10,7 @@ public class GodMode : EssentialsChatPlugin{
public static void Run(SvPlayer player, string message) {
{
ReadFile.Run(GodListFile);
- string name = GetArgument.Run(1, false, true, message).Trim();
+ string name = GetArgument.Run(1, false, true, message);
string msg = String.Empty;
if (String.IsNullOrEmpty(name))
{
@@ -30,13 +30,13 @@ public static void Run(SvPlayer player, string message) {
{
RemoveStringFromFile.Run(GodListFile, name);
ReadFile.Run(GodListFile);
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, String.Format(msg, "disabled"));
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, String.Format(msg, "disabled"));
}
else
{
File.AppendAllText(GodListFile, name + Environment.NewLine);
GodListPlayers.Add(name);
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, String.Format(msg, "enabled"));
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, String.Format(msg, "enabled"));
}
}
diff --git a/source/BP-Essentials/Chat/Commands/Admin/Heal.cs b/source/BP-Essentials/Chat/Commands/Admin/Heal.cs
index b8505f1a..1b98a596 100644
--- a/source/BP-Essentials/Chat/Commands/Admin/Heal.cs
+++ b/source/BP-Essentials/Chat/Commands/Admin/Heal.cs
@@ -12,12 +12,12 @@ class Heal : EssentialsChatPlugin
{
public static void Run(SvPlayer player, string message)
{
- string arg1 = GetArgument.Run(1, false, true, message).Trim();
+ string arg1 = GetArgument.Run(1, false, true, message);
string msg = $"Healed {{0}}.";
if (String.IsNullOrEmpty(arg1))
{
player.Heal(100);
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, String.Format(msg, "yourself"));
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, String.Format(msg, "yourself"));
}
else
{
@@ -27,11 +27,11 @@ public static void Run(SvPlayer player, string message)
if (!shPlayer.svPlayer.IsServerside())
{
shPlayer.svPlayer.Heal(100);
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, String.Format(msg, shPlayer.username));
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, String.Format(msg, shPlayer.username));
found = true;
}
if (!found)
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, NotFoundOnline);
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, NotFoundOnline);
}
}
}
diff --git a/source/BP-Essentials/Chat/Commands/Admin/Info.cs b/source/BP-Essentials/Chat/Commands/Admin/Info.cs
index 36ba432e..2e4c21e1 100644
--- a/source/BP-Essentials/Chat/Commands/Admin/Info.cs
+++ b/source/BP-Essentials/Chat/Commands/Admin/Info.cs
@@ -20,7 +20,7 @@ public static void Run(SvPlayer player, string message)
if (shPlayer.username == arg1 || shPlayer.ID.ToString() == arg1.ToString())
if (!shPlayer.svPlayer.IsServerside())
{
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, "Info about: '" + shPlayer.username + "'.");
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, "Info about: '" + shPlayer.username + "'.");
string[] contentarray = {
"Username: " + shPlayer.username,
"",
@@ -38,15 +38,15 @@ public static void Run(SvPlayer player, string message)
var content = string.Join("\r\n", contentarray);
- player.SendToSelf(Channel.Reliable, ClPacket.ServerInfo, content);
+ player.Send(SvSendType.Self, Channel.Reliable, ClPacket.ServerInfo, content);
found = true;
}
if (!(found))
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, NotFoundOnline);
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, NotFoundOnline);
}
else
- player.SendToSelf(Channel.Reliable, ClPacket.GameMessage, ArgRequired);
+ player.Send(SvSendType.Self, Channel.Reliable, ClPacket.GameMessage, ArgRequired);
}
}
}
diff --git a/source/BP-Essentials/Chat/Commands/Admin/Jail.cs b/source/BP-Essentials/Chat/Commands/Admin/Jail.cs
index 1db2884a..04fc24a5 100644
--- a/source/BP-Essentials/Chat/Commands/Admin/Jail.cs
+++ b/source/BP-Essentials/Chat/Commands/Admin/Jail.cs
@@ -18,24 +18,24 @@ public static void Run(SvPlayer player, string message)
var shPlayer = GetShByStr.Run(arg1);
if (shPlayer == null)
{
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, NotFoundOnline);
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, NotFoundOnline);
return;
}
if (float.TryParse(message.Split(' ').Last().Trim(), out float t))
{
if (SendToJail.Run(shPlayer, t))
{
- shPlayer.svPlayer.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"{player.playerData.username} sent you to jail.");
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Sent {shPlayer.username} To jail.");
+ shPlayer.svPlayer.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"{player.playerData.username} sent you to jail.");
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"Sent {shPlayer.username} To jail.");
}
else
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Cannot send {shPlayer.username} To jail.");
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"Cannot send {shPlayer.username} To jail.");
}
else
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, ArgRequired);
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, ArgRequired);
}
else
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, ArgRequired);
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, ArgRequired);
}
}
}
diff --git a/source/BP-Essentials/Chat/Commands/Admin/Kick.cs b/source/BP-Essentials/Chat/Commands/Admin/Kick.cs
index be7724c9..7a39a68c 100644
--- a/source/BP-Essentials/Chat/Commands/Admin/Kick.cs
+++ b/source/BP-Essentials/Chat/Commands/Admin/Kick.cs
@@ -18,14 +18,14 @@ public static void Run(SvPlayer player, string message)
var shPlayer = GetShByStr.Run(arg1);
if (shPlayer == null)
{
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, NotFoundOnline);
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, NotFoundOnline);
return;
}
player.svManager.Kick(shPlayer.svPlayer.connection);
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Kicked " + shPlayer.username + $".");
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"Kicked " + shPlayer.username + $".");
}
else
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, ArgRequired);
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, ArgRequired);
}
}
}
diff --git a/source/BP-Essentials/Chat/Commands/Admin/Kill.cs b/source/BP-Essentials/Chat/Commands/Admin/Kill.cs
index b78d91db..71d05417 100644
--- a/source/BP-Essentials/Chat/Commands/Admin/Kill.cs
+++ b/source/BP-Essentials/Chat/Commands/Admin/Kill.cs
@@ -18,14 +18,14 @@ public static void Run(SvPlayer player, string message)
var shPlayer = GetShByStr.Run(arg1);
if (shPlayer == null)
{
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, NotFoundOnline);
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, NotFoundOnline);
return;
}
shPlayer.svPlayer.SvSuicide();
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Killed " + shPlayer.username + $".");
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"Killed " + shPlayer.username + $".");
}
else
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, ArgRequired);
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, ArgRequired);
}
}
}
diff --git a/source/BP-Essentials/Chat/Commands/Admin/Knockout.cs b/source/BP-Essentials/Chat/Commands/Admin/Knockout.cs
index 3029a63e..e320375d 100644
--- a/source/BP-Essentials/Chat/Commands/Admin/Knockout.cs
+++ b/source/BP-Essentials/Chat/Commands/Admin/Knockout.cs
@@ -18,14 +18,14 @@ public static void Run(SvPlayer player, string message)
var shPlayer = GetShByStr.Run(arg1);
if (shPlayer == null)
{
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, NotFoundOnline);
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, NotFoundOnline);
return;
}
shPlayer.svPlayer.SvForceStance(StanceIndex.KnockedOut);
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Knocked out {shPlayer.username}.");
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"Knocked out {shPlayer.username}.");
}
else
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, ArgRequired);
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, ArgRequired);
}
}
}
diff --git a/source/BP-Essentials/Chat/Commands/Admin/LatestVoteResults.cs b/source/BP-Essentials/Chat/Commands/Admin/LatestVoteResults.cs
index ac75ce3f..321a8c8f 100644
--- a/source/BP-Essentials/Chat/Commands/Admin/LatestVoteResults.cs
+++ b/source/BP-Essentials/Chat/Commands/Admin/LatestVoteResults.cs
@@ -13,11 +13,11 @@ class LatestVoteResults : EssentialsChatPlugin
public static void Run(SvPlayer player)
{
if (!LatestVotePeople.Any())
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"The list seems empty.");
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"The list seems empty.");
else
{
string content = string.Join("\r\n", LatestVotePeople.ToArray());
- player.SendToSelf(Channel.Unsequenced, ClPacket.ServerInfo, "\r\nPlayers that voted 'yes' on the latest votekick: \r\n\r\n" + content);
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.ServerInfo, "\r\nPlayers that voted 'yes' on the latest votekick: \r\n\r\n" + content);
}
}
}
diff --git a/source/BP-Essentials/Chat/Commands/Admin/Launch.cs b/source/BP-Essentials/Chat/Commands/Admin/Launch.cs
index d5efdc85..a5f3dd4c 100644
--- a/source/BP-Essentials/Chat/Commands/Admin/Launch.cs
+++ b/source/BP-Essentials/Chat/Commands/Admin/Launch.cs
@@ -14,7 +14,7 @@ public static void Run(SvPlayer player, string message)
{
string arg1 = GetArgument.Run(1, false, true, message);
if (String.IsNullOrEmpty(arg1))
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, ArgRequired);
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, ArgRequired);
else
{
bool playerfound = false;
@@ -22,12 +22,12 @@ public static void Run(SvPlayer player, string message)
if (shPlayer.username == arg1 && !shPlayer.svPlayer.IsServerside() || shPlayer.ID.ToString() == arg1 && !shPlayer.svPlayer.IsServerside())
{
shPlayer.svPlayer.SvForce(new Vector3(0f, 6500f, 0f));
- shPlayer.svPlayer.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Off you go!");
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"You've launched {shPlayer.username} into space!");
+ shPlayer.svPlayer.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"Off you go!");
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"You've launched {shPlayer.username} into space!");
playerfound = true;
}
if (!playerfound)
- player.SendToSelf(Channel.Reliable, ClPacket.GameMessage, NotFoundOnline);
+ player.Send(SvSendType.Self, Channel.Reliable, ClPacket.GameMessage, NotFoundOnline);
}
}
}
diff --git a/source/BP-Essentials/Chat/Commands/Admin/Money.cs b/source/BP-Essentials/Chat/Commands/Admin/Money.cs
index 12991159..efdc7874 100644
--- a/source/BP-Essentials/Chat/Commands/Admin/Money.cs
+++ b/source/BP-Essentials/Chat/Commands/Admin/Money.cs
@@ -15,9 +15,9 @@ public static void Run(SvPlayer player, string message)
string CorrSyntax = $"" + GetArgument.Run(0, false, false, message) + $" [Player] [Amount] (Incorrect or missing argument(s).)";
string arg1 = GetArgument.Run(1, false, true, message);
string arg2 = message.Split(' ').Last().Trim();
- if (String.IsNullOrEmpty(GetArgument.Run(1, false, false, message)) || String.IsNullOrEmpty(arg2))
+ if (String.IsNullOrEmpty(arg1) || String.IsNullOrEmpty(arg2))
{
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, CorrSyntax);
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, CorrSyntax);
return;
}
else
@@ -33,16 +33,16 @@ public static void Run(SvPlayer player, string message)
foreach (var shPlayer in FindObjectsOfType())
if (shPlayer.username == arg1 && !shPlayer.svPlayer.IsServerside() || shPlayer.ID.ToString() == arg1 && !shPlayer.svPlayer.IsServerside())
{
- shPlayer.TransferMoney(1, arg2int, true);
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Successfully gave " + shPlayer.username + " " + arg2int + $"$");
- shPlayer.svPlayer.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"" + player.playerData.username + $" gave you " + arg2int + $"$!");
+ shPlayer.TransferMoney(DeltaInv.AddToMe, arg2int, true);
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"Successfully gave " + shPlayer.username + " " + arg2int + $"$");
+ shPlayer.svPlayer.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"" + player.playerData.username + $" gave you " + arg2int + $"$!");
found = true;
}
if (!found)
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, NotFoundOnline);
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, NotFoundOnline);
}
else
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, CorrSyntax);
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, CorrSyntax);
}
}
}
diff --git a/source/BP-Essentials/Chat/Commands/Admin/Mute.cs b/source/BP-Essentials/Chat/Commands/Admin/Mute.cs
index d6d0226d..6b545f64 100644
--- a/source/BP-Essentials/Chat/Commands/Admin/Mute.cs
+++ b/source/BP-Essentials/Chat/Commands/Admin/Mute.cs
@@ -25,7 +25,7 @@ public static void Run(SvPlayer player, string message)
}
if (!found)
{
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, NotFoundOnline);
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, NotFoundOnline);
return;
}
ReadFile.Run(MuteListFile);
@@ -33,14 +33,14 @@ public static void Run(SvPlayer player, string message)
{
MutePlayers.Add(muteuser);
File.AppendAllText(MuteListFile, muteuser + Environment.NewLine);
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Muted " + muteuser + "");
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"Muted " + muteuser + "");
}
else
{
RemoveStringFromFile.Run(MuteListFile, muteuser);
ReadFile.Run(MuteListFile);
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Unmuted " + muteuser + "");
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"Unmuted " + muteuser + "");
}
}
}
diff --git a/source/BP-Essentials/Chat/Commands/Admin/Promote.cs b/source/BP-Essentials/Chat/Commands/Admin/Promote.cs
index 4556f28e..b0efacea 100644
--- a/source/BP-Essentials/Chat/Commands/Admin/Promote.cs
+++ b/source/BP-Essentials/Chat/Commands/Admin/Promote.cs
@@ -13,19 +13,19 @@ public static void Run(SvPlayer player, string message)
var shPlayer = GetShByStr.Run(arg1);
if (shPlayer == null)
{
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, NotFoundOnline);
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, NotFoundOnline);
return;
}
if (shPlayer.rank >= 2)
{
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"{shPlayer.username} Already has the highest rank!");
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"{shPlayer.username} Already has the highest rank!");
return;
}
shPlayer.svPlayer.Reward(shPlayer.maxExperience - shPlayer.experience + 1, 0);
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Promoted {shPlayer.username} to rank {shPlayer.rank +1}.");
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"Promoted {shPlayer.username} to rank {shPlayer.rank +1}.");
}
else
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, ArgRequired);
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, ArgRequired);
}
}
}
\ No newline at end of file
diff --git a/source/BP-Essentials/Chat/Commands/Admin/Reload.cs b/source/BP-Essentials/Chat/Commands/Admin/Reload.cs
index 116cac4d..657ff96a 100644
--- a/source/BP-Essentials/Chat/Commands/Admin/Reload.cs
+++ b/source/BP-Essentials/Chat/Commands/Admin/Reload.cs
@@ -12,14 +12,10 @@ class Reload : EssentialsChatPlugin
{
public static void Run(SvPlayer player)
{
- var shPlayer = GetShBySv.Run(player);
- if (shPlayer != null)
- {
- if (shPlayer.admin)
- BP_Essentials.Reload.Run(false, player);
- else
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, MsgNoPerm);
- }
+ if (player.player.admin)
+ BP_Essentials.Reload.Run(false, player);
+ else
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, MsgNoPerm);
}
}
}
diff --git a/source/BP-Essentials/Chat/Commands/Admin/Restrain.cs b/source/BP-Essentials/Chat/Commands/Admin/Restrain.cs
index 7118f80b..fd52555b 100644
--- a/source/BP-Essentials/Chat/Commands/Admin/Restrain.cs
+++ b/source/BP-Essentials/Chat/Commands/Admin/Restrain.cs
@@ -18,18 +18,18 @@ public static void Run(SvPlayer player, string message)
var shPlayer = GetShByStr.Run(arg1);
if (shPlayer == null)
{
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, NotFoundOnline);
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, NotFoundOnline);
return;
}
shPlayer.svPlayer.Restrain(shPlayer.manager.handcuffed);
var shRetained = shPlayer.curEquipable as ShRestrained;
shPlayer.svPlayer.SvSetEquipable(shRetained.otherRestrained.index);
if (!shPlayer.svPlayer.IsServerside())
- shPlayer.svPlayer.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, "You've been restrained");
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Restrained " + shPlayer.username + $".");
+ shPlayer.svPlayer.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, "You've been restrained");
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"Restrained " + shPlayer.username + $".");
}
else
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, ArgRequired);
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, ArgRequired);
}
}
}
diff --git a/source/BP-Essentials/Chat/Commands/Admin/Say.cs b/source/BP-Essentials/Chat/Commands/Admin/Say.cs
index 3f3c44bd..738a36c6 100644
--- a/source/BP-Essentials/Chat/Commands/Admin/Say.cs
+++ b/source/BP-Essentials/Chat/Commands/Admin/Say.cs
@@ -15,11 +15,11 @@ public static void Run(SvPlayer player, string message)
{
string arg1 = GetArgument.Run(1, false, true, message);
if (String.IsNullOrEmpty(arg1))
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, ArgRequired);
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, ArgRequired);
else
{
arg1 = new Regex("(<)").Replace(arg1, "<");
- player.SendToAll(Channel.Unsequenced, ClPacket.GameMessage, $"{MsgSayPrefix} {player.playerData.username}: {arg1}");
+ player.Send(SvSendType.All, Channel.Unsequenced, ClPacket.GameMessage, $"{MsgSayPrefix} {player.playerData.username}: {arg1}");
}
}
}
diff --git a/source/BP-Essentials/Chat/Commands/Admin/Search.cs b/source/BP-Essentials/Chat/Commands/Admin/Search.cs
index 4a77bf3f..ec409808 100644
--- a/source/BP-Essentials/Chat/Commands/Admin/Search.cs
+++ b/source/BP-Essentials/Chat/Commands/Admin/Search.cs
@@ -14,7 +14,7 @@ public static void Run(SvPlayer player, string message)
{
string arg1 = GetArgument.Run(1, false, true, message);
if (String.IsNullOrEmpty(arg1))
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, ArgRequired);
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, ArgRequired);
else
{
foreach (var shPlayer2 in FindObjectsOfType())
@@ -29,14 +29,14 @@ public static void Run(SvPlayer player, string message)
shPlayer2.svPlayer.SvStopInventory(true);
shPlayer2.viewers.Add(shPlayer);
shPlayer.otherEntity = shPlayer2;
- player.SendToSelf(Channel.Fragmented, 13, shPlayer.otherEntity.ID, shPlayer.otherEntity.SerializeMyItems());
+ player.Send(SvSendType.Self, 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, ClPacket.GameMessage, $"Viewing inventory of {shPlayer2.username}");
- shPlayer2.svPlayer.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"{AdminSearchingInv}");
+ shPlayer2.svPlayer.Send(SvSendType.Self, Channel.Reliable, 16, new System.Object[] { });
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"Viewing inventory of {shPlayer2.username}");
+ shPlayer2.svPlayer.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"{AdminSearchingInv}");
}
else
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Player is dead.");
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"Player is dead.");
}
}
}
diff --git a/source/BP-Essentials/Chat/Commands/Admin/Slap.cs b/source/BP-Essentials/Chat/Commands/Admin/Slap.cs
index 766ceb40..26557d5a 100644
--- a/source/BP-Essentials/Chat/Commands/Admin/Slap.cs
+++ b/source/BP-Essentials/Chat/Commands/Admin/Slap.cs
@@ -14,7 +14,7 @@ public static void Run(SvPlayer player, string message)
{
string arg1 = GetArgument.Run(1, false, true, message);
if (String.IsNullOrEmpty(arg1))
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, ArgRequired);
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, ArgRequired);
else
{
bool playerfound = false;
@@ -27,13 +27,13 @@ public static void Run(SvPlayer player, 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, ClPacket.GameMessage, $"You got slapped by {shPlayer2.username}! [-{amount} HP]");
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"You've slapped {shPlayer.username}. [-{amount} HP]");
+ shPlayer.svPlayer.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"You got slapped by {shPlayer2.username}! [-{amount} HP]");
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"You've slapped {shPlayer.username}. [-{amount} HP]");
playerfound = true;
}
}
if (!playerfound)
- player.SendToSelf(Channel.Reliable, ClPacket.GameMessage, NotFoundOnline);
+ player.Send(SvSendType.Self, Channel.Reliable, ClPacket.GameMessage, NotFoundOnline);
}
}
diff --git a/source/BP-Essentials/Chat/Commands/Admin/SpawnVehicle.cs b/source/BP-Essentials/Chat/Commands/Admin/SpawnVehicle.cs
new file mode 100644
index 00000000..fc40acbd
--- /dev/null
+++ b/source/BP-Essentials/Chat/Commands/Admin/SpawnVehicle.cs
@@ -0,0 +1,46 @@
+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.Commands
+{
+ class SpawnVehicle : EssentialsChatPlugin
+ {
+ public static void Run(SvPlayer player, string message)
+ {
+ string arg1 = GetArgument.Run(1, false, false, message);
+ if (String.IsNullOrEmpty(arg1))
+ {
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, ArgRequired);
+ return;
+ }
+ bool Parsed = int.TryParse(arg1, out int arg1int);
+ if (Parsed)
+ {
+ if (arg1int > 0 && arg1int <= IDs_Vehicles.Length)
+ {
+ var shPlayer = player.player;
+ var pos = shPlayer.GetPosition();
+ if (player.player.GetPlaceIndex() != 0)
+ {
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"Cannot spawn inside a building.");
+ return;
+ }
+ if (arg1.Length > 4)
+ SvMan.AddNewEntity(shPlayer.manager.GetEntity(arg1int).gameObject, shPlayer.manager.places[0], new Vector3(pos.x, pos.y + 10F, pos.z), shPlayer.GetRotation());
+ else
+ SvMan.AddNewEntity(shPlayer.manager.GetEntity(IDs_Vehicles[arg1int - 1]).gameObject, shPlayer.manager.places[0], new Vector3(pos.x, pos.y + 7F, pos.z), shPlayer.GetRotation());
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"Spawning in vehicle with the ID: {arg1}");
+ }
+ else
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"Error: The ID must be between 1 and {IDs_Vehicles.Length}.");
+ }
+ else
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"Error: Is that a valid number you provided as argument?");
+ }
+ }
+}
diff --git a/source/BP-Essentials/Chat/Commands/Admin/Spy.cs b/source/BP-Essentials/Chat/Commands/Admin/Spy.cs
index e103cf76..e68da780 100644
--- a/source/BP-Essentials/Chat/Commands/Admin/Spy.cs
+++ b/source/BP-Essentials/Chat/Commands/Admin/Spy.cs
@@ -5,12 +5,9 @@ public class Spy : EssentialsChatPlugin
{
public static void Run(SvPlayer player)
{
- var shPlayer = GetShBySv.Run(player);
- if (shPlayer != null)
- {
- playerList[shPlayer.ID].spyEnabled = !playerList[shPlayer.ID].spyEnabled;
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"SpyChat {(playerList[shPlayer.ID].spyEnabled ? "Enabled" : "Disabled")}.");
- }
+ var shPlayer = player.player;
+ playerList[shPlayer.ID].spyEnabled = !playerList[shPlayer.ID].spyEnabled;
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"SpyChat {(playerList[shPlayer.ID].spyEnabled ? "Enabled" : "Disabled")}.");
}
}
}
diff --git a/source/BP-Essentials/Chat/Commands/Admin/Strip.cs b/source/BP-Essentials/Chat/Commands/Admin/Strip.cs
index 3299a7e9..38ec5005 100644
--- a/source/BP-Essentials/Chat/Commands/Admin/Strip.cs
+++ b/source/BP-Essentials/Chat/Commands/Admin/Strip.cs
@@ -14,7 +14,7 @@ public static void Run(SvPlayer player, string message)
{
string arg1 = GetArgument.Run(1, false, true, message);
if (String.IsNullOrEmpty(arg1))
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, ArgRequired);
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, ArgRequired);
else
{
bool playerfound = false;
@@ -33,12 +33,12 @@ public static void Run(SvPlayer player, string message)
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, ClPacket.GameMessage, $"{player.playerData.username} Removed your clothes.");
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Removed {shPlayer.username}'s clothes.");
+ shPlayer.svPlayer.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"{player.playerData.username} Removed your clothes.");
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"Removed {shPlayer.username}'s clothes.");
playerfound = true;
}
if (!playerfound)
- player.SendToSelf(Channel.Reliable, ClPacket.GameMessage, NotFoundOnline);
+ player.Send(SvSendType.Self, Channel.Reliable, ClPacket.GameMessage, NotFoundOnline);
}
}
diff --git a/source/BP-Essentials/Chat/Commands/Admin/ToggleReceiveStaffChat.cs b/source/BP-Essentials/Chat/Commands/Admin/ToggleReceiveStaffChat.cs
index 976bdec0..16bb9b76 100644
--- a/source/BP-Essentials/Chat/Commands/Admin/ToggleReceiveStaffChat.cs
+++ b/source/BP-Essentials/Chat/Commands/Admin/ToggleReceiveStaffChat.cs
@@ -12,16 +12,16 @@ class ToggleReceiveStaffChat : EssentialsChatPlugin
{
public static void Run(SvPlayer player)
{
- var shplayer = GetShBySv.Run(player);
+ var shplayer = player.player;
if (playerList[shplayer.ID].receiveStaffChat)
{
playerList[shplayer.ID].receiveStaffChat = false;
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Staff chat messages disabled. You'll not receive any staff chat messages anymore.");
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"Staff chat messages disabled. You'll not receive any staff chat messages anymore.");
}
else
{
playerList[shplayer.ID].receiveStaffChat = true;
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Staff chat message enabled. You'll now receive staff messages.");
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"Staff chat message enabled. You'll now receive staff messages.");
}
}
}
diff --git a/source/BP-Essentials/Chat/Commands/Admin/ToggleStaffChat.cs b/source/BP-Essentials/Chat/Commands/Admin/ToggleStaffChat.cs
index 56f60331..abd24395 100644
--- a/source/BP-Essentials/Chat/Commands/Admin/ToggleStaffChat.cs
+++ b/source/BP-Essentials/Chat/Commands/Admin/ToggleStaffChat.cs
@@ -14,18 +14,18 @@ class ToggleStaffChat : EssentialsChatPlugin
public static void Run(SvPlayer player, string message)
{
var arg1 = GetArgument.Run(1, false, true, message);
- var shplayer = GetShBySv.Run(player);
+ var shplayer = player.player;
if (string.IsNullOrEmpty(arg1))
{
if (playerList[shplayer.ID].staffChatEnabled)
{
playerList[shplayer.ID].staffChatEnabled = false;
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Staff chat disabled.");
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"Staff chat disabled.");
}
else
{
playerList[shplayer.ID].staffChatEnabled = true;
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Staff chat enabled.");
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"Staff chat enabled.");
}
}
else
diff --git a/source/BP-Essentials/Chat/Commands/Admin/Tp.cs b/source/BP-Essentials/Chat/Commands/Admin/Tp.cs
index 60ed1f2e..c8db807f 100644
--- a/source/BP-Essentials/Chat/Commands/Admin/Tp.cs
+++ b/source/BP-Essentials/Chat/Commands/Admin/Tp.cs
@@ -12,14 +12,14 @@ public static void Run(SvPlayer player, string message)
var shPlayer = GetShByStr.Run(arg1);
if (shPlayer == null)
{
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, NotFoundOnline);
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, NotFoundOnline);
return;
}
player.SvReset(shPlayer.GetPosition(), shPlayer.GetRotation(), shPlayer.GetPlaceIndex());
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Teleported to " + shPlayer.username + $".");
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"Teleported to " + shPlayer.username + $".");
}
else
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, ArgRequired);
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, ArgRequired);
}
}
}
\ No newline at end of file
diff --git a/source/BP-Essentials/Chat/Commands/Admin/TpAll.cs b/source/BP-Essentials/Chat/Commands/Admin/TpAll.cs
new file mode 100644
index 00000000..30002b97
--- /dev/null
+++ b/source/BP-Essentials/Chat/Commands/Admin/TpAll.cs
@@ -0,0 +1,19 @@
+using static BP_Essentials.EssentialsVariablesPlugin;
+using System;
+using static BP_Essentials.EssentialsMethodsPlugin;
+
+namespace BP_Essentials.Commands
+{
+ public class TpAll : EssentialsChatPlugin
+ {
+ public static void Run(SvPlayer player)
+ {
+ var pos = player.player.GetPosition();
+ var rot = player.player.GetRotation();
+ var pIndex = player.player.GetPlaceIndex();
+ foreach (var currPlayer in SvMan.players.Values)
+ currPlayer.svPlayer.SvReset(pos, rot, pIndex);
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"Teleported everyone to your location.");
+ }
+ }
+}
\ No newline at end of file
diff --git a/source/BP-Essentials/Chat/Commands/Admin/TpHere.cs b/source/BP-Essentials/Chat/Commands/Admin/TpHere.cs
index 81bb900e..ff1e56e9 100644
--- a/source/BP-Essentials/Chat/Commands/Admin/TpHere.cs
+++ b/source/BP-Essentials/Chat/Commands/Admin/TpHere.cs
@@ -12,18 +12,18 @@ public static void Run(SvPlayer player, string message)
if (!string.IsNullOrEmpty(arg1))
{
var shPlayer = GetShByStr.Run(arg1);
- var shPlayer1 = GetShBySv.Run(player);
+ var shPlayer1 = player.player;
if (shPlayer == null)
{
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, NotFoundOnline);
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, NotFoundOnline);
return;
}
shPlayer.svPlayer.SvReset(shPlayer1.GetPosition(), shPlayer1.GetRotation(), shPlayer1.GetPlaceIndex());
- shPlayer.svPlayer.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"" + shPlayer1.username + $" Teleported you to him.");
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Teleported " + shPlayer.username + $" To you.");
+ shPlayer.svPlayer.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"" + shPlayer1.username + $" Teleported you to him.");
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"Teleported " + shPlayer.username + $" To you.");
}
else
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, ArgRequired);
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, ArgRequired);
}
}
}
\ No newline at end of file
diff --git a/source/BP-Essentials/Chat/Commands/Admin/TpLocation.cs b/source/BP-Essentials/Chat/Commands/Admin/TpLocation.cs
new file mode 100644
index 00000000..ebb60844
--- /dev/null
+++ b/source/BP-Essentials/Chat/Commands/Admin/TpLocation.cs
@@ -0,0 +1,30 @@
+using static BP_Essentials.EssentialsVariablesPlugin;
+using System;
+using static BP_Essentials.EssentialsMethodsPlugin;
+using System.Collections.Generic;
+using UnityEngine;
+using System.Linq;
+
+namespace BP_Essentials.Commands
+{
+ public class TpLocation : EssentialsChatPlugin
+ {
+ public static void Run(SvPlayer player, string message)
+ {
+ var arg1 = GetArgument.Run(1, false, true, message);
+ if (string.IsNullOrEmpty(arg1.Trim()))
+ {
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, ArgRequired);
+ return;
+ }
+ foreach (var currKey in PlaceDictionary.Keys)
+ if (currKey.Contains(arg1))
+ {
+ player.SvReset(PlaceDictionary[currKey], player.player.GetRotation(), 0);
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"Teleported to {currKey[1]}.");
+ return;
+ }
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"Invalid place name!");
+ }
+ }
+}
\ No newline at end of file
diff --git a/source/BP-Essentials/Chat/Commands/Admin/TpToApartment.cs b/source/BP-Essentials/Chat/Commands/Admin/TpToApartment.cs
index 7d973755..594aedaf 100644
--- a/source/BP-Essentials/Chat/Commands/Admin/TpToApartment.cs
+++ b/source/BP-Essentials/Chat/Commands/Admin/TpToApartment.cs
@@ -9,7 +9,7 @@ public static void Run(SvPlayer player, string message)
var arg1 = GetArgument.Run(1, false, true, message);
if (string.IsNullOrEmpty(arg1))
{
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, ArgRequired);
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, ArgRequired);
return;
}
switch (arg1)
@@ -20,23 +20,23 @@ public static void Run(SvPlayer player, string message)
case "1.200":
case "1000":
player.SvReset(new Vector3(643.1F, 0, -61.4F), Quaternion.identity, 0);
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Teleported to 1.2k apartment.");
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"Teleported to 1.2k apartment.");
break;
case "5k":
case "2":
case "5000":
player.SvReset(new Vector3(518.8F, 0, -127.2F), Quaternion.identity, 0);
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Teleported to 5k apartment.");
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"Teleported to 5k apartment.");
break;
case "10k":
case "10":
case "3":
case "10000":
player.SvReset(new Vector3(1.7F, 0, -92.8F), Quaternion.identity, 0);
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Teleported to 10k apartment.");
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"Teleported to 10k apartment.");
break;
default:
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"{GetArgument.Run(0, false, false, message)} [1.2k, 5k, 10k]");
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"{GetArgument.Run(0, false, false, message)} [1.2k, 5k, 10k]");
break;
}
}
diff --git a/source/BP-Essentials/Chat/Commands/Admin/_SetJob.cs b/source/BP-Essentials/Chat/Commands/Admin/_SetJob.cs
index f5b677a1..59ff5a48 100644
--- a/source/BP-Essentials/Chat/Commands/Admin/_SetJob.cs
+++ b/source/BP-Essentials/Chat/Commands/Admin/_SetJob.cs
@@ -15,11 +15,11 @@ public static void Run(SvPlayer player, string message)
{
string NotValidArg = $"Error: Is that a valid number you provided as argument?";
string arg1 = GetArgument.Run(1, false, false, message);
- string arg2 = GetArgument.Run(2, false, true, message + " ");
+ string arg2 = GetArgument.Run(2, false, true, message);
byte arg1int = 10;
string msg = $"Set {{0}}'s Job to {{1}}.";
if (String.IsNullOrEmpty(arg2))
- arg2 = player.playerData.username;
+ arg2 = player.player.username;
if (!String.IsNullOrEmpty(arg1))
{
bool Parsed = true;
@@ -33,18 +33,18 @@ public static void Run(SvPlayer player, string message)
if (shPlayer.username == arg2 || shPlayer.ID.ToString() == arg2.ToString())
if (arg1int <= Jobs.Length && arg1int >= 0)
{
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, String.Format(msg, arg2, Jobs[arg1int]));
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, String.Format(msg, shPlayer.username, Jobs[arg1int]));
SetJob.Run(shPlayer, arg1int, true, false);
}
else
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Error: The value must be between 0 and {Jobs.Length}.");
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"Error: The value must be between 0 and {Jobs.Length}.");
}
else
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, NotValidArg);
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, NotValidArg);
}
else
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, NotValidArg);
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, NotValidArg);
}
}
}
diff --git a/source/BP-Essentials/Chat/Commands/Everyone/Afk.cs b/source/BP-Essentials/Chat/Commands/Everyone/Afk.cs
index bd32e800..565f55b6 100644
--- a/source/BP-Essentials/Chat/Commands/Everyone/Afk.cs
+++ b/source/BP-Essentials/Chat/Commands/Everyone/Afk.cs
@@ -10,13 +10,13 @@ public static void Run(SvPlayer player)
{
RemoveStringFromFile.Run(AfkListFile, player.playerData.username);
ReadFile.Run(AfkListFile);
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"You are no longer AFK.");
+ player.Send(SvSendType.Self, 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, ClPacket.GameMessage, $"You are now AFK.");
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"You are now AFK.");
}
}
}
diff --git a/source/BP-Essentials/Chat/Commands/Everyone/Atm.cs b/source/BP-Essentials/Chat/Commands/Everyone/Atm.cs
index f806bc03..6cb814de 100644
--- a/source/BP-Essentials/Chat/Commands/Everyone/Atm.cs
+++ b/source/BP-Essentials/Chat/Commands/Everyone/Atm.cs
@@ -17,11 +17,11 @@ public static void Run(SvPlayer player)
if (!shPlayer.svPlayer.IsServerside())
if (shPlayer.wantedLevel == 0)
{
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Opening ATM menu..");
- player.SendToSelf(Channel.Reliable, 40, player.bankBalance);
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"Opening ATM menu..");
+ player.Send(SvSendType.Self, Channel.Reliable, 40, player.bankBalance);
}
else if (shPlayer.wantedLevel != 0)
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Criminal Activity: Account Locked");
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"Criminal Activity: Account Locked");
}
}
}
diff --git a/source/BP-Essentials/Chat/Commands/Everyone/ClearChat.cs b/source/BP-Essentials/Chat/Commands/Everyone/ClearChat.cs
index c95bd628..d16d8a6f 100644
--- a/source/BP-Essentials/Chat/Commands/Everyone/ClearChat.cs
+++ b/source/BP-Essentials/Chat/Commands/Everyone/ClearChat.cs
@@ -7,24 +7,24 @@ namespace BP_Essentials.Commands {
public class ClearChat : EssentialsChatPlugin {
public static void Run(SvPlayer player, string message)
{
- string arg1 = GetArgument.Run(1, false, false, message).Trim();
+ string arg1 = GetArgument.Run(1, false, false, message);
if (arg1 == "all" || arg1 == "everyone")
{
if (AdminsListPlayers.Contains(player.playerData.username))
{
for (var i = 0; i < 6; i++)
- player.SendToAll(Channel.Unsequenced, 10, " ");
- player.SendToAll(Channel.Unsequenced, 10, $"{player.playerData.username} Cleared the chat for everyone.");
+ player.Send(SvSendType.All, Channel.Unsequenced, 10, " ");
+ player.Send(SvSendType.All, Channel.Unsequenced, 10, $"{player.playerData.username} Cleared the chat for everyone.");
}
else
- player.SendToSelf(Channel.Unsequenced, 10, MsgNoPerm);
+ player.Send(SvSendType.Self, Channel.Unsequenced, 10, MsgNoPerm);
}
else
{
for (var i = 0; i < 6; i++)
- player.SendToSelf(Channel.Unsequenced, 10, " ");
- player.SendToSelf(Channel.Unsequenced, 10, $"Cleared the chat for yourself.");
+ player.Send(SvSendType.Self, Channel.Unsequenced, 10, " ");
+ player.Send(SvSendType.Self, Channel.Unsequenced, 10, $"Cleared the chat for yourself.");
}
}
}
diff --git a/source/BP-Essentials/Chat/Commands/Everyone/Confirm.cs b/source/BP-Essentials/Chat/Commands/Everyone/Confirm.cs
index c0de1517..0290dcfc 100644
--- a/source/BP-Essentials/Chat/Commands/Everyone/Confirm.cs
+++ b/source/BP-Essentials/Chat/Commands/Everyone/Confirm.cs
@@ -12,20 +12,20 @@ class Confirm : EssentialsChatPlugin
{
public static bool Run(SvPlayer player)
{
- var shPlayer = GetShBySv.Run(player);
+ var shPlayer = player.player;
if (shPlayer.ownedApartment)
{
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Selling apartment...");
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"Selling apartment...");
SellApartment(shPlayer);
}
else
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"You don't have a apartment to sell!");
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"You don't have a apartment to sell!");
return true;
}
public static void SellApartment(ShPlayer shPlayer)
{
- shPlayer.TransferMoney(1, shPlayer.ownedApartment.value / 2, true);
- shPlayer.svPlayer.SendToSelf(Channel.Reliable, ClPacket.ApartmentOwner, new object[]{0,0});
+ shPlayer.TransferMoney(DeltaInv.AddToMe, shPlayer.ownedApartment.value / 2, true);
+ shPlayer.svPlayer.Send(SvSendType.Self, Channel.Reliable, ClPacket.ApartmentOwner, new object[]{0,0});
CleanupApartment.Run(shPlayer);
}
}
diff --git a/source/BP-Essentials/Chat/Commands/Everyone/Essentials.cs b/source/BP-Essentials/Chat/Commands/Everyone/Essentials.cs
index 710ebb70..ba092371 100644
--- a/source/BP-Essentials/Chat/Commands/Everyone/Essentials.cs
+++ b/source/BP-Essentials/Chat/Commands/Everyone/Essentials.cs
@@ -6,28 +6,28 @@ public static void Run(SvPlayer player, string message)
{
string arg = GetArgument.Run(1, false, false, message).Trim().ToLower();
if (arg == "ver" || arg == "version")
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, "Version: " + EssentialsVariablesPlugin.Version);
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, "Version: " + EssentialsVariablesPlugin.Version);
else if (arg == "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. ");
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, "Essentials Created by UserR00T & DeathByKorea & BP");
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, "Version " + EssentialsVariablesPlugin.Version);
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, "Type '/essentials help' for more info. ");
}
else if (arg == "help")
{
- 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.");
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, "Subcommands for /essentials:");
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, " - help : Shows this menu.");
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, " - info : Shows infomation about the developer.");
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, " - ver/version : Shows version number.");
+ player.Send(SvSendType.Self, 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, ClPacket.GameMessage, "Up to date help can be found at http://bit.do/BPEssentials");
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, "Up to date help can be found at http://bit.do/BPEssentials");
else
{
- 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. ");
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, "Essentials Created by UserR00T & DeathByKorea & BP.");
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, "Version " + EssentialsVariablesPlugin.Version);
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, "Type '/essentials help' for more info. ");
}
}
}
diff --git a/source/BP-Essentials/Chat/Commands/Everyone/GetKit.cs b/source/BP-Essentials/Chat/Commands/Everyone/GetKit.cs
new file mode 100644
index 00000000..96538bee
--- /dev/null
+++ b/source/BP-Essentials/Chat/Commands/Everyone/GetKit.cs
@@ -0,0 +1,46 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using UnityEngine;
+using static BP_Essentials.EssentialsVariablesPlugin;
+using static BP_Essentials.EssentialsMethodsPlugin;
+using System.IO;
+
+namespace BP_Essentials.Commands
+{
+ public class GetKit : EssentialsChatPlugin
+ {
+ public static void Run(SvPlayer player, string message)
+ {
+ var arg1 = GetArgument.Run(1, false, true, message);
+ if (string.IsNullOrEmpty(arg1.Trim()))
+ {
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, ArgRequired);
+ return;
+ }
+ if (!listKits.Any(x=>x.Name == arg1))
+ {
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"That kit doesn't exist.");
+ return;
+ }
+ var obj = listKits.FirstOrDefault(x => x.Name == arg1);
+ if (obj.Disabled)
+ {
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"That kit is currently disabled.");
+ return;
+ }
+ if (obj.CurrentlyInCooldown.ContainsKey(player.player.username))
+ {
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"You already used this kit. Please wait {obj.CurrentlyInCooldown[player.player.username]} second(s) before executing this command again.");
+ return;
+ }
+ foreach (var item in obj.Items)
+ {
+ player.player.TransferItem(DeltaInv.AddToMe, item.Id, item.Amount, true);
+ }
+ player.StartCoroutine(Kits.KitCooldown(player, obj));
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"You've been given the kit {arg1}.");
+ }
+ }
+}
diff --git a/source/BP-Essentials/Chat/Commands/Everyone/ListKits.cs b/source/BP-Essentials/Chat/Commands/Everyone/ListKits.cs
new file mode 100644
index 00000000..fb9cc018
--- /dev/null
+++ b/source/BP-Essentials/Chat/Commands/Everyone/ListKits.cs
@@ -0,0 +1,19 @@
+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.Commands
+{
+ class ListKits : EssentialsChatPlugin
+ {
+ public static void Run(SvPlayer player)
+ {
+ var kits = listKits.Where(x => !x.Disabled && HasPermission.Run(player, x.ExecutableBy)).Select(n=>n.Name).ToArray();
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"Kits you can obtain ({kits.Length}): {(kits == null || kits.Length == 0 ? "none" : string.Join(", ", kits))}");
+ }
+ }
+}
diff --git a/source/BP-Essentials/Chat/Commands/Everyone/OnlinePlayers.cs b/source/BP-Essentials/Chat/Commands/Everyone/OnlinePlayers.cs
index 1d21f75c..62ec97b4 100644
--- a/source/BP-Essentials/Chat/Commands/Everyone/OnlinePlayers.cs
+++ b/source/BP-Essentials/Chat/Commands/Everyone/OnlinePlayers.cs
@@ -16,10 +16,10 @@ public static void Run(SvPlayer player)
switch (realPlayers)
{
case 1:
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"There is {realPlayers} player online");
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"There is {realPlayers} player online");
break;
default:
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"There are {realPlayers} players online");
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"There are {realPlayers} players online");
break;
}
}
diff --git a/source/BP-Essentials/Chat/Commands/Everyone/Pay.cs b/source/BP-Essentials/Chat/Commands/Everyone/Pay.cs
index 84c98ee5..1d317491 100644
--- a/source/BP-Essentials/Chat/Commands/Everyone/Pay.cs
+++ b/source/BP-Essentials/Chat/Commands/Everyone/Pay.cs
@@ -14,7 +14,7 @@ public static void Run(SvPlayer player, string message)
string arg2 = message.Split(' ').Last().Trim();
if (String.IsNullOrEmpty(GetArgument.Run(1, false, false, message)) || String.IsNullOrEmpty(arg2))
{
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, CorrSyntax);
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, CorrSyntax);
return;
}
else
@@ -28,7 +28,7 @@ public static void Run(SvPlayer player, string message)
{
if (arg2Int <= 0)
{
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Cannot transfer 0$.");
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"Cannot transfer 0$.");
return;
}
foreach (var shPlayer in UnityEngine.Object.FindObjectsOfType())
@@ -38,20 +38,20 @@ public static void Run(SvPlayer player, string message)
{
if (_shPlayer.MyMoneyCount() >= arg2Int)
{
- _shPlayer.TransferMoney(2, arg2Int, true);
- shPlayer.TransferMoney(1, arg2Int, true);
- 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}$!");
+ _shPlayer.TransferMoney(DeltaInv.RemoveFromMe, arg2Int, true);
+ shPlayer.TransferMoney(DeltaInv.AddToMe, arg2Int, true);
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"Successfully transfered {arg2Int}$ to {shPlayer.username}!");
+ shPlayer.svPlayer.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"{player.playerData.username} gave you {arg2Int}$!");
}
else
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Cannot transfer money, do you have " + arg2Int + $"$ in your inventory?");
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"Cannot transfer money, do you have " + arg2Int + $"$ in your inventory?");
return;
}
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, NotFoundOnline);
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, NotFoundOnline);
}
else
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, CorrSyntax);
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, CorrSyntax);
}
}
}
diff --git a/source/BP-Essentials/Chat/Commands/Everyone/Report.cs b/source/BP-Essentials/Chat/Commands/Everyone/Report.cs
index d80578b3..1dca7ccc 100644
--- a/source/BP-Essentials/Chat/Commands/Everyone/Report.cs
+++ b/source/BP-Essentials/Chat/Commands/Everyone/Report.cs
@@ -31,29 +31,27 @@ public static void Run(SvPlayer player, string message)
var builder = new StringBuilder();
builder.Append("Reporting " + arg1 + "\nReason:\n\n");
for (int i = 0; i < ReportReasons.Length; i++)
- {
builder.Append("F" + (i + 2) + ": " + ReportReasons[i] + "\n");
- }
- player.SendToSelf(Channel.Reliable, ClPacket.ShowFunctionMenu, builder + "\nPress F11 To close this (G)UI");
+ player.Send(SvSendType.Self, Channel.Reliable, ClPacket.ShowFunctionMenu, builder + "\nPress F11 To close this (G)UI");
item.Value.LastMenu = CurrentMenu.Report;
item.Value.reportedPlayer = shPlayer;
}
else
- player.SendToSelf(Channel.Reliable, ClPacket.GameMessage, $"Hey! You cannot report an admin.");
+ player.Send(SvSendType.Self, Channel.Reliable, ClPacket.GameMessage, $"Hey! You cannot report an admin.");
break;
}
if (!playerfound)
- player.SendToSelf(Channel.Reliable, ClPacket.GameMessage, NotFoundOnline);
+ player.Send(SvSendType.Self, Channel.Reliable, ClPacket.GameMessage, NotFoundOnline);
}
else
- player.SendToSelf(Channel.Reliable, ClPacket.GameMessage, $"Hey! You cannot report as admin.");
+ player.Send(SvSendType.Self, Channel.Reliable, ClPacket.GameMessage, $"Hey! You cannot report as admin.");
}
else
- player.SendToSelf(Channel.Reliable, ClPacket.GameMessage, $"Hey! You cannot report yourself, dummy.");
+ player.Send(SvSendType.Self, Channel.Reliable, ClPacket.GameMessage, $"Hey! You cannot report yourself, dummy.");
}
}
else
- player.SendToSelf(Channel.Reliable, ClPacket.GameMessage, $"Missing argument! Correct syntax: {GetArgument.Run(0, false, false, message)} [player]");
+ player.Send(SvSendType.Self, Channel.Reliable, ClPacket.GameMessage, $"Missing argument! Correct syntax: {GetArgument.Run(0, false, false, message)} [player]");
}
}
}
diff --git a/source/BP-Essentials/Chat/Commands/Everyone/ToggleChat.cs b/source/BP-Essentials/Chat/Commands/Everyone/ToggleChat.cs
index 102484d2..f51bc67b 100644
--- a/source/BP-Essentials/Chat/Commands/Everyone/ToggleChat.cs
+++ b/source/BP-Essentials/Chat/Commands/Everyone/ToggleChat.cs
@@ -19,12 +19,12 @@ public static void Run(SvPlayer player)
if (player2.chatEnabled)
{
player2.chatEnabled = false;
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Chat disabled.");
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"Chat disabled.");
}
else
{
player2.chatEnabled = true;
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Chat enabled.");
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"Chat enabled.");
}
break;
}
diff --git a/source/BP-Essentials/EssentialsChat.cs b/source/BP-Essentials/EssentialsChat.cs
index ccfbe57b..4098808b 100644
--- a/source/BP-Essentials/EssentialsChat.cs
+++ b/source/BP-Essentials/EssentialsChat.cs
@@ -31,8 +31,8 @@ public static bool SvGlobalChatMessage(SvPlayer player, ref string message)
foreach (var command2 in CustomCommands)
if (message.StartsWith(command2))
i = CustomCommands.IndexOf(command2);
- foreach (string line in Responses[i].Split(new[] { "\\r\\n", "\\r", "\\n" }, StringSplitOptions.None))
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, GetPlaceHolders.Run(line, player));
+ foreach (string line in Responses[i].Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None))
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, GetPlaceHolders.Run(line, player));
return true;
}
// Go through all registered commands and check if the command that the user entered matches
@@ -41,7 +41,7 @@ public static bool SvGlobalChatMessage(SvPlayer player, ref string message)
{
if (cmd.commandDisabled == true)
{
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, DisabledCommand);
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, DisabledCommand);
return true;
}
if (HasPermission.Run(player, cmd.commandGroup, true))
@@ -49,7 +49,7 @@ public static bool SvGlobalChatMessage(SvPlayer player, ref string message)
// Improve (use LINQ, not that familiar with it though
foreach (var currPlayer in playerList.Values)
if (currPlayer.spyEnabled && currPlayer.shplayer.svPlayer != player)
- currPlayer.shplayer.svPlayer.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"[SPYCHAT] {player.playerData.username}: {message}");
+ currPlayer.shplayer.svPlayer.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"[SPYCHAT] {player.playerData.username}: {message}");
switch (cmd.commandName)
{
// If anyone knows a way to improve this, let me know :)
@@ -86,6 +86,12 @@ public static bool SvGlobalChatMessage(SvPlayer player, ref string message)
case "GetLogs":
Commands.GetLogs.Run(player, ChatLogFile);
break;
+ case "TpAll":
+ Commands.TpAll.Run(player);
+ break;
+ case "ListKits":
+ Commands.ListKits.Run(player);
+ break;
default:
cmd.RunMethod.Invoke(player, message);
break;
@@ -97,24 +103,24 @@ public static bool SvGlobalChatMessage(SvPlayer player, ref string message)
Commands.Afk.Run(player);
if (MsgUnknownCommand)
{
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Unknown command. Type {CmdCommandCharacter}essentials cmds for more info.");
+ player.Send(SvSendType.Self, 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, ClPacket.GameMessage, SelfIsMuted);
+ player.Send(SvSendType.Self, 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, ClPacket.GameMessage, PlayerIsAFK);
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, PlayerIsAFK);
- var shplayer = GetShBySv.Run(player);
+ var shplayer = player.player;
if (!playerList[shplayer.ID].chatEnabled)
{
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Please enable your chat again by typing {CmdCommandCharacter}{CmdToggleChat}.");
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"Please enable your chat again by typing {CmdCommandCharacter}{CmdToggleChat}.");
return true;
}
if (playerList[shplayer.ID].staffChatEnabled)
@@ -123,7 +129,7 @@ public static bool SvGlobalChatMessage(SvPlayer player, ref string message)
_msg = _msg.Replace("{username}", new Regex("(<)").Replace(shplayer.username, "<"));
_msg = _msg.Replace("{id}", $"{shplayer.ID}");
_msg = _msg.Replace("{jobindex}", $"{shplayer.job.jobIndex}");
- _msg = _msg.Replace("{jobname}", $"{shplayer.job.info.jobName}");
+ _msg = _msg.Replace("{jobname}", $"{Jobs[shplayer.job.jobIndex]}");
_msg = _msg.Replace("{message}", new Regex("(<)").Replace(Chat.LangAndChatBlock.Run(message), "<"));
SendChatMessageToAdmins.Run(_msg);
return true;
@@ -137,7 +143,7 @@ public static bool SvGlobalChatMessage(SvPlayer player, ref string message)
_msg = _msg.Replace("{username}", new Regex("(<)").Replace(player.playerData.username, "<"));
_msg = _msg.Replace("{id}", $"{shplayer.ID}");
_msg = _msg.Replace("{jobindex}", $"{shplayer.job.jobIndex}");
- _msg = _msg.Replace("{jobname}", $"{shplayer.job.info.jobName}");
+ _msg = _msg.Replace("{jobname}", $"{Jobs[shplayer.job.jobIndex]}");
_msg = _msg.Replace("{message}", new Regex("(<)").Replace(Chat.LangAndChatBlock.Run(message), "<"));
SendChatMessage.Run(_msg);
return true;
@@ -149,7 +155,7 @@ public static bool SvGlobalChatMessage(SvPlayer player, ref string message)
_msg = _msg.Replace("{username}", new Regex("(<)").Replace(player.playerData.username, "<"));
_msg = _msg.Replace("{id}", $"{shplayer.ID}");
_msg = _msg.Replace("{jobindex}", $"{shplayer.job.jobIndex}");
- _msg = _msg.Replace("{jobname}", $"{shplayer.job.info.jobName}");
+ _msg = _msg.Replace("{jobname}", $"{Jobs[shplayer.job.jobIndex]}");
_msg = _msg.Replace("{message}", new Regex("(<)").Replace(Chat.LangAndChatBlock.Run(message), "<"));
SendChatMessage.Run(_msg);
return true;
@@ -158,7 +164,7 @@ public static bool SvGlobalChatMessage(SvPlayer player, ref string message)
_msg = _msg.Replace("{username}", new Regex("(<)").Replace(player.playerData.username, "<"));
_msg = _msg.Replace("{id}", $"{shplayer.ID}");
_msg = _msg.Replace("{jobindex}", $"{shplayer.job.jobIndex}");
- _msg = _msg.Replace("{jobname}", $"{shplayer.job.info.jobName}");
+ _msg = _msg.Replace("{jobname}", $"{Jobs[shplayer.job.jobIndex]}");
_msg = _msg.Replace("{message}", new Regex("(<)").Replace(Chat.LangAndChatBlock.Run(message), "<"));
SendChatMessage.Run(_msg);
return true;
diff --git a/source/BP-Essentials/EssentialsCore.cs b/source/BP-Essentials/EssentialsCore.cs
index 3171b8db..3b828bf8 100644
--- a/source/BP-Essentials/EssentialsCore.cs
+++ b/source/BP-Essentials/EssentialsCore.cs
@@ -4,6 +4,7 @@
BP:Essentials
Created by UserR00T, DBK, and BP.
+ Currently only being worked on by UserR00T unfortunately. :(
License: GPLv3.
@@ -20,7 +21,8 @@
using static BP_Essentials.EssentialsVariablesPlugin;
namespace BP_Essentials
{
- public class EssentialsCorePlugin {
+ public class EssentialsCorePlugin
+ {
//Initialization
[Hook("SvManager.StartServer")]
@@ -30,6 +32,7 @@ public static void StartServer(SvManager svManager)
{
SvMan = svManager;
Reload.Run(true);
+ CheckAutoReloadFile.Run(AutoReloader);
if (EssentialsVariablesPlugin.Version != LocalVersion)
{
Debug.Log("[ERROR] Essentials - Versions do not match!");
diff --git a/source/BP-Essentials/EssentialsMethods.cs b/source/BP-Essentials/EssentialsMethods.cs
index e9e28608..a85caebc 100644
--- a/source/BP-Essentials/EssentialsMethods.cs
+++ b/source/BP-Essentials/EssentialsMethods.cs
@@ -17,7 +17,7 @@ public class EssentialsMethodsPlugin : EssentialsCorePlugin
[Hook("SvPlayer.SvSellApartment")]
public static bool SvSellApartment(SvPlayer player)
{
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Are you sure you want to sell your apartment? Type '{CmdCommandCharacter}{CmdConfirm}' to confirm."); //softcode command
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"Are you sure you want to sell your apartment? Type '{CmdCommandCharacter}{CmdConfirm}' to confirm."); //softcode command
return true;
}
@@ -67,7 +67,7 @@ public static bool HitEffect(ShRestraint player, ref ShEntity hitTarget, ref ShP
{
if (shPlayer != hitTarget) continue;
if (!GodListPlayers.Contains(shPlayer.username)) continue;
- shPlayer.svPlayer.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, "Being handcuffed Blocked!");
+ shPlayer.svPlayer.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, "Being handcuffed Blocked!");
return true;
}
return false;
@@ -78,7 +78,7 @@ public static bool SvBan(SvPlayer player, ref int otherID)
{
if (BlockBanButtonTabMenu)
{
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"This button has been disabled. Please use the ban commands.");
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"This button has been disabled. Please use the ban commands.");
return true;
}
foreach (var shPlayer in UnityEngine.Object.FindObjectsOfType())
@@ -86,7 +86,7 @@ public static bool SvBan(SvPlayer player, ref int otherID)
if (!shPlayer.svPlayer.IsServerside() && !shPlayer.svPlayer.IsServerside())
{
LogMessage.LogOther($"{SetTimeStamp.Run()}[INFO] {shPlayer.username} Got banned by {player.playerData.username}");
- player.SendToAll(Channel.Unsequenced, ClPacket.GameMessage, $"{shPlayer.username} Just got banned by {player.playerData.username}");
+ player.Send(SvSendType.All, Channel.Unsequenced, ClPacket.GameMessage, $"{shPlayer.username} Just got banned by {player.playerData.username}");
SendDiscordMessage.BanMessage(shPlayer.username, player.playerData.username);
}
return false;
@@ -110,10 +110,10 @@ public static bool SvStartVote(SvPlayer player, ref byte voteIndex, ref int ID)
player.svManager.vote = shIssuer.manager.votes[voteIndex];
if (player.svManager.vote.CheckVote(ID))
{
- player.SendToAll(Channel.Reliable, 60, voteIndex, ID);
+ player.Send(SvSendType.All, 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, ClPacket.GameMessage, $"{player.playerData.username} Has issued a vote kick against {shPlayer.username}");
+ player.Send(SvSendType.All, Channel.Unsequenced, ClPacket.GameMessage, $"{player.playerData.username} Has issued a vote kick against {shPlayer.username}");
LatestVotePeople.Clear();
}
else
@@ -121,7 +121,7 @@ public static bool SvStartVote(SvPlayer player, ref byte voteIndex, ref int ID)
}
}
else
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"Vote kicking has been disabled on this server.");
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"Vote kicking has been disabled on this server.");
return true;
}
return false;
@@ -149,11 +149,12 @@ public static bool SvFunctionKey(SvPlayer player, ref byte key)
#region Report
if (item.Value.LastMenu == CurrentMenu.Report && key > 1 && key < 11)
{
- player.SendToSelf(Channel.Reliable, ClPacket.CloseFunctionMenu);
- player.SendToSelf(Channel.Reliable, ClPacket.GameMessage, $"Reported \"{item.Value.reportedPlayer.username}\" With the reason \"{ReportReasons[key - 2]}\".");
+ player.Send(SvSendType.Self, Channel.Reliable, ClPacket.CloseFunctionMenu);
+ player.Send(SvSendType.Self, Channel.Reliable, ClPacket.GameMessage, $"Reported \"{item.Value.reportedPlayer.username}\" With the reason \"{ReportReasons[key - 2]}\".");
item.Value.reportedReason = ReportReasons[key - 2];
item.Value.LastMenu = CurrentMenu.Main;
- ReportPlayer.Run(player.playerData.username, ReportReasons[key - 2], item.Value.reportedPlayer);
+ SendDiscordMessage.ReportMessage(item.Value.reportedPlayer.username, player.player.username, ReportReasons[key - 2]);
+ ReportPlayer.Run(player.player.username, ReportReasons[key - 2], item.Value.reportedPlayer);
return true;
}
#endregion
@@ -162,49 +163,49 @@ public static bool SvFunctionKey(SvPlayer player, ref byte key)
{
case 1:
if (HasPermission.Run(player, AccessMoneyMenu) || HasPermission.Run(player, AccessItemMenu) || HasPermission.Run(player, AccessSetHPMenu) || HasPermission.Run(player, AccessSetStatsMenu) || HasPermission.Run(player, AccessCWMenu))
- player.SendToSelf(Channel.Reliable, ClPacket.ShowFunctionMenu, "Main menu:\n\nF3: Server info menu\nF10: Extras menu\n\nPress F11 To close this (G)UI");
+ player.Send(SvSendType.Self, Channel.Reliable, ClPacket.ShowFunctionMenu, "Main menu:\n\nF3: Server info menu\nF10: Extras menu\n\nPress F11 To close this (G)UI");
else
- player.SendToSelf(Channel.Reliable, ClPacket.ShowFunctionMenu, "Main menu:\n\nF3: Server info menu\n\nPress F11 To close this (G)UI");
+ player.Send(SvSendType.Self, Channel.Reliable, ClPacket.ShowFunctionMenu, "Main menu:\n\nF3: Server info menu\n\nPress F11 To close this (G)UI");
item.Value.LastMenu = CurrentMenu.Main;
break;
case 2:
if (item.Value.LastMenu == CurrentMenu.ServerInfo)
{
- player.SendToSelf(Channel.Reliable, ClPacket.CloseFunctionMenu);
- player.SendToSelf(Channel.Fragmented, ClPacket.ServerInfo, File.ReadAllText("server_info.txt"));
+ player.Send(SvSendType.Self, Channel.Reliable, ClPacket.CloseFunctionMenu);
+ player.Send(SvSendType.Self, Channel.Fragmented, ClPacket.ServerInfo, File.ReadAllText("server_info.txt"));
item.Value.LastMenu = CurrentMenu.Main;
}
if (item.Value.LastMenu == CurrentMenu.Staff && HasPermission.Run(player, AccessMoneyMenu))
{
- player.SendToSelf(Channel.Reliable, ClPacket.ShowFunctionMenu, "Give Money menu:\n\nF2: Give 1.000 dollars (1k)\nF3: Give 10.000 dollars (10k)\nF4: Give 100.000 dollars (100k)\n\nPress F11 To close this (G)UI");
+ player.Send(SvSendType.Self, Channel.Reliable, ClPacket.ShowFunctionMenu, "Give Money menu:\n\nF2: Give 1.000 dollars (1k)\nF3: Give 10.000 dollars (10k)\nF4: Give 100.000 dollars (100k)\n\nPress F11 To close this (G)UI");
item.Value.LastMenu = CurrentMenu.GiveMoney;
}
else if (item.Value.LastMenu == CurrentMenu.GiveMoney)
{
- player.SendToSelf(Channel.Reliable, ClPacket.CloseFunctionMenu);
- shPlayer.TransferMoney(1, 1000, true);
- player.SendToSelf(Channel.Reliable, ClPacket.GameMessage, $"You have given yourself 1.000 dollars.");
+ player.Send(SvSendType.Self, Channel.Reliable, ClPacket.CloseFunctionMenu);
+ shPlayer.TransferMoney(DeltaInv.AddToMe, 1000, true);
+ player.Send(SvSendType.Self, 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.Value.LastMenu = CurrentMenu.Main;
}
else if (item.Value.LastMenu == CurrentMenu.GiveItems)
{
- player.SendToSelf(Channel.Reliable, ClPacket.CloseFunctionMenu);
+ player.Send(SvSendType.Self, Channel.Reliable, ClPacket.CloseFunctionMenu);
shPlayer.TransferItem(1, CommonIDs[0], 500, true);
- player.SendToSelf(Channel.Reliable, ClPacket.GameMessage, $"You have given yourself 500 pistol ammo.");
+ player.Send(SvSendType.Self, 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.Value.LastMenu = CurrentMenu.Main;
}
else if (item.Value.LastMenu == CurrentMenu.AdminReport && shPlayer.admin)
{
- player.SendToSelf(Channel.Reliable, ClPacket.CloseFunctionMenu);
+ player.Send(SvSendType.Self, Channel.Reliable, ClPacket.CloseFunctionMenu);
if (IsOnline.Run(item.Value.reportedPlayer))
{
shPlayer.SetPosition(item.Value.reportedPlayer.GetPosition());
- player.SendToSelf(Channel.Reliable, ClPacket.GameMessage, $"Teleported to \"{item.Value.reportedPlayer.username}\".");
+ player.Send(SvSendType.Self, Channel.Reliable, ClPacket.GameMessage, $"Teleported to \"{item.Value.reportedPlayer.username}\".");
}
else
- player.SendToSelf(Channel.Reliable, ClPacket.GameMessage, "Player not online anymore.");
+ player.Send(SvSendType.Self, Channel.Reliable, ClPacket.GameMessage, "Player not online anymore.");
item.Value.reportedPlayer = null;
item.Value.LastMenu = CurrentMenu.Main;
}
@@ -213,48 +214,48 @@ public static bool SvFunctionKey(SvPlayer player, ref byte key)
case 3:
if (item.Value.LastMenu == CurrentMenu.Staff && HasPermission.Run(player, AccessItemMenu))
{
- player.SendToSelf(Channel.Reliable, ClPacket.ShowFunctionMenu, "Give Items menu:\n\nF2: Give 500 Pistol Ammo\nF3: Give 20 Handcuffs\nF4: Give 10 Taser ammo\nF5: Give all Licenses\n\nPress F11 To close this (G)UI");
+ player.Send(SvSendType.Self, Channel.Reliable, ClPacket.ShowFunctionMenu, "Give Items menu:\n\nF2: Give 500 Pistol Ammo\nF3: Give 20 Handcuffs\nF4: Give 10 Taser ammo\nF5: Give all Licenses\n\nPress F11 To close this (G)UI");
item.Value.LastMenu = CurrentMenu.GiveItems;
}
else if (item.Value.LastMenu == CurrentMenu.GiveMoney)
{
- player.SendToSelf(Channel.Reliable, ClPacket.CloseFunctionMenu);
- shPlayer.TransferMoney(1, 10000, true);
- player.SendToSelf(Channel.Reliable, ClPacket.GameMessage, $"You have given yourself 10.000 dollars.");
+ player.Send(SvSendType.Self, Channel.Reliable, ClPacket.CloseFunctionMenu);
+ shPlayer.TransferMoney(DeltaInv.AddToMe, 10000, true);
+ player.Send(SvSendType.Self, 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.Value.LastMenu = CurrentMenu.Main;
return true;
}
else if (item.Value.LastMenu == CurrentMenu.GiveItems)
{
- player.SendToSelf(Channel.Reliable, ClPacket.CloseFunctionMenu);
+ player.Send(SvSendType.Self, Channel.Reliable, ClPacket.CloseFunctionMenu);
shPlayer.TransferItem(1, CommonIDs[1], 20, true);
- player.SendToSelf(Channel.Reliable, ClPacket.GameMessage, $"You have given yourself 20 handcuffs.");
+ player.Send(SvSendType.Self, 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.Value.LastMenu = CurrentMenu.Main;
return true;
}
else if (item.Value.LastMenu == CurrentMenu.AdminReport && shPlayer.admin)
{
- player.SendToSelf(Channel.Reliable, ClPacket.CloseFunctionMenu);
+ player.Send(SvSendType.Self, Channel.Reliable, ClPacket.CloseFunctionMenu);
item.Value.LastMenu = CurrentMenu.Main;
return true;
}
if (item.Value.LastMenu == CurrentMenu.Main)
{
- player.SendToSelf(Channel.Reliable, ClPacket.ShowFunctionMenu, "Server info menu:\n\nF2: Show rules\nF3: Show admins\n\nPress F11 To close this (G)UI");
+ player.Send(SvSendType.Self, Channel.Reliable, ClPacket.ShowFunctionMenu, "Server info menu:\n\nF2: Show rules\nF3: Show admins\n\nPress F11 To close this (G)UI");
item.Value.LastMenu = CurrentMenu.ServerInfo;
}
else if (item.Value.LastMenu == CurrentMenu.ServerInfo)
{
- player.SendToSelf(Channel.Reliable, ClPacket.CloseFunctionMenu);
+ player.Send(SvSendType.Self, Channel.Reliable, ClPacket.CloseFunctionMenu);
var builder = new StringBuilder();
builder.Append("All admins on this server:\n\n");
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, ClPacket.ServerInfo, builder.ToString());
+ player.Send(SvSendType.Self, Channel.Fragmented, ClPacket.ServerInfo, builder.ToString());
item.Value.LastMenu = CurrentMenu.Main;
}
@@ -262,33 +263,33 @@ public static bool SvFunctionKey(SvPlayer player, ref byte key)
case 4:
if (item.Value.LastMenu == CurrentMenu.GiveMoney)
{
- item.Value.shplayer.TransferMoney(1, 100000, true);
- player.SendToSelf(Channel.Reliable, ClPacket.GameMessage, $"You have given yourself 100.000 dollars.");
+ item.Value.shplayer.TransferMoney(DeltaInv.AddToMe, 100000, true);
+ player.Send(SvSendType.Self, 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.Value.LastMenu = CurrentMenu.Main;
}
else if (item.Value.LastMenu == CurrentMenu.Staff && HasPermission.Run(player, AccessSetHPMenu))
{
player.Heal(100);
- player.SendToSelf(Channel.Reliable, ClPacket.GameMessage, $"You've been healed.");
+ player.Send(SvSendType.Self, Channel.Reliable, ClPacket.GameMessage, $"You've been healed.");
Debug.Log(SetTimeStamp.Run() + "[INFO] " + player.playerData.username + " healed himself through the functionUI");
item.Value.LastMenu = CurrentMenu.Main;
}
else if (item.Value.LastMenu == CurrentMenu.GiveItems)
{
- player.SendToSelf(Channel.Reliable, ClPacket.CloseFunctionMenu);
+ player.Send(SvSendType.Self, Channel.Reliable, ClPacket.CloseFunctionMenu);
shPlayer.TransferItem(1, CommonIDs[2], ClPacket.GameMessage, true);
- player.SendToSelf(Channel.Reliable, ClPacket.GameMessage, $"You have given yourself 10 Taser ammo.");
+ player.Send(SvSendType.Self, 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.Value.LastMenu = CurrentMenu.Main;
}
- player.SendToSelf(Channel.Reliable, ClPacket.CloseFunctionMenu);
+ player.Send(SvSendType.Self, Channel.Reliable, ClPacket.CloseFunctionMenu);
break;
case 5:
if (item.Value.LastMenu == CurrentMenu.Staff && HasPermission.Run(player, AccessSetStatsMenu))
{
- player.UpdateStats(100f, 100f, 100f, 100f);
- player.SendToSelf(Channel.Reliable, ClPacket.GameMessage, $"Maxed out stats for yourself.");
+ player.UpdateStats(100F, 100F, 100F, 100F);
+ player.Send(SvSendType.Self, Channel.Reliable, ClPacket.GameMessage, $"Maxed out stats for yourself.");
Debug.Log(SetTimeStamp.Run() + "[INFO] " + player.playerData.username + " Maxed out stats through the functionUI");
item.Value.LastMenu = CurrentMenu.Main;
}
@@ -296,24 +297,24 @@ 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, ClPacket.GameMessage, $"You have given yourself all licenses.");
+ player.Send(SvSendType.Self, 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.Value.LastMenu = CurrentMenu.Main;
}
- player.SendToSelf(Channel.Reliable, ClPacket.CloseFunctionMenu);
+ player.Send(SvSendType.Self, Channel.Reliable, ClPacket.CloseFunctionMenu);
break;
case 6:
if (item.Value.LastMenu == CurrentMenu.Staff && HasPermission.Run(player, AccessCWMenu))
{
shPlayer.ClearCrimes();
- player.SendToSelf(Channel.Reliable, 33, shPlayer.ID);
- player.SendToSelf(Channel.Reliable, ClPacket.GameMessage, $"Cleared wanted level.");
+ player.Send(SvSendType.Self, Channel.Reliable, 33, shPlayer.ID);
+ player.Send(SvSendType.Self, Channel.Reliable, ClPacket.GameMessage, $"Cleared wanted level.");
Debug.Log(SetTimeStamp.Run() + "[INFO] " + player.playerData.username + " Removed his wantedlevel through the functionUI");
item.Value.LastMenu = CurrentMenu.Main;
}
- player.SendToSelf(Channel.Reliable, ClPacket.CloseFunctionMenu);
+ player.Send(SvSendType.Self, Channel.Reliable, ClPacket.CloseFunctionMenu);
break;
case 10:
if (item.Value.LastMenu == CurrentMenu.Main)
@@ -330,7 +331,7 @@ public static bool SvFunctionKey(SvPlayer player, ref byte key)
sb.Append("F5: Set Stats to full\n");
if (HasPermission.Run(player, AccessCWMenu))
sb.Append("F6: Clear wanted level\n\n");
- player.SendToSelf(Channel.Reliable, ClPacket.ShowFunctionMenu, $"{sb}Press F11 To close this (G)UI");
+ player.Send(SvSendType.Self, Channel.Reliable, ClPacket.ShowFunctionMenu, $"{sb}Press F11 To close this (G)UI");
item.Value.LastMenu = CurrentMenu.Staff;
}
break;
@@ -342,7 +343,7 @@ public static bool SvFunctionKey(SvPlayer player, ref byte key)
foreach (KeyValuePair item in playerList)
if (item.Value.shplayer.svPlayer == player)
item.Value.LastMenu = CurrentMenu.Main;
- player.SendToSelf(Channel.Reliable, ClPacket.CloseFunctionMenu);
+ player.Send(SvSendType.Self, Channel.Reliable, ClPacket.CloseFunctionMenu);
}
catch (Exception ex)
{
@@ -357,13 +358,13 @@ public static bool SvSuicide(SvPlayer player)
if (player.IsServerside())
return true;
- var shPlayer = GetShBySv.Run(player);
+ var shPlayer = player.player;
if (shPlayer.IsDead())
return true;
shPlayer.ShDie();
- player.SendToLocal(Channel.Reliable, ClPacket.UpdateHealth, shPlayer.ID, shPlayer.health);
+ player.Send(SvSendType.Local, Channel.Reliable, ClPacket.UpdateHealth, shPlayer.ID, shPlayer.health);
return true;
}
[Hook("SvPlayer.SvGetJob")]
@@ -371,12 +372,12 @@ public static bool SvGetJob(SvPlayer player, ref int employerID)
{
try
{
- var shPlayer = GetShBySv.Run(player);
+ var shPlayer = player.player;
var shEmployer = shPlayer.manager.FindByID(employerID);
if (WhitelistedJobs.ContainsKey(shEmployer.job.jobIndex))
if (!HasPermission.Run(player, WhitelistedJobs[shEmployer.job.jobIndex], false, shPlayer.job.jobIndex))
{
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, MsgNoPermJob);
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, MsgNoPermJob);
return true;
}
return false;
@@ -408,7 +409,7 @@ public static bool TransferItem(ShPlayer player, ref byte deltaType, ref int ite
{
if (player != null && BlockedItems.Count > 0 && BlockedItems.Contains(itemIndex))
{
- player.svPlayer.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, BlockedItemMessage);
+ player.svPlayer.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, BlockedItemMessage);
return true;
}
}
@@ -418,5 +419,41 @@ public static bool TransferItem(ShPlayer player, ref byte deltaType, ref int ite
}
return false;
}
+
+
+ [Hook("ShPlayer.RemoveItemsDeath")]
+ public static bool RemoveItemsDeath(ShPlayer player)
+ {
+ if (!blockLicenseRemoved)
+ return false;
+ foreach (InventoryItem inventoryItem in player.myItems.Values.ToArray())
+ {
+ if (blockLicenseRemoved && inventoryItem.item.name.StartsWith("License"))
+ continue;
+ int extraCount = GetExtraCount.Run(player, inventoryItem);
+ if (extraCount > 0)
+ {
+ var shWearable = inventoryItem.item as ShWearable;
+ if (!shWearable || shWearable.illegal || player.curWearables[(int)shWearable.type].index != shWearable.index)
+ player.TransferItem(2, inventoryItem.item.index, extraCount, true);
+ }
+ }
+ if (blockLicenseRemoved)
+ player.svPlayer.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"This server disabled losing licenses on death.");
+ return true;
+ }
+
+ [Hook("ShMovable.ShDie")]
+ public static void ShDie(ShMovable shMoveable)
+ {
+ shMoveable.CleanUp();
+ shMoveable.ResetInputs();
+ shMoveable.health = 0f;
+ if (shMoveable.manager.isServer)
+ if (!shMoveable.svEntity.respawnable)
+ shMoveable.Destroy();
+ else
+ shMoveable.StartCoroutine(shMoveable.svMovable.RespawnDelay());
+ }
}
}
\ No newline at end of file
diff --git a/source/BP-Essentials/EssentialsVariables.cs b/source/BP-Essentials/EssentialsVariables.cs
index f6592d46..b5ad2605 100644
--- a/source/BP-Essentials/EssentialsVariables.cs
+++ b/source/BP-Essentials/EssentialsVariables.cs
@@ -1,18 +1,20 @@
using System;
using System.Collections.Generic;
-using System.Linq;
-using System.Text;
+using System.IO;
+using UnityEngine;
namespace BP_Essentials
{
public class EssentialsVariablesPlugin : EssentialsCorePlugin
{
- public const string Version = "2.5.2";
- public const bool isPreRelease = false;
+ public const string Version = "2.5.3";
+ public static bool isPreRelease;
// Generic Constants
public const string FileDirectory = "Essentials/";
- public const string LogDirectory = FileDirectory + "logs/";
+
+ public static string LogDirectory = Path.Combine(FileDirectory, "logs/");
+ public static string KitDirectory = Path.Combine(FileDirectory, "kits/");
public const string SettingsFile = FileDirectory + "essentials_settings.txt";
public const string LanguageBlockFile = FileDirectory + "languageblock.txt";
@@ -25,18 +27,21 @@ public class EssentialsVariablesPlugin : EssentialsCorePlugin
public const string ExceptionFile = FileDirectory + "exceptions.txt";
public const string CustomCommandsFile = FileDirectory + "CustomCommands.txt";
public const string CustomGroupsFile = FileDirectory + "CustomGroups.txt";
- public const string IdListFile = FileDirectory + "ID_list.txt";
+ public const string IdListItemsFile = FileDirectory + "ID_list-Items.txt";
+ public const string IdListVehicleFile = FileDirectory + "ID_list-Vehicles.txt";
+
+ public const string AutoReloader = FileDirectory + "autoReloader.txt";
public const string AdminListFile = "admin_list.txt";
public const string RulesFile = "server_info.txt";
public const string BansFile = "ban_list.txt";
-
- public const string LogFile = LogDirectory + "all.txt";
- public const string ChatLogFile = LogDirectory + "chat.txt";
- public const string CommandLogFile = LogDirectory + "commands.txt";
+ public static readonly string LogFile = Path.Combine(LogDirectory, "all.txt");
+ public static readonly string ChatLogFile = Path.Combine(LogDirectory, "chat.txt");
+ public static readonly string CommandLogFile = Path.Combine(LogDirectory, "commands.txt");
// Bools
public static bool MsgUnknownCommand;
+
public static bool ChatBlock;
public static bool LanguageBlock;
public static bool CheckAlt;
@@ -49,12 +54,15 @@ public class EssentialsVariablesPlugin : EssentialsCorePlugin
public static bool ShowDMGMessage;
public static bool VoteKickDisabled;
public static bool DownloadIdList;
- public static bool EnableDiscordWebhook;
+ public static bool EnableDiscordWebhook_Ban;
+ public static bool EnableDiscordWebhook_Report;
public static bool BlockBanButtonTabMenu;
public static bool CheckBannedEnabled;
+ public static bool blockLicenseRemoved;
// Lists
public static List CustomCommands = new List();
+
public static List Responses = new List();
public static List ChatBlockWords = new List();
public static List LanguageBlockWords = new List();
@@ -65,13 +73,31 @@ public class EssentialsVariablesPlugin : EssentialsCorePlugin
public static List LatestVotePeople = new List();
public static List BlockedItems = new List();
+ public static List listKits = new List();
// Arrays
public static string[] Announcements;
- public static readonly string[] Jobs = { "Citizen", "Criminal", "Prisoner", "Police", "Paramedic", "Firefighter", "Gangster: Red", "Gangster: Green", "Gangster: Blue", "Mayor", "DeliveryDriver", "TaxiDriver", "Special Forces" };
+
+ public static string[] Jobs = {
+ // default values
+ "Citizen",
+ "Criminal",
+ "Prisoner",
+ "Police",
+ "Paramedic",
+ "Firefighter",
+ "Gangster: Red",
+ "Gangster: Green",
+ "Gangster: Blue",
+ "Mayor",
+ "DeliveryDriver",
+ "TaxiDriver",
+ "Special Forces"
+ };
// Messages
public static string MsgSayPrefix;
+
public static string MsgNoPerm;
public static string MsgNoPermJob;
public static string MsgDiscord;
@@ -88,8 +114,10 @@ public class EssentialsVariablesPlugin : EssentialsCorePlugin
public static string BlockedItemMessage;
public static string infoColor, errorColor, warningColor, argColor;
+
// Strings
public static string Rules;
+
public static string DisabledSpawnBots;
public static string LocalVersion;
public static string MsgSayColor;
@@ -102,17 +130,21 @@ public class EssentialsVariablesPlugin : EssentialsCorePlugin
public static string CmdStaffChatExecutableBy;
public static string CmdConfirm;
public static string CmdToggleChat;
- public static string DiscordWebhook;
+ public static string DiscordWebhook_Ban;
+ public static string DiscordWebhook_Report;
// Ints
public const int SaveTime = 5 * 60;
+
public static int AnnounceIndex;
public static int TimeBetweenAnnounce;
public static int[] BlockedSpawnIds;
public static int DebugLevel;
public static int GodModeLevel;
+
// Misc.
public static string _msg;
+
public static string username;
public static string TimestampFormat;
public const string CensoredText = "******";
@@ -123,6 +155,33 @@ public class EssentialsVariablesPlugin : EssentialsCorePlugin
public static Dictionary WhitelistedJobs = new Dictionary();
public static System.Timers.Timer _Timer = new System.Timers.Timer();
public static SvManager SvMan;
+
+ public static Dictionary PlaceDictionary = new Dictionary
+ {
+ { new[] { "1", "PoliceStation", "Police Station" }, new Vector3(-17.0F, 0.0F, 46.0F) },
+ { new[] { "2", "FireStation", "Fire Station" }, new Vector3(173.0F, 0.0F, 237.0F)},
+ { new[] { "3", "Hospital", "Ambulance Station" }, new Vector3(111.0F, 0.0F, 148.0F)},
+ { new[] { "4", "GunShop", "Gun Shop", "ammunition" }, new Vector3(55.0F, 0.0F, 112.0F) },
+ { new[] { "5", "ElectronicsShop", "Electronics Shop" }, new Vector3(567.0F, 0.0F, -92.0F) },
+ { new[] { "6", "PawnShop", "Pawn Shop" }, new Vector3(448.0F, 0.0F, -203.0F) },
+ { new[] { "7", "FastFoodShop", "Fast Food Shop" }, new Vector3(645.0F, 0.0F, -168.0F) },
+ { new[] { "8", "CoffeeShop", "Coffee Shop" }, new Vector3(618.0F, 0.0F, 148.0F) },
+ { new[] { "9", "ClothingShop", "Clothing Shop" }, new Vector3(595.0F, 0.0F, 81.0F) },
+ { new[] { "10", "GreenGang", "Green St. Fam Boss" }, new Vector3(32.0F, 0.0F, -202.0F) },
+ { new[] { "11", "BlueGang", "Borgata Blue Boss" }, new Vector3(504.0F, 0.0F, 23.0F) },
+ { new[] { "12", "RedGang", "Rojo Loco Boss" }, new Vector3(521.0F, 0.0F, 199.0F) },
+ { new[] { "13", "10k", "Large Apartment" }, new Vector3(2.0F, 0.0F, -92.0F) },
+ { new[] { "14", "5k", "Medium Apartment" }, new Vector3(519.0F, 0.0F, -125.0F) },
+ { new[] { "15", "1.2k", "Small Apartment" }, new Vector3(643.0F, 0.0F, -61.0F) },
+ { new[] { "16", "DeliveryJob", "Delivery Job" }, new Vector3(64.0F, 0.0F, -92.0F) },
+ { new[] { "17", "TaxiJob", "Taxi Job" }, new Vector3(-232.0F, 0.0F, 87.0F) },
+ { new[] { "18", "TownHall", "Town Hall", "Mayor", "MayorOffice" }, new Vector3(127.0F, 0.0F, -56.0F) },
+ { new[] { "19", "Bank" }, new Vector3(447.0F, 0.0F, -23.0F) },
+ { new[] { "20", "DrugDealer", "Drug Dealer" }, new Vector3(288.0F, 0.0F, -236.0F) },
+ { new[] { "21", "SpecOps", "Spec Ops Job", "MilitaryBase", "Military Base" }, new Vector3(654.0F, 0.0F, 278.0F) },
+ { new[] { "22", "Bomb", "BombLocation", "Bomb Location" }, new Vector3(1010.0F, 0.0F, 401.0F) }
+ };
+
public static string[] ReportReasons =
{
// default values
@@ -136,6 +195,7 @@ public class EssentialsVariablesPlugin : EssentialsCorePlugin
"Bullying, Harrasing, or Discriminating someone",
"Alternative account's (alts)"
};
+
public static int[] CommonIDs =
{
// need a better way of doing this
@@ -147,8 +207,51 @@ public class EssentialsVariablesPlugin : EssentialsCorePlugin
499504400, //License Gun
607710552 //License Pilots
};
+
#region ID LIST
- public static int[] IDs = {
+ public static int[] IDs_Vehicles = {
+0, // you don't want to use ID 0
+-161239262, //Apache1
+1869282968, //Apache2
+409849358, //Apache3
+-1511445516, //SmallHelo1
+1021344334, //SmallHelo2
+1273449176, //SmallHelo3
+-724826434, //Boat1
+1304778500, //Boat2
+985819026, //Boat3
+1510028342, //ArmyFuel1
+-1022859892, //ArmyFuel2
+-1274063590, //ArmyFuel3
+-1389915498, //Car1
+875479852, //Car2
+1126822842, //Car3
+1629858698, //CarPizza
+-1372418684, //Hatchback1
+926669886, //Hatchback2
+1077734568, //Hatchback3
+-1892890957, //Pickup1
+371562249, //Pickup2
+1629661087, //Pickup3
+-1852539457, //SportsCar1
+144518149, //SportsCar2
+2140806291, //SportsCar3
+-1840453330, //StairTruck
+800352739, //SUV1
+-1229113255, //SUV2
+-1044772657, //SUV3
+-4797188, //Taxi
+1696421938, //TowTractor
+-701513985, //TroopCar1
+1327951685, //TroopCar2
+941744083, //TroopCar3
+748120166, //Van1
+-1247921700, //Van2
+-1030158006, //Van3
+ };
+
+
+ public static int[] IDs_Items = {
0, // you don't want to use ID 0
-2081117539, //FireExtinguisher
-1490613521, //FireHose
@@ -912,7 +1015,28 @@ public class EssentialsVariablesPlugin : EssentialsCorePlugin
-890140811, //TopSheriff
};
- #endregion
+ #endregion ID LIST
+ }
+ public class Kits_Json
+ {
+ public class Kits_Item
+ {
+ public int Id { get; set; }
+ public int Amount { get; set; }
+ }
+ public class Kits_RootObj
+ {
+ public Kits_RootObj() {
+ Items = new List();
+ CurrentlyInCooldown = new Dictionary();
+ }
+ public string Name { get; set; }
+ public int Delay { get; set; }
+ public string ExecutableBy { get; set; }
+ public bool Disabled { get; set; }
+ public List Items { get; set; }
+ public Dictionary CurrentlyInCooldown { get; set; }
+ }
}
public class _CommandList
{
@@ -922,6 +1046,7 @@ public class _CommandList
public string commandGroup;
public string commandName;
}
+
public class _PlayerList
{
public ShPlayer shplayer { get; set; }
diff --git a/source/BP-Essentials/GlobalSuppressions.cs b/source/BP-Essentials/GlobalSuppressions.cs
index 769e1619..98346f44 100644
--- a/source/BP-Essentials/GlobalSuppressions.cs
+++ b/source/BP-Essentials/GlobalSuppressions.cs
@@ -36,4 +36,5 @@
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "CC0037:Remove commented code.", Justification = "", Scope = "member", Target = "~M:BP_Essentials.SendDiscordMessage.Run(System.String)")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CC0057:Unused parameters", Justification = "", Scope = "member", Target = "~M:BP_Essentials.EssentialsMethodsPlugin.HitEffect(ShRestraint,ShEntity@,ShPlayer@,UnityEngine.Collider@)~System.Boolean")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CC0057:Unused parameters", Justification = "", Scope = "member", Target = "~M:BP_Essentials.EssentialsMethodsPlugin.SvAddCrime(SvPlayer,System.Byte@,ShEntity@)~System.Boolean")]
+[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CC0022:Should dispose object", Justification = "", Scope = "member", Target = "~M:BP_Essentials.CheckAutoReloadFile.Run(System.String)")]
diff --git a/source/BP-Essentials/Methods/API/DownloadAndWriteToFile.cs b/source/BP-Essentials/Methods/API/DownloadAndWriteToFile.cs
new file mode 100644
index 00000000..69ad5f2d
--- /dev/null
+++ b/source/BP-Essentials/Methods/API/DownloadAndWriteToFile.cs
@@ -0,0 +1,31 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using UnityEngine;
+using static BP_Essentials.EssentialsVariablesPlugin;
+using static BP_Essentials.EssentialsMethodsPlugin;
+using System.IO;
+using System.Net;
+using System.Collections;
+
+namespace BP_Essentials
+{
+ class DownloadAndWriteToFile : EssentialsChatPlugin
+ {
+ public static void Run(string fileName, string websiteLink)
+ {
+ var output = DownloadFile.Run(websiteLink);
+ if (output != null)
+ File.WriteAllText(fileName, output);
+ }
+ public static void Run(string fileName, string websiteLink, Action callback)
+ {
+ SvMan.StartCoroutine(DownloadFile.Run(websiteLink, new Action((output) => {
+ if (output != null)
+ File.WriteAllText(fileName, output);
+ callback?.Invoke(output != null);
+ })));
+ }
+ }
+}
diff --git a/source/BP-Essentials/Methods/API/DownloadFile.cs b/source/BP-Essentials/Methods/API/DownloadFile.cs
index d9a58a36..6664b8d3 100644
--- a/source/BP-Essentials/Methods/API/DownloadFile.cs
+++ b/source/BP-Essentials/Methods/API/DownloadFile.cs
@@ -7,11 +7,14 @@
using static BP_Essentials.EssentialsMethodsPlugin;
using System.IO;
using System.Net;
+using System.Collections;
namespace BP_Essentials
{
class DownloadFile : EssentialsChatPlugin
{
+ // Redo method(s)
+
public static string Run(string DownloadLink)
{
using (WebClient client = new WebClient())
@@ -21,5 +24,22 @@ public static string Run(string DownloadLink)
return reader.ReadToEnd();
}
}
+
+
+ public static IEnumerator Run(string link, Action callback)
+ {
+ using (var www = new WWW(link))
+ {
+ yield return www;
+ if (www.error != null)
+ {
+ Debug.Log($"{SetTimeStamp.Run()}[ERROR] {link} responded with HTTP error code: {www.error}!");
+ callback?.Invoke(null);
+ yield break;
+ }
+ callback?.Invoke(www.text);
+ yield break;
+ }
+ }
}
}
diff --git a/source/BP-Essentials/Methods/API/GetArgument.cs b/source/BP-Essentials/Methods/API/GetArgument.cs
index 40625395..1370e8d9 100644
--- a/source/BP-Essentials/Methods/API/GetArgument.cs
+++ b/source/BP-Essentials/Methods/API/GetArgument.cs
@@ -21,29 +21,34 @@ public static string Run(int nr, bool UseRegex, bool IncludeSpaces, string messa
.Cast()
.Select(m => m.Value)
.ToList();
-
return args[nr];
}
else
{
if (IncludeSpaces)
{
- string tmessage = message + " ";
- string[] args = tmessage.Split(' ');
- return tmessage.IndexOf(args[nr]) != 0 ? tmessage.Substring(tmessage.IndexOf(args[nr])).TrimEnd() : string.Empty;
+ message = message.Trim();
+ if (nr == 0)
+ return message;
+ if (!message.Contains(" "))
+ return "";
+ var args = message.Split(' ');
+ if (nr > args.Length)
+ return "";
+ return message.Substring(message.IndexOf(args[nr])).TrimEnd();
}
else
{
- string tmessage = message + " ";
- string[] args = tmessage.Split(' ');
- return nr < args.Length ? args[nr] : string.Empty;
+ var args = message.Trim().Split(' ');
+ if (nr > args.Length - 1)
+ return "";
+ return args[nr];
}
}
}
- catch (Exception ex)
+ catch (Exception)
{
- ErrorLogging.Run(ex);
- return null;
+ return "";
}
}
}
diff --git a/source/BP-Essentials/Methods/API/GetPlaceHolders.cs b/source/BP-Essentials/Methods/API/GetPlaceHolders.cs
index 846ae9a6..63658385 100644
--- a/source/BP-Essentials/Methods/API/GetPlaceHolders.cs
+++ b/source/BP-Essentials/Methods/API/GetPlaceHolders.cs
@@ -14,7 +14,7 @@ public static string Run(string str, SvPlayer player)
{
try
{
- var shPlayer = GetShBySv.Run(player);
+ var shPlayer = player.player;
var src = DateTime.Now;
var hm = new DateTime(src.Year, src.Month, src.Day, src.Hour, src.Minute, src.Second);
var placeHolderText = str;
@@ -46,7 +46,7 @@ public static string Run(string str, SvPlayer player)
if (str.ToLower().Contains("{id}"))
placeHolderText = placeHolderText.Replace("{id}", $"{shPlayer.ID}");
if (str.ToLower().Contains("{jobname}"))
- placeHolderText = placeHolderText.Replace("{jobname}", shPlayer.job.info.jobName);
+ placeHolderText = placeHolderText.Replace("{jobname}", Jobs[shPlayer.job.jobIndex]);
if (str.ToLower().Contains("{jobindex}"))
placeHolderText = placeHolderText.Replace("{jobindex}", $"{shPlayer.job.jobIndex}");
diff --git a/source/BP-Essentials/Methods/API/GetShByStr.cs b/source/BP-Essentials/Methods/API/GetShByStr.cs
index ce760f8b..2a726256 100644
--- a/source/BP-Essentials/Methods/API/GetShByStr.cs
+++ b/source/BP-Essentials/Methods/API/GetShByStr.cs
@@ -14,7 +14,7 @@ public static ShPlayer Run(string player, bool idOnly = false)
{
try
{
- foreach (var shPlayer in UnityEngine.Object.FindObjectsOfType())
+ foreach (var shPlayer in SvMan.players.Values)
if ((shPlayer.ID.ToString() == player || shPlayer.username == player) && !idOnly || shPlayer.ID.ToString() == player && idOnly)
return shPlayer;
return null;
diff --git a/source/BP-Essentials/Methods/API/GetShBySv.cs b/source/BP-Essentials/Methods/API/GetShBySv.cs
deleted file mode 100644
index ca7d18fb..00000000
--- a/source/BP-Essentials/Methods/API/GetShBySv.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-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 1f24b0ca..d0b87efa 100644
--- a/source/BP-Essentials/Methods/API/HasPermission.cs
+++ b/source/BP-Essentials/Methods/API/HasPermission.cs
@@ -25,7 +25,7 @@ public static bool Run(SvPlayer player, string ExeBy, bool ShowNoPermMessage = f
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, ClPacket.GameMessage, $"{MsgNoPerm}");
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"{MsgNoPerm}");
return false;
}
}
diff --git a/source/BP-Essentials/Methods/API/SendDiscordMessage.cs b/source/BP-Essentials/Methods/API/SendDiscordMessage.cs
index e61a143d..7ee19433 100644
--- a/source/BP-Essentials/Methods/API/SendDiscordMessage.cs
+++ b/source/BP-Essentials/Methods/API/SendDiscordMessage.cs
@@ -16,16 +16,16 @@ namespace BP_Essentials
{
class SendDiscordMessage : MonoBehaviour
{
- public static void Run(string json)
+ public static void Run(string json, string link, bool enabled)
{
try
{
- if (!EnableDiscordWebhook)
+ if (!enabled)
return;
if (DebugLevel >= 2)
- Debug.Log($"{SetTimeStamp.Run()}[INFO] Creating POST request to {DiscordWebhook}");
+ Debug.Log($"{SetTimeStamp.Run()}[INFO] Creating POST request to {link}");
var formData = Encoding.UTF8.GetBytes(json);
- var www = new WWW(DiscordWebhook, formData);
+ var www = new WWW(link, formData);
SvMan.StartCoroutine(WaitForRequest(www));
if (DebugLevel >= 2)
Debug.Log($"{SetTimeStamp.Run()}[INFO] Post request sent!");
@@ -35,6 +35,13 @@ public static void Run(string json)
ErrorLogging.Run(ex);
}
}
+ public static void ReportMessage(string username, string issuer, string reason)
+ {
+ var fUsername = JsonConvert.ToString(username);
+ var fIssuer = JsonConvert.ToString(issuer);
+ var fReason = JsonConvert.ToString(reason);
+ Run(@"{ ""username"":""BP-Essentials Report Log"", ""avatar_url"":""https://i.imgur.com/ckuPXOH.jpg"", ""embeds"":[ {""title"":""New report AutoLogger"",""description"":""\u200B"",""color"":3837400,""timestamp"":""2018-06-23T12:26:09.635Z"",""footer"":{""text"":""BP-Essentials""},""fields"":[{""name"":""Username"",""value"":" + fUsername + @"},{""name"":""Issuer"",""value"":" + fIssuer + @"},{""name"":""Reason"",""value"":" + fReason + @"},{""name"":""Date (UTC)"",""value"":""" + DateTime.UtcNow + @"""}]}] }", DiscordWebhook_Report, EnableDiscordWebhook_Report);
+ }
public static void BanMessage(string username, string issuer)
{
BanMessage(username, issuer, "No reason provided. (Used tab menu)");
@@ -44,13 +51,13 @@ public static void BanMessage(string username, string issuer, string banReason)
var fUsername = JsonConvert.ToString(username);
var fIssuer = JsonConvert.ToString(issuer);
var fReason = JsonConvert.ToString(banReason);
- Run(@"{ ""username"":""BP-Essentials Ban Log"", ""avatar_url"":""https://i.imgur.com/ckuPXOH.jpg"", ""embeds"":[ {""title"":""New ban AutoLogger"",""description"":""\u200B"",""color"":3837400,""timestamp"":""2018-06-23T12:26:09.635Z"",""footer"":{""text"":""BP-Essentials""},""fields"":[{""name"":""Username"",""value"":" + fUsername + @"},{""name"":""Issuer"",""value"":" + fIssuer + @"},{""name"":""Reason"",""value"":" + fReason + @"},{""name"":""Date (UTC)"",""value"":""" + DateTime.UtcNow + @"""}]}] }");
+ Run(@"{ ""username"":""BP-Essentials Ban Log"", ""avatar_url"":""https://i.imgur.com/ckuPXOH.jpg"", ""embeds"":[ {""title"":""New ban AutoLogger"",""description"":""\u200B"",""color"":3837400,""timestamp"":""2018-06-23T12:26:09.635Z"",""footer"":{""text"":""BP-Essentials""},""fields"":[{""name"":""Username"",""value"":" + fUsername + @"},{""name"":""Issuer"",""value"":" + fIssuer + @"},{""name"":""Reason"",""value"":" + fReason + @"},{""name"":""Date (UTC)"",""value"":""" + DateTime.UtcNow + @"""}]}] }", DiscordWebhook_Ban, EnableDiscordWebhook_Ban);
}
static IEnumerator WaitForRequest(WWW www)
{
yield return www;
if (DebugLevel >= 2)
- Debug.Log($"{SetTimeStamp.Run()}[INFO] Post request response received: {(www.error ?? www.text)}");
+ Debug.Log($"{SetTimeStamp.Run()}[INFO] Post request response received: {(www.error ?? $"[HTTP-ERROR] {www.text}")}");
www.Dispose();
}
}
diff --git a/source/BP-Essentials/Methods/API/StringToVar.cs b/source/BP-Essentials/Methods/API/StringToVar.cs
deleted file mode 100644
index d3a4f40d..00000000
--- a/source/BP-Essentials/Methods/API/StringToVar.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-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 StringToVar : EssentialsChatPlugin
- {
- public static void Run(string s, string cmd1, string cmd2 = null, string ExeBy = null, bool? Disabled = null)
- {
- try
- {
- typeof(EssentialsVariablesPlugin).GetField(@"Cmd" + s).SetValue("Cmd" + s, CmdCommandCharacter + cmd1);
- if (!string.IsNullOrEmpty(cmd2))
- typeof(EssentialsVariablesPlugin).GetField(@"Cmd" + s + "2").SetValue("Cmd" + s + "2", CmdCommandCharacter + cmd2);
- if (!string.IsNullOrEmpty(ExeBy))
- typeof(EssentialsVariablesPlugin).GetField(@"Cmd" + s + "ExecutableBy").SetValue("Cmd" + s + "ExecutableBy", ExeBy);
- if (!string.IsNullOrEmpty(Disabled.ToString()))
- typeof(EssentialsVariablesPlugin).GetField(@"Cmd" + s + nameof(Disabled)).SetValue("Cmd" + s + nameof(Disabled), Disabled);
- }
- catch (Exception ex)
- {
- ErrorLogging.Run(ex);
- }
- }
- }
-}
diff --git a/source/BP-Essentials/Methods/Check/CheckAltAcc.cs b/source/BP-Essentials/Methods/Check/CheckAltAcc.cs
index d04868c4..62684f1d 100644
--- a/source/BP-Essentials/Methods/Check/CheckAltAcc.cs
+++ b/source/BP-Essentials/Methods/Check/CheckAltAcc.cs
@@ -16,21 +16,15 @@ public static void Run(SvPlayer player)
{
if (CheckAlt)
{
- Thread.Sleep(3000);
try
{
+ Thread.Sleep(3000);
if (!string.IsNullOrEmpty(player.playerData.username.Trim()))
- if (File.ReadAllText(BansFile).Contains(player.svManager.GetAddress(player.connection)))
+ if (!player.player.admin && File.ReadAllText(IpListFile).Contains(player.svManager.GetAddress(player.connection)))
{
- Debug.Log(SetTimeStamp.Run() + "[WARNING] " + player.playerData.username + " Joined with a possible alt! IP: " + player.svManager.GetAddress(player.connection));
- foreach (var shPlayer in FindObjectsOfType())
- if (shPlayer.svPlayer == player)
- if (!shPlayer.svPlayer.IsServerside())
- {
- player.svManager.AddBanned(shPlayer);
- player.svManager.Disconnect(player.connection);
- }
-
+ Debug.Log($"{SetTimeStamp.Run()}[WARNING] {player.player.username} Joined with a possible alt! IP: {player.svManager.GetAddress(player.connection)}");
+ player.svManager.AddBanned(player.player);
+ player.svManager.Disconnect(player.connection);
}
}
catch (Exception ex)
diff --git a/source/BP-Essentials/Methods/Check/CheckBanned.cs b/source/BP-Essentials/Methods/Check/CheckBanned.cs
index 29d6e26e..3155cac6 100644
--- a/source/BP-Essentials/Methods/Check/CheckBanned.cs
+++ b/source/BP-Essentials/Methods/Check/CheckBanned.cs
@@ -19,25 +19,14 @@ public static void Run(SvPlayer player)
try
{
Thread.Sleep(3000);
- if (!string.IsNullOrEmpty(player.svManager.GetAddress(player.connection).Trim()))
+ if (!player.player.admin && !string.IsNullOrEmpty(player.svManager.GetAddress(player.connection).Trim()))
foreach (var line in File.ReadAllLines(BansFile))
- {
if (line.StartsWith(player.playerData.username))
{
- Debug.Log(SetTimeStamp.Run() + "[WARNING] " + player.playerData.username + " Joined while banned! IP: " + player.svManager.GetAddress(player.connection));
- foreach (var shPlayer in UnityEngine.Object.FindObjectsOfType())
- {
- if (shPlayer.svPlayer == player)
- {
- if (!shPlayer.svPlayer.IsServerside())
- {
- player.svManager.AddBanned(shPlayer);
- player.svManager.Disconnect(player.connection);
- }
- }
- }
+ Debug.Log($"{SetTimeStamp.Run()}[WARNING] {player.player.username} Joined while banned! IP: {player.svManager.GetAddress(player.connection)}");
+ player.svManager.AddBanned(player.player);
+ player.svManager.Disconnect(player.connection);
}
- }
}
catch (Exception ex)
{
diff --git a/source/BP-Essentials/Methods/Check/CheckGodMode.cs b/source/BP-Essentials/Methods/Check/CheckGodMode.cs
index 371de7c5..eb02ed3e 100644
--- a/source/BP-Essentials/Methods/Check/CheckGodMode.cs
+++ b/source/BP-Essentials/Methods/Check/CheckGodMode.cs
@@ -17,9 +17,9 @@ public static bool Run(SvPlayer player, float? amount = null, string customMessa
if (GodListPlayers.Contains(player.playerData.username))
{
if (amount != null && ShowDMGMessage)
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"{amount} DMG Blocked!");
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"{amount} DMG Blocked!");
if (customMessage != null)
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, customMessage);
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, customMessage);
return true;
}
}
diff --git a/source/BP-Essentials/Methods/FileHandler/CheckAutoReloadFile.cs b/source/BP-Essentials/Methods/FileHandler/CheckAutoReloadFile.cs
new file mode 100644
index 00000000..7d5e2aa5
--- /dev/null
+++ b/source/BP-Essentials/Methods/FileHandler/CheckAutoReloadFile.cs
@@ -0,0 +1,37 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using UnityEngine;
+
+namespace BP_Essentials
+{
+ class CheckAutoReloadFile : EssentialsChatPlugin
+ {
+ public static void Run(string file)
+ {
+ try
+ {
+ var watcher = new FileSystemWatcher
+ {
+ Path = Path.GetDirectoryName(file),
+ Filter = Path.GetFileName(file),
+ NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite
+ | NotifyFilters.FileName | NotifyFilters.DirectoryName,
+ EnableRaisingEvents = true
+ };
+ watcher.Changed += new FileSystemEventHandler((sender, e) =>
+ {
+ Debug.Log($"{SetTimeStamp.Run()}[INFO] Found a change in file {file}, reloading all files...");
+ Debug.Log(" ");
+ Reload.Run(true);
+ });
+ }
+ catch (Exception ex)
+ {
+ ErrorLogging.Run(ex);
+ }
+ }
+ }
+}
diff --git a/source/BP-Essentials/Methods/FileHandler/CheckFiles.cs b/source/BP-Essentials/Methods/FileHandler/CheckFiles.cs
index f74dc627..578b1c15 100644
--- a/source/BP-Essentials/Methods/FileHandler/CheckFiles.cs
+++ b/source/BP-Essentials/Methods/FileHandler/CheckFiles.cs
@@ -11,118 +11,107 @@ namespace BP_Essentials
{
class CheckFiles : EssentialsChatPlugin
{
- public static void Run(string fileName)
+ public static void Run()
{
try
{
// this really needs some improvement
// I don't know when I added that comment but seriously I should really redo this method.. whenever I have time
- if (fileName == "all")
- {
- if (!Directory.Exists(FileDirectory))
- {
- Directory.CreateDirectory(FileDirectory);
- Debug.Log(FileDirectory + " Does not exist! Creating one.");
- }
- if (!Directory.Exists(LogDirectory))
- {
- Directory.CreateDirectory(LogDirectory);
- Debug.Log(LogDirectory + " Does not exist! Creating one.");
- }
- if (!File.Exists(AfkListFile))
- {
- File.Create(AfkListFile).Close();
- Debug.Log(AfkListFile + " Does not exist! Creating one.");
- }
- if (!File.Exists(MuteListFile))
- {
- File.Create(MuteListFile).Close();
- Debug.Log(MuteListFile + " Does not exist! Creating one.");
- }
- if (!File.Exists(ChatBlockFile))
- {
- File.Create(ChatBlockFile).Close();
- CreateFile.Run(ChatBlockFile);
- Debug.Log(ChatBlockFile + " Does not exist! Creating one.");
- }
- if (!File.Exists(GodListFile))
- {
- File.Create(GodListFile).Close();
- Debug.Log(GodListFile + " Does not exist! Creating one.");
- }
- if (!File.Exists(IpListFile))
- {
- File.Create(IpListFile).Close();
- Debug.Log(IpListFile + " Does not exist! Creating one.");
- }
- if (!File.Exists(LanguageBlockFile))
- {
- File.Create(LanguageBlockFile).Close();
- CreateFile.Run(LanguageBlockFile);
- Debug.Log(LanguageBlockFile + " Does not exist! Creating one.");
- }
- if (!File.Exists(MuteListFile))
- {
- File.Create(MuteListFile).Close();
- Debug.Log(MuteListFile + " Does not exist! Creating one.");
- }
- if (!File.Exists(SettingsFile))
- {
- File.Create(SettingsFile).Close();
- CreateFile.Run(SettingsFile);
- Debug.Log(SettingsFile + " Does not exist! Creating one.");
- }
- if (!File.Exists(CustomGroupsFile))
- {
- File.Create(CustomGroupsFile).Close();
- CreateFile.Run(CustomGroupsFile);
- Debug.Log(CustomGroupsFile + " Does not exist! Creating one.");
- }
- if (!File.Exists(CustomCommandsFile))
- {
- File.Create(CustomCommandsFile).Close();
- CreateFile.Run(CustomCommandsFile);
- Debug.Log(CustomCommandsFile + " Does not exist! Creating one.");
- }
- if (!File.Exists(AnnouncementsFile))
- {
- File.Create(AnnouncementsFile).Close();
- Debug.Log(AnnouncementsFile + " Does not exist! Creating one.");
- }
- if (!File.Exists(LogFile))
- {
- File.Create(LogFile).Close();
- Debug.Log(LogFile + " Does not exist! Creating one.");
- }
- if (!File.Exists(ChatLogFile))
- {
- File.Create(ChatLogFile).Close();
- Debug.Log(ChatLogFile + " Does not exist! Creating one.");
- }
- if (!File.Exists(CommandLogFile))
- {
- File.Create(CommandLogFile).Close();
- Debug.Log(CommandLogFile + " Does not exist! Creating one.");
- }
- }
- else
- {
- if (!File.Exists(fileName))
- {
- if (fileName == SettingsFile || fileName == ChatBlockFile || fileName == LanguageBlockFile || fileName == CustomCommandsFile || fileName == CustomGroupsFile)
- {
- File.Create(fileName).Close();
- CreateFile.Run(fileName);
- Debug.Log(fileName + " Does not exist! Creating one.");
- }
- else
- {
- File.Create(fileName).Close();
- Debug.Log(fileName + " Does not exist! Creating one.");
- }
- }
+ if (!Directory.Exists(FileDirectory))
+ {
+ Directory.CreateDirectory(FileDirectory);
+ Debug.Log(FileDirectory + " Does not exist! Creating one.");
+ }
+ if (!Directory.Exists(LogDirectory))
+ {
+ Directory.CreateDirectory(LogDirectory);
+ Debug.Log(LogDirectory + " Does not exist! Creating one.");
+ }
+ if (!Directory.Exists(KitDirectory))
+ {
+ Directory.CreateDirectory(KitDirectory);
+ Debug.Log(KitDirectory + " Does not exist! Creating one.");
+ }
+ if (!File.Exists(AutoReloader))
+ {
+ File.Create(AutoReloader).Close();
+ Debug.Log(AutoReloader + " Does not exist! Creating one.");
+ }
+ if (!File.Exists(AfkListFile))
+ {
+ File.Create(AfkListFile).Close();
+ Debug.Log(AfkListFile + " Does not exist! Creating one.");
+ }
+ if (!File.Exists(MuteListFile))
+ {
+ File.Create(MuteListFile).Close();
+ Debug.Log(MuteListFile + " Does not exist! Creating one.");
+ }
+ if (!File.Exists(ChatBlockFile))
+ {
+ File.Create(ChatBlockFile).Close();
+ CreateFile.Run(ChatBlockFile);
+ Debug.Log(ChatBlockFile + " Does not exist! Creating one.");
+ }
+ if (!File.Exists(GodListFile))
+ {
+ File.Create(GodListFile).Close();
+ Debug.Log(GodListFile + " Does not exist! Creating one.");
+ }
+ if (!File.Exists(IpListFile))
+ {
+ File.Create(IpListFile).Close();
+ Debug.Log(IpListFile + " Does not exist! Creating one.");
+ }
+ if (!File.Exists(LanguageBlockFile))
+ {
+ File.Create(LanguageBlockFile).Close();
+ CreateFile.Run(LanguageBlockFile);
+ Debug.Log(LanguageBlockFile + " Does not exist! Creating one.");
+ }
+ if (!File.Exists(MuteListFile))
+ {
+ File.Create(MuteListFile).Close();
+ Debug.Log(MuteListFile + " Does not exist! Creating one.");
+ }
+ if (!File.Exists(SettingsFile))
+ {
+ File.Create(SettingsFile).Close();
+ CreateFile.Run(SettingsFile);
+ Debug.Log(SettingsFile + " Does not exist! Creating one.");
+ }
+ if (!File.Exists(CustomGroupsFile))
+ {
+ File.Create(CustomGroupsFile).Close();
+ CreateFile.Run(CustomGroupsFile);
+ Debug.Log(CustomGroupsFile + " Does not exist! Creating one.");
+ }
+ if (!File.Exists(CustomCommandsFile))
+ {
+ File.Create(CustomCommandsFile).Close();
+ CreateFile.Run(CustomCommandsFile);
+ Debug.Log(CustomCommandsFile + " Does not exist! Creating one.");
+ }
+ if (!File.Exists(AnnouncementsFile))
+ {
+ File.Create(AnnouncementsFile).Close();
+ Debug.Log(AnnouncementsFile + " Does not exist! Creating one.");
+ }
+ if (!File.Exists(LogFile))
+ {
+ File.Create(LogFile).Close();
+ Debug.Log(LogFile + " Does not exist! Creating one.");
+ }
+ if (!File.Exists(ChatLogFile))
+ {
+ File.Create(ChatLogFile).Close();
+ Debug.Log(ChatLogFile + " Does not exist! Creating one.");
+ }
+ if (!File.Exists(CommandLogFile))
+ {
+ File.Create(CommandLogFile).Close();
+ Debug.Log(CommandLogFile + " Does not exist! Creating one.");
}
-
}
catch (Exception ex)
{
diff --git a/source/BP-Essentials/Methods/FileHandler/CreateFile.cs b/source/BP-Essentials/Methods/FileHandler/CreateFile.cs
index 3b75dd65..5a141160 100644
--- a/source/BP-Essentials/Methods/FileHandler/CreateFile.cs
+++ b/source/BP-Essentials/Methods/FileHandler/CreateFile.cs
@@ -20,13 +20,9 @@ public static void Run(string fileName)
case SettingsFile:
{
if (isPreRelease)
-#pragma warning disable CS0162 // Unreachable code detected / *shrugs*
- File.WriteAllText(SettingsFile, DownloadFile.Run("http://www.UserR00T.com/dev/BPEssentials/settings_test.txt"));
-#pragma warning restore CS0162 // Unreachable code detected
+ DownloadAndWriteToFile.Run(SettingsFile, "http://www.UserR00T.com/dev/BPEssentials/settings_test.txt");
else
-#pragma warning disable CS0162 // Unreachable code detected / *shrugs*
- File.WriteAllText(SettingsFile, DownloadFile.Run("http://www.UserR00T.com/dev/BPEssentials/settings.txt"));
-#pragma warning restore CS0162 // Unreachable code detected
+ DownloadAndWriteToFile.Run(SettingsFile, "http://www.UserR00T.com/dev/BPEssentials/settings.txt");
break;
}
case ChatBlockFile:
@@ -43,12 +39,12 @@ public static void Run(string fileName)
}
case CustomCommandsFile:
{
- File.WriteAllText(CustomCommandsFile, DownloadFile.Run("http://www.UserR00T.com/dev/BPEssentials/customcommands.txt"));
+ DownloadAndWriteToFile.Run(CustomCommandsFile, "http://www.UserR00T.com/dev/BPEssentials/customcommands.txt");
break;
}
case CustomGroupsFile:
{
- File.WriteAllText(CustomGroupsFile, DownloadFile.Run("http://www.UserR00T.com/dev/BPEssentials/customgroups.txt"));
+ DownloadAndWriteToFile.Run(CustomGroupsFile, "http://www.UserR00T.com/dev/BPEssentials/customgroups.txt");
break;
}
}
diff --git a/source/BP-Essentials/Methods/FileHandler/Kits.cs b/source/BP-Essentials/Methods/FileHandler/Kits.cs
new file mode 100644
index 00000000..ffb2e284
--- /dev/null
+++ b/source/BP-Essentials/Methods/FileHandler/Kits.cs
@@ -0,0 +1,65 @@
+using Newtonsoft.Json;
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using UnityEngine;
+using static BP_Essentials.EssentialsVariablesPlugin;
+
+namespace BP_Essentials
+{
+ public class Kits
+ {
+ public static void LoadAllKits()
+ {
+ if (DebugLevel >= 1)
+ Debug.Log($"{SetTimeStamp.Run()}[INFO] Loading kits..");
+ listKits.Clear();
+ foreach (string file in Directory.EnumerateFiles(KitDirectory, "*.json", SearchOption.AllDirectories))
+ {
+ var obj = JsonConvert.DeserializeObject(FilterComments.Run(file));
+ if (listKits.Any(x => x.Name == obj.Name))
+ {
+ Debug.Log($"{SetTimeStamp.Run()}[ERROR] Cannot add kit {obj.Name} because it already exists in the list!");
+ continue;
+ }
+ listKits.Add(obj);
+ if (DebugLevel >= 1)
+ Debug.Log($"{SetTimeStamp.Run()}[INFO] Loaded kit: {obj.Name}");
+ }
+ if (DebugLevel >= 1)
+ Debug.Log($"{SetTimeStamp.Run()}[INFO] Loaded in {listKits.Count} kit(s).");
+ }
+ public static void CreateKit(SvPlayer player, string name, int delay, string fileName)
+ {
+ var obj = new Kits_Json.Kits_RootObj
+ {
+ Name = name,
+ Delay = delay,
+ Disabled = false,
+ ExecutableBy = "everyone"
+ };
+ foreach (var item in player.player.myItems.Values)
+ obj.Items.Add(new Kits_Json.Kits_Item { Amount = item.count, Id = item.item.index });
+ File.WriteAllText(fileName, JsonConvert.SerializeObject(obj, Formatting.Indented));
+ listKits.Add(obj);
+ }
+
+ public static IEnumerator KitCooldown(SvPlayer player, Kits_Json.Kits_RootObj kit)
+ {
+ if (!kit.CurrentlyInCooldown.ContainsKey(player.player.username))
+ kit.CurrentlyInCooldown.Add(player.player.username, kit.Delay);
+ var passedTime = 0f;
+ while (passedTime < kit.Delay)
+ {
+ yield return new WaitForSeconds(1);
+ ++passedTime;
+ --kit.CurrentlyInCooldown[player.player.username];
+ }
+ if (kit.CurrentlyInCooldown.ContainsKey(player.player.username))
+ kit.CurrentlyInCooldown.Remove(player.player.username);
+ }
+ }
+}
diff --git a/source/BP-Essentials/Methods/FileHandler/ReadFile.cs b/source/BP-Essentials/Methods/FileHandler/ReadFile.cs
index 98ada028..39a55581 100644
--- a/source/BP-Essentials/Methods/FileHandler/ReadFile.cs
+++ b/source/BP-Essentials/Methods/FileHandler/ReadFile.cs
@@ -27,9 +27,12 @@ public class _General
public bool VoteKickDisabled { get; set; }
public bool ShowDMGMessage { get; set; }
public int DebugLevel { get; set; }
- public string DiscordWebhook { get; set; }
- public bool EnableDiscordWebhook { get; set; }
+ public string DiscordWebhook_Ban { get; set; }
+ public bool EnableDiscordWebhook_Ban { get; set; }
+ public string DiscordWebhook_Report { get; set; }
+ public bool EnableDiscordWebhook_Report { get; set; }
public bool BlockBanButtonTabMenu { get; set; }
+ public bool BlockLicenseRemoved { get; set; }
}
[Serializable]
public class _Messages
@@ -81,6 +84,23 @@ public class ReportOptions
public string F10 { get; set; }
}
[Serializable]
+ public class JobIndexArray
+ {
+ public string Citizen { get; set; }
+ public string Criminal { get; set; }
+ public string Prisoner { get; set; }
+ public string Police { get; set; }
+ public string Paramedic { get; set; }
+ public string Firefighter { get; set; }
+ public string Rojo_Loco { get; set; }
+ public string Green_St_Fam { get; set; }
+ public string Borgata_Blue { get; set; }
+ public string Mayor { get; set; }
+ public string DeliveryDriver { get; set; }
+ public string TaxiDriver { get; set; }
+ public string SpecOps { get; set; }
+ }
+ [Serializable]
public class _Misc
{
public bool enableChatBlock { get; set; }
@@ -115,6 +135,7 @@ public class __RootObject
public MessageColors MessageColors { get; set; }
public FunctionUI FunctionUI { get; set; }
public ReportOptions ReportOptions { get; set; }
+ public JobIndexArray JobIndexArray { get; set; }
public _Misc Misc { get; set; }
public List BlockedItems { get; set; }
public List WhitelistedJobs { get; set; }
@@ -139,10 +160,13 @@ public static void Run(string fileName)
{
try
{
+ IdListObject idlist;
switch (fileName)
{
case SettingsFile:
__RootObject m = JsonConvert.DeserializeObject<__RootObject>(FilterComments.Run(SettingsFile));
+
+
LocalVersion = m.General.version;
CmdCommandCharacter = m.General.CommandCharacter;
DownloadIdList = m.General.DownloadIDList;
@@ -152,15 +176,24 @@ public static void Run(string fileName)
VoteKickDisabled = m.General.VoteKickDisabled;
ShowDMGMessage = m.General.ShowDMGMessage;
DebugLevel = m.General.DebugLevel;
- EnableDiscordWebhook = m.General.EnableDiscordWebhook;
- if (EnableDiscordWebhook && string.IsNullOrEmpty(m.General.DiscordWebhook.Trim()))
+ EnableDiscordWebhook_Ban = m.General.EnableDiscordWebhook_Ban;
+ if (EnableDiscordWebhook_Ban && string.IsNullOrEmpty(m.General.DiscordWebhook_Ban.Trim()))
{
- Debug.Log("[ERROR] Discord webhook is empty but EnableDiscordWebhook is true! Disabling webhook.");
- EnableDiscordWebhook = false;
+ Debug.Log("[ERROR] Discord webhook_Ban is empty but EnableDiscordWebhook_Ban is true! Disabling webhook_Ban.");
+ EnableDiscordWebhook_Ban = false;
}
else
- DiscordWebhook = m.General.DiscordWebhook;
+ DiscordWebhook_Ban = m.General.DiscordWebhook_Ban;
+ EnableDiscordWebhook_Report = m.General.EnableDiscordWebhook_Report;
+ if (EnableDiscordWebhook_Report && string.IsNullOrEmpty(m.General.DiscordWebhook_Report.Trim()))
+ {
+ Debug.Log("[ERROR] Discord webhook_Report is empty but EnableDiscordWebhook_Report is true! Disabling webhook_Report.");
+ EnableDiscordWebhook_Report = false;
+ }
+ else
+ DiscordWebhook_Report = m.General.DiscordWebhook_Report;
BlockBanButtonTabMenu = m.General.BlockBanButtonTabMenu;
+ blockLicenseRemoved = m.General.BlockLicenseRemoved;
infoColor = m.MessageColors.info;
errorColor = m.MessageColors.error;
@@ -191,6 +224,9 @@ public static void Run(string fileName)
ReportReasons = new string[] { m.ReportOptions.F2, m.ReportOptions.F3, m.ReportOptions.F4, m.ReportOptions.F5, m.ReportOptions.F6, m.ReportOptions.F7, m.ReportOptions.F8, m.ReportOptions.F9, m.ReportOptions.F10 };
+ // Softcode this someday
+ Jobs = new string[] { m.JobIndexArray.Citizen, m.JobIndexArray.Criminal, m.JobIndexArray.Prisoner, m.JobIndexArray.Police, m.JobIndexArray.Paramedic, m.JobIndexArray.Firefighter, m.JobIndexArray.Rojo_Loco, m.JobIndexArray.Green_St_Fam, m.JobIndexArray.Borgata_Blue, m.JobIndexArray.Mayor, m.JobIndexArray.DeliveryDriver, m.JobIndexArray.TaxiDriver, m.JobIndexArray.SpecOps };
+
BlockedItems = m.BlockedItems;
EnableBlockSpawnBot = m.Misc.EnableBlockSpawnBot;
@@ -202,7 +238,7 @@ public static void Run(string fileName)
if (_Timer.Enabled)
{
_Timer.Enabled = false;
- _Timer.Interval = m.Misc.TimeBetweenAnnounce * 1000;
+ _Timer.Interval = TimeBetweenAnnounce * 1000;
_Timer.Enabled = true;
}
BlockedSpawnIds = m.Misc.BlockSpawnBot.Split(',').Select(int.Parse).ToArray();
@@ -217,11 +253,14 @@ public static void Run(string fileName)
}
RegisterCommands.Run(m.Commands);
break;
- case IdListFile:
- var idlist = JsonConvert.DeserializeObject(FilterComments.Run(IdListFile));
- IDs = idlist.items.Select(x => x.gameid).ToArray();
+ case IdListItemsFile:
+ idlist = JsonConvert.DeserializeObject(FilterComments.Run(IdListItemsFile));
+ IDs_Items = idlist.items.Select(x => x.gameid).ToArray();
+ break;
+ case IdListVehicleFile:
+ idlist = JsonConvert.DeserializeObject(FilterComments.Run(IdListVehicleFile));
+ IDs_Vehicles = idlist.items.Select(x => x.gameid).ToArray();
break;
-
case AnnouncementsFile:
Announcements = File.ReadAllLines(fileName);
break;
diff --git a/source/BP-Essentials/Methods/FileHandler/RemoveStringFromFile.cs b/source/BP-Essentials/Methods/FileHandler/RemoveStringFromFile.cs
index c6652afc..689b439e 100644
--- a/source/BP-Essentials/Methods/FileHandler/RemoveStringFromFile.cs
+++ b/source/BP-Essentials/Methods/FileHandler/RemoveStringFromFile.cs
@@ -15,15 +15,7 @@ public static void Run(string FileName, string RemoveString)
{
try
{
- string content = null;
- foreach (var line in File.ReadAllLines(FileName))
- {
- if (!line.Contains(RemoveString))
- {
- content = content + line + Environment.NewLine;
- }
- }
- File.WriteAllText(FileName, content);
+ File.WriteAllLines(FileName, File.ReadLines(FileName).Where(s => !s.Contains(RemoveString)).ToList());
}
catch (Exception ex)
{
diff --git a/source/BP-Essentials/Methods/FileHandler/WriteIpToFile.cs b/source/BP-Essentials/Methods/FileHandler/WriteIpToFile.cs
index f6f045f5..9a55161b 100644
--- a/source/BP-Essentials/Methods/FileHandler/WriteIpToFile.cs
+++ b/source/BP-Essentials/Methods/FileHandler/WriteIpToFile.cs
@@ -17,7 +17,7 @@ public static void Run(SvPlayer player)
try
{
Thread.Sleep(500);
- Debug.Log(SetTimeStamp.Run() + "[INFO] " + "[JOIN] " + player.playerData.username + " IP is: " + player.svManager.GetAddress(player.connection));
+ Debug.Log($"{SetTimeStamp.Run()}[INFO] [JOIN] {player.playerData.username} IP is: {player.svManager.GetAddress(player.connection)}");
int tries = 0;
while (tries < 2)
try
diff --git a/source/BP-Essentials/Methods/GameMethods/GetExtraCount.cs b/source/BP-Essentials/Methods/GameMethods/GetExtraCount.cs
new file mode 100644
index 00000000..cb12365e
--- /dev/null
+++ b/source/BP-Essentials/Methods/GameMethods/GetExtraCount.cs
@@ -0,0 +1,34 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using UnityEngine;
+using static BP_Essentials.EssentialsVariablesPlugin;
+using static BP_Essentials.EssentialsMethodsPlugin;
+using System.Reflection;
+
+namespace BP_Essentials
+{
+ class GetExtraCount : EssentialsVariablesPlugin
+ {
+ public static int Run(ShPlayer player, InventoryItem myItem)
+ {
+ try
+ {
+ if (player.job.info.rankItems.Length > player.rank)
+ {
+ for (int i = player.rank; i >= 0; i--)
+ foreach (InventoryItem inventoryItem in player.job.info.rankItems[i].items)
+ if (myItem.item.index == inventoryItem.item.index)
+ return Mathf.Max(0, myItem.count - inventoryItem.count);
+ }
+ return myItem.count;
+ }
+ catch (Exception ex)
+ {
+ ErrorLogging.Run(ex);
+ }
+ return 0;
+ }
+ }
+}
diff --git a/source/BP-Essentials/Methods/GameMethods/SendToJail.cs b/source/BP-Essentials/Methods/GameMethods/SendToJail.cs
index 10d89d02..7a25b53b 100644
--- a/source/BP-Essentials/Methods/GameMethods/SendToJail.cs
+++ b/source/BP-Essentials/Methods/GameMethods/SendToJail.cs
@@ -20,7 +20,7 @@ public static bool Run(ShPlayer shPlayer, float time)
shPlayer.StartCoroutine(shPlayer.svPlayer.JailTimer(time));
shPlayer.svPlayer.SvClearCrimes();
shPlayer.RemoveItemsJail();
- shPlayer.svPlayer.SendToSelf(Channel.Reliable, ClPacket.Timer, time);
+ shPlayer.svPlayer.Send(SvSendType.Self, Channel.Reliable, ClPacket.Timer, time);
return true;
}
}
diff --git a/source/BP-Essentials/Methods/GameMethods/UnRetain.cs b/source/BP-Essentials/Methods/GameMethods/UnRestrain.cs
similarity index 71%
rename from source/BP-Essentials/Methods/GameMethods/UnRetain.cs
rename to source/BP-Essentials/Methods/GameMethods/UnRestrain.cs
index b831d53b..46a5221c 100644
--- a/source/BP-Essentials/Methods/GameMethods/UnRetain.cs
+++ b/source/BP-Essentials/Methods/GameMethods/UnRestrain.cs
@@ -9,13 +9,13 @@
namespace BP_Essentials
{
- class UnRetain : EssentialsVariablesPlugin
+ class UnRestrain : EssentialsVariablesPlugin
{
public static void Run(SvPlayer player)
{
try
{
- typeof(SvPlayer).GetMethod(nameof(UnRetain), BindingFlags.NonPublic | BindingFlags.Instance).Invoke(player, new object[] { });
+ typeof(SvPlayer).GetMethod(nameof(UnRestrain), BindingFlags.NonPublic | BindingFlags.Instance).Invoke(player, new object[] { });
}
catch (Exception ex)
{
diff --git a/source/BP-Essentials/Methods/misc/ErrorLogging.cs b/source/BP-Essentials/Methods/misc/ErrorLogging.cs
index 5d530638..e8c2e20d 100644
--- a/source/BP-Essentials/Methods/misc/ErrorLogging.cs
+++ b/source/BP-Essentials/Methods/misc/ErrorLogging.cs
@@ -18,9 +18,6 @@ public static void Run(Exception ex)
try
{
Thread.Sleep(20);
-
-
-
System.Diagnostics.StackTrace st = new System.Diagnostics.StackTrace(ex, true);
var frame = st.GetFrame(st.FrameCount - 1);
Debug.Log("-------------------------------------------------------------------------------------------------------------------------------------------------------------");
diff --git a/source/BP-Essentials/Methods/misc/GetIdList.cs b/source/BP-Essentials/Methods/misc/GetIdList.cs
index 95d8cb1d..6ca86925 100644
--- a/source/BP-Essentials/Methods/misc/GetIdList.cs
+++ b/source/BP-Essentials/Methods/misc/GetIdList.cs
@@ -13,20 +13,21 @@ class GetIdList : EssentialsChatPlugin
{
public static bool Run(bool silent)
{
- if (silent)
+ // yeah eh redo
+ if (!silent)
+ Debug.Log("Downloading newest ID list's and reloading them...");
+ DownloadAndWriteToFile.Run(IdListItemsFile, "http://www.UserR00T.com/dev/BPEssentials/idlist_items.txt", new Action((success) =>
{
- File.WriteAllText(IdListFile, DownloadFile.Run("http://www.UserR00T.com/dev/BPEssentials/idlist.txt"));
- ReadFile.Run(IdListFile);
- }
- else
- {
- Debug.Log("Downloading newest ID list...");
- File.WriteAllText(IdListFile, DownloadFile.Run("http://www.UserR00T.com/dev/BPEssentials/idlist.txt"));
- Debug.Log("[OK] ID list downloaded");
- Debug.Log("Reloading ID list..");
- ReadFile.Run(IdListFile);
- Debug.Log($"[OK] Downloaded newest ID list and reloaded it! ({IDs.Length} entries loaded in.)");
- }
+ if (success)
+ ReadFile.Run(IdListItemsFile);
+ DownloadAndWriteToFile.Run(IdListVehicleFile, "http://www.UserR00T.com/dev/BPEssentials/idlist_vehicles.txt", new Action((success2) =>
+ {
+ if (success2)
+ ReadFile.Run(IdListVehicleFile);
+ if (!silent && success && success2)
+ Debug.Log($"[OK] Downloaded newest ID list's and reloaded them! ({IDs_Items.Length}(items) {IDs_Vehicles.Length}(vehicles) entries loaded in.)");
+ }));
+ }));
return true;
}
}
diff --git a/source/BP-Essentials/Methods/misc/IsOnline.cs b/source/BP-Essentials/Methods/misc/IsOnline.cs
index 081742ed..1a6a8c25 100644
--- a/source/BP-Essentials/Methods/misc/IsOnline.cs
+++ b/source/BP-Essentials/Methods/misc/IsOnline.cs
@@ -1,11 +1,13 @@
-namespace BP_Essentials
+using System;
+using static BP_Essentials.EssentialsVariablesPlugin;
+namespace BP_Essentials
{
class IsOnline : EssentialsChatPlugin
{
public static bool Run(ShPlayer player)
{
- foreach (var shPlayer in FindObjectsOfType())
- if (shPlayer == player && !shPlayer.svPlayer.IsServerside())
+ foreach (var currPlayer in SvMan.players.Values)
+ if (currPlayer == player)
return true;
return false;
}
diff --git a/source/BP-Essentials/Methods/misc/Reload.cs b/source/BP-Essentials/Methods/misc/Reload.cs
index c107f696..955b043b 100644
--- a/source/BP-Essentials/Methods/misc/Reload.cs
+++ b/source/BP-Essentials/Methods/misc/Reload.cs
@@ -5,6 +5,8 @@
using UnityEngine;
using static BP_Essentials.EssentialsVariablesPlugin;
using static BP_Essentials.EssentialsMethodsPlugin;
+using System.Threading;
+
namespace BP_Essentials
{
class Reload : EssentialsChatPlugin
@@ -17,45 +19,50 @@ public static void Run(bool silentExecution, SvPlayer player = null)
{
if (AdminsListPlayers.Contains(player.playerData.username))
{
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, "Checking if file's exist...");
- CheckFiles.Run("all");
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, "Reloading config files...");
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, "[WAIT] Reloading all files..");
+ CheckFiles.Run();
ReadFile.Run(SettingsFile);
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, "[OK] Config file reloaded");
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, "Reloading critical .txt files...");
ReadCustomCommands.Run();
ReadGroups.Run();
+ Kits.LoadAllKits();
ReadStream.Run(LanguageBlockFile, LanguageBlockWords);
ReadStream.Run(ChatBlockFile, ChatBlockWords);
ReadStream.Run(AdminListFile, AdminsListPlayers);
LanguageBlockWords = LanguageBlockWords.ConvertAll(d => d.ToLower());
ChatBlockWords = ChatBlockWords.ConvertAll(d => d.ToLower());
- // Doesn't seem like a good idea to get the id list every /reload
+ ReadFile.Run(IdListItemsFile);
+ ReadFile.Run(IdListVehicleFile);
ReadFile.Run(AnnouncementsFile);
ReadFile.Run(GodListFile);
ReadFile.Run(MuteListFile);
ReadFile.Run(AfkListFile);
ReadFile.Run(RulesFile);
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, "[OK] Critical .txt files reloaded");
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, "[OK] Critical .txt files reloaded");
}
else
{
- player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, MsgNoPerm);
+ player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, MsgNoPerm);
}
}
else
{
- CheckFiles.Run("all");
+ CheckFiles.Run();
ReadFile.Run(SettingsFile);
ReadStream.Run(LanguageBlockFile, LanguageBlockWords);
ReadStream.Run(ChatBlockFile, ChatBlockWords);
ReadStream.Run(AdminListFile, AdminsListPlayers);
ReadCustomCommands.Run();
ReadGroups.Run();
+ Kits.LoadAllKits();
LanguageBlockWords = LanguageBlockWords.ConvertAll(d => d.ToLower());
ChatBlockWords = ChatBlockWords.ConvertAll(d => d.ToLower());
if (DownloadIdList)
GetIdList.Run(false);
+ else
+ {
+ ReadFile.Run(IdListItemsFile);
+ ReadFile.Run(IdListVehicleFile);
+ }
ReadFile.Run(AnnouncementsFile);
ReadFile.Run(GodListFile);
ReadFile.Run(MuteListFile);
diff --git a/source/BP-Essentials/Methods/misc/ReportPlayer.cs b/source/BP-Essentials/Methods/misc/ReportPlayer.cs
index e137c770..d96ba736 100644
--- a/source/BP-Essentials/Methods/misc/ReportPlayer.cs
+++ b/source/BP-Essentials/Methods/misc/ReportPlayer.cs
@@ -7,21 +7,20 @@ namespace BP_Essentials
{
class ReportPlayer : EssentialsVariablesPlugin
{
- public static void Run(string Reporter, string ReportReason, object ReportedPlayer)
+ public static void Run(string Reporter, string ReportReason, ShPlayer ReportedPlayer)
{
try
{
- var reportedPlayer = (ShPlayer)ReportedPlayer;
- foreach (KeyValuePair item in playerList)
+ foreach (var currItem in playerList.Values)
{
- if (item.Value.shplayer.admin)
+ if (currItem.shplayer.admin)
{
- if (item.Value.LastMenu == CurrentMenu.Main)
+ if (currItem.LastMenu == CurrentMenu.Main)
{
- item.Value.shplayer.svPlayer.SendToSelf(Channel.Reliable, ClPacket.CloseFunctionMenu);
- item.Value.shplayer.svPlayer.SendToSelf(Channel.Reliable, ClPacket.ShowFunctionMenu, "New report:\nUsername: " + reportedPlayer.username + "\nReporter: " + Reporter + "\nReason: " + ReportReason + "\n\nF2: Teleport to player\nF3-11: Close menu\n\nPress F11 To close this (G)UI");
- item.Value.LastMenu = CurrentMenu.AdminReport;
- item.Value.reportedPlayer = reportedPlayer;
+ currItem.shplayer.svPlayer.Send(SvSendType.Self, Channel.Reliable, ClPacket.CloseFunctionMenu);
+ currItem.shplayer.svPlayer.Send(SvSendType.Self, Channel.Reliable, ClPacket.ShowFunctionMenu, "New report:\nUsername: " + ReportedPlayer.username + "\nReporter: " + Reporter + "\nReason: " + ReportReason + "\n\nF2: Teleport to player\nF3-11: Close menu\n\nPress F11 To close this (G)UI");
+ currItem.LastMenu = CurrentMenu.AdminReport;
+ currItem.reportedPlayer = ReportedPlayer;
}
}
continue;
diff --git a/source/BP-Essentials/Methods/misc/SaveNow.cs b/source/BP-Essentials/Methods/misc/SaveNow.cs
index 637183db..43aa74c9 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.svPlayer.IsServerside())
{
if (shPlayer.GetPlaceIndex() >= 13) continue;
- shPlayer.svPlayer.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, "Saving game.. This can take up to 5 seconds.");
+ shPlayer.svPlayer.Send(SvSendType.Self, 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 3c354bd7..eeb2b590 100644
--- a/source/BP-Essentials/Methods/misc/SavePeriodically.cs
+++ b/source/BP-Essentials/Methods/misc/SavePeriodically.cs
@@ -35,7 +35,7 @@ static void OnTime(object onetMan)
if (!shPlayer.svPlayer.IsServerside())
{
if (shPlayer.GetPlaceIndex() >= 13) continue;
- shPlayer.svPlayer.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, "Saving game.. This can take up to 5 seconds.");
+ shPlayer.svPlayer.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, "Saving game.. This can take up to 5 seconds.");
shPlayer.svPlayer.Save();
}
}
diff --git a/source/BP-Essentials/Methods/misc/SendChatMessage.cs b/source/BP-Essentials/Methods/misc/SendChatMessage.cs
index fa14f9e3..8d8bc09c 100644
--- a/source/BP-Essentials/Methods/misc/SendChatMessage.cs
+++ b/source/BP-Essentials/Methods/misc/SendChatMessage.cs
@@ -16,7 +16,7 @@ class SendChatMessage : EssentialsChatPlugin
public static void Run(string message)
{
foreach (var player in playerList.Where(x => x.Value.chatEnabled))
- player.Value.shplayer.svPlayer.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, message);
+ player.Value.shplayer.svPlayer.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, message);
}
}
}
diff --git a/source/BP-Essentials/Methods/misc/SendChatMessageToAdmins.cs b/source/BP-Essentials/Methods/misc/SendChatMessageToAdmins.cs
index 41104bd3..6fcc9942 100644
--- a/source/BP-Essentials/Methods/misc/SendChatMessageToAdmins.cs
+++ b/source/BP-Essentials/Methods/misc/SendChatMessageToAdmins.cs
@@ -16,7 +16,7 @@ class SendChatMessageToAdmins : EssentialsChatPlugin
public static void Run(string message)
{
foreach (var player in playerList.Where(x =>x.Value.receiveStaffChat && HasPermission.Run(x.Value.shplayer.svPlayer, CmdStaffChatExecutableBy)))
- player.Value.shplayer.svPlayer.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, message);
+ player.Value.shplayer.svPlayer.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, message);
}
}
}