效果如图,输入指令!ray开启

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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
new g_Sprite;
new shexian = 0;
public Plugin:myinfo=
{
name = "子弹射线",
author = "笨蛋海绵",
description = "子弹射线",
url = "https://abbw.ml"
};
public OnPluginStart()
{
RegAdminCmd("sm_ray",abbw_shexian, ADMFLAG_ROOT, "开关");
}
public OnMapStart()
{
g_Sprite = PrecacheModel("materials/sprites/laserbeam.vmt");
}
public Action:abbw_shexian(client, args)
{
if (shexian == 1)
{
PrintHintTextToAll("关闭子弹射线");
shexian = 0;
UnhookEvent("bullet_impact", Event_ZDPZ);
} else
{
PrintHintTextToAll("开启子弹射线");
shexian = 1;
HookEvent("bullet_impact", Event_ZDPZ);
}
}
public Event_ZDPZ(Handle:event,const String:name[],bool:dontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(event, "userid"));
decl Float:Origin[3];
Origin[0] = GetEventFloat(event,"x");
Origin[1] = GetEventFloat(event,"y");
Origin[2] = GetEventFloat(event,"z");
decl color[4];
color[0] = GetRandomInt(0, 255);
color[1] = GetRandomInt(0, 255);
color[2] = GetRandomInt(0, 255);
color[3] = 128;
decl Float:Pos[3];
GetClientAbsOrigin(client, Pos);
decl Float:bulletPos[3];
bulletPos = Origin;
decl Float:playerPos[3];
GetClientEyePosition(client, playerPos);
decl Float:lineVector[3];
SubtractVectors(playerPos, Origin, lineVector);
NormalizeVector(lineVector, lineVector);
ScaleVector(lineVector, 20.0);
SubtractVectors(playerPos, lineVector, Origin);
TE_SetupBeamPoints(Origin, bulletPos, g_Sprite, 0, 0, 0, 0.5, 0.5, 0.5, 1, 0.0, color, 0);
TE_SendToAll();
}