Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ https://www.youtube.com/watch?v=Be7qop6pVpI
When number keys are bound with the following snippet, automatically detected and the menu will look like it used to in CSS and CS:GO:

```
bind 1 "slot1;css_1"
bind 1 "slot1;css_1" // menuselect 1 is also supported
bind 2 "slot2;css_2"
...
bind 9 "slot9;css_9"
Expand Down
26 changes: 26 additions & 0 deletions src/SharpModMenu/SharpModMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@
cmd->Base->SideMove = 0.0f;
cmd->Base->ForwardMove = 0.0f;
cmd->Base->UpMove = 0.0f;

Check warning on line 293 in src/SharpModMenu/SharpModMenu.cs

View workflow job for this annotation

GitHub Actions / Continuous integration

Unreachable code detected
if ((nint)cmd->Base->Buttons != nint.Zero)
{
var buttons = cmd->Base->Buttons->ButtonState3;
Expand Down Expand Up @@ -338,6 +338,32 @@
return HookResult.Continue;
}

[ConsoleCommand("menuselect")]
public void MenuSelect(CCSPlayerController player, CommandInfo info)
{
if (player is null || !player.IsValid)
return;
var menuState = DriverInstance?.GetMenuState(player, create: true);
if (menuState is null)
return;

if (info.ArgCount < 2)
{
info.ReplyToCommand($"menuselect: Invalid number of arguments provided");
return;
}

var valStr = info.ArgByIndex(1);
if (!int.TryParse(valStr, CultureInfo.InvariantCulture, out var val))
{
info.ReplyToCommand($"menuselect: Failed to parse argument as int: {valStr}");
return;
}

var key = (PlayerKey)((int)PlayerKey.SelectItem1 + (val - 1));
menuState.HandleInput(key, info.CallingContext == CommandCallingContext.Console);
}

[ConsoleCommand("css_1")]
public void Css1(CCSPlayerController player, CommandInfo info)
{
Expand Down