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