Skip to content

Commit

Permalink
CustomItem support
Browse files Browse the repository at this point in the history
  • Loading branch information
rayzerbrain committed Jun 14, 2022
1 parent c22f73b commit 3323091
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 13 deletions.
28 changes: 25 additions & 3 deletions ShootingRange/API/SpectatorRange.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
using UnityEngine;
using System;

using UnityEngine;

using MEC;

using Mirror;

using Exiled.API.Enums;
using Exiled.API.Features;
using Exiled.API.Features.Toys;
using Exiled.API.Extensions;
using Mirror;
using Exiled.CustomItems.API.Features;

using Object = UnityEngine.Object;

namespace ShootingRange.API
{
Expand Down Expand Up @@ -45,8 +51,24 @@ public bool TryAdmit(Player player)
player.SetRole(RoleType.Tutorial);
Timing.CallDelayed(0.5f, () =>
{
foreach (string str in PluginMain.Singleton.Config.RangerInventory)
{
if (Enum.TryParse(str, out ItemType type))
{
player.AddItem(type);
continue;
}
if (CustomItem.TryGet(str, out CustomItem item))
{
item.Give(player, false);
continue;
}
Log.Error($"Your config is not set up properly! (Could not find item {str})");
}
player.Position = Spawn;
player.AddItem(PluginMain.Singleton.Config.RangerInventory);
player.Health = 100000;
player.ChangeAppearance(RoleType.ChaosConscript);
player.Broadcast(PluginMain.Singleton.Config.RangeGreeting);
Expand Down
20 changes: 10 additions & 10 deletions ShootingRange/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ public class Config : IConfig
public Vector4 RangeLocation { get; set; } = default;
[Description("Determines if the above location will be used or not")]
public bool UseRangeLocation { get; set; } = false;
[Description("The items one will spawn with on the range")]
public List<ItemType> RangerInventory { get; set; } = new()
[Description("The items one will spawn with on the range (may be ItemType or the name of a CustomItem")]
public List<string> RangerInventory { get; set; } = new()
{
ItemType.GunAK,
ItemType.GunCOM18,
ItemType.GunCrossvec,
ItemType.GunE11SR,
ItemType.GunFSP9,
ItemType.GunLogicer,
ItemType.GunRevolver,
ItemType.GunShotgun
"GunAK",
"GunCOM18",
"GunCrossvec",
"GunE11SR",
"GunFSP9",
"GunLogicer",
"GunRevolver",
"GunShotgun",
};
[Description("Player broadcast that appears when a player dies or joins as a spectator (This will not show if force_spectators is true)")]
public PlayerBroadcast DeathBroadcast { get; set; } = new()
Expand Down

0 comments on commit 3323091

Please sign in to comment.