Skip to content

Commit

Permalink
Merge pull request #6 from schwarper/PlayerGagSystem
Browse files Browse the repository at this point in the history
Added player gag system
  • Loading branch information
schwarper authored Jun 11, 2024
2 parents bdc6f86 + 18e4ed9 commit 325fb36
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 12 deletions.
2 changes: 2 additions & 0 deletions TagsApi/ITagsApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ public interface ITagApi
{
public static readonly PluginCapability<ITagApi?> Capability = new("tags:api");

public void GagPlayer(ulong steamID);
public void UngagPlayer(ulong steamID);
public string GetPlayerTag(CCSPlayerController player, Tags_Tags tag);
public void SetPlayerTag(CCSPlayerController player, Tags_Tags tag, string newtag);
public void ResetPlayerTag(CCSPlayerController player, Tags_Tags tag);
Expand Down
4 changes: 3 additions & 1 deletion TagsApi/TagsApi.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace TagsApi;
using CounterStrikeSharp.API.Core;

namespace TagsApi;

public abstract class Tags
{
Expand Down
10 changes: 10 additions & 0 deletions cs2-tags/src/api/api.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ public TagsAPI()
{
}

public void GagPlayer(ulong steamID)
{
PlayerGagList.Add(steamID);
}

public void UngagPlayer(ulong steamID)
{
PlayerGagList.Remove(steamID);
}

public string GetPlayerTag(CCSPlayerController player, Tags_Tags tag)
{
if (Instance.PlayerTagDatas.TryGetValue(player.Slot, out Tag? playerTag) && playerTag != null)
Expand Down
3 changes: 2 additions & 1 deletion cs2-tags/src/cs2-tag.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ namespace Tags;
public partial class Tags : BasePlugin, IPluginConfig<TagsConfig>
{
public override string ModuleName => "Tag";
public override string ModuleVersion => "0.0.3";
public override string ModuleVersion => "0.0.4";
public override string ModuleAuthor => "schwarper";

public TagsConfig Config { get; set; } = new TagsConfig();
public Dictionary<int, Tag> PlayerTagDatas { get; set; } = [];
public Dictionary<int, bool> PlayerToggleTags { get; set; } = [];
public static Tags Instance { get; set; } = new Tags();
public int GlobalTick { get; set; }
public static HashSet<ulong> PlayerGagList { get; set; } = [];

public override void Load(bool hotReload)
{
Expand Down
21 changes: 11 additions & 10 deletions cs2-tags/src/event/event.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using CounterStrikeSharp.API.Modules.Utils;
using static CounterStrikeSharp.API.Core.Listeners;
using static Tags.Tags;
using static Tags.TagsAPI;
using static TagsApi.Tags;

namespace Tags;
Expand Down Expand Up @@ -66,30 +67,30 @@ public static HookResult OnPlayerChat(CCSPlayerController? player, CommandInfo i
return HookResult.Continue;
}

if (!Instance.PlayerTagDatas.TryGetValue(player.Slot, out Tag? playerData) || playerData == null)
string command = info.GetArg(1);

if (CoreConfig.SilentChatTrigger.Any(i => command.StartsWith(i)))
{
return HookResult.Continue;
}

string command = info.GetArg(1);
if (PlayerGagList.Contains(player.SteamID))
{
return HookResult.Handled;
}

if (CoreConfig.PublicChatTrigger.Any(i => command.StartsWith(i)))
{
/* TO DO
* Try to find something else, for now ignore it.
player.ExecuteClientCommandFromServer($"css_{command[1..]}");
*/

return HookResult.Continue;
}

if (CoreConfig.SilentChatTrigger.Any(i => command.StartsWith(i)))
if (!Instance.PlayerTagDatas.TryGetValue(player.Slot, out Tag? playerData) || playerData == null)
{
return HookResult.Handled;
return HookResult.Continue;
}

string deadname = player.PawnIsAlive ? string.Empty : Instance.Config.Settings["deadname"];
bool teammessage = info.GetArg(0) == "say_team";
string deadname = player.PawnIsAlive ? string.Empty : Instance.Config.Settings["deadname"];
string tag = playerData.ChatTag;
string namecolor = playerData.NameColor;
string chatcolor = playerData.ChatColor;
Expand Down

0 comments on commit 325fb36

Please sign in to comment.