Skip to content

Commit a93a9ab

Browse files
committed
feat: menu auto bind for 1-9
1 parent e240be5 commit a93a9ab

3 files changed

Lines changed: 49 additions & 6 deletions

File tree

.github/workflows/release.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ name: Create Release
22

33
on:
44
push:
5-
# Trigger on tags that start with "v", for example: v2.4.0
65
tags:
76
- 'v*'
87

@@ -17,11 +16,11 @@ jobs:
1716
uses: softprops/action-gh-release@v1
1817
with:
1918
tag_name: ${{ github.ref }}
20-
release_name: 'Release ${{ github.ref }}'
19+
name: 'Release ${{ github.ref }}'
2120
body: |
22-
**What's New in this Release:**
21+
# Update
22+
23+
- fix: menu sounds plays when menu has no option (KeyPress)
2324
24-
- Add your release information here.
25-
- You can include changelogs, features, bug fixes, etc.
2625
env:
27-
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
26+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Extensions/Extensions.cs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Text.Json;
44
using System.Text.Json.Nodes;
55
using System.Text.Json.Serialization;
6+
using CounterStrikeSharp.API.Core;
67

78
namespace CS2ScreenMenuAPI.Extensions
89
{
@@ -38,6 +39,44 @@ public override void Write(Utf8JsonWriter writer, Color value, JsonSerializerOpt
3839
: ColorTranslator.ToHtml(value);
3940
writer.WriteStringValue(colorString);
4041
}
42+
}
43+
public static class Helper
44+
{
45+
46+
public static void SetBinds(CCSPlayerController player)
47+
{
48+
player.ExecuteClientCommand("echo test | bind 1 \"slot1;css_1\"");
49+
player.ExecuteClientCommand("echo test | bind 2 \"slot2;css_2\"");
50+
player.ExecuteClientCommand("echo test | bind 3 \"slot3;css_3\"");
51+
player.ExecuteClientCommand("echo test | bind 4 \"slot4;css_4\"");
52+
player.ExecuteClientCommand("echo test | bind 5 \"slot5;css_5\"");
53+
player.ExecuteClientCommand("echo test | bind 6 \"slot6;css_6\"");
54+
player.ExecuteClientCommand("echo test | bind 7 \"slot7;css_7\"");
55+
player.ExecuteClientCommand("echo test | bind 8 \"slot8;css_8\"");
56+
player.ExecuteClientCommand("echo test | bind 9 \"slot9;css_9\"");
57+
}
58+
public static void RemoveBinds(CCSPlayerController player)
59+
{
4160

61+
player.ExecuteClientCommand("echo test | unbind 1 \"slot1;\"");
62+
player.ExecuteClientCommand("echo test | unbind 2 \"slot2;\"");
63+
player.ExecuteClientCommand("echo test | unbind 3 \"slot3;\"");
64+
player.ExecuteClientCommand("echo test | unbind 4 \"slot4;\"");
65+
player.ExecuteClientCommand("echo test | unbind 5 \"slot5;\"");
66+
player.ExecuteClientCommand("echo test | unbind 6 \"slot6;\"");
67+
player.ExecuteClientCommand("echo test | unbind 7 \"slot7;\"");
68+
player.ExecuteClientCommand("echo test | unbind 8 \"slot8;\"");
69+
player.ExecuteClientCommand("echo test | unbind 9 \"slot9;\"");
70+
71+
player.ExecuteClientCommand("echo test | bind 1 \"css_1\"");
72+
player.ExecuteClientCommand("echo test | bind 2 \"css_2\"");
73+
player.ExecuteClientCommand("echo test | bind 3 \"css_3\"");
74+
player.ExecuteClientCommand("echo test | bind 4 \"css_4\"");
75+
player.ExecuteClientCommand("echo test | bind 5 \"css_5\"");
76+
player.ExecuteClientCommand("echo test | bind 6 \"css_6\"");
77+
player.ExecuteClientCommand("echo test | bind 7 \"css_7\"");
78+
player.ExecuteClientCommand("echo test | bind 8 \"css_8\"");
79+
player.ExecuteClientCommand("echo test | bind 9 \"css_9\"");
80+
}
4281
}
4382
}

MenuAPI.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using CounterStrikeSharp.API.Core;
22
using CS2ScreenMenuAPI.Interfaces;
33
using CS2ScreenMenuAPI.Internal;
4+
using CS2ScreenMenuAPI.Extensions;
45

56
namespace CS2ScreenMenuAPI
67
{
@@ -22,6 +23,7 @@ public static void OpenMenu(BasePlugin plugin, CCSPlayerController player, Scree
2223
ActiveMenus[player.Handle] = new ScreenMenuInstance(plugin, player, menu);
2324
ActiveMenus[player.Handle].Display();
2425
});
26+
Helper.RemoveBinds(player);
2527
}
2628

2729
public static void OpenSubMenu(BasePlugin plugin, CCSPlayerController player, ScreenMenu menu)
@@ -35,6 +37,7 @@ public static void OpenSubMenu(BasePlugin plugin, CCSPlayerController player, Sc
3537
}
3638
ActiveMenus[player.Handle] = new ScreenMenuInstance(plugin, player, menu);
3739
ActiveMenus[player.Handle].Display();
40+
Helper.RemoveBinds(player);
3841
}
3942

4043
public static void CloseActiveMenu(CCSPlayerController player)
@@ -44,6 +47,7 @@ public static void CloseActiveMenu(CCSPlayerController player)
4447
if (ActiveMenus.TryGetValue(player.Handle, out var menu))
4548
{
4649
menu.Close();
50+
Helper.SetBinds(player);
4751
ActiveMenus.Remove(player.Handle);
4852
}
4953
}
@@ -54,6 +58,7 @@ public static void RemoveActiveMenu(CCSPlayerController player)
5458
return;
5559

5660
ActiveMenus.Remove(player.Handle);
61+
Helper.SetBinds(player);
5762
}
5863

5964
public static IMenuInstance? GetActiveMenu(CCSPlayerController player)

0 commit comments

Comments
 (0)