Skip to content

Commit

Permalink
1.4.8a
Browse files Browse the repository at this point in the history
- Removed message of checking server ip
- Fixed some commands
- Changed workshopmaps config
- Probably fixed votes (untested)  - let me know if not
- Minimum css version - 246
  • Loading branch information
daffyyyy committed Jun 29, 2024
1 parent cdd7715 commit a395a7d
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 23 deletions.
4 changes: 2 additions & 2 deletions CS2-SimpleAdmin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace CS2_SimpleAdmin;

[MinimumApiVersion(228)]
[MinimumApiVersion(246)]
public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdminConfig>
{
public static CS2_SimpleAdmin Instance { get; private set; } = new();
Expand Down Expand Up @@ -39,7 +39,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
public override string ModuleName => "CS2-SimpleAdmin" + (Helper.IsDebugBuild ? " (DEBUG)" : " (RELEASE)");
public override string ModuleDescription => "Simple admin plugin for Counter-Strike 2 :)";
public override string ModuleAuthor => "daffyy & Dliix66";
public override string ModuleVersion => "1.4.7a";
public override string ModuleVersion => "1.4.8a";

public CS2_SimpleAdminConfig Config { get; set; } = new();

Expand Down
4 changes: 2 additions & 2 deletions CS2-SimpleAdmin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.244" />
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.246" />
<PackageReference Include="Dapper" Version="2.1.35" />
<PackageReference Include="Discord.Net.Webhook" Version="3.15.1" />
<PackageReference Include="Discord.Net.Webhook" Version="3.15.2" />
<PackageReference Include="MySqlConnector" Version="2.3.7" />
<PackageReference Include="Newtonsoft.Json" Version="*" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Commands/basecommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ public void OnKickCommand(CCSPlayerController? caller, CommandInfo command)

playersToTarget.ForEach(player =>
{
if (!player.IsBot && player.SteamID.ToString().Length != 17)
if (player == null || !player.IsValid)
return;

if (caller!.CanTarget(player))
Expand Down
6 changes: 3 additions & 3 deletions Commands/basevotes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ public void OnVoteCommand(CCSPlayerController? caller, CommandInfo command)
StringBuilder sb = new(_localizer["sa_prefix"]);
sb.Append(_localizer["sa_admin_vote_message", caller == null ? "Console" : caller.PlayerName, question]);
player.PrintToChat(sb.ToString());
voteMenu.OpenToAll();

voteMenu.Open(player);

//MenuManager.OpenChatMenu(player, voteMenu);
}
}
Expand Down
6 changes: 0 additions & 6 deletions Commands/funcommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,6 @@ public void OnFreezeCommand(CCSPlayerController? caller, CommandInfo command)

playersToTarget.ForEach(player =>
{
if (!player.IsBot && player.Connected == PlayerConnectedState.PlayerConnected)
return;

if (caller!.CanTarget(player))
{
Freeze(caller, player, time, callerName);
Expand Down Expand Up @@ -115,9 +112,6 @@ public void OnUnfreezeCommand(CCSPlayerController? caller, CommandInfo command)

playersToTarget.ForEach(player =>
{
if (!player.IsBot && player.Connected == PlayerConnectedState.PlayerConnected)
return;

Unfreeze(caller, player, callerName, command);
});
}
Expand Down
2 changes: 1 addition & 1 deletion Commands/playercommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public void OnHpCommand(CCSPlayerController? caller, CommandInfo command)

public void SetHp(CCSPlayerController? caller, CCSPlayerController? player, int health, CommandInfo? command = null)
{
if (player != null && !player.IsBot && player.Connected == PlayerConnectedState.PlayerConnected)
if (player == null || !player.IsValid || player.IsHLTV)
return;

var callerName = caller == null ? "Console" : caller.PlayerName;
Expand Down
2 changes: 1 addition & 1 deletion Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public class CS2_SimpleAdminConfig : BasePluginConfig
public List<string> DefaultMaps { get; set; } = new();

[JsonPropertyName("WorkshopMaps")]
public List<string> WorkshopMaps { get; set; } = new();
public Dictionary<string, long?> WorkshopMaps { get; set; } = new();

[JsonPropertyName("CustomServerCommands")]
public List<CustomServerCommandData> CustomServerCommands { get; set; } = new();
Expand Down
8 changes: 2 additions & 6 deletions Events.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ private void OnGameServerSteamAPIActivated()
if (string.IsNullOrEmpty(ipAddress) || ipAddress.StartsWith("0.0.0"))
{
ipAddress = Helper.GetServerIp();
Logger.LogError("Unable to get server ip, Check that you have added the correct start parameter \"-ip <ip>\"");
Logger.LogError($"Using alternative method... Server IP {ipAddress}");
}

if (string.IsNullOrEmpty(ipAddress) || ipAddress.StartsWith("0.0.0"))
Expand Down Expand Up @@ -188,7 +186,7 @@ public HookResult OnPlayerFullConnect(EventPlayerConnectFull @event, GameEventIn
{
// Add player's IP and SteamID to bannedPlayers list if not already present
if (Config.BanType > 0 && playerInfo.IpAddress != null &&
!BannedPlayers.Contains(playerInfo.IpAddress))
!BannedPlayers.Contains(playerInfo.IpAddress))
{
BannedPlayers.Add(playerInfo.IpAddress);
}
Expand All @@ -202,7 +200,7 @@ public HookResult OnPlayerFullConnect(EventPlayerConnectFull @event, GameEventIn
await Server.NextFrameAsync(() =>
{
var victim = Utilities.GetPlayerFromUserid(playerInfo.UserId);

if (victim?.UserId != null)
{
if (UnlockedCommands)
Expand Down Expand Up @@ -365,8 +363,6 @@ public void OnMapStart(string mapName)
{
return;
ipAddress = Helper.GetServerIp();

Check warning on line 365 in Events.cs

View workflow job for this annotation

GitHub Actions / build

Unreachable code detected

Check warning on line 365 in Events.cs

View workflow job for this annotation

GitHub Actions / build

Unreachable code detected

Check warning on line 365 in Events.cs

View workflow job for this annotation

GitHub Actions / publish

Unreachable code detected

Check warning on line 365 in Events.cs

View workflow job for this annotation

GitHub Actions / publish

Unreachable code detected
Logger.LogError("Unable to get server ip, Check that you have added the correct start parameter \"-ip <ip>\"");
Logger.LogError($"Using alternative method... Server IP {ipAddress}");
}

var address = $"{ipAddress}:{ConVar.Find("hostport")?.GetPrimitiveValue<int>()}";
Expand Down
2 changes: 1 addition & 1 deletion Menus/ManageServerMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ private static void ChangeMapMenu(CCSPlayerController admin)
options.AddRange(maps.Select(map => new ChatMenuOptionData(map, () => ExecuteChangeMap(admin, map, false))));

var wsMaps = CS2_SimpleAdmin.Instance.Config.WorkshopMaps;
options.AddRange(wsMaps.Select(map => new ChatMenuOptionData($"{map} (WS)", () => ExecuteChangeMap(admin, map, true))));
options.AddRange(wsMaps.Select(map => new ChatMenuOptionData($"{map.Key} (WS)", () => ExecuteChangeMap(admin, map.Value?.ToString() ?? map.Key, true))));

foreach (var menuOptionData in options)
{
Expand Down

0 comments on commit a395a7d

Please sign in to comment.