-
Notifications
You must be signed in to change notification settings - Fork 1
/
grenades_dlight.sma
82 lines (67 loc) · 2.45 KB
/
grenades_dlight.sma
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include <amxmodx>
#include <reapi>
#define AUTO_CFG // автоматическое создание конфига с кварами
enum CVARS {
HE_COLOR,
FB_COLOR
};
new cvar[CVARS];
public plugin_init() {
register_plugin("[ReAPI] Grenades Dynamic Light", "1.1", "szawesome");
RegisterCvars();
new alert_he[128];
get_pcvar_string(cvar[HE_COLOR], alert_he, sizeof alert_he);
if(strlen(alert_he)) {
RegisterHookChain(RG_CGrenade_ExplodeHeGrenade, "CGrenade_ExplodeHE_Post", true);
}
new alert_fb[128];
get_pcvar_string(cvar[FB_COLOR], alert_fb, sizeof alert_fb);
if(strlen(alert_fb)) {
RegisterHookChain(RG_CGrenade_ExplodeFlashbang, "CGrenade_ExplodeFB_Post", true);
}
}
RegisterCvars() {
cvar[HE_COLOR] = create_cvar(
.name = "gdl_he",
.string = "255 220 0",
.flags = FCVAR_NONE,
.description = "Цвет дин. освещения при взырве HE. Формат: R G B^nОставьте пустым чтобы отключить еффект"
);
cvar[FB_COLOR] = create_cvar(
.name = "gdl_fb",
.string = "255 255 255",
.flags = FCVAR_NONE,
.description = "Цвет дин. освещения при взырве FB. Формат: R G B^nОставьте пустым чтобы отключить еффект"
);
#if defined AUTO_CFG
AutoExecConfig();
#endif
}
public CGrenade_ExplodeHE_Post(ent) {
new he_color[11]; get_pcvar_string(cvar[HE_COLOR], he_color, sizeof he_color);
new red[5], green[5], blue[5]; parse(he_color, red, 4, green, 4, blue, 4);
new Float:origin[3];
get_entvar(ent, var_origin, origin);
make_dyn_light(origin, str_to_num(red), str_to_num(green), str_to_num(blue));
}
public CGrenade_ExplodeFB_Post(ent) {
new fb_color[11]; get_pcvar_string(cvar[FB_COLOR], fb_color, sizeof fb_color);
new red[5], green[5], blue[5]; parse(fb_color, red, 4, green, 4, blue, 4);
new Float:origin[3];
get_entvar(ent, var_origin, origin);
make_dyn_light(origin, str_to_num(red), str_to_num(green), str_to_num(blue));
}
stock make_dyn_light(Float:origin[3], red, green, blue) {
message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
write_byte(TE_DLIGHT);
write_coord(floatround(origin[0]));
write_coord(floatround(origin[1]));
write_coord(floatround(origin[2]));
write_byte(50);
write_byte(red);
write_byte(green);
write_byte(blue);
write_byte(8);
write_byte(60);
message_end();
}