Skip to content

Commit

Permalink
Update 1.7
Browse files Browse the repository at this point in the history
- Added preset-based blacklist for item id's
- Added Anti-vehicle spam (keeps a player from spawning more than 1 car at a time)
- Added new command "/giveslot <player> <amount> <item limit>" to manually give players more slots for kits
- Removed the Slot Shop
- Slightly tweaked Translation & Configuration files
- Updated to latest version of Unturned & Rocket
- Many bug fixes & stability improvements
  • Loading branch information
Teyhota6 authored Mar 7, 2018
1 parent 7012bce commit c7e6814
Show file tree
Hide file tree
Showing 24 changed files with 2,382 additions and 0 deletions.
44 changes: 44 additions & 0 deletions Commands/Command_AutoCopy.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using System.Collections.Generic;
using Rocket.Unturned.Chat;
using Rocket.Unturned.Player;
using Rocket.API;
using Steamworks;
using UnityEngine;

namespace Teyhota.CustomKits.Commands
{
public class Command_AutoCopy : IRocketCommand
{
public static List<CSteamID> AutoCopy = new List<CSteamID>();
public static Dictionary<CSteamID, CSteamID> Murdered = new Dictionary<CSteamID, CSteamID>();

public AllowedCaller AllowedCaller => AllowedCaller.Player;

public string Name => "autocopy";

public string Help => "Toggle Auto-copy";

public string Syntax => string.Empty;

public List<string> Aliases => new List<string>() { "acopy" };

public List<string> Permissions => new List<string> { "ck.autocopy" };


public void Execute(IRocketPlayer caller, string[] command)
{
UnturnedPlayer callr = (UnturnedPlayer)caller;

if (AutoCopy.Contains(callr.CSteamID))
{
AutoCopy.Remove(callr.CSteamID);
UnturnedChat.Say(caller, Plugin.CustomKitsPlugin.Instance.Translate("autocopy_off"), Color.green);
}
else
{
AutoCopy.Add(callr.CSteamID);
UnturnedChat.Say(caller, Plugin.CustomKitsPlugin.Instance.Translate("autocopy_on"), Color.green);
}
}
}
}
81 changes: 81 additions & 0 deletions Commands/Command_AutoLoad.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
using System.Collections.Generic;
using Rocket.Unturned.Chat;
using Rocket.Unturned.Player;
using Rocket.API;
using Steamworks;
using UnityEngine;

namespace Teyhota.CustomKits.Commands
{
public class Command_AutoLoad : IRocketCommand
{
public static Dictionary<CSteamID, string> AutoLoad = new Dictionary<CSteamID, string>();

public AllowedCaller AllowedCaller => AllowedCaller.Player;

public string Name => "autoload";

public string Help => "Auto-load any of your kits when you die";

public string Syntax => "<kit name>";

public List<string> Aliases => new List<string>() { "aload" };

public List<string> Permissions => new List<string> { "ck.autoload" };


public void Execute(IRocketPlayer caller, string[] command)
{
UnturnedPlayer callr = (UnturnedPlayer)caller;
string kitName = null;

if (command.Length == 0)
{
if (!AutoLoad.ContainsKey(callr.CSteamID))
{
if (Plugin.CustomKitsPlugin.Instance.Configuration.Instance.DefaultKitName == "preset_name")
{
foreach (Plugin.CustomKitsConfig.Preset Preset in Plugin.CustomKitsPlugin.Instance.Configuration.Instance.Presets)
{
if (caller.HasPermission(Plugin.CustomKitsPlugin.PERMISSION + Preset.Name))
{
kitName = Preset.Name;
}
}
}
else
{
kitName = Plugin.CustomKitsPlugin.Instance.Configuration.Instance.DefaultKitName;
}
}
else
{
AutoLoad.Remove(callr.CSteamID);
UnturnedChat.Say(caller, Plugin.CustomKitsPlugin.Instance.Translate("autoload_off"), Color.green);
return;
}
}
else
{
kitName = command[0];
}

if (!KitManager.HasKit(callr, kitName, KitManager.Kits))
{
UnturnedChat.Say(caller, Plugin.CustomKitsPlugin.Instance.Translate("no_kit_exists"), Color.red);
return;
}

if (!AutoLoad.ContainsKey(callr.CSteamID))
{
AutoLoad.Add(callr.CSteamID, kitName);
UnturnedChat.Say(caller, Plugin.CustomKitsPlugin.Instance.Translate("autoload_on", kitName), Color.green);
}
else
{
AutoLoad[callr.CSteamID] = kitName;
UnturnedChat.Say(caller, Plugin.CustomKitsPlugin.Instance.Translate("autoload_on", kitName), Color.green);
}
}
}
}
88 changes: 88 additions & 0 deletions Commands/Command_AutoSave.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
using System.Collections.Generic;
using Rocket.Unturned.Chat;
using Rocket.Unturned.Player;
using Rocket.API;
using Steamworks;
using UnityEngine;

namespace Teyhota.CustomKits.Commands
{
public class Command_AutoSave : IRocketCommand
{
public static Dictionary<CSteamID, string> AutoSave = new Dictionary<CSteamID, string>();

public AllowedCaller AllowedCaller => AllowedCaller.Player;

public string Name => "autosave";

public string Help => "Toggle Auto-save";

public string Syntax => "<kit name>";

public List<string> Aliases => new List<string>() { "asave" };

public List<string> Permissions => new List<string> { "ck.autosave" };


public void Execute(IRocketPlayer caller, string[] command)
{
UnturnedPlayer callr = (UnturnedPlayer)caller;
string kitName = null;

if (command.Length == 0)
{
if (!AutoSave.ContainsKey(callr.CSteamID))
{
if (Plugin.CustomKitsPlugin.Instance.Configuration.Instance.DefaultKitName == "preset_name")
{
foreach (Plugin.CustomKitsConfig.Preset Preset in Plugin.CustomKitsPlugin.Instance.Configuration.Instance.Presets)
{
if (caller.HasPermission(Plugin.CustomKitsPlugin.PERMISSION + Preset.Name))
{
kitName = Preset.Name;
}
}
}
else
{
kitName = Plugin.CustomKitsPlugin.Instance.Configuration.Instance.DefaultKitName;
}
}
else
{
AutoSave.Remove(callr.CSteamID);
UnturnedChat.Say(caller, Plugin.CustomKitsPlugin.Instance.Translate("autosave_off"), Color.green);
return;
}
}

int slotCount = SlotManager.Slots[callr.CSteamID.m_SteamID].Count;

if (kitName == "*")
{
UnturnedChat.Say(caller, Plugin.CustomKitsPlugin.Instance.Translate("unsupported_character", "*"), Color.red);
return;
}

if (KitManager.KitCount(callr, KitManager.Kits) >= slotCount)
{
if (!caller.IsAdmin || !caller.HasPermission("ck.admin"))
{
UnturnedChat.Say(caller, Plugin.CustomKitsPlugin.Instance.Translate("no_kits_left"), Color.red);
return;
}
}

if (!AutoSave.ContainsKey(callr.CSteamID))
{
AutoSave.Add(callr.CSteamID, kitName);
UnturnedChat.Say(caller, Plugin.CustomKitsPlugin.Instance.Translate("autosave_on", kitName), Color.green);
}
else
{
AutoSave[callr.CSteamID] = kitName;
UnturnedChat.Say(caller, Plugin.CustomKitsPlugin.Instance.Translate("autosave_on", kitName), Color.green);
}
}
}
}
43 changes: 43 additions & 0 deletions Commands/Command_AutoSkills.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using System.Collections.Generic;
using Rocket.Unturned.Chat;
using Rocket.Unturned.Player;
using Rocket.API;
using Steamworks;
using UnityEngine;

namespace Teyhota.CustomKits.Commands
{
public class Command_AutoSkills : IRocketCommand
{
public static List<CSteamID> AutoSkills = new List<CSteamID>();

public AllowedCaller AllowedCaller => AllowedCaller.Player;

public string Name => "autoskills";

public string Help => "Toggle Auto-maxskills";

public string Syntax => string.Empty;

public List<string> Aliases => new List<string>() { "askills" };

public List<string> Permissions => new List<string> { "ck.autoskills" };


public void Execute(IRocketPlayer caller, string[] command)
{
UnturnedPlayer callr = (UnturnedPlayer)caller;

if (AutoSkills.Contains(callr.CSteamID))
{
AutoSkills.Remove(callr.CSteamID);
UnturnedChat.Say(caller, Plugin.CustomKitsPlugin.Instance.Translate("autoskills_off"), Color.green);
}
else
{
AutoSkills.Add(callr.CSteamID);
UnturnedChat.Say(caller, Plugin.CustomKitsPlugin.Instance.Translate("autoskills_on"), Color.green);
}
}
}
}
88 changes: 88 additions & 0 deletions Commands/Command_ClearInventory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
using System.Collections.Generic;
using System;
using Rocket.Unturned.Chat;
using Rocket.Unturned.Player;
using Rocket.API;
using UnityEngine;

namespace Teyhota.CustomKits.Commands
{
public class Command_ClearInventory : IRocketCommand
{
public AllowedCaller AllowedCaller => AllowedCaller.Both;

public string Name => "clearinventory";

public string Help => "Clear somebody's inventory";

public string Syntax => "[player]";

public List<string> Aliases => new List<string>() { "ci" };

public List<string> Permissions => new List<string> { "ck.clearinventory" };

public const string OTHER_PERM = "ck.clearinventory.other";


public void Execute(IRocketPlayer caller, string[] command)
{
if (command.Length == 0)
{
if (caller is ConsolePlayer)
{
Plugin.CustomKitsPlugin.Write("<player>", ConsoleColor.Red);
return;
}

UnturnedPlayer callr = (UnturnedPlayer)caller;

InventoryManager.Clear(callr, true);

UnturnedChat.Say(caller, Plugin.CustomKitsPlugin.Instance.Translate("inventory_cleared"));
}

if (command.Length == 1)
{
UnturnedPlayer toPlayer = UnturnedPlayer.FromName(command[0]);

if (toPlayer.IsAdmin || toPlayer.HasPermission("ck.admin"))
{
UnturnedChat.Say(caller, Plugin.CustomKitsPlugin.Instance.Translate("ci_bypass", toPlayer.CharacterName), Color.red);
return;
}

if (caller is ConsolePlayer)
{
if (toPlayer == null)
{
Plugin.CustomKitsPlugin.Write(Plugin.CustomKitsPlugin.Instance.Translate("player_doesn't_exist", command[0]), ConsoleColor.Red);
return;
}

InventoryManager.Clear(toPlayer, true);

Plugin.CustomKitsPlugin.Write(Plugin.CustomKitsPlugin.Instance.Translate("inventory_cleared_other", toPlayer.CharacterName), ConsoleColor.Cyan);
return;
}

if (caller.HasPermission(OTHER_PERM))
{
if (toPlayer == null)
{
UnturnedChat.Say(caller, Plugin.CustomKitsPlugin.Instance.Translate("player_doesn't_exist", command[0]), Color.red);
return;
}

InventoryManager.Clear(toPlayer, true);

UnturnedChat.Say(toPlayer, Plugin.CustomKitsPlugin.Instance.Translate("inventory_cleared"));
UnturnedChat.Say(caller, Plugin.CustomKitsPlugin.Instance.Translate("inventory_cleared_other", toPlayer.CharacterName));
}
else
{
UnturnedChat.Say(caller, "You do not have permissions to execute this command.", Color.red);
}
}
}
}
}
Loading

0 comments on commit c7e6814

Please sign in to comment.