forked from dordnung/Stamm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstamm_colored_smokes.sp
251 lines (179 loc) · 5.45 KB
/
stamm_colored_smokes.sp
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
/**
* -----------------------------------------------------
* File stamm_colored_smokes.sp
* Authors David <popoklopsi> Ordnung
* License GPLv3
* Web http://popoklopsi.de
* -----------------------------------------------------
*
* Copyright (C) 2012-2014 David <popoklopsi> Ordnung
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
// Includes
#include <sourcemod>
#include <sdktools>
#include <autoexecconfig>
#undef REQUIRE_PLUGIN
#include <stamm>
#pragma semicolon 1
new Handle:g_hColors;
new Handle:g_hModeSmoke;
public Plugin:myinfo =
{
name = "Stamm Feature Colored Smokes",
author = "Popoklopsi",
version = "${-version-}", // Version is replaced by GitLab runner due the build phase
description = "Give VIP's colored smokes",
url = "https://gitlab.com/PushTheLimits/Sourcemod/Stamm/wikis"
};
public STAMM_OnFeatureLoaded(const String:basename[])
{
}
// Add Feature
public OnAllPluginsLoaded()
{
if (!STAMM_IsAvailable())
{
SetFailState("Can't Load Feature, Stamm is not installed!");
}
if (STAMM_GetGame() != GameCSS && STAMM_GetGame() != GameCSGO)
{
SetFailState("Can't Load Feature, not Supported for your game!");
}
STAMM_LoadTranslation();
STAMM_RegisterFeature("VIP Colored Smokes");
}
// Add descriptions
public STAMM_OnClientRequestFeatureInfo(client, block, &Handle:array)
{
decl String:fmt[256];
Format(fmt, sizeof(fmt), "%T", "GetColoredSmokes", client);
PushArrayString(array, fmt);
}
// Create config
public OnPluginStart()
{
AutoExecConfig_SetFile("colored_smokes", "stamm/features");
AutoExecConfig_SetCreateFile(true);
g_hModeSmoke = AutoExecConfig_CreateConVar("smoke_mode", "0", "The Mode: 0=Team Colors, 1=Random, 2=Party, 3=Custom");
g_hColors = AutoExecConfig_CreateConVar("smoke_color", "255 255 255", "When mode = 3: RGB colors of the smoke");
AutoExecConfig_CleanFile();
AutoExecConfig_ExecuteFile();
HookEvent("smokegrenade_detonate", eventHeDetonate);
}
// Smoke grenade Detonate
public Action:eventHeDetonate(Handle:event, const String:name[], bool:dontBroadcast)
{
decl String:colors[64];
new client = GetClientOfUserId(GetEventInt(event, "userid"));
GetConVarString(g_hColors, colors, sizeof(colors));
if (STAMM_IsClientValid(client))
{
if (STAMM_HaveClientFeature(client))
{
new Float:origin[3];
decl String:sBuffer[64];
// Get origin
origin[0] = GetEventFloat(event, "x");
origin[1] = GetEventFloat(event, "y");
origin[2] = GetEventFloat(event, "z");
// Create a light ;D
new ent_light = CreateEntityByName("light_dynamic");
// Could we create it?
if (ent_light != -1)
{
// Switch Mode
switch (GetConVarInt(g_hModeSmoke))
{
case 0:
{
// Team color
new team = GetClientTeam(client);
if (team == 2)
{
DispatchKeyValue(ent_light, "_light", "255 0 0");
}
else if (team == 3)
{
DispatchKeyValue(ent_light, "_light", "0 0 255");
}
}
case 1:
{
// Random color
new color_r = GetRandomInt(0, 255);
new color_g = GetRandomInt(0, 255);
new color_b = GetRandomInt(0, 255);
Format(sBuffer, sizeof(sBuffer), "%i %i %i", color_r, color_g, color_b);
DispatchKeyValue(ent_light, "_light", sBuffer);
}
case 2:
{
// Party Mode
CreateTimer(0.2, PartyLight, ent_light, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
}
case 3:
{
// Own color
DispatchKeyValue(ent_light, "_light", sBuffer);
}
}
// Set it up
DispatchKeyValue(ent_light, "pitch", "-90");
DispatchKeyValue(ent_light, "distance", "256");
DispatchKeyValue(ent_light, "spotlight_radius", "96");
DispatchKeyValue(ent_light, "brightness", "3");
DispatchKeyValue(ent_light, "style", "6");
DispatchKeyValue(ent_light, "spawnflags", "1");
DispatchSpawn(ent_light);
AcceptEntityInput(ent_light, "DisableShadow");
AcceptEntityInput(ent_light, "TurnOn");
// Create and teleport to smoke
TeleportEntity(ent_light, origin, NULL_VECTOR, NULL_VECTOR);
CreateTimer(20.0, Timer_Delete, ent_light, TIMER_FLAG_NO_MAPCHANGE);
}
}
}
}
// Party Mode
public Action:PartyLight(Handle:timer, any:light)
{
// finish
if (!IsValidEntity(light))
{
return Plugin_Stop;
}
// Always set up with random color
decl String:sBuffer[64];
new color_r = GetRandomInt(0, 255);
new color_g = GetRandomInt(0, 255);
new color_b = GetRandomInt(0, 255);
Format(sBuffer, sizeof(sBuffer), "%i %i %i 200", color_r, color_g, color_b);
DispatchKeyValue(light, "_light", sBuffer);
return Plugin_Continue;
}
// Delete the light on finish
public Action:Timer_Delete(Handle:timer, any:light)
{
if (IsValidEntity(light))
{
decl String:class[128];
GetEdictClassname(light, class, sizeof(class));
if (StrEqual(class, "light_dynamic"))
{
RemoveEdict(light);
}
}
}