roflmuffin / CounterStrikeSharp

CounterStrikeSharp allows you to write server plugins in C# for Counter-Strike 2/Source2/CS2
https://docs.cssharp.dev
Other
714 stars 111 forks source link

GiveNamedItem(String item) #428

Closed Mr-Robot-ops closed 2 months ago

Mr-Robot-ops commented 2 months ago

I've been writing my first plugin over the last few weeks, working with CSharp. And yes, I'm aware that it's certainly not perfect. But after a lot of back and forth and testing, it finally did what I wanted it to do.

And now, after yesterday's update of VALVE, my plugin no longer works, so I switched to version V215. Unfortunately without any change. I already tried to debug the whole thing and the weapon values are transferred correctly.

I know you guys are very busy at the moment and have more important things to do. Maybe someone can take a look at my makeshift code?

18:36:19 [EROR] (cssharp:Core) Error invoking callback
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> CounterStrikeSharp.API.Core.NativeException: Invalid function pointer
   at CounterStrikeSharp.API.Core.ScriptContext.CheckErrors() in /home/runner/work/CounterStrikeSharp/CounterStrikeSharp/managed/CounterStrikeSharp.API/Core/ScriptContext.cs:line 176
   at CounterStrikeSharp.API.Core.NativeAPI.ExecuteVirtualFunction[T](IntPtr function, Object[] arguments) in /home/runner/work/CounterStrikeSharp/CounterStrikeSharp/managed/CounterStrikeSharp.API/Core/API.cs:line 1059
   at CounterStrikeSharp.API.Modules.Memory.DynamicFunctions.BaseMemoryFunction.InvokeInternal[T](Object[] args) in /home/runner/work/CounterStrikeSharp/CounterStrikeSharp/managed/CounterStrikeSharp.API/Modules/Memory/DynamicFunctions/BaseMemoryFunction.cs:line 72
   at CounterStrikeSharp.API.Modules.Memory.DynamicFunctions.MemoryFunctionWithReturn`7.Invoke(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6) in /home/runner/work/CounterStrikeSharp/CounterStrikeSharp/managed/CounterStrikeSharp.API/Modules/Memory/DynamicFunctions/MemoryFunctionWithReturn.cs:line 154
   at CounterStrikeSharp.API.Core.CCSPlayerController.GiveNamedItem(String item) in /home/runner/work/CounterStrikeSharp/CounterStrikeSharp/managed/CounterStrikeSharp.API/Core/Model/CCSPlayerController.cs:line 26
   at DecoyPlugin.DecoyPlugin.GiveMissingWeapons(CCSPlayerController player, HashSet`1 expectedWeapons) in C:\Users\Censored\Documents\CSSHARP\test3\Decoy\Decoy.cs:line 93
   at DecoyPlugin.DecoyPlugin.<Load>b__6_2() in C:\Users\Censored\Documents\CSSHARP\test3\Decoy\Decoy.cs:line 53
   at InvokeStub_Action.Invoke(Object, Object, IntPtr*)
   at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
   --- End of inner exception stack trace ---
   at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
   at System.Delegate.DynamicInvokeImpl(Object[] args)
   at CounterStrikeSharp.API.Core.FunctionReference.<CreateWrappedCallback>b__18_0(fxScriptContext* context) in /home/runner/work/CounterStrikeSharp/CounterStrikeSharp/managed/CounterStrikeSharp.API/Core/FunctionReference.cs:line 100

Gist-Decoy.cs GitHub

roflmuffin commented 2 months ago

I've just merged in a change to make givenameditem more resilient after updates, please try again with v216

crashzk commented 2 months ago

Linux subscription, does it need to be updated @roflmuffin?

https://github.com/ianlucas/cs2-inventory-simulator-plugin/issues/7

I tested it here and everything worked fine.

  "GiveNamedItem": {
    "signatures": {
      "library": "server",
      "windows": "\\x48\\x89\\x5C\\x24\\x2A\\x48\\x89\\x74\\x24\\x2A\\x55\\x57\\x41\\x2A\\x41\\x2A\\x41\\x2A\\x48\\x2A\\x2A\\x2A\\x2A\\x48\\x2A\\x2A\\x2A\\x2A\\x2A\\x2A\\x4D\\x2A\\x2A\\x48",
      "linux": "\\x55\\x48\\x89\\xE5\\x41\\x57\\x41\\x56\\x49\\x89\\xD6\\x41\\x55\\x49\\x89\\xFD\\x41\\x54\\x48"
    }
  },
roflmuffin commented 2 months ago

@crashzk Updated the linux sig in v218

Mr-Robot-ops commented 2 months ago

Thank you from the bottom of my heart for your quick response. Everything is working again