-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathFunBulletTeleport.cs
More file actions
37 lines (33 loc) · 1.33 KB
/
FunBulletTeleport.cs
File metadata and controls
37 lines (33 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Utils;
namespace FunMatchPlugin;
public class FunBulletTeleport : FunBaseClass
{
public override string Decription => "Bullet Teleport 瞬移子弹";
public FunBulletTeleport (FunMatchPlugin plugin): base(plugin){}
private BasePlugin.GameEventHandler<EventBulletImpact>? EventBulletImpactHandler;
public override void Fun(FunMatchPlugin plugin)
{
if (Enabled) return;
Enabled = true;
plugin.RegisterEventHandler <EventBulletImpact>(EventBulletImpactHandler = (@event, info) =>
{
if (Enabled == false) return HookResult.Stop;
Vector Position = new Vector(@event.X,@event.Y,@event.Z);
var oringin = @event.Userid!.OriginalControllerOfCurrentPawn.Get()!;
if (oringin is null) return HookResult.Continue;
var oringinpawn = oringin.PlayerPawn.Get();
if (oringinpawn is null) return HookResult.Continue;
oringinpawn!.Teleport(Position);
return HookResult.Continue;
});
}
public override void RegisterCommand(FunMatchPlugin plugin)
{
}
public override void EndFun(FunMatchPlugin plugin)
{
plugin.DeregisterEventHandler<EventBulletImpact> (EventBulletImpactHandler!);
Enabled = false;
}
}