Skip to content

Commit

Permalink
Update 2.6.0
Browse files Browse the repository at this point in the history
Updated to game version 0.88
Added kit price, set to 0 to disable
Added delete kit command
Added warps, *almost* the same as kits
  • Loading branch information
UserR00T committed Nov 11, 2018
1 parent 8433b4b commit 7a9ea6a
Show file tree
Hide file tree
Showing 34 changed files with 384 additions and 41 deletions.
6 changes: 6 additions & 0 deletions source/BP-Essentials/BP-Essentials.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
<Compile Include="Chat\Commands\Admin\CheckAlts.cs" />
<Compile Include="Chat\Commands\Admin\Clear.cs" />
<Compile Include="Chat\Commands\Admin\ClearWanted.cs" />
<Compile Include="Chat\Commands\Admin\DeleteKit.cs" />
<Compile Include="Chat\Commands\Admin\DeleteWarp.cs" />
<Compile Include="Chat\Commands\Admin\CreateWarp.cs" />
<Compile Include="Chat\Commands\Admin\CreateKit.cs" />
<Compile Include="Chat\Commands\Admin\Disconnect.cs" />
<Compile Include="Chat\Commands\Admin\FakeJoin.cs" />
Expand Down Expand Up @@ -87,8 +90,10 @@
<Compile Include="Chat\Commands\Admin\GodMode.cs" />
<Compile Include="Chat\Commands\Admin\Mute.cs" />
<Compile Include="Chat\Commands\Everyone\GetKit.cs" />
<Compile Include="Chat\Commands\Everyone\GoToWarp.cs" />
<Compile Include="Chat\Commands\Everyone\Home.cs" />
<Compile Include="Chat\Commands\Everyone\ListKits.cs" />
<Compile Include="Chat\Commands\Everyone\ListWarps.cs" />
<Compile Include="Chat\Commands\Everyone\OnlinePlayers.cs" />
<Compile Include="Chat\Commands\Everyone\Pay.cs" />
<Compile Include="Chat\Commands\Admin\Reload.cs" />
Expand All @@ -108,6 +113,7 @@
<Compile Include="EssentialsVariables.cs" />
<Compile Include="GlobalSuppressions.cs" />
<Compile Include="Chat\Announce.cs" />
<Compile Include="Methods\FileHandler\Warps.cs" />
<Compile Include="Methods\Utils\FillPlaceholders.cs" />
<Compile Include="Methods\Utils\FilterComments.cs" />
<Compile Include="Methods\Utils\GetShByStr.cs" />
Expand Down
2 changes: 1 addition & 1 deletion source/BP-Essentials/Chat/Commands/Admin/ClearWanted.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static void Run(SvPlayer player, string message)
msg = "yourself";
}
foreach (var shPlayer in UnityEngine.Object.FindObjectsOfType<ShPlayer>())
if (shPlayer.username == arg1 && !shPlayer.svPlayer.IsServerside() || shPlayer.ID.ToString() == arg1.ToString() && !shPlayer.svPlayer.IsServerside())
if (shPlayer.username == arg1 && !shPlayer.svPlayer.serverside || shPlayer.ID.ToString() == arg1.ToString() && !shPlayer.svPlayer.serverside)
{
msg = shPlayer.username;
shPlayer.ClearCrimes();
Expand Down
11 changes: 6 additions & 5 deletions source/BP-Essentials/Chat/Commands/Admin/CreateKit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@ public class CreateKit
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()))
var arg2 = GetArgument.Run(2, false, false, message);
var arg3 = GetArgument.Run(3, false, true, message);
if (string.IsNullOrEmpty(arg1.Trim()) || string.IsNullOrEmpty(arg2.Trim()) || string.IsNullOrEmpty(arg3.Trim()))
{
player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, ArgRequired);
return;
}
if (!int.TryParse(arg1, out int arg1i))
if (!int.TryParse(arg1, out int arg1i) || !int.TryParse(arg2, out int arg2i))
{
player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"<color={errorColor}>Cannot convert {arg1} to a integer.</color>");
player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"<color={errorColor}>Cannot convert {arg1} or {arg2} to a integer.</color>");
return;
}
if (arg1i < 0)
Expand All @@ -34,7 +35,7 @@ public static void Run(SvPlayer player, string message)
player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"<color={errorColor}>A kit already exists with that name.</color>");
return;
}
Kits.CreateKit(player, arg2, arg1i, file);
Kits.CreateKit(player, arg3, arg1i, arg2i, file);
player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"<color={infoColor}>Kit created. Please edit </color><color={argColor}>{file}</color> <color={infoColor}>to add ExecuteableBy.</color>");
}
}
Expand Down
42 changes: 42 additions & 0 deletions source/BP-Essentials/Chat/Commands/Admin/CreateWarp.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
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 CreateWarp
{
public static void Run(SvPlayer player, string message)
{
var arg1 = GetArgument.Run(1, false, false, message);
var arg2 = GetArgument.Run(2, false, false, message);
var arg3 = GetArgument.Run(3, false, true, message);
if (string.IsNullOrEmpty(arg1.Trim()) || string.IsNullOrEmpty(arg2.Trim()) || string.IsNullOrEmpty(arg3.Trim()))
{
player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, ArgRequired);
return;
}
if (!int.TryParse(arg1, out int arg1i) || !int.TryParse(arg2, out int arg2i))
{
player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"<color={errorColor}>Cannot convert {arg1} or {arg2} to a integer.</color>");
return;
}
if (arg1i < 0)
{
player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"<color={errorColor}>The delay must be a positive number (0 to disable)</color>");
return;
}
var file = Path.Combine(WarpDirectory, $"{arg3}.json");
if (File.Exists(file))
{
player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"<color={errorColor}>A warp already exists with that name.</color>");
return;
}
Warps.CreateWarp(player, arg3, arg1i, arg2i, file);
player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"<color={infoColor}>Warp created. Please edit </color><color={argColor}>{file}</color> <color={infoColor}>to add ExecuteableBy and Price.</color>");
}
}
}
30 changes: 30 additions & 0 deletions source/BP-Essentials/Chat/Commands/Admin/DeleteKit.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
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 DeleteKit
{
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;
}
var file = Path.Combine(KitDirectory, $"{arg1}.json");
if (!File.Exists(file))
{
player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"<color={errorColor}>No kits exist with that name.</color>");
return;
}
Kits.DeleteKit(player, file, arg1);
player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"<color={infoColor}>Kit deleted.</color>");
}
}
}
30 changes: 30 additions & 0 deletions source/BP-Essentials/Chat/Commands/Admin/DeleteWarp.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
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 DeleteWarp
{
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;
}
var file = Path.Combine(WarpDirectory, $"{arg1}.json");
if (!File.Exists(file))
{
player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"<color={errorColor}>No warps exist with that name.</color>");
return;
}
Warps.DeleteWarp(player, file, arg1);
player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"<color={infoColor}>Warp deleted.</color>");
}
}
}
2 changes: 1 addition & 1 deletion source/BP-Essentials/Chat/Commands/Admin/Feed.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static void Run(SvPlayer player, string message)
bool found = false;
foreach (var shPlayer in UnityEngine.Object.FindObjectsOfType<ShPlayer>())
if (shPlayer.username == arg1 || shPlayer.ID.ToString() == arg1.ToString())
if (!shPlayer.svPlayer.IsServerside())
if (!shPlayer.svPlayer.serverside)
{
shPlayer.svPlayer.UpdateStats(100F, 100F, 100F, 100F);
player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, String.Format(msg, shPlayer.username));
Expand Down
2 changes: 1 addition & 1 deletion source/BP-Essentials/Chat/Commands/Admin/GodMode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static void Run(SvPlayer player, string message) {
}
else
foreach (var shPlayer in UnityEngine.Object.FindObjectsOfType<ShPlayer>())
if (shPlayer.username == name && !shPlayer.svPlayer.IsServerside() || shPlayer.ID.ToString() == name && !shPlayer.svPlayer.IsServerside())
if (shPlayer.username == name && !shPlayer.svPlayer.serverside || shPlayer.ID.ToString() == name && !shPlayer.svPlayer.serverside)
{
name = shPlayer.username;
msg = $"<color={infoColor}>Godmode </color><color={argColor}>{{0}}</color><color={infoColor}> for </color><color={argColor}>'{name}'</color><color={infoColor}>.</color>";
Expand Down
2 changes: 1 addition & 1 deletion source/BP-Essentials/Chat/Commands/Admin/Heal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static void Run(SvPlayer player, string message)
bool found = false;
foreach (var shPlayer in UnityEngine.Object.FindObjectsOfType<ShPlayer>())
if (shPlayer.username == arg1 || shPlayer.ID.ToString() == arg1.ToString())
if (!shPlayer.svPlayer.IsServerside())
if (!shPlayer.svPlayer.serverside)
{
shPlayer.svPlayer.Heal(100);
player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, String.Format(msg, shPlayer.username));
Expand Down
4 changes: 2 additions & 2 deletions source/BP-Essentials/Chat/Commands/Admin/Info.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static void Run(SvPlayer player, string message)
{
foreach (var shPlayer in UnityEngine.Object.FindObjectsOfType<ShPlayer>())
if (shPlayer.username == arg1 || shPlayer.ID.ToString() == arg1.ToString())
if (!shPlayer.svPlayer.IsServerside())
if (!shPlayer.svPlayer.serverside)
{
player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, "Info about: '" + shPlayer.username + "'.");
string[] contentarray = {
Expand All @@ -33,7 +33,7 @@ public static void Run(SvPlayer player, string message)
"IsAdmin: " + shPlayer.admin,
"BankBalance: " + shPlayer.svPlayer.bankBalance,
"ChatEnabled: " + playerList[shPlayer.ID].chatEnabled,
"IP: " + shPlayer.svPlayer.svManager.GetAddress(shPlayer.svPlayer.connection)
"IP: " + shPlayer.svPlayer.connection.IP
};

var content = string.Join("\r\n", contentarray);
Expand Down
2 changes: 1 addition & 1 deletion source/BP-Essentials/Chat/Commands/Admin/Launch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static void Run(SvPlayer player, string message)
{
bool playerfound = false;
foreach (var shPlayer in UnityEngine.Object.FindObjectsOfType<ShPlayer>())
if (shPlayer.username == arg1 && !shPlayer.svPlayer.IsServerside() || shPlayer.ID.ToString() == arg1 && !shPlayer.svPlayer.IsServerside())
if (shPlayer.username == arg1 && !shPlayer.svPlayer.serverside || shPlayer.ID.ToString() == arg1 && !shPlayer.svPlayer.serverside)
{
shPlayer.svPlayer.SvForce(new Vector3(0f, 6500f, 0f));
shPlayer.svPlayer.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"<color={warningColor}>Off you go!</color>");
Expand Down
2 changes: 1 addition & 1 deletion source/BP-Essentials/Chat/Commands/Admin/Money.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static void Run(SvPlayer player, string message)
{
bool found = false;
foreach (var shPlayer in UnityEngine.Object.FindObjectsOfType<ShPlayer>())
if (shPlayer.username == arg1 && !shPlayer.svPlayer.IsServerside() || shPlayer.ID.ToString() == arg1 && !shPlayer.svPlayer.IsServerside())
if (shPlayer.username == arg1 && !shPlayer.svPlayer.serverside || shPlayer.ID.ToString() == arg1 && !shPlayer.svPlayer.serverside)
{
shPlayer.TransferMoney(DeltaInv.AddToMe, arg2int, true);
player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"<color={infoColor}>Successfully gave</color><color={argColor}> " + shPlayer.username + " " + arg2int + $"</color><color={infoColor}>$</color>");
Expand Down
2 changes: 1 addition & 1 deletion source/BP-Essentials/Chat/Commands/Admin/Mute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static void Run(SvPlayer player, string message)
muteuser = GetArgument.Run(1, false, true, message);
foreach (var shPlayer in UnityEngine.Object.FindObjectsOfType<ShPlayer>())
if (shPlayer.username == muteuser.ToString() || shPlayer.ID.ToString() == muteuser.ToString())
if (!shPlayer.svPlayer.IsServerside())
if (!shPlayer.svPlayer.serverside)
{
muteuser = shPlayer.username;
found = true;
Expand Down
2 changes: 1 addition & 1 deletion source/BP-Essentials/Chat/Commands/Admin/Restrain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static void Run(SvPlayer player, string message)
shPlayer.svPlayer.Restrain(shPlayer.manager.handcuffed);
var shRetained = shPlayer.curEquipable as ShRestrained;
shPlayer.svPlayer.SvSetEquipable(shRetained.otherRestrained.index);
if (!shPlayer.svPlayer.IsServerside())
if (!shPlayer.svPlayer.serverside)
shPlayer.svPlayer.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, "You've been restrained");
player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"<color={infoColor}>Restrained</color> <color={argColor}>" + shPlayer.username + $"</color><color={infoColor}>.</color>");
}
Expand Down
6 changes: 3 additions & 3 deletions source/BP-Essentials/Chat/Commands/Admin/Search.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ public static void Run(SvPlayer player, string message)
else
{
foreach (var shPlayer2 in UnityEngine.Object.FindObjectsOfType<ShPlayer>())
if (shPlayer2.username == arg1 && !shPlayer2.svPlayer.IsServerside() || shPlayer2.ID.ToString() == arg1 && !shPlayer2.svPlayer.IsServerside())
if (shPlayer2.username == arg1 && !shPlayer2.svPlayer.serverside || shPlayer2.ID.ToString() == arg1 && !shPlayer2.svPlayer.serverside)
{
foreach (var shPlayer in UnityEngine.Object.FindObjectsOfType<ShPlayer>())
if (shPlayer.svPlayer == player && !shPlayer.svPlayer.IsServerside())
if (shPlayer.svPlayer == player && !shPlayer.svPlayer.serverside)
{
if (!shPlayer2.IsDead())
{
Expand All @@ -30,7 +30,7 @@ public static void Run(SvPlayer player, string message)
shPlayer2.viewers.Add(shPlayer);
shPlayer.otherEntity = shPlayer2;
player.Send(SvSendType.Self, Channel.Fragmented, 13, shPlayer.otherEntity.ID, shPlayer.otherEntity.SerializeMyItems());
if (!shPlayer2.svPlayer.IsServerside() && shPlayer2.viewers.Count == 1)
if (!shPlayer2.svPlayer.serverside && shPlayer2.viewers.Count == 1)
shPlayer2.svPlayer.Send(SvSendType.Self, Channel.Reliable, 16, new System.Object[] { });
player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"<color={infoColor}>Viewing inventory of</color> <color={argColor}>{shPlayer2.username}</color>");
shPlayer2.svPlayer.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"{AdminSearchingInv}");
Expand Down
4 changes: 2 additions & 2 deletions source/BP-Essentials/Chat/Commands/Admin/Slap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ public static void Run(SvPlayer player, string message)
{
bool playerfound = false;
foreach (var shPlayer in UnityEngine.Object.FindObjectsOfType<ShPlayer>())
if (shPlayer.username == arg1 && !shPlayer.svPlayer.IsServerside() || shPlayer.ID.ToString() == arg1 && !shPlayer.svPlayer.IsServerside())
if (shPlayer.username == arg1 && !shPlayer.svPlayer.serverside || shPlayer.ID.ToString() == arg1 && !shPlayer.svPlayer.serverside)
{
foreach (var shPlayer2 in UnityEngine.Object.FindObjectsOfType<ShPlayer>())
if (shPlayer2.svPlayer == player && !shPlayer2.svPlayer.IsServerside())
if (shPlayer2.svPlayer == player && !shPlayer2.svPlayer.serverside)
{
int amount = new System.Random().Next(4, 15);
shPlayer.svPlayer.Damage(DamageIndex.Null, amount, null, null);
Expand Down
2 changes: 1 addition & 1 deletion source/BP-Essentials/Chat/Commands/Admin/Strip.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static void Run(SvPlayer player, string message)
{
bool playerfound = false;
foreach (var shPlayer in UnityEngine.Object.FindObjectsOfType<ShPlayer>())
if (shPlayer.username == arg1 && !shPlayer.svPlayer.IsServerside() || shPlayer.ID.ToString() == arg1 && !shPlayer.svPlayer.IsServerside())
if (shPlayer.username == arg1 && !shPlayer.svPlayer.serverside || shPlayer.ID.ToString() == arg1 && !shPlayer.svPlayer.serverside)
{
// To be improved
shPlayer.svPlayer.SvSetWearable(-1626497894); //NullArmor
Expand Down
9 changes: 9 additions & 0 deletions source/BP-Essentials/Chat/Commands/Everyone/GetKit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ public static void Run(SvPlayer player, string message)
player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"<color={errorColor}>You already used this kit. Please wait</color> <color={argColor}>{obj.CurrentlyInCooldown[player.player.username]}</color> <color={errorColor}>second(s) before executing this command again.</color>");
return;
}
if (obj.Price > 0)
{
if (player.player.MyMoneyCount() < obj.Price)
{
player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"<color={errorColor}>You do not have enough money to get this kit. (You have: {player.player.MyMoneyCount()} | Needed: {obj.Price})</color>");
return;
}
player.player.TransferMoney(DeltaInv.RemoveFromMe, obj.Price, true);
}
foreach (var item in obj.Items)
{
player.player.TransferItem(DeltaInv.AddToMe, item.Id, item.Amount, true);
Expand Down
Loading

0 comments on commit 7a9ea6a

Please sign in to comment.