-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial release
- Loading branch information
Showing
14 changed files
with
659 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
|
||
# cs2-tags | ||
|
||
## Commands | ||
``` | ||
css_tags_reload - Reloads tag | ||
css_toggletags - Hide/Show tag | ||
``` | ||
|
||
## Colors | ||
``` | ||
Default | ||
White | ||
DarkRed | ||
Green | ||
LightYellow | ||
LightBlue | ||
Olive | ||
Lime | ||
Red | ||
LightPurple | ||
Purple | ||
Grey | ||
Yellow | ||
Gold | ||
Silver | ||
Blue | ||
DarkBlue | ||
BlueGrey | ||
Magenta | ||
LightRed | ||
Orange | ||
``` | ||
|
||
## Configuration | ||
```json | ||
{ | ||
"settings": { | ||
"deadname": "{TeamColor}*DEAD* ", | ||
"nonename": "{White}(NONE) ", | ||
"specname": "{Purple}(SPEC) ", | ||
"tname": "{TeamColor}(T) ", | ||
"ctname": "{TeamColor}(CT) " | ||
}, | ||
"tags": { | ||
"default": { | ||
"ScoreTag": "", | ||
"ChatTag": "", | ||
"NameColor": "{TeamColor}", | ||
"ChatColor": "{White}" | ||
} | ||
"76561198397942039": { | ||
"ScoreTag": "ADMIN", | ||
"ChatTag": "{yellow}", | ||
"NameColor": "{yellow}", | ||
"ChatColor": "{Green}" | ||
}, | ||
"#Owner": { | ||
"ScoreTag": "Owner", | ||
"ChatTag": "{DarkRed}[Owner] ", | ||
"NameColor": "{TeamColor}", | ||
"ChatColor": "{Green}" | ||
}, | ||
"@css/admin": { | ||
"ScoreTag": "Admin", | ||
"ChatTag": "{DarkRed}[Admin] ", | ||
"NameColor": "{TeamColor}", | ||
"ChatColor": "{Green}" | ||
} | ||
} | ||
} | ||
``` | ||
|
||
## Screenshots | ||
|
||
![image](https://github.com/schwarper/cs2-tags/assets/75811921/d7dea9c8-0183-415a-841b-e62ca0cc1e31) | ||
|
||
![image](https://github.com/schwarper/cs2-tags/assets/75811921/fa2fd391-ea45-43e3-bd76-338082970b61) | ||
|
||
![image](https://github.com/schwarper/cs2-tags/assets/75811921/d4bc4425-a9a9-4534-8de6-f8c6464194a2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using CounterStrikeSharp.API.Core; | ||
using CounterStrikeSharp.API.Core.Capabilities; | ||
using static TagApi.Tag; | ||
|
||
namespace TagApi; | ||
|
||
public interface ITagApi | ||
{ | ||
public static readonly PluginCapability<ITagApi?> Capability = new("tag:api"); | ||
|
||
public string GetClientTag(CCSPlayerController player, Tags tag); | ||
public void SetClientTag(CCSPlayerController player, Tags tag, string newtag); | ||
public void ResetClientTag(CCSPlayerController player, Tags tag); | ||
public string GetClientColor(CCSPlayerController player, Colors color); | ||
public void SetClientColor(CCSPlayerController player, Colors color, string newcolor); | ||
public void ResetClientColor(CCSPlayerController player, Colors color); | ||
public void ReloadTags(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
namespace TagApi; | ||
|
||
public abstract class Tag | ||
{ | ||
public class CTag | ||
{ | ||
public string ScoreTag { get; set; } = string.Empty; | ||
public string ChatTag { get; set; } = string.Empty; | ||
public string ChatColor { get; set; } = string.Empty; | ||
public string NameColor { get; set; } = string.Empty; | ||
} | ||
|
||
public enum Tags | ||
{ | ||
ScoreTag, | ||
ChatTag | ||
} | ||
|
||
public enum Colors | ||
{ | ||
ChatColor, | ||
NameColor | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.202" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "cs2-tags", "cs2-tags\cs2-tags.csproj", "{8F7EF308-8867-4802-B12F-5E27A2AF9995}" | ||
EndProject | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TagApi", "TagApi\TagApi.csproj", "{A4E0FE20-CD3C-4E3D-95CE-AE48F7A77DF7}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{8F7EF308-8867-4802-B12F-5E27A2AF9995}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{8F7EF308-8867-4802-B12F-5E27A2AF9995}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{8F7EF308-8867-4802-B12F-5E27A2AF9995}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{8F7EF308-8867-4802-B12F-5E27A2AF9995}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{A4E0FE20-CD3C-4E3D-95CE-AE48F7A77DF7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{A4E0FE20-CD3C-4E3D-95CE-AE48F7A77DF7}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{A4E0FE20-CD3C-4E3D-95CE-AE48F7A77DF7}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{A4E0FE20-CD3C-4E3D-95CE-AE48F7A77DF7}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {9061A6F9-8330-43EE-A1A0-6DBC08696E5D} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.205" /> | ||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> | ||
</ItemGroup> | ||
|
||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\TagApi\TagApi.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"deadicon": "\u2620", | ||
"tags": { | ||
"default": { | ||
"ScoreTag": "", | ||
"ChatTag": "", | ||
"NameColor": "{TeamColor}", | ||
"ChatColor": "{White}" | ||
}, | ||
"76561199165718810": { | ||
"ScoreTag": "schwarper", | ||
"ChatTag": "{DarkRed}[schwarper] ", | ||
"NameColor": "{TeamColor}", | ||
"ChatColor": "{Green}" | ||
}, | ||
"#Owner": { | ||
"ScoreTag": "Owner", | ||
"ChatTag": "{DarkRed}[Owner] ", | ||
"NameColor": "{TeamColor}", | ||
"ChatColor": "{Green}" | ||
}, | ||
"@css/admin": { | ||
"ScoreTag": "Admin", | ||
"ChatTag": "{DarkRed}[Admin] ", | ||
"NameColor": "{TeamColor}", | ||
"ChatColor": "{Green}" | ||
} | ||
}, | ||
"ConfigVersion": 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
using CounterStrikeSharp.API.Core; | ||
using TagApi; | ||
using static Tag.Tag; | ||
using static TagApi.Tag; | ||
|
||
namespace Tag; | ||
|
||
public class TagAPI : ITagApi | ||
{ | ||
public TagAPI() | ||
{ | ||
} | ||
|
||
public string GetClientTag(CCSPlayerController player, Tags tag) | ||
{ | ||
return tag switch | ||
{ | ||
Tags.ScoreTag => Instance.PlayerDatas[player.Slot].ScoreTag, | ||
Tags.ChatTag => Instance.PlayerDatas[player.Slot].ChatTag, | ||
_ => string.Empty | ||
}; | ||
} | ||
|
||
public void SetClientTag(CCSPlayerController player, Tags tag, string newtag) | ||
{ | ||
if (tag == Tags.ScoreTag) | ||
{ | ||
Instance.PlayerDatas[player.Slot].ScoreTag = newtag; | ||
} | ||
else | ||
{ | ||
Instance.PlayerDatas[player.Slot].ChatTag = newtag; | ||
} | ||
} | ||
|
||
public void ResetClientTag(CCSPlayerController player, Tags tag) | ||
{ | ||
if (tag == Tags.ScoreTag) | ||
{ | ||
Instance.PlayerDatas[player.Slot].ScoreTag = GetTag(player).ScoreTag; | ||
} | ||
else | ||
{ | ||
Instance.PlayerDatas[player.Slot].ChatTag = GetTag(player).ChatTag; | ||
} | ||
} | ||
|
||
public string GetClientColor(CCSPlayerController player, Colors color) | ||
{ | ||
return color switch | ||
{ | ||
Colors.NameColor => Instance.PlayerDatas[player.Slot].NameColor, | ||
Colors.ChatColor => Instance.PlayerDatas[player.Slot].ChatColor, | ||
_ => string.Empty | ||
}; | ||
} | ||
|
||
public void SetClientColor(CCSPlayerController player, Colors color, string newcolor) | ||
{ | ||
if (color == Colors.ChatColor) | ||
{ | ||
Instance.PlayerDatas[player.Slot].ChatColor = newcolor; | ||
} | ||
else | ||
{ | ||
Instance.PlayerDatas[player.Slot].NameColor = newcolor; | ||
} | ||
} | ||
|
||
public void ResetClientColor(CCSPlayerController player, Colors color) | ||
{ | ||
CTag defaultTag = GetTag(player); | ||
|
||
if (color == Colors.ChatColor) | ||
{ | ||
Instance.PlayerDatas[player.Slot].ChatColor = defaultTag.ChatColor; | ||
} | ||
else | ||
{ | ||
Instance.PlayerDatas[player.Slot].NameColor = defaultTag.NameColor; | ||
} | ||
} | ||
|
||
public void ReloadTags() | ||
{ | ||
Json.ReadConfig(); | ||
UpdatePlayerTags(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using CounterStrikeSharp.API.Core; | ||
using CounterStrikeSharp.API.Core.Attributes.Registration; | ||
using CounterStrikeSharp.API.Modules.Admin; | ||
using CounterStrikeSharp.API.Modules.Commands; | ||
using static Tag.Tag; | ||
using static TagApi.Tag; | ||
|
||
namespace Tag; | ||
|
||
public partial class Tag | ||
{ | ||
[ConsoleCommand("css_tags_reload")] | ||
[RequiresPermissions("@css/root")] | ||
public void Command_Tags_Reload(CCSPlayerController? player, CommandInfo info) | ||
{ | ||
Json.ReadConfig(); | ||
UpdatePlayerTags(); | ||
|
||
info.ReplyToCommand("[cs2-tags] Tags are reloaded."); | ||
} | ||
|
||
[ConsoleCommand("css_toggletags")] | ||
[RequiresPermissions("@css/admin")] | ||
[CommandHelper(whoCanExecute: CommandUsage.CLIENT_ONLY)] | ||
public void Command_Toggletags(CCSPlayerController? player, CommandInfo info) | ||
{ | ||
if (Instance.PlayerToggleTags[player!.Slot]) | ||
{ | ||
Instance.PlayerDatas[player.Slot] = Instance.Config.Tags.FirstOrDefault(tag => tag.Key == "default").Value ?? new CTag(); | ||
|
||
Instance.PlayerToggleTags[player.Slot] = false; | ||
|
||
info.ReplyToCommand("[cs2-tags] Toggletags is false"); | ||
} | ||
else | ||
{ | ||
Instance.PlayerDatas[player.Slot] = GetTag(player); | ||
|
||
Instance.PlayerToggleTags[player.Slot] = true; | ||
|
||
info.ReplyToCommand("[cs2-tags] Toggletags is true"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using CounterStrikeSharp.API.Core; | ||
using System.Collections.Concurrent; | ||
using System.Text.Json.Serialization; | ||
using static TagApi.Tag; | ||
|
||
namespace Tag; | ||
|
||
public class TagConfig : BasePluginConfig | ||
{ | ||
[JsonPropertyName("settings")] | ||
public Dictionary<string, string> Settings { get; set; } = new Dictionary<string, string> | ||
{ | ||
{ "deadname", "☠" }, | ||
{ "nonename", "{White}(NONE)" }, | ||
{ "specname", "{Purple}(SPEC)" }, | ||
{ "tname", "{Yellow}(T)" }, | ||
{ "ctname", "{Blue}(CT)" } | ||
}; | ||
|
||
[JsonPropertyName("tags")] | ||
public ConcurrentDictionary<string, CTag> Tags { get; set; } = new ConcurrentDictionary<string, CTag> | ||
{ | ||
["default"] = new CTag { ChatColor = "", ChatTag = "{Grey}[Player]", NameColor = "", ScoreTag = "" } | ||
}; | ||
} |
Oops, something went wrong.