Console Command - bgrade.down
/downgrade
/upgrade - which you can already do within the Chat Commands.
/downgrade
/upgrade - which you can already do within the Chat Commands.
Implemented the feature for my usecase, not sure how to contribute. Allows for binds on mousewheelup and mousewheeldown to rotate through the grades. Needs more testing with regards to grade 1-4 permissions. Assuming the following unified diff is located in a file `BGrade.diff`, it can be applied via `git apply BGrade.diff` to the current version of `BGrade.cs`.
diff --git a/BGrade.cs b/BGrade.cs
index ee7664f..a877916 100644
--- a/BGrade.cs
+++ b/BGrade.cs
@@ -60,7 +60,8 @@ namespace Oxide.Plugins
}, "Command Settings", "Chat Commands");
ConsoleCommands = GetConfig(new List<string>
{
- "bgrade.up"
+ "bgrade.up",
+ "bgrade.down"
}, "Command Settings", "Console Commands");
CheckLastAttack = GetConfig(true, "Building Attack Settings", "Enabled");
UpgradeCooldown = GetConfig(30, "Building Attack Settings", "Cooldown Time");
@@ -165,7 +166,14 @@ namespace Oxide.Plugins
foreach (var command in ConsoleCommands)
{
- cmd.AddConsoleCommand(command, this, nameof(BGradeUpCommand));
+ if (command.Equals("bgrade.up"))
+ {
+ cmd.AddConsoleCommand(command, this, nameof(BGradeUpCommand));
+ }
+ if (command.Equals("bgrade.down"))
+ {
+ cmd.AddConsoleCommand(command, this, nameof(BGradeDownCommand));
+ }
}
}
@@ -688,6 +696,16 @@ namespace Oxide.Plugins
}
private void BGradeUpCommand(ConsoleSystem.Arg arg)
+ {
+ BGradeUpOrDownCommand(arg, true);
+ }
+
+ private void BGradeDownCommand(ConsoleSystem.Arg arg)
+ {
+ BGradeUpOrDownCommand(arg, false);
+ }
+
+ private void BGradeUpOrDownCommand(ConsoleSystem.Arg arg, bool isGradeUp)
{
var player = arg?.Player();
if (player == null)
@@ -706,27 +724,16 @@ namespace Oxide.Plugins
{
bgradePlayer = player.gameObject.AddComponent<BGradePlayer>();
}
- var grade = bgradePlayer.GetGrade() + 1;
- var count = 0;
- if (!player.HasPluginPerm("all"))
+ var grade = isGradeUp ? bgradePlayer.GetGrade() + 1 : bgradePlayer.GetGrade() - 1;
+ if (isGradeUp && grade > 4)
{
- while (!player.HasPluginPerm(grade.ToString()))
- {
- var newGrade = grade++;
- if (newGrade > 4)
- {
- grade = 1;
- }
-
- if (count > bgradePlayer.GetGrade() + 4)
- {
- player.ChatMessage("Permission".Lang(player.UserIDString));
- return;
- }
- }
+ grade = 1;
+ }
+ else if (!isGradeUp && grade < 1)
+ {
+ grade = 4;
}
- else if (grade > 4) grade = 1;
var chatMsgs = new List<string>();
bgradePlayer.SetGrade(grade);