add and fix a lot
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
using LabApi.Events.Handlers;
|
||||
using LabApi.Features;
|
||||
using LabApi.Loader.Features.Plugins;
|
||||
|
||||
namespace ScpSwap;
|
||||
|
||||
public class ScpSwap : Plugin
|
||||
{
|
||||
public override string Name => "ScpSwap";
|
||||
public override string Author => "HoherGeist, Code002Lover";
|
||||
public override Version Version { get; } = new(1, 0, 0);
|
||||
public override string Description => "Swap SCPs.";
|
||||
public override Version RequiredApiVersion { get; } = new(LabApiProperties.CompiledVersion);
|
||||
|
||||
public override void Enable()
|
||||
{
|
||||
}
|
||||
|
||||
public override void Disable()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net48</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>disable</Nullable>
|
||||
<LangVersion>latest</LangVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||
<Optimize>true</Optimize>
|
||||
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
|
||||
<DebugType>full</DebugType>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||
<Optimize>true</Optimize>
|
||||
<CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
|
||||
<DebugType>none</DebugType>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="Assembly-CSharp">
|
||||
<HintPath>..\dependencies\Assembly-CSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="CommandSystem.Core">
|
||||
<HintPath>..\dependencies\CommandSystem.Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Mirror">
|
||||
<HintPath>..\dependencies\Mirror.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Pooling">
|
||||
<HintPath>..\dependencies\Pooling.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.CoreModule">
|
||||
<HintPath>..\dependencies\UnityEngine.CoreModule.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Northwood.LabAPI" Version="1.0.2" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,81 @@
|
||||
using CommandSystem;
|
||||
using LabApi.Features.Wrappers;
|
||||
using PlayerRoles;
|
||||
|
||||
namespace ScpSwap;
|
||||
|
||||
[CommandHandler(typeof(ClientCommandHandler))]
|
||||
public class SwapCommand : ICommand
|
||||
{
|
||||
public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out string response)
|
||||
{
|
||||
if (arguments.Count != 1)
|
||||
{
|
||||
response = "Usage: .scpswap <SCP_NUMBER>";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Player.TryGet(sender, out var player))
|
||||
{
|
||||
response = "You must be a player to use this command!";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Round.Duration.TotalSeconds > 120)
|
||||
{
|
||||
response = "You can't swap SCPs during a round!";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!player.IsSCP)
|
||||
{
|
||||
response = "You must be an SCP to use this command!";
|
||||
return false;
|
||||
}
|
||||
|
||||
List<string> validScp =
|
||||
[
|
||||
"049",
|
||||
"079",
|
||||
"096",
|
||||
"106",
|
||||
"173",
|
||||
"939",
|
||||
];
|
||||
|
||||
var arg = arguments.First();
|
||||
|
||||
if (!validScp.Contains(arg))
|
||||
{
|
||||
response = "Invalid SCP number.";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Player.List.Where(x=>x.IsSCP).Select(x=>x.RoleBase).Any(playerRole => playerRole.RoleName == "SCP-" + arg))
|
||||
{
|
||||
response = "Already exists";
|
||||
return false;
|
||||
}
|
||||
|
||||
var role = arg switch
|
||||
{
|
||||
"049" => RoleTypeId.Scp049,
|
||||
"079" => RoleTypeId.Scp079,
|
||||
"096" => RoleTypeId.Scp096,
|
||||
"106" => RoleTypeId.Scp106,
|
||||
"173" => RoleTypeId.Scp173,
|
||||
"939" => RoleTypeId.Scp939,
|
||||
_ => throw new ArgumentOutOfRangeException()
|
||||
};
|
||||
|
||||
player.SetRole(role);
|
||||
|
||||
response = "Swapping...";
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public string Command { get; } = "scpswap";
|
||||
public string[] Aliases { get; } = ["ss"];
|
||||
public string Description { get; } = "Swaps SCPs";
|
||||
}
|
||||
Reference in New Issue
Block a user