CounterStrikeSharp icon indicating copy to clipboard operation
CounterStrikeSharp copied to clipboard

Error and requests for ChatMenu

Open Ganter1234 opened this issue 1 year ago • 2 comments

Requests:

Add an “exit” button, and add the ability for the “exit” and “back” buttons to enable them yourself, and add separate callbacks for them Do the same as in Sourcemod, add a separate line with information and display ( AddMenuOption(string info, string display, Action<CCSPlayerController, ChatMenuOption> onSelect, bool disabled = false); )

Error:

If there are, for example, 2 items in the menu, then if you write !3 an error will appear [EROR] (cssharp:Core) Error invoking callback System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index') at System.Collections.Generic.List`1.get_Item(Int32 index) at CounterStrikeSharp.API.Modules.Menu.ChatMenuInstance.OnKeyPress(CCSPlayerController player, Int32 key) in /home/runner/work/CounterStrikeSharp/CounterStrikeSharp/managed/CounterStrikeSharp.API/Modules/Menu/ChatMenu.cs:line 115 at CounterStrikeSharp.API.Modules.Menu.ChatMenus.OnKeyPress(CCSPlayerController player, Int32 key) in /home/runner/work/CounterStrikeSharp/CounterStrikeSharp/managed/CounterStrikeSharp.API/Modules/Menu/ChatMenu.cs:line 162 at CounterStrikeSharp.API.Core.Application.<>c.<Start>b__15_0(CCSPlayerController player, CommandInfo info) in /home/runner/work/CounterStrikeSharp/CounterStrikeSharp/managed/CounterStrikeSharp.API/Core/Application.cs:line 92 at CounterStrikeSharp.API.Modules.Utils.CommandUtils.<>c__DisplayClass0_0.<AddStandaloneCommand>b__0(Int32 i, IntPtr ptr) in /home/runner/work/CounterStrikeSharp/CounterStrikeSharp/managed/CounterStrikeSharp.API/Modules/Utils/StandaloneCommand.cs:line 99 at InvokeStub_Action`2.Invoke(Object, Object, IntPtr*) at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr) --- End of inner exception stack trace --- at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.Delegate.DynamicInvokeImpl(Object[] args) at CounterStrikeSharp.API.Core.FunctionReference.<>c__DisplayClass3_0.<.ctor>b__0(fxScriptContext* context) in /home/runner/work/CounterStrikeSharp/CounterStrikeSharp/managed/CounterStrikeSharp.API/Core/FunctionReference.cs:line 82

Ganter1234 avatar Jan 18 '24 13:01 Ganter1234

https://github.com/roflmuffin/CounterStrikeSharp/pull/268

xLeviNx avatar Jan 19 '24 18:01 xLeviNx

#268

I'll test this on my latest PR build now, thanks 👍

Tested: It doesn't throw an exception.

B3none avatar Jan 19 '24 18:01 B3none

As this is now working on the latest build I'm going to close out this issue.

B3none avatar Nov 09 '24 12:11 B3none