SHOW:
|
|
- or go back to the newest paste.
1 | #include <a_samp> | |
2 | #pragma tabsize 0 | |
3 | ||
4 | - | #define VERSION "0.4" |
4 | + | #define VERSION "0.4b" |
5 | ||
6 | - | #define MAX_FLAMES 100 // maxmimal flames |
6 | + | #define MAX_FIRES 100 // max amout of fires able to exist at once |
7 | - | #define BurnOthers // Should other players burn, too, if they are touching a burning player? |
7 | + | #define BurnOthers // should players be able to ignite other players by touching? |
8 | - | //#define EarnMoney // Do you want to earn money for extinguish a fire? |
8 | + | #define FireMessageColor 0x00FF55FF // color used for the extinguishing message |
9 | - | #define FireMessageColor 0x00FF55FF // color used for the extinguish-message |
9 | + | |
10 | #define BURNING_RADIUS 1.2 // radius in which you start burning if you're too close to a fire | |
11 | - | //#define MessageToAll // Should the extinguish-message be sent to all players? |
11 | + | #define ONFOOT_RADIUS 1.5 // radius in which you can extinguish the fire by foot |
12 | #define PISSING_DISTANCE 2.0 // radius in which you can extinguish the fire by peeing | |
13 | - | #define FLAME_ZONE 1.2 // radius in which you start burning if you're too close to a flame |
13 | + | #define CAR_RADIUS 8.0 // radius in which you can extinguish the fire by firetruck/SWAT Van |
14 | - | #define ONFOOT_RADIUS 1.5 // radius in which you can extinguish the flames by foot |
14 | + | #define Z_DIFFERENCE 2.5 // height which is used for technical accurancy of extinguishing. Please do not change |
15 | - | #define PISSING_WAY 2.0 // radius in which you can extinguish the flames by peeing |
15 | + | #define FIRE_UPDATE_TIMER_DELAY 500 // amount of milliseconds the fire timer should loop in |
16 | - | #define CAR_RADIUS 8.0 // radius in which you can extinguish the flames by firetruck/SWAT Van |
16 | + | #define EXTINGUISH_TIME_VEHICLE 1 // time you have to spray at the fire with a firetruck (seconds) |
17 | - | #define Z_DIFFERENCE 2.5 // height which is important for the accurancy of extinguishing. please do not change |
17 | + | #define EXTINGUISH_TIME_ONFOOT 4 // time you have to spray at the fire onfoot (seconds) |
18 | - | #define EXTINGUISH_TIME_VEHICLE 1 // time you have to spray at the fire with a firetruck (seconds) |
18 | + | #define EXTINGUISH_TIME_PEEING 10 // time you have to pee at the fire (seconds) |
19 | - | #define EXTINGUISH_TIME_ONFOOT 4 // time you have to spray at the fire onfoot (seconds) |
19 | + | #define EXTINGUISH_TIME_PLAYER 2 // time it takes to extinguish a player (seconds) |
20 | - | #define EXTINGUISH_TIME_PEEING 10 // time you have to pee at the fire (seconds) |
20 | + | #define FIRE_OBJECT_SLOT 1 // the slot used with SetPlayerAttachedObject and RemovePlayerAttachedObject |
21 | - | #define EXTINGUISH_TIME_PLAYER 3 // time it takes to extinguish a player (seconds) |
21 | + | |
22 | - | #define FIRE_OBJECT_SLOT 1 // the slot used with SetPlayerAttachedObject and RemovePlayerAttachedObject |
22 | + | |
23 | //#define MessageToAll // Should the extinguishing message be sent to all players? | |
24 | ||
25 | - | #define SPECIAL_ACTION_PISSING 68 |
25 | + | |
26 | #define SPECIAL_ACTION_PISSING (68) | |
27 | #endif | |
28 | ||
29 | // Using a streamer? Maybe that would come handy ... | |
30 | - | forward AddFire(Float:x, Float:y, Float:z); |
30 | + | //#define DRAW_DISTANCE 200.0 |
31 | - | forward KillFire(id); |
31 | + | //#define CreateObject(%0) CreateDynamicObject(%0, -1, -1, -1, DRAW_DISTANCE) |
32 | - | forward AddSmoke(Float:x, Float:y, Float:z); |
32 | + | //#define DestroyObject(%0) DestroyDynamicObject(%0) |
33 | - | forward KillSmoke(id); |
33 | + | |
34 | - | forward DestroyTheSmokeFromFlame(id); |
34 | + | |
35 | ||
36 | - | forward FireTimer(playerid, id); |
36 | + | forward CreateFire(Float:x, Float:y, Float:z); |
37 | - | forward SetPlayerBurn(playerid); |
37 | + | forward CreateSmoke(Float:x, Float:y, Float:z); |
38 | forward DestroyFire(id); | |
39 | - | forward StopPlayerBurning(playerid); |
39 | + | forward DestroySmoke(id); |
40 | forward RemoveSmokeFromFire(id); | |
41 | forward TogglePlayerBurning(playerid, burning); | |
42 | ||
43 | forward OnFireUpdate(); | |
44 | forward ExtinguishTimer(playerid, id); | |
45 | forward BurningTimer(playerid); | |
46 | ||
47 | //===================== Variables ==================== | |
48 | ||
49 | enum FlameInfo | |
50 | { | |
51 | - | new Flame[MAX_FLAMES][FlameInfo]; |
51 | + | |
52 | - | new ExtTimer[MAX_PLAYERS]; |
52 | + | |
53 | - | new PlayerOnFire[MAX_PLAYERS]; |
53 | + | |
54 | - | new PlayerOnFireTimer[MAX_PLAYERS]; |
54 | + | |
55 | - | new PlayerOnFireTimer2[MAX_PLAYERS]; |
55 | + | |
56 | ||
57 | new Flame[MAX_FIRES][FlameInfo]; | |
58 | new PlayerFireTimer[MAX_PLAYERS][3]; // Burn, StopBurn, Extinguish a fire | |
59 | new Float:PlayerOnFireHP[MAX_PLAYERS]; | |
60 | ||
61 | //===================== Normal Publics ==================== | |
62 | ||
63 | public OnGameModeInit() { OnFilterScriptInit(); } | |
64 | public OnGameModeExit() { OnFilterScriptExit(); } | |
65 | ||
66 | public OnFilterScriptInit() | |
67 | { | |
68 | AntiDeAMX(); | |
69 | ||
70 | for(new i; i < MAX_PLAYERS; i++) | |
71 | { | |
72 | PlayerFireTimer[i][2] = -1; | |
73 | } | |
74 | ||
75 | print(" "); | |
76 | print(" /\\_/¯\\_/¯\\_/¯\\_/¯\\_/¯\\_/\\"); | |
77 | print(" < >"); | |
78 | #if defined German | |
79 | - | print(" > www.SpitNex.de <"); |
79 | + | |
80 | #else | |
81 | print(" > Extinguishable Fire "#VERSION" <"); | |
82 | - | SetTimer("OnFireUpdate", 500, 1); |
82 | + | |
83 | #if defined German | |
84 | print(" < von Meta >"); | |
85 | - | ExtTimer[i] = -1; |
85 | + | |
86 | print(" < by Meta >"); | |
87 | #endif | |
88 | print(" \\/¯\\_/¯\\_/¯\\_/¯\\_/¯\\_/¯\\/\n"); | |
89 | SetTimer("OnFireUpdate", FIRE_UPDATE_TIMER_DELAY, 1); | |
90 | return 1; | |
91 | } | |
92 | - | for(new i; i < MAX_FLAMES; i++) |
92 | + | |
93 | public OnFilterScriptExit() | |
94 | - | KillFire(i); |
94 | + | |
95 | for(new i; i < MAX_FIRES; i++) | |
96 | { | |
97 | DestroyFire(i); | |
98 | - | if(PlayerOnFire[playerid] && !CanPlayerBurn(playerid, 1)) |
98 | + | |
99 | for(new playerid; playerid < MAX_PLAYERS; playerid++) | |
100 | - | StopPlayerBurning(playerid); |
100 | + | |
101 | if(GetPVarInt(playerid, "IsOnFire") && !CanPlayerBurn(playerid, 1)) | |
102 | { | |
103 | TogglePlayerBurning(playerid, false); | |
104 | } | |
105 | } | |
106 | return 1; | |
107 | } | |
108 | ||
109 | public OnPlayerCommandText(playerid, cmdtext[]) | |
110 | { | |
111 | new idx, cmd[256]; | |
112 | cmd = strtok(cmdtext, idx); | |
113 | if(IsPlayerAdmin(playerid)) | |
114 | { | |
115 | #if defined German | |
116 | if(strcmp("/feuer", cmd, true) == 0) | |
117 | #else | |
118 | if(strcmp("/fire", cmd, true) == 0) | |
119 | #endif | |
120 | - | /*CallRemoteFuntion("*/AddFire(/*", "fff", */x, y, z); |
120 | + | |
121 | new Float:x, Float:y, Float:z, Float:a; | |
122 | GetXYInFrontOfPlayer(playerid, x, y, z, a, 2.5); | |
123 | /*CallRemoteFuntion("*/CreateFire(/*", "fff", */x, y, z); | |
124 | return 1; | |
125 | } | |
126 | } | |
127 | return 0; | |
128 | } | |
129 | - | if(PlayerOnFire[playerid]) |
129 | + | |
130 | public OnPlayerDeath(playerid, killerid, reason) | |
131 | { | |
132 | - | SendClientMessage(playerid, 0xff000000, "Du bist verbrannt!"); StopPlayerBurning(playerid); |
132 | + | if(GetPVarInt(playerid, "IsOnFire")) |
133 | { | |
134 | - | SendClientMessage(playerid, 0xff000000, "You died because of the fire!"); StopPlayerBurning(playerid); |
134 | + | |
135 | SendClientMessage(playerid, 0xff000000, "Du bist verbrannt!"); | |
136 | #else | |
137 | SendClientMessage(playerid, 0xff000000, "You got fried!"); | |
138 | #endif | |
139 | TogglePlayerBurning(playerid, false); | |
140 | } | |
141 | } | |
142 | ||
143 | public OnFireUpdate() | |
144 | { | |
145 | new aim, piss; | |
146 | - | if(PlayerOnFire[playerid] && !CanPlayerBurn(playerid, 1)) |
146 | + | |
147 | { | |
148 | - | StopPlayerBurning(playerid); |
148 | + | |
149 | if(!IsPlayerConnected(playerid) || IsPlayerNPC(playerid)) { continue; } | |
150 | if(GetPVarInt(playerid, "IsOnFire") && !CanPlayerBurn(playerid, 1)) | |
151 | { | |
152 | TogglePlayerBurning(playerid, false); | |
153 | } | |
154 | if(Pissing_at_Flame(playerid) != -1 || Aiming_at_Flame(playerid) != -1) | |
155 | { | |
156 | piss = Pissing_at_Flame(playerid); aim = Aiming_at_Flame(playerid); | |
157 | - | GameTextForPlayer(playerid, " ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~r~~h~Flame ahead", 1500, 6); |
157 | + | |
158 | #if defined German | |
159 | - | if(ExtTimer[playerid] == -1 && ((aim != -1 && Pressing(playerid) & KEY_FIRE) || piss != -1)) |
159 | + | |
160 | #else | |
161 | GameTextForPlayer(playerid, " ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~r~~h~Fire in sight", 1500, 6); | |
162 | #endif | |
163 | if(PlayerFireTimer[playerid][2] == -1 && ((aim != -1 && Pressing(playerid) & KEY_FIRE) || piss != -1)) | |
164 | { | |
165 | new value, time, Float:x, Float:y, Float:z; | |
166 | if(piss != -1) | |
167 | { | |
168 | value = piss; | |
169 | time = EXTINGUISH_TIME_PEEING; | |
170 | } | |
171 | else if(aim != -1) | |
172 | { | |
173 | value = aim; | |
174 | if(GetPlayerWeapon(playerid) == 41) | |
175 | { | |
176 | CreateExplosion(Flame[value][Flame_pos][0], Flame[value][Flame_pos][1], Flame[value][Flame_pos][2], 2, 5); | |
177 | continue; | |
178 | } | |
179 | if(IsPlayerInAnyVehicle(playerid)) | |
180 | { | |
181 | time = EXTINGUISH_TIME_VEHICLE; | |
182 | } | |
183 | else | |
184 | { | |
185 | time = EXTINGUISH_TIME_ONFOOT; | |
186 | } | |
187 | } | |
188 | if(value < -1) { time = EXTINGUISH_TIME_PLAYER; } | |
189 | time *= 1000; | |
190 | if(value >= -1) | |
191 | - | DestroyTheSmokeFromFlame(value); |
191 | + | |
192 | x = Flame[value][Flame_pos][0]; | |
193 | y = Flame[value][Flame_pos][1]; | |
194 | z = Flame[value][Flame_pos][2]; | |
195 | RemoveSmokeFromFire(value); | |
196 | Flame[value][Smoke][0] = CreateObject(18727, x, y, z, 0.0, 0.0, 0.0); | |
197 | - | SetTimerEx("DestroyTheSmokeFromFlame", time, 0, "d", value); |
197 | + | |
198 | Flame[value][Smoke][2] = CreateObject(18727, x-1, y, z, 0.0, 0.0, 0.0); | |
199 | - | ExtTimer[playerid] = SetTimerEx("FireTimer", time, 0, "dd", playerid, value); |
199 | + | |
200 | Flame[value][Smoke][4] = CreateObject(18727, x, y-1, z, 0.0, 0.0, 0.0); | |
201 | } | |
202 | PlayerFireTimer[playerid][2] = SetTimerEx("ExtinguishTimer", time, 0, "dd", playerid, value); | |
203 | } | |
204 | - | SetPlayerBurn(playerid); |
204 | + | |
205 | if(CanPlayerBurn(playerid) && IsAtFlame(playerid)) | |
206 | { | |
207 | TogglePlayerBurning(playerid, true); | |
208 | } | |
209 | #if defined BurnOthers | |
210 | new Float:x, Float:y, Float:z; | |
211 | for(new i; i < MAX_PLAYERS; i++) | |
212 | - | if(CanPlayerBurn(i) && PlayerOnFire[playerid] && !PlayerOnFire[i]) |
212 | + | |
213 | if(playerid != i && IsPlayerConnected(i) && !IsPlayerNPC(i)) | |
214 | { | |
215 | - | if(IsPlayerInRangeOfPoint(playerid, 1, x, y, z)) |
215 | + | if(CanPlayerBurn(i) && GetPVarInt(playerid, "IsOnFire") && !GetPVarInt(i, "IsOnFire")) |
216 | { | |
217 | - | SetPlayerBurn(i); |
217 | + | |
218 | if(IsPlayerInRangeOfPoint(playerid, BURNING_RADIUS, x, y, z)) | |
219 | { | |
220 | TogglePlayerBurning(i, true); | |
221 | } | |
222 | } | |
223 | } | |
224 | } | |
225 | #endif | |
226 | } | |
227 | return 1; | |
228 | } | |
229 | ||
230 | ||
231 | //===================== stocks ==================== | |
232 | ||
233 | stock GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, &Float:z, &Float:a, Float:distance) | |
234 | { | |
235 | GetPlayerPos(playerid, x, y ,z); | |
236 | if(IsPlayerInAnyVehicle(playerid)) | |
237 | { | |
238 | GetVehicleZAngle(GetPlayerVehicleID(playerid),a); | |
239 | } | |
240 | else | |
241 | { | |
242 | GetPlayerFacingAngle(playerid, a); | |
243 | } | |
244 | x += (distance * floatsin(-a, degrees)); | |
245 | y += (distance * floatcos(-a, degrees)); | |
246 | return 0; | |
247 | } | |
248 | ||
249 | stock strtok(const string[], &index) | |
250 | { | |
251 | new length = strlen(string); | |
252 | while ((index < length) && (string[index] <= ' ')) | |
253 | { | |
254 | index++; | |
255 | } | |
256 | new offset = index; | |
257 | new result[256]; | |
258 | while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1))) | |
259 | { | |
260 | result[index - offset] = string[index]; | |
261 | index++; | |
262 | } | |
263 | result[index - offset] = EOS; | |
264 | return result; | |
265 | } | |
266 | ||
267 | #if !defined ReturnUser | |
268 | stock ReturnUser(text[]) | |
269 | { | |
270 | new pos = 0; | |
271 | while (text[pos] < 0x21) | |
272 | { | |
273 | if(text[pos] == 0) return INVALID_PLAYER_ID; | |
274 | pos++; | |
275 | } | |
276 | new userid = INVALID_PLAYER_ID; | |
277 | if(isNumeric(text[pos])) | |
278 | { | |
279 | userid = strval(text[pos]); | |
280 | if(userid >=0 && userid < MAX_PLAYERS) | |
281 | { | |
282 | if(!IsPlayerConnected(userid)) | |
283 | userid = INVALID_PLAYER_ID; | |
284 | else return userid; | |
285 | } | |
286 | } | |
287 | new len = strlen(text[pos]); | |
288 | new count = 0; | |
289 | new pname[MAX_PLAYER_NAME]; | |
290 | for (new i = 0; i < MAX_PLAYERS; i++) | |
291 | { | |
292 | if(IsPlayerConnected(i)) | |
293 | { | |
294 | GetPlayerName(i, pname, sizeof (pname)); | |
295 | if(strcmp(pname, text[pos], true, len) == 0) | |
296 | { | |
297 | if(len == strlen(pname)) return i; | |
298 | else | |
299 | { | |
300 | count++; | |
301 | userid = i; | |
302 | } | |
303 | } | |
304 | } | |
305 | } | |
306 | if(count != 1) | |
307 | { | |
308 | userid = INVALID_PLAYER_ID; | |
309 | } | |
310 | return userid; | |
311 | } | |
312 | #endif | |
313 | #if !defined isNumeric | |
314 | stock isNumeric(const string[]) | |
315 | { | |
316 | new length=strlen(string); | |
317 | if (length==0) return false; | |
318 | for (new i = 0; i < length; i++) | |
319 | { | |
320 | if ((string[i] > '9' || string[i] < '0' && string[i]!='-' && string[i]!='+') /*Not a number,'+' or '-'*/|| (string[i]=='-' && i!=0)/* A '-' but not at first.*/|| (string[i]=='+' && i!=0)/* A '+' but not at first.*/) | |
321 | { | |
322 | return false; | |
323 | } | |
324 | } | |
325 | if (length==1 && (string[0]=='-' || string[0]=='+')) { return false; } | |
326 | return true; | |
327 | } | |
328 | #endif | |
329 | ||
330 | stock Float:GetDistanceBetweenPoints(Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2) //By Gabriel "Larcius" Cordes | |
331 | { | |
332 | return floatadd(floatadd(floatsqroot(floatpower(floatsub(x1,x2),2)),floatsqroot(floatpower(floatsub(y1,y2),2))),floatsqroot(floatpower(floatsub(z1,z2),2))); | |
333 | } | |
334 | ||
335 | stock Float:DistanceCameraTargetToLocation(Float:CamX, Float:CamY, Float:CamZ, Float:ObjX, Float:ObjY, Float:ObjZ, Float:FrX, Float:FrY, Float:FrZ) | |
336 | { | |
337 | new Float:TGTDistance; | |
338 | ||
339 | // get distance from camera to target | |
340 | TGTDistance = floatsqroot((CamX - ObjX) * (CamX - ObjX) + (CamY - ObjY) * (CamY - ObjY) + (CamZ - ObjZ) * (CamZ - ObjZ)); | |
341 | ||
342 | new Float:tmpX, Float:tmpY, Float:tmpZ; | |
343 | ||
344 | tmpX = FrX * TGTDistance + CamX; | |
345 | tmpY = FrY * TGTDistance + CamY; | |
346 | tmpZ = FrZ * TGTDistance + CamZ; | |
347 | ||
348 | return floatsqroot((tmpX - ObjX) * (tmpX - ObjX) + (tmpY - ObjY) * (tmpY - ObjY) + (tmpZ - ObjZ) * (tmpZ - ObjZ)); | |
349 | } | |
350 | ||
351 | stock IsPlayerAimingAt(playerid, Float:x, Float:y, Float:z, Float:radius) | |
352 | { | |
353 | new Float:cx,Float:cy,Float:cz,Float:fx,Float:fy,Float:fz; | |
354 | GetPlayerCameraPos(playerid, cx, cy, cz); | |
355 | GetPlayerCameraFrontVector(playerid, fx, fy, fz); | |
356 | return (radius >= DistanceCameraTargetToLocation(cx, cy, cz, x, y, z, fx, fy, fz)); | |
357 | } | |
358 | - | public AddFire(Float:x, Float:y, Float:z) |
358 | + | |
359 | //===================== Own Publics ==================== | |
360 | ||
361 | public CreateFire(Float:x, Float:y, Float:z) | |
362 | { | |
363 | new slot = GetFlameSlot(); | |
364 | if(slot == -1) {return slot;} | |
365 | Flame[slot][Flame_Exists] = 1; | |
366 | Flame[slot][Flame_pos][0] = x; | |
367 | Flame[slot][Flame_pos][1] = y; | |
368 | Flame[slot][Flame_pos][2] = z - Z_DIFFERENCE; | |
369 | Flame[slot][Flame_id] = CreateObject(18689, Flame[slot][Flame_pos][0], Flame[slot][Flame_pos][1], Flame[slot][Flame_pos][2], 0.0, 0.0, 0.0); | |
370 | - | public KillFire(id) |
370 | + | |
371 | for(new i; i < 5; i++) | |
372 | { | |
373 | Flame[slot][Smoke][i] = -1; | |
374 | } | |
375 | return slot; | |
376 | } | |
377 | - | DestroyTheSmokeFromFlame(id); |
377 | + | |
378 | public DestroyFire(id) | |
379 | { | |
380 | DestroyObject(Flame[id][Flame_id]); | |
381 | Flame[id][Flame_Exists] = 0; | |
382 | Flame[id][Flame_pos][0] = 0.0; | |
383 | Flame[id][Flame_pos][1] = 0.0; | |
384 | - | public AddSmoke(Float:x, Float:y, Float:z) |
384 | + | |
385 | RemoveSmokeFromFire(id); | |
386 | } | |
387 | ||
388 | //# A suggestion from a user of this script. Very simple functions to add and remove smoke without flames. | |
389 | - | public KillSmoke(id) |
389 | + | |
390 | //# Maybe you could link smoke on a house with variables to a flame inside a house so if the flame gets extinguished the smoke disappears. | |
391 | ||
392 | public CreateSmoke(Float:x, Float:y, Float:z) | |
393 | { | |
394 | return CreateObject(18727, x, y, z, 0.0, 0.0, 0.0); | |
395 | - | public DestroyTheSmokeFromFlame(id) |
395 | + | |
396 | ||
397 | - | for(new i; i < 5; i++) { DestroyObject(Flame[id][Smoke][i]); } |
397 | + | public DestroySmoke(id) |
398 | { | |
399 | DestroyObject(id); | |
400 | - | public FireTimer(playerid, id) |
400 | + | |
401 | ||
402 | - | if(id < -1 && (Aiming_at_Flame(playerid) == id || Pissing_at_Flame(playerid) == id)) { StopPlayerBurning(id+MAX_PLAYERS); } |
402 | + | |
403 | public RemoveSmokeFromFire(id) | |
404 | { | |
405 | for(new i; i < 5; i++) | |
406 | { | |
407 | DestroyObject(Flame[id][Smoke][i]); | |
408 | Flame[id][Smoke][i] = -1; | |
409 | } | |
410 | } | |
411 | ||
412 | public ExtinguishTimer(playerid, id) | |
413 | { | |
414 | if(id < -1 && (Aiming_at_Flame(playerid) == id || Pissing_at_Flame(playerid) == id)) { TogglePlayerBurning(id+MAX_PLAYERS, false); } | |
415 | else if(Flame[id][Flame_Exists] && ((Pressing(playerid) & KEY_FIRE && Aiming_at_Flame(playerid) == id) || (Pissing_at_Flame(playerid) == id))) | |
416 | { | |
417 | new sendername[MAX_PLAYER_NAME+26]; | |
418 | GetPlayerName(playerid, sendername, sizeof(sendername)); | |
419 | #if defined MessageToAll | |
420 | if(Pissing_at_Flame(playerid) == id) | |
421 | { | |
422 | #if defined German | |
423 | format(sendername, sizeof(sendername), "* %s hat einen Brand ausgepisst! *", sendername); | |
424 | #else | |
425 | format(sendername, sizeof(sendername), "* %s pissed out a fire! *", sendername); | |
426 | #endif | |
427 | } | |
428 | else if(Aiming_at_Flame(playerid) == id) | |
429 | { | |
430 | #if defined German | |
431 | format(sendername, sizeof(sendername), "* %s hat einen Brand gelöscht! *", sendername); | |
432 | #else | |
433 | format(sendername, sizeof(sendername), "* %s extinguished a fire! *", sendername); | |
434 | #endif | |
435 | } | |
436 | SendClientMessageToAll(FireMessageColor, sendername); | |
437 | #else | |
438 | if(Pissing_at_Flame(playerid) == id) | |
439 | { | |
440 | #if defined German | |
441 | SendClientMessage(playerid, FireMessageColor, "* Du hast einen Brand ausgepisst! *"); | |
442 | #else | |
443 | - | KillFire(id); |
443 | + | |
444 | - | #if defined EarnMoney |
444 | + | |
445 | - | GivePlayerMoney(playerid, 500); |
445 | + | |
446 | else if(Aiming_at_Flame(playerid) == id) | |
447 | { | |
448 | - | KillTimer(ExtTimer[playerid]); |
448 | + | |
449 | - | ExtTimer[playerid] = -1; |
449 | + | |
450 | #else | |
451 | SendClientMessage(playerid, FireMessageColor, "* You extinguished a fire! *"); | |
452 | - | public SetPlayerBurn(playerid) |
452 | + | |
453 | } | |
454 | - | SetPlayerAttachedObject(playerid, FIRE_OBJECT_SLOT, 18690, 2, -1, 0, -1.9, 0, 0); |
454 | + | |
455 | - | PlayerOnFire[playerid] = 1; |
455 | + | DestroyFire(id); |
456 | - | GetPlayerHealth(playerid, PlayerOnFireHP[playerid]); |
456 | + | |
457 | - | KillTimer(PlayerOnFireTimer[playerid]); KillTimer(PlayerOnFireTimer2[playerid]); |
457 | + | KillTimer(PlayerFireTimer[playerid][2]); |
458 | - | PlayerOnFireTimer[playerid] = SetTimerEx("BurningTimer", 91, 1, "d", playerid); |
458 | + | PlayerFireTimer[playerid][2] = -1; |
459 | - | PlayerOnFireTimer2[playerid] = SetTimerEx("StopPlayerBurning", 7000, 0, "d", playerid); |
459 | + | |
460 | ||
461 | public TogglePlayerBurning(playerid, burning) | |
462 | { | |
463 | if(burning) | |
464 | { | |
465 | - | if(PlayerOnFire[playerid]) |
465 | + | SetPlayerAttachedObject(playerid, FIRE_OBJECT_SLOT, 18690, 2, -1, 0, -1.9, 0, 0); |
466 | GetPlayerHealth(playerid, PlayerOnFireHP[playerid]); | |
467 | KillTimer(PlayerFireTimer[playerid][0]); KillTimer(PlayerFireTimer[playerid][1]); | |
468 | PlayerFireTimer[playerid][0] = SetTimerEx("BurningTimer", 91, 1, "d", playerid); | |
469 | PlayerFireTimer[playerid][1] = SetTimerEx("TogglePlayerBurning", 7000, 0, "dd", playerid, 0); | |
470 | } | |
471 | else | |
472 | { | |
473 | - | CallRemoteFunction("SetPlayerHealth", "dd", playerid, PlayerOnFireHP[playerid]-1.0); |
473 | + | KillTimer(PlayerFireTimer[playerid][0]); |
474 | RemovePlayerAttachedObject(playerid, FIRE_OBJECT_SLOT); | |
475 | } | |
476 | - | else { KillTimer(PlayerOnFireTimer[playerid]); KillTimer(PlayerOnFireTimer2[playerid]); } |
476 | + | SetPVarInt(playerid, "IsOnFire", burning); |
477 | return 1; | |
478 | } | |
479 | - | public StopPlayerBurning(playerid) |
479 | + | |
480 | public BurningTimer(playerid) | |
481 | - | KillTimer(PlayerOnFireTimer[playerid]); |
481 | + | |
482 | - | PlayerOnFire[playerid] = 0; |
482 | + | if(GetPVarInt(playerid, "IsOnFire")) |
483 | - | RemovePlayerAttachedObject(playerid, FIRE_OBJECT_SLOT); |
483 | + | |
484 | new Float:hp; | |
485 | GetPlayerHealth(playerid, hp); | |
486 | if(hp < PlayerOnFireHP[playerid]) | |
487 | { | |
488 | PlayerOnFireHP[playerid] = hp; | |
489 | } | |
490 | PlayerOnFireHP[playerid] -= 1.0; | |
491 | SetPlayerHealth(playerid, PlayerOnFireHP[playerid]); | |
492 | - | for(new i; i < MAX_FLAMES; i++) |
492 | + | |
493 | else { KillTimer(PlayerFireTimer[playerid][0]); KillTimer(PlayerFireTimer[playerid][1]); } | |
494 | } | |
495 | ||
496 | //===================== Other Functions ==================== | |
497 | ||
498 | stock GetFireID(Float:x, Float:y, Float:z, &Float:dist) | |
499 | { | |
500 | new id = -1; | |
501 | dist = 99999.99; | |
502 | for(new i; i < MAX_FIRES; i++) | |
503 | { | |
504 | if(GetDistanceBetweenPoints(x,y,z,Flame[i][Flame_pos][0],Flame[i][Flame_pos][1],Flame[i][Flame_pos][2]) < dist) | |
505 | - | if(CallRemoteFunction("CanBurn", "d", playerid) >= 0 && !IsPlayerInWater(playerid) && GetPlayerSkin(playerid) != 277 && GetPlayerSkin(playerid) != 278 && GetPlayerSkin(playerid) != 279 && ((!val && !PlayerOnFire[playerid]) || (val && PlayerOnFire[playerid]))) { return 1; } |
505 | + | |
506 | dist = GetDistanceBetweenPoints(x,y,z,Flame[i][Flame_pos][0],Flame[i][Flame_pos][1],Flame[i][Flame_pos][2]); | |
507 | id = i; | |
508 | } | |
509 | } | |
510 | return id; | |
511 | } | |
512 | ||
513 | stock CanPlayerBurn(playerid, val = 0) | |
514 | { | |
515 | if(CallRemoteFunction("CanBurn", "d", playerid) >= 0 && !IsPlayerInWater(playerid) && GetPlayerSkin(playerid) != 277 && GetPlayerSkin(playerid) != 278 && GetPlayerSkin(playerid) != 279 && ((!val && !GetPVarInt(playerid, "IsOnFire")) || (val && GetPVarInt(playerid, "IsOnFire")))) { return 1; } | |
516 | return 0; | |
517 | } | |
518 | ||
519 | /* //Uncomment or copy to your script. | |
520 | ||
521 | forward CanBurn(playerid); | |
522 | public CanBurn(playerid) | |
523 | { | |
524 | if(...) | |
525 | { | |
526 | return 1; | |
527 | } | |
528 | return -1; // IMPORTANT! | |
529 | } | |
530 | ||
531 | */ | |
532 | ||
533 | stock IsPlayerInWater(playerid) | |
534 | { | |
535 | new Float:X, Float:Y, Float:Z, an = GetPlayerAnimationIndex(playerid); | |
536 | GetPlayerPos(playerid, X, Y, Z); | |
537 | if((1544 >= an >= 1538 || an == 1062 || an == 1250) && (Z <= 0 || (Z <= 41.0 && IsPlayerInArea(playerid, -1387, -473, 2025, 2824))) || | |
538 | (1544 >= an >= 1538 || an == 1062 || an == 1250) && (Z <= 2 || (Z <= 39.0 && IsPlayerInArea(playerid, -1387, -473, 2025, 2824)))) | |
539 | { | |
540 | return 1; | |
541 | } | |
542 | return 0; | |
543 | } | |
544 | ||
545 | stock IsPlayerInArea(playerid, Float:MinX, Float:MaxX, Float:MinY, Float:MaxY) | |
546 | - | for(new i = 0; i < MAX_FLAMES; i++) |
546 | + | |
547 | new Float:x, Float:y, Float:z; | |
548 | GetPlayerPos(playerid, x, y, z); | |
549 | #pragma unused z | |
550 | if(x >= MinX && x <= MaxX && y >= MinY && y <= MaxY) { return 1; } | |
551 | return 0; | |
552 | } | |
553 | ||
554 | stock GetFlameSlot() | |
555 | { | |
556 | for(new i = 0; i < MAX_FIRES; i++) | |
557 | - | for(new i; i < MAX_FLAMES; i++) |
557 | + | |
558 | if(!Flame[i][Flame_Exists]) { return i; } | |
559 | - | |
559 | + | |
560 | return -1; | |
561 | } | |
562 | - | if(!IsPlayerInAnyVehicle(playerid) && (IsPlayerInRangeOfPoint(playerid, FLAME_ZONE, Flame[i][Flame_pos][0], Flame[i][Flame_pos][1], Flame[i][Flame_pos][2]+Z_DIFFERENCE) || |
562 | + | |
563 | - | IsPlayerInRangeOfPoint(playerid, FLAME_ZONE, Flame[i][Flame_pos][0], Flame[i][Flame_pos][1], Flame[i][Flame_pos][2]+Z_DIFFERENCE-1))) |
563 | + | |
564 | ||
565 | stock IsAtFlame(playerid) | |
566 | { | |
567 | for(new i; i < MAX_FIRES; i++) | |
568 | { | |
569 | if(Flame[i][Flame_Exists]) | |
570 | { | |
571 | if(!IsPlayerInAnyVehicle(playerid) && (IsPlayerInRangeOfPoint(playerid, BURNING_RADIUS, Flame[i][Flame_pos][0], Flame[i][Flame_pos][1], Flame[i][Flame_pos][2]+Z_DIFFERENCE) || | |
572 | IsPlayerInRangeOfPoint(playerid, BURNING_RADIUS, Flame[i][Flame_pos][0], Flame[i][Flame_pos][1], Flame[i][Flame_pos][2]+Z_DIFFERENCE-1))) | |
573 | { | |
574 | return 1; | |
575 | } | |
576 | } | |
577 | } | |
578 | return 0; | |
579 | } | |
580 | ||
581 | new AaF_cache[MAX_PLAYERS] = { -1, ... }; | |
582 | new AaF_cacheTime[MAX_PLAYERS]; | |
583 | ||
584 | stock Aiming_at_Flame(playerid) | |
585 | { | |
586 | if(gettime() - AaF_cacheTime[playerid] < 1) | |
587 | { | |
588 | return AaF_cache[playerid]; | |
589 | } | |
590 | AaF_cacheTime[playerid] = gettime(); | |
591 | ||
592 | new id = -1; | |
593 | new Float:dis = 99999.99; | |
594 | new Float:dis2; | |
595 | new Float:px, Float:py, Float:pz; | |
596 | new Float:x, Float:y, Float:z, Float:a; | |
597 | - | if(IsPlayerConnected(i) && PlayerOnFire[i] && (IsInWaterCar(playerid) || HasExtinguisher(playerid) || GetPlayerWeapon(playerid) == 41 || Peeing(playerid)) && PlayerOnFire[i]) |
597 | + | |
598 | z -= Z_DIFFERENCE; | |
599 | ||
600 | new Float:cx,Float:cy,Float:cz,Float:fx,Float:fy,Float:fz; | |
601 | GetPlayerCameraPos(playerid, cx, cy, cz); | |
602 | GetPlayerCameraFrontVector(playerid, fx, fy, fz); | |
603 | ||
604 | for(new i; i < MAX_PLAYERS; i++) | |
605 | { | |
606 | if(IsPlayerConnected(i) && GetPVarInt(i, "IsOnFire") && (IsInWaterCar(playerid) || HasExtinguisher(playerid) || GetPlayerWeapon(playerid) == 41 || Peeing(playerid)) && GetPVarInt(i, "IsOnFire")) | |
607 | { | |
608 | GetPlayerPos(i, px, py, pz); | |
609 | if(!Peeing(playerid)) | |
610 | { | |
611 | dis2 = DistanceCameraTargetToLocation(cx, cy, cz, px, py, pz, fx, fy, fz); | |
612 | } | |
613 | else | |
614 | { | |
615 | if(IsPlayerInRangeOfPoint(playerid, ONFOOT_RADIUS, px, py, pz)) | |
616 | { | |
617 | dis2 = 0.0; | |
618 | } | |
619 | } | |
620 | if(dis2 < dis) | |
621 | { | |
622 | dis = dis2; | |
623 | - | for(new i; i < MAX_FLAMES; i++) |
623 | + | |
624 | if(Peeing(playerid)) | |
625 | { | |
626 | return id; | |
627 | } | |
628 | } | |
629 | } | |
630 | } | |
631 | if(id != -1) { return id-MAX_PLAYERS; } | |
632 | for(new i; i < MAX_FIRES; i++) | |
633 | { | |
634 | if(Flame[i][Flame_Exists]) | |
635 | { | |
636 | if(IsInWaterCar(playerid) || HasExtinguisher(playerid) || GetPlayerWeapon(playerid) == 41 || Peeing(playerid)) | |
637 | - | if((IsPlayerInAnyVehicle(playerid) && dis2 < CAR_RADIUS && dis2 < dis) || (!IsPlayerInAnyVehicle(playerid) && ((dis2 < ONFOOT_RADIUS && dis2 < dis) || (Peeing(playerid) && dis2 < PISSING_WAY && dis2 < dis)))) |
637 | + | |
638 | if(!Peeing(playerid)) | |
639 | { | |
640 | dis2 = DistanceCameraTargetToLocation(cx, cy, cz, Flame[i][Flame_pos][0], Flame[i][Flame_pos][1], Flame[i][Flame_pos][2]+Z_DIFFERENCE, fx, fy, fz); | |
641 | } | |
642 | else | |
643 | { | |
644 | dis2 = GetDistanceBetweenPoints(x,y,z,Flame[i][Flame_pos][0],Flame[i][Flame_pos][1],Flame[i][Flame_pos][2]); | |
645 | } | |
646 | if((IsPlayerInAnyVehicle(playerid) && dis2 < CAR_RADIUS && dis2 < dis) || (!IsPlayerInAnyVehicle(playerid) && ((dis2 < ONFOOT_RADIUS && dis2 < dis) || (Peeing(playerid) && dis2 < PISSING_DISTANCE && dis2 < dis)))) | |
647 | { | |
648 | dis = dis2; | |
649 | id = i; | |
650 | } | |
651 | } | |
652 | } | |
653 | } | |
654 | if(id != -1) | |
655 | { | |
656 | if | |
657 | ( | |
658 | ( | |
659 | IsPlayerInAnyVehicle(playerid) && !IsPlayerInRangeOfPoint(playerid, 50, Flame[id][Flame_pos][0], Flame[id][Flame_pos][1], Flame[id][Flame_pos][2]) | |
660 | ) | |
661 | || | |
662 | ( | |
663 | !IsPlayerInAnyVehicle(playerid) && !IsPlayerInRangeOfPoint(playerid, 5, Flame[id][Flame_pos][0], Flame[id][Flame_pos][1], Flame[id][Flame_pos][2]) | |
664 | ) | |
665 | ) | |
666 | { id = -1; } | |
667 | - | new string[22]; |
667 | + | |
668 | - | format(string, sizeof(string), "%d", Aiming_at_Flame(playerid)); |
668 | + | |
669 | - | SendClientMessage(playerid, 0xFFFFFFFF, string); |
669 | + | |
670 | - | return strval(string); |
670 | + | |
671 | ||
672 | stock Pissing_at_Flame(playerid) | |
673 | { | |
674 | if(Peeing(playerid)) | |
675 | { | |
676 | return Aiming_at_Flame(playerid); | |
677 | } | |
678 | return -1; | |
679 | } | |
680 | ||
681 | stock IsInWaterCar(playerid) | |
682 | { | |
683 | if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 407 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 601) { return 1; } | |
684 | return 0; | |
685 | } | |
686 | ||
687 | stock HasExtinguisher(playerid) | |
688 | { | |
689 | if(GetPlayerWeapon(playerid) == 42 && !IsPlayerInAnyVehicle(playerid)) { return 1; } | |
690 | return 0; | |
691 | } | |
692 | ||
693 | stock Peeing(playerid) | |
694 | { | |
695 | return GetPlayerSpecialAction(playerid) == SPECIAL_ACTION_PISSING; | |
696 | } | |
697 | ||
698 | stock Pressing(playerid) | |
699 | { | |
700 | new keys, updown, leftright; | |
701 | GetPlayerKeys(playerid, keys, updown, leftright); | |
702 | return keys; | |
703 | } | |
704 | ||
705 | //===================== Important Shit ==================== | |
706 | ||
707 | forward MMF_ExtFire(version[15]); | |
708 | public MMF_ExtFire(version[15]) | |
709 | { | |
710 | if(strcmp(VERSION, version, true) && strlen(version)) | |
711 | { | |
712 | return 2; | |
713 | } | |
714 | return 1; | |
715 | } | |
716 | ||
717 | AntiDeAMX() | |
718 | { | |
719 | new foo[][] = | |
720 | { | |
721 | "l33t", | |
722 | "lol xD" | |
723 | }; | |
724 | #pragma unused foo | |
725 | } |