VirtualFunctions.ClientPrint not working inside EventBulletImpact, working for EventItemPickup example
RegisterEventHandler<EventBulletImpact>((@event, info) =>
{
var player = @event.Userid;
if (player == null || !player.IsValid)
return HookResult.Continue;
player.PrintToChat($"123"); // doesn't work
player.PrintToCenterAlert("123"); // doesn't work
player.PrintToCenter("123"); // doesn't work
player.PrintToConsole("123"); // works
player.PrintToCenterHtml("123"); // works
player.PlayerPawn.Value!.Teleport(new Vector(@event.X, @event.Y, @event.Z), QAngle.Zero, Vector.Zero); // works
Console.WriteLine($"{@event.X}, {@event.Y}, {@event.Z}"); // works
return HookResult.Continue;
});
RegisterEventHandler<EventItemPickup>((@event, info) =>
{
var player = @event.Userid;
if (player == null || !player.IsValid)
return HookResult.Continue;
player.PrintToChat($"123"); // works
player.PrintToCenterAlert("123"); // works
player.PrintToCenter("123"); // works
player.PrintToConsole("123"); // works
player.PrintToCenterHtml("123"); // works
//player.PlayerPawn.Value!.Teleport(new Vector(@event.X, @event.Y, @event.Z), QAngle.Zero, Vector.Zero); // works
//Console.WriteLine($"{@event.X}, {@event.Y}, {@event.Z}"); // works
return HookResult.Continue;
});
CounterStrikeSharp was created and is maintained by Michael "roflmuffin" Wilson. Counter-Strike Sharp uses code borrowed from SourceMod, Source.Python, FiveM, Saul Rennison, source2gen and CS2Fixes. See ACKNOWLEDGEMENTS.md for more information. Current API Version: v287 (1.0.287+6cf124b)
Metamod:Source Version Information Metamod:Source version 2.0.0-dev+1314
use with
Server.NextFrame(() => { //print here });
use with
Server.NextFrame(() => { //print here });
This just results in a seg fault
RegisterEventHandler<EventBulletImpact>((@event, info) =>
{
var player = @event.Userid;
if (player == null || !player.IsValid)
return HookResult.Continue;
Server.NextFrame(() =>
{
player.PrintToChat($"{@event.X}, {@event.Y}, {@event.Z}");
});
Console.WriteLine($"{@event.X}, {@event.Y}, {@event.Z}"); // works
return HookResult.Continue;
});
https://pastebin.com/cV2ZwZM6
it is logical that in the next frame there is no event anymore copy the values before this
float x = @event.X;
float y = @event.Y;
float z = @event.Z;
Server.NextFrame...
it is logical that in the next frame there is no event anymore copy the values before this
float x = @event.X; float y = @event.Y; float z = @event.Z; Server.NextFrame...
Perhaps we might need to add more documentation that clarifies that game events don't exist on the next frame.