Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Commit

Permalink
Framework update for Smod Beta
Browse files Browse the repository at this point in the history
  • Loading branch information
Rnen committed Jun 23, 2020
1 parent 47a8fac commit 9c9d80a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 19 deletions.
24 changes: 13 additions & 11 deletions AdminToolbox/AdminToolbox/API/Utility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
using System.Linq;
using Smod2.API;

using SMRoleType = Smod2.API.RoleType;
using SMItemType = Smod2.API.ItemType;

namespace AdminToolbox.API
{
Expand All @@ -12,15 +14,15 @@ public static class Utility
/// <returns>Returns <see cref="bool"/> based on success</returns>
/// <para>Invalid <see cref="int"/> parameters returns <see cref="Smod2.API.Role.UNASSIGNED"/></para>
/// </summary>
public static bool TryParseRole(int roleID, out Smod2.API.RoleType role)
public static bool TryParseRole(int roleID, out SMRoleType role)
{
role = Smod2.API.RoleType.UNASSIGNED;
int[] validRoles = Enum.GetValues(typeof(Role)).Cast<int>().ToArray();
role = SMRoleType.UNASSIGNED;
int[] validRoles = Enum.GetValues(typeof(RoleType)).Cast<int>().ToArray();
if (!validRoles.Contains(roleID))
return false;
else
{
role = (Smod2.API.RoleType)roleID;
role = (SMRoleType)roleID;
return true;
}
}
Expand All @@ -30,15 +32,15 @@ public static bool TryParseRole(int roleID, out Smod2.API.RoleType role)
/// <returns>Returns <see cref="bool"/> based on success</returns>
/// <para>Invalid <see cref="int"/> parameters returns <see cref="Smod2.API.ItemType.NULL"/></para>
/// </summary>
public static bool TryParseItem(int itemID, out Smod2.API.ItemType itemType)
public static bool TryParseItem(int itemID, out SMItemType itemType)
{
itemType = Smod2.API.ItemType.NULL;
int[] validItems = Enum.GetValues(typeof(Smod2.API.ItemType)).Cast<int>().ToArray();
itemType = SMItemType.NULL;
int[] validItems = Enum.GetValues(typeof(SMItemType)).Cast<int>().ToArray();
if (!validItems.Contains(itemID))
return false;
else
{
itemType = (Smod2.API.ItemType)itemID;
itemType = (SMItemType)itemID;
return true;
}
}
Expand All @@ -48,14 +50,14 @@ public static bool TryParseItem(int itemID, out Smod2.API.ItemType itemType)
/// <returns>Returns <see cref="bool"/> based on success</returns>
/// <para>Tries to cast to <see cref="int"/> first, then compares names</para>
/// </summary>
public static bool TryParseItem(string item, out Smod2.API.ItemType itemType)
public static bool TryParseItem(string item, out SMItemType itemType)
{
if (int.TryParse(item, out int x))
return TryParseItem(x, out itemType);

itemType = Smod2.API.ItemType.NULL;
itemType = SMItemType.NULL;

foreach (Smod2.API.ItemType i in Enum.GetValues(typeof(Smod2.API.ItemType)))
foreach (SMItemType i in Enum.GetValues(typeof(SMItemType)))
{
if (i.ToString().ToUpper().Contains(item.ToUpper()))
{
Expand Down
2 changes: 1 addition & 1 deletion AdminToolbox/AdminToolbox/AdminToolbox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace AdminToolbox
public class AdminToolbox : Plugin
{
internal const string AT_Version = "1.3.8";
internal const string AT_Revision = "14";
internal const string AT_Revision = "15";

#region GitHub release info
private DateTime LastOnlineCheck = DateTime.Now;
Expand Down
6 changes: 3 additions & 3 deletions AdminToolbox/AdminToolbox/AdminToolbox.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>AdminToolbox</RootNamespace>
<AssemblyName>AdminToolbox</AssemblyName>
<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
Expand Down Expand Up @@ -44,7 +44,7 @@
<ItemGroup>
<Reference Include="Assembly-CSharp, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Builds\Assembly-CSharp.dll</HintPath>
<HintPath>..\..\..\..\SCP_SL_SERVER\SCPSL_Data\Managed\Assembly-CSharp.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
Expand All @@ -54,7 +54,7 @@
</Reference>
<Reference Include="Smod2, Version=3.6.0.2, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Builds\Smod2.dll</HintPath>
<HintPath>..\..\..\..\SCP_SL_SERVER\SCPSL_Data\Managed\Smod2.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System" />
Expand Down
8 changes: 4 additions & 4 deletions AdminToolbox/AdminToolbox/Commands/Player/RoleCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,23 @@ public string[] OnCall(ICommandSender sender, string[] args)
{
if (args.Length > 1)
{
if (int.TryParse(args[1], out int j) && Utility.TryParseRole(j, out Smod2.API.RoleType spesifiedRole))
if (int.TryParse(args[1], out int j) && Utility.TryParseRole(j, out Smod2.API.RoleType specifiedRole))
{
int playerNum = 0;
foreach (Player pl in Server.GetPlayers())
{
Vector originalPos = pl.GetPosition();
if (pl.TeamRole.Role == Smod2.API.RoleType.UNASSIGNED || pl.TeamRole.Role == Smod2.API.RoleType.SPECTATOR)
pl.ChangeRole(spesifiedRole, true, true);
pl.ChangeRole(specifiedRole, true, true);
else
{
pl.ChangeRole(spesifiedRole, true, false);
pl.ChangeRole(specifiedRole, true, false);
pl.Teleport(originalPos, true);
}
pl.SetHealth(pl.TeamRole.MaxHP);
playerNum++;
}
return new string[] { playerNum + " " + (playerNum > 1 ? "roles" : "role") + " set to " + spesifiedRole };
return new string[] { playerNum + " " + (playerNum > 1 ? "roles" : "role") + " set to " + specifiedRole };
}
else
{
Expand Down

0 comments on commit 9c9d80a

Please sign in to comment.