Skip to content

Commit bbaca90

Browse files
committed
Adding not found for Tags
1 parent caaec09 commit bbaca90

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

CustomCommands/Functions.cs

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using CounterStrikeSharp.API.Modules.Utils;
99
using CustomCommands.Model;
1010
using Microsoft.Extensions.Logging;
11+
1112
namespace CustomCommands;
1213
public partial class CustomCommands
1314
{
@@ -32,6 +33,7 @@ private void RegisterListeners()
3233

3334
});
3435
}
36+
3537
private List<Commands> CheckForDuplicateCommands(List<Commands> comms)
3638
{
3739
List<Commands> duplicateCommands = new();
@@ -85,7 +87,7 @@ private void AddCommands(Commands com)
8587
{
8688
if (player == null) return;
8789

88-
if (com.Permission.PermissionList.Count >= 1)
90+
if (com.Permission.PermissionList.Count > 0 && com.Permission != null)
8991
if (!RequiresPermissions(player, com.Permission))
9092
return;
9193

@@ -212,21 +214,21 @@ private string ReplaceMessageTags(string input, CCSPlayerController player)
212214

213215
Dictionary<string, string> replacements = new()
214216
{
215-
{"{PREFIX}", PrefixCache},
216-
{"{MAP}", NativeAPI.GetMapName()},
217-
{"{TIME}", DateTime.Now.ToString("HH:mm:ss")},
218-
{"{DATE}", DateTime.Now.ToString("dd.MM.yyyy")},
219-
{"{PLAYERNAME}", player.PlayerName},
220-
{"{STEAMID2}", steamId.SteamId2},
221-
{"{STEAMID3}", steamId.SteamId3},
222-
{"{STEAMID32}", steamId.SteamId32.ToString()},
223-
{"{STEAMID64}", steamId.SteamId64.ToString()},
224-
{"{SERVERNAME}", ConVar.Find("hostname")!.StringValue},
225-
{"{IP}", ConVar.Find("ip")!.StringValue},
226-
{"{PORT}", ConVar.Find("hostport")!.GetPrimitiveValue<int>().ToString()},
227-
{"{MAXPLAYERS}", Server.MaxPlayers.ToString()},
217+
{"{PREFIX}", PrefixCache ?? "<PREFIX not found>"},
218+
{"{MAP}", NativeAPI.GetMapName() ?? "<MAP not found>"},
219+
{"{TIME}", DateTime.Now.ToString("HH:mm:ss") ?? "<TIME not found>"},
220+
{"{DATE}", DateTime.Now.ToString("dd.MM.yyyy") ?? "<DATE not found>"},
221+
{"{PLAYERNAME}", player.PlayerName ?? "<PLAYERNAME not found>"},
222+
{"{STEAMID2}", steamId.SteamId2 ?? "<STEAMID2 not found>"},
223+
{"{STEAMID3}", steamId.SteamId3 ?? "<STEAMID3 not found>"},
224+
{"{STEAMID32}", steamId.SteamId32.ToString() ?? "<STEAMID32 not found>"},
225+
{"{STEAMID64}", steamId.SteamId64.ToString() ?? "<STEAMID64 not found>"},
226+
{"{SERVERNAME}", ConVar.Find("hostname")!.StringValue ?? "<SERVERNAME not found>"},
227+
{"{IP}", ConVar.Find("ip")!.StringValue ?? "<IP not found>"},
228+
{"{PORT}", ConVar.Find("hostport")!.GetPrimitiveValue<int>().ToString() ?? "<PORT not found>"},
229+
{"{MAXPLAYERS}", Server.MaxPlayers.ToString() ?? "<MAXPLAYERS not found>"},
228230
{"{PLAYERS}",
229-
Utilities.GetPlayers().Count(u => u.PlayerPawn.Value != null && u.PlayerPawn.Value.IsValid).ToString()}
231+
Utilities.GetPlayers().Count(u => u.PlayerPawn.Value != null && u.PlayerPawn.Value.IsValid).ToString() ?? "<PLAYERS not found>"}
230232
};
231233

232234
foreach (var pair in replacements)

0 commit comments

Comments
 (0)