Advertisement
Meta__

ExtFire 0.3d

Aug 28th, 2011
952
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 20.23 KB | None | 0 0
  1. #include <a_samp>
  2. #pragma tabsize 0
  3.  
  4. #define VERSION "0.3d"
  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.     for(new playerid; playerid < MAX_PLAYERS; playerid++)
  142.     {
  143.         if(!IsPlayerConnected(playerid) || IsPlayerNPC(playerid)) { continue; }
  144.         if(PlayerOnFire[playerid] && !CanPlayerBurn(playerid, 1))
  145.         { StopPlayerBurning(playerid); }
  146.         if(Pissing_at_Flame(playerid) != -1 || Aiming_at_Flame(playerid) != -1)
  147.         {
  148.             #if defined German
  149.             GameTextForPlayer(playerid, " ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~r~~h~Feuer in Sicht", 1500, 6);
  150.             #else
  151.             GameTextForPlayer(playerid, " ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~r~~h~Flame ahead", 1500, 6);
  152.             #endif
  153.             if(ExtTimer[playerid] == -1 && ((Aiming_at_Flame(playerid) != -1 && Pressing(playerid) & KEY_FIRE) || Pissing_at_Flame(playerid) != -1))
  154.             {
  155.                 new value, time, Float:x, Float:y, Float:z;
  156.                 if(Pissing_at_Flame(playerid) != -1)
  157.                 {
  158.                     value = Pissing_at_Flame(playerid);
  159.                     time = EXTINGUISH_TIME_PEEING;
  160.                 }
  161.                 else if(Aiming_at_Flame(playerid) != -1)
  162.                 {
  163.                     value = Aiming_at_Flame(playerid);
  164.                     if(GetPlayerWeapon(playerid) == 41)
  165.                     {
  166.                         CreateExplosion(Flame[value][Flame_pos][0], Flame[value][Flame_pos][1], Flame[value][Flame_pos][2], 2, 5);
  167.                         continue;
  168.                     }
  169.                     if(IsPlayerInAnyVehicle(playerid))
  170.                     {
  171.                         time = EXTINGUISH_TIME_VEHICLE;
  172.                     }
  173.                     else
  174.                     {
  175.                         time = EXTINGUISH_TIME_ONFOOT;
  176.                     }
  177.                 }
  178.                 if(value < -1) { time = EXTINGUISH_TIME_PLAYER; }
  179.                 time *= 1000;
  180.                 if(value >= -1)
  181.                 {
  182.                     x = Flame[value][Flame_pos][0];
  183.                     y = Flame[value][Flame_pos][1];
  184.                     z = Flame[value][Flame_pos][2];
  185.                     DestroyTheSmokeFromFlame(value);
  186.                     Flame[value][Smoke][0] = CreateObject(18727, x, y, z, 0.0, 0.0, 0.0);
  187.                     Flame[value][Smoke][1] = CreateObject(18727, x+1, y, z, 0.0, 0.0, 0.0);
  188.                     Flame[value][Smoke][2] = CreateObject(18727, x-1, y, z, 0.0, 0.0, 0.0);
  189.                     Flame[value][Smoke][3] = CreateObject(18727, x, y+1, z, 0.0, 0.0, 0.0);
  190.                     Flame[value][Smoke][4] = CreateObject(18727, x, y-1, z, 0.0, 0.0, 0.0);
  191.                     SetTimerEx("DestroyTheSmokeFromFlame", time, 0, "d", value);
  192.                 }
  193.                 ExtTimer[playerid] = SetTimerEx("FireTimer", time, 0, "dd", playerid, value);
  194.             }
  195.         }
  196.         if(CanPlayerBurn(playerid) && IsAtFlame(playerid)) { SetPlayerBurn(playerid); }
  197.         #if defined BurnOthers
  198.         new Float:x, Float:y, Float:z;
  199.         for(new i; i < MAX_PLAYERS; i++)
  200.         {
  201.             if(playerid != i && IsPlayerConnected(i) && !IsPlayerNPC(i))
  202.             {
  203.                 if(CanPlayerBurn(i) && PlayerOnFire[playerid] && !PlayerOnFire[i])
  204.                 {
  205.                     GetPlayerPos(i, x, y, z);
  206.                     if(IsPlayerInRangeOfPoint(playerid, 1, x, y, z))
  207.                     {
  208.                         SetPlayerBurn(i);
  209.                     }
  210.                 }
  211.             }
  212.         }
  213.         #endif
  214.     }
  215.     return 1;
  216. }
  217.  
  218.  
  219. //===================== stocks ====================
  220.  
  221. stock GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, &Float:z, &Float:a, Float:distance)
  222. {
  223.     GetPlayerPos(playerid, x, y ,z);
  224.     if(IsPlayerInAnyVehicle(playerid))
  225.     {
  226.         GetVehicleZAngle(GetPlayerVehicleID(playerid),a);
  227.     }
  228.     else
  229.     {
  230.         GetPlayerFacingAngle(playerid, a);
  231.     }
  232.     x += (distance * floatsin(-a, degrees));
  233.     y += (distance * floatcos(-a, degrees));
  234.     return 0;
  235. }
  236.  
  237. stock strtok(const string[], &index)
  238. {
  239.     new length = strlen(string);
  240.     while ((index < length) && (string[index] <= ' '))
  241.     {
  242.         index++;
  243.     }
  244.     new offset = index;
  245.     new result[256];
  246.     while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  247.     {
  248.         result[index - offset] = string[index];
  249.         index++;
  250.     }
  251.     result[index - offset] = EOS;
  252.     return result;
  253. }
  254.  
  255. #if !defined ReturnUser
  256. stock ReturnUser(text[])
  257. {
  258.     new pos = 0;
  259.     while (text[pos] < 0x21)
  260.     {
  261.         if(text[pos] == 0) return INVALID_PLAYER_ID;
  262.         pos++;
  263.     }
  264.     new userid = INVALID_PLAYER_ID;
  265.     if(isNumeric(text[pos]))
  266.     {
  267.         userid = strval(text[pos]);
  268.         if(userid >=0 && userid < MAX_PLAYERS)
  269.         {
  270.             if(!IsPlayerConnected(userid))
  271.                 userid = INVALID_PLAYER_ID;
  272.             else return userid;
  273.         }
  274.     }
  275.     new len = strlen(text[pos]);
  276.     new count = 0;
  277.     new pname[MAX_PLAYER_NAME];
  278.     for (new i = 0; i < MAX_PLAYERS; i++)
  279.     {
  280.         if(IsPlayerConnected(i))
  281.         {
  282.             GetPlayerName(i, pname, sizeof (pname));
  283.             if(strcmp(pname, text[pos], true, len) == 0)
  284.             {
  285.                 if(len == strlen(pname)) return i;
  286.                 else
  287.                 {
  288.                     count++;
  289.                     userid = i;
  290.                 }
  291.             }
  292.         }
  293.     }
  294.     if(count != 1)
  295.     {
  296.         userid = INVALID_PLAYER_ID;
  297.     }
  298.     return userid;
  299. }
  300. #endif
  301. #if !defined isNumeric
  302. stock isNumeric(const string[])
  303. {
  304.     new length=strlen(string);
  305.     if (length==0) return false;
  306.     for (new i = 0; i < length; i++)
  307.     {
  308.         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.*/)
  309.         {
  310.             return false;
  311.         }
  312.     }
  313.     if (length==1 && (string[0]=='-' || string[0]=='+')) { return false; }
  314.     return true;
  315. }
  316. #endif
  317.  
  318. stock Float:GetDistanceBetweenPoints(Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2) //By Gabriel "Larcius" Cordes
  319. {
  320.     return floatadd(floatadd(floatsqroot(floatpower(floatsub(x1,x2),2)),floatsqroot(floatpower(floatsub(y1,y2),2))),floatsqroot(floatpower(floatsub(z1,z2),2)));
  321. }
  322.  
  323. stock Float:DistanceCameraTargetToLocation(Float:CamX, Float:CamY, Float:CamZ, Float:ObjX, Float:ObjY, Float:ObjZ, Float:FrX, Float:FrY, Float:FrZ)
  324. {
  325.     new Float:TGTDistance;
  326.  
  327.     // get distance from camera to target
  328.     TGTDistance = floatsqroot((CamX - ObjX) * (CamX - ObjX) + (CamY - ObjY) * (CamY - ObjY) + (CamZ - ObjZ) * (CamZ - ObjZ));
  329.  
  330.     new Float:tmpX, Float:tmpY, Float:tmpZ;
  331.  
  332.     tmpX = FrX * TGTDistance + CamX;
  333.     tmpY = FrY * TGTDistance + CamY;
  334.     tmpZ = FrZ * TGTDistance + CamZ;
  335.  
  336.     return floatsqroot((tmpX - ObjX) * (tmpX - ObjX) + (tmpY - ObjY) * (tmpY - ObjY) + (tmpZ - ObjZ) * (tmpZ - ObjZ));
  337. }
  338.  
  339. stock IsPlayerAimingAt(playerid, Float:x, Float:y, Float:z, Float:radius)
  340. {
  341.     new Float:cx,Float:cy,Float:cz,Float:fx,Float:fy,Float:fz;
  342.     GetPlayerCameraPos(playerid, cx, cy, cz);
  343.     GetPlayerCameraFrontVector(playerid, fx, fy, fz);
  344.     return (radius >= DistanceCameraTargetToLocation(cx, cy, cz, x, y, z, fx, fy, fz));
  345. }
  346.  
  347. //===================== Own Publics ====================
  348.  
  349. public AddFire(Float:x, Float:y, Float:z)
  350. {
  351.     new slot = GetFlameSlot();
  352.     if(slot == -1) {return slot;}
  353.     Flame[slot][Flame_Exists] = 1;
  354.     Flame[slot][Flame_pos][0] = x;
  355.     Flame[slot][Flame_pos][1] = y;
  356.     Flame[slot][Flame_pos][2] = z - Z_DIFFERENCE;
  357.     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);
  358.     return slot;
  359. }
  360.  
  361. public KillFire(id)
  362. {
  363.     DestroyObject(Flame[id][Flame_id]);
  364.     Flame[id][Flame_Exists] = 0;
  365.     Flame[id][Flame_pos][0] = 0.0;
  366.     Flame[id][Flame_pos][1] = 0.0;
  367.     Flame[id][Flame_pos][2] = 0.0;
  368.     DestroyTheSmokeFromFlame(id);
  369. }
  370.  
  371. //# A suggestion from a user of this script. Very simple functions to add and remove smoke without flames.
  372. //# Think about a way to kill the smoke and use it, if you wish.
  373. //# 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.
  374.  
  375. public AddSmoke(Float:x, Float:y, Float:z)
  376. {
  377.     return CreateObject(18727, x, y, z, 0.0, 0.0, 0.0);
  378. }
  379.  
  380. public KillSmoke(id)
  381. {
  382.     DestroyObject(id);
  383. }
  384.  
  385. // Destroys extinguishing-smoke
  386. public DestroyTheSmokeFromFlame(id)
  387. {
  388.     for(new i; i < 5; i++) { DestroyObject(Flame[id][Smoke][i]); }
  389. }
  390.  
  391. public FireTimer(playerid, id)
  392. {
  393.     if(id < -1 && (Aiming_at_Flame(playerid) == id || Pissing_at_Flame(playerid) == id)) { StopPlayerBurning(id+MAX_PLAYERS); }
  394.     else if(Flame[id][Flame_Exists] && ((Pressing(playerid) & KEY_FIRE && Aiming_at_Flame(playerid) == id) || (Pissing_at_Flame(playerid) == id)))
  395.     {
  396.         new sendername[MAX_PLAYER_NAME+26];
  397.         GetPlayerName(playerid, sendername, sizeof(sendername));
  398.         #if defined MessageToAll
  399.             if(Pissing_at_Flame(playerid) == id)
  400.             {
  401.                 #if defined German
  402.                     format(sendername, sizeof(sendername), "* %s hat einen Brand ausgepisst! *", sendername);
  403.                 #else
  404.                     format(sendername, sizeof(sendername), "* %s pissed out a fire! *", sendername);
  405.                 #endif
  406.             }
  407.             else if(Aiming_at_Flame(playerid) == id)
  408.             {
  409.                 #if defined German
  410.                     format(sendername, sizeof(sendername), "* %s hat einen Brand gelöscht! *", sendername);
  411.                 #else
  412.                     format(sendername, sizeof(sendername), "* %s extinguished a fire! *", sendername);
  413.                 #endif
  414.             }
  415.             SendClientMessageToAll(FireMessageColor, sendername);
  416.         #else
  417.             if(Pissing_at_Flame(playerid) == id)
  418.             {
  419.                 #if defined German
  420.                     SendClientMessage(playerid, FireMessageColor, "* Du hast einen Brand ausgepisst! *");
  421.                 #else
  422.                     SendClientMessage(playerid, FireMessageColor, "* You pissed out a fire! *");
  423.                 #endif
  424.             }
  425.             else if(Aiming_at_Flame(playerid) == id)
  426.             {
  427.                 #if defined German
  428.                     SendClientMessage(playerid, FireMessageColor, "* Du hast einen Brand gelöscht! *");
  429.                 #else
  430.                     SendClientMessage(playerid, FireMessageColor, "* You extinguished a fire! *");
  431.                 #endif
  432.             }
  433.         #endif
  434.         KillFire(id);
  435.         #if defined EarnMoney
  436.         GivePlayerMoney(playerid, 500);
  437.         #endif
  438.     }
  439.     KillTimer(ExtTimer[playerid]);
  440.     ExtTimer[playerid] = -1;
  441. }
  442.  
  443. public SetPlayerBurn(playerid)
  444. {
  445.     SetPlayerAttachedObject(playerid, FIRE_OBJECT_SLOT, 18690, 2, -1, 0, -1.9, 0, 0);
  446.     PlayerOnFire[playerid] = 1;
  447.     GetPlayerHealth(playerid, PlayerOnFireHP[playerid]);
  448.     KillTimer(PlayerOnFireTimer[playerid]); KillTimer(PlayerOnFireTimer2[playerid]);
  449.     PlayerOnFireTimer[playerid] = SetTimerEx("BurningTimer", 91, 1, "d", playerid);
  450.     PlayerOnFireTimer2[playerid] = SetTimerEx("StopPlayerBurning", 7000, 0, "d", playerid);
  451.     return 1;
  452. }
  453.  
  454. public BurningTimer(playerid)
  455. {
  456.     if(PlayerOnFire[playerid])
  457.     {
  458.         new Float:hp;
  459.         GetPlayerHealth(playerid, hp);
  460.         if(hp < PlayerOnFireHP[playerid])
  461.         {
  462.             PlayerOnFireHP[playerid] = hp;
  463.         }
  464.         SetPlayerHealth(playerid, PlayerOnFireHP[playerid]-1.0);
  465.         PlayerOnFireHP[playerid] -= 1.0;
  466.     }
  467.     else { KillTimer(PlayerOnFireTimer[playerid]); KillTimer(PlayerOnFireTimer2[playerid]); }
  468. }
  469.  
  470. public StopPlayerBurning(playerid)
  471. {
  472.     KillTimer(PlayerOnFireTimer[playerid]);
  473.     PlayerOnFire[playerid] = 0;
  474.     RemovePlayerAttachedObject(playerid, FIRE_OBJECT_SLOT);
  475. }
  476.  
  477. //===================== Other Functions ====================
  478.  
  479. stock GetFireID(Float:x, Float:y, Float:z, &Float:dist)
  480. {
  481.     new id = -1;
  482.     dist = 99999.99;
  483.     for(new i; i < MAX_FLAMES; i++)
  484.     {
  485.         if(GetDistanceBetweenPoints(x,y,z,Flame[i][Flame_pos][0],Flame[i][Flame_pos][1],Flame[i][Flame_pos][2]) < dist)
  486.         {
  487.             dist = GetDistanceBetweenPoints(x,y,z,Flame[i][Flame_pos][0],Flame[i][Flame_pos][1],Flame[i][Flame_pos][2]);
  488.             id = i;
  489.         }
  490.     }
  491.     return id;
  492. }
  493.  
  494. stock CanPlayerBurn(playerid, val = 0)
  495. {
  496.     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; }
  497.     return 0;
  498. }
  499.  
  500. /* //Uncomment or copy to your script.
  501.  
  502. forward CanBurn(playerid);
  503. public CanBurn(playerid)
  504. {
  505.     if(...)
  506.     {
  507.         return 1;
  508.     }
  509.     return -1; // IMPORTANT!
  510. }
  511.  
  512. */
  513.  
  514. stock IsPlayerInWater(playerid)
  515. {
  516.     new Float:X, Float:Y, Float:Z, an = GetPlayerAnimationIndex(playerid);
  517.     GetPlayerPos(playerid, X, Y, Z);
  518.     if((1544 >= an >= 1538 || an == 1062 || an == 1250) && (Z <= 0 || (Z <= 41.0 && IsPlayerInArea(playerid, -1387, -473, 2025, 2824))) ||
  519.     (1544 >= an >= 1538 || an == 1062 || an == 1250) && (Z <= 2 || (Z <= 39.0 && IsPlayerInArea(playerid, -1387, -473, 2025, 2824))))
  520.     {
  521.         return 1;
  522.     }
  523.     return 0;
  524. }
  525.  
  526. stock IsPlayerInArea(playerid, Float:MinX, Float:MaxX, Float:MinY, Float:MaxY)
  527. {
  528.     new Float:x, Float:y, Float:z;
  529.     GetPlayerPos(playerid, x, y, z);
  530.     #pragma unused z
  531.     if(x >= MinX && x <= MaxX && y >= MinY && y <= MaxY) { return 1; }
  532.     return 0;
  533. }
  534.  
  535. stock GetFlameSlot()
  536. {
  537.     for(new i = 0; i < MAX_FLAMES; i++)
  538.     {
  539.         if(!Flame[i][Flame_Exists]) { return i; }
  540.     }
  541.     return -1;
  542. }
  543.  
  544. //===================== "Callbacks" ====================
  545.  
  546. stock IsAtFlame(playerid)
  547. {
  548.     for(new i; i < MAX_PLAYERS; i++)
  549.     {
  550.        
  551.         if(Flame[i][Flame_Exists])
  552.         {
  553.             if(!IsPlayerInAnyVehicle(playerid) && (IsPlayerInRangeOfPoint(playerid, FLAME_ZONE, Flame[i][Flame_pos][0], Flame[i][Flame_pos][1], Flame[i][Flame_pos][2]+Z_DIFFERENCE) ||
  554.                                                    IsPlayerInRangeOfPoint(playerid, FLAME_ZONE, Flame[i][Flame_pos][0], Flame[i][Flame_pos][1], Flame[i][Flame_pos][2]+Z_DIFFERENCE-1)))
  555.             {
  556.                 return 1;
  557.             }
  558.         }
  559.     }
  560.     return 0;
  561. }
  562.  
  563. stock Aiming_at_Flame(playerid)
  564. {
  565.     new id = -1;
  566.     new Float:dis = 99999.99;
  567.     new Float:dis2;
  568.     new Float:px, Float:py, Float:pz;
  569.    
  570.     new Float:cx,Float:cy,Float:cz,Float:fx,Float:fy,Float:fz;
  571.     GetPlayerCameraPos(playerid, cx, cy, cz);
  572.     GetPlayerCameraFrontVector(playerid, fx, fy, fz);
  573.     for(new i; i < MAX_PLAYERS; i++)
  574.     {
  575.         if(IsPlayerConnected(i) && PlayerOnFire[i] && (IsInWaterCar(playerid) || HasExtinguisher(playerid) || GetPlayerWeapon(playerid) == 41) && PlayerOnFire[i])
  576.         {
  577.             GetPlayerPos(i, px, py, pz);
  578.             dis2 = DistanceCameraTargetToLocation(cx, cy, cz, px, py, pz, fx, fy, fz);
  579.             if(dis2 < dis)
  580.             {
  581.                 dis = dis2;
  582.                 id = i;
  583.             }
  584.         }
  585.     }
  586.     if(id != -1) { return id-MAX_PLAYERS; }
  587.     for(new i; i < MAX_FLAMES; i++)
  588.     {
  589.         if(Flame[i][Flame_Exists])
  590.         {
  591.             if(IsInWaterCar(playerid) || HasExtinguisher(playerid) || GetPlayerWeapon(playerid) == 41)
  592.             {
  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);
  594.                 if(IsPlayerInAnyVehicle(playerid) && dis2 < CAR_RADIUS && dis2 < dis)
  595.                 {
  596.                     dis = dis2;
  597.                     id = i;
  598.                 }
  599.                 else if(!IsPlayerInAnyVehicle(playerid) && dis2 < ONFOOT_RADIUS && dis2 < dis)
  600.                 {
  601.                     dis = dis2;
  602.                     id = i;
  603.                 }
  604.             }
  605.         }
  606.     }
  607.     if(id != -1)
  608.     {
  609.         if
  610.         (
  611.             (
  612.                 IsPlayerInAnyVehicle(playerid) && !IsPlayerInRangeOfPoint(playerid, 50, Flame[id][Flame_pos][0], Flame[id][Flame_pos][1], Flame[id][Flame_pos][2])
  613.             )
  614.             ||
  615.             (
  616.                 !IsPlayerInAnyVehicle(playerid)  && !IsPlayerInRangeOfPoint(playerid, 5, Flame[id][Flame_pos][0], Flame[id][Flame_pos][1], Flame[id][Flame_pos][2])
  617.             )
  618.         )
  619.         { id = -1; }
  620.     }
  621.     return id;
  622. }
  623.  
  624. stock Pissing_at_Flame(playerid)
  625. {
  626.     new id = -1;
  627.     new Float:dis = 99999.99, Float:dis2;
  628.     new Float:x,Float:y,Float:z,Float:x1,Float:y1,Float:z1,Float:a;
  629.     GetXYInFrontOfPlayer(playerid, x, y, z, a, 1);
  630.     z -= Z_DIFFERENCE;
  631.     if(GetPlayerSpecialAction(playerid) == SPECIAL_ACTION_PISSING)
  632.     {
  633.         for(new i; i < MAX_PLAYERS; i++)
  634.         {
  635.             if(IsPlayerConnected(i) && PlayerOnFire[i] && PlayerOnFire[i])
  636.             {
  637.                 GetPlayerPos(i, x1, y1, z1);
  638.                 if(IsPlayerInRangeOfPoint(playerid, ONFOOT_RADIUS, x1, y1, z1))
  639.                 {
  640.                     id = i;
  641.                 }
  642.             }
  643.         }
  644.         if(id != -1) { return id-MAX_PLAYERS; }
  645.         for(new i; i < MAX_FLAMES; i++)
  646.         {
  647.             if(Flame[i][Flame_Exists])
  648.             {
  649.                 if(!IsPlayerInAnyVehicle(playerid))
  650.                 {
  651.                     dis2 = GetDistanceBetweenPoints(x,y,z,Flame[i][Flame_pos][0],Flame[i][Flame_pos][1],Flame[i][Flame_pos][2]);
  652.                     if(dis2 < PISSING_WAY && dis2 < dis)
  653.                     {
  654.                         id = i;
  655.                         dis = dis2;
  656.                     }
  657.                 }
  658.             }
  659.         }
  660.     }
  661.     return id;
  662. }
  663.  
  664. stock IsInWaterCar(playerid)
  665. {
  666.     if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 407 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 601) { return 1; }
  667.     return 0;
  668. }
  669.  
  670. stock HasExtinguisher(playerid)
  671. {
  672.     if(GetPlayerWeapon(playerid) == 42 && !IsPlayerInAnyVehicle(playerid)) { return 1; }
  673.     return 0;
  674. }
  675.  
  676. stock Pressing(playerid)
  677. {
  678.     new keys, updown, leftright;
  679.     GetPlayerKeys(playerid, keys, updown, leftright);
  680.     return keys;
  681. }
  682.  
  683. //===================== Important Shit ====================
  684.  
  685. forward MMF_ExtFire(version[15]);
  686. public MMF_ExtFire(version[15])
  687. {
  688.     if(strcmp(VERSION, version, true) && strlen(version))
  689.     {
  690.         return 2;
  691.     }
  692.     return 1;
  693. }
  694.  
  695. AntiDeAMX()
  696. {
  697.     new foo[][] =
  698.     {
  699.         "l33t",
  700.         "lol xD"
  701.     };
  702.     #pragma unused foo
  703. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement