Advertisement
Stefantjuh97

Police Flash V3.0

Aug 24th, 2012
9,104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 7.34 KB | None | 0 0
  1. /*
  2. © Stefantjuh97
  3. Mail: S.dorst1997@gmail.com
  4. SAMP Forum name: Stefand.
  5. Release Date: 18-6-2012
  6. Version: 3.0
  7.  
  8.  
  9. Changelog V2.0
  10. Fixed:
  11. - Headlights keep flashing when you are out of the vehicle.
  12.   Thanks to BrandyPenguin
  13.  
  14. - if you did /flash 2 times without /flashoff you had a bugged vehicle.
  15.  
  16. Added:
  17. - Working for ambulance
  18. - Working for Firetruck
  19.  
  20. Changelog V3.0
  21. Fixed:
  22. - /flash for turning flash on and /flash for turning it off
  23.   Thanks to BrandyPenguin
  24.  
  25. Added:
  26. - Nothing
  27. */
  28.  
  29. #include <a_samp>
  30. #include <zcmd>
  31.  
  32. #define FILTERSCRIPT
  33.  
  34. forward FlasherFunc();
  35.  
  36. new obj[MAX_VEHICLES] = { INVALID_OBJECT_ID, ... };
  37. new obj2[MAX_VEHICLES] = { INVALID_OBJECT_ID, ... };
  38. new LightPwr[MAX_VEHICLES];
  39. new Flasher[MAX_VEHICLES] = 0;
  40. new FlasherState[MAX_VEHICLES];
  41. new FlashTimer;
  42.  
  43. public OnFilterScriptInit()
  44. {
  45.     print("\n--------------------------------------");
  46.     print(" Police Flash lights V2.1");
  47.     print(" By Stefantjuh97");
  48.     print("--------------------------------------\n");
  49.  
  50.     for (new x=0; x<MAX_VEHICLES; x++)
  51.     {
  52.         LightPwr[x]=1;
  53.         Flasher[x]=0;
  54.         FlasherState[x]=0;
  55.     }
  56.  
  57.     FlashTimer = SetTimer("FlasherFunc",200,1); // "200" is the speed from the flashing headlights
  58.     return 1;
  59. }
  60.  
  61. public OnFilterScriptExit()
  62. {
  63.     KillTimer(FlashTimer);
  64.     for (new i = 0; i < MAX_VEHICLES; i++)
  65.     {
  66.         DestroyObject(obj[i]);
  67.         DestroyObject(obj2[i]);
  68.     }
  69.     return 1;
  70. }
  71.  
  72.  
  73.  
  74.  
  75. public OnVehicleSpawn(vehicleid)
  76. {
  77.     DestroyObject(obj[vehicleid]);
  78.     DestroyObject(obj2[vehicleid]);
  79.     Flasher[vehicleid] = 0;
  80.     return 1;
  81. }
  82.  
  83. public OnVehicleDeath(vehicleid, killerid)
  84. {
  85.     DestroyObject(obj[vehicleid]);
  86.     DestroyObject(obj2[vehicleid]);
  87.     Flasher[vehicleid] = 0;
  88.     return 1;
  89. }
  90.  
  91. command(flash, playerid, params[])
  92. {
  93.     new vehicleid,panels,doors,lights,tires;
  94.     vehicleid = GetPlayerVehicleID(playerid);
  95.     if(!Flasher[vehicleid]) {
  96.         if (GetPlayerState(playerid) != PLAYER_STATE_DRIVER)
  97.         {
  98.             return SendClientMessage(playerid, -1, "* You are not the driver!");
  99.         }
  100.         if (!GetVehicleModel(vehicleid)) return SendClientMessage(playerid, -1, "* You are not in a vehicle!");
  101.         if (IsValidObject(obj[vehicleid]) || IsValidObject(obj2[vehicleid]))
  102.         {
  103.             SendClientMessage(playerid, -1, "You switched off the lights."), DestroyObject(obj[vehicleid]), DestroyObject(obj2[vehicleid]);
  104.             GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
  105.             if(LightPwr[vehicleid] == 1)
  106.             UpdateVehicleDamageStatus(vehicleid, panels, doors, 0, tires);
  107.             else
  108.             UpdateVehicleDamageStatus(vehicleid, panels, doors, 5, tires);
  109.             Flasher[vehicleid] = 0;
  110.         }
  111.         switch (GetVehicleModel(vehicleid))
  112.         {
  113.             case 596:
  114.             {
  115.                 obj[vehicleid] = CreateObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
  116.                 obj2[vehicleid] = CreateObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
  117.                 AttachObjectToVehicle(obj[vehicleid], vehicleid, 0.599999,-0.375000,0.899999,0.000000,0.000000,0.000000);
  118.                 AttachObjectToVehicle(obj2[vehicleid], vehicleid, -0.599999,-0.375000,0.899999,0.000000,0.000000,0.000000);
  119.                 GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
  120.                 Flasher[vehicleid] = 1;
  121.             }
  122.             case 597:
  123.             {
  124.                 obj[vehicleid] = CreateObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
  125.                 obj2[vehicleid] = CreateObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
  126.                 AttachObjectToVehicle(obj[vehicleid], vehicleid, 0.599999,-0.375000,0.899999,0.000000,0.000000,0.000000);
  127.                 AttachObjectToVehicle(obj2[vehicleid], vehicleid, -0.599999,-0.375000,0.899999,0.000000,0.000000,0.000000);
  128.  
  129.                 GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
  130.                 Flasher[vehicleid] = 1;
  131.             }
  132.             case 598:
  133.             {
  134.                 obj[vehicleid] = CreateObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
  135.                 obj2[vehicleid] = CreateObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
  136.                 AttachObjectToVehicle(obj[vehicleid], vehicleid, 0.524999, -0.300000, 0.899999, 0.000000, 0.000000, 0.000000);
  137.                 AttachObjectToVehicle(obj2[vehicleid], vehicleid, -0.524999, -0.300000, 0.899999, 0.000000, 0.000000, 0.000000);
  138.                 GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
  139.                 Flasher[vehicleid] = 1;
  140.             }
  141.             case 599:
  142.             {
  143.                 obj[vehicleid] = CreateObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
  144.                 obj2[vehicleid] = CreateObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
  145.                 AttachObjectToVehicle(obj[vehicleid], vehicleid, 0.524999,0.000000,1.125000,0.000000,0.000000,0.000000);
  146.                 AttachObjectToVehicle(obj2[vehicleid], vehicleid, -0.524999,0.000000,1.125000,0.000000,0.000000,0.000000);
  147.                 GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
  148.                 Flasher[vehicleid] = 1;
  149.             }
  150.             case 541://bullet
  151.             {
  152.                 obj[vehicleid] = CreateObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
  153.                 AttachObjectToVehicle(obj[vehicleid], vehicleid, 0.375000,0.524999,0.375000,0.000000,0.000000,0.000000);
  154.  
  155.                 GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
  156.                 Flasher[vehicleid] = 1;
  157.             }
  158.             case 426://premier
  159.             {
  160.                 obj[vehicleid] = CreateObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
  161.                 AttachObjectToVehicle(obj[vehicleid], vehicleid, 0.524999,0.749999,0.375000,0.000000,0.000000,0.000000);
  162.  
  163.                 GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
  164.                 Flasher[vehicleid] = 1;
  165.             }
  166.             case 427://enforcer
  167.             {
  168.                 GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
  169.                 Flasher[vehicleid] = 1;
  170.             }
  171.             case 416://Ambulance
  172.             {
  173.                 GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
  174.                 Flasher[vehicleid] = 1;
  175.             }
  176.             case 407://FireTruck
  177.             {
  178.                 GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
  179.                 Flasher[vehicleid] = 1;
  180.             }
  181.             case 560://sultan
  182.             {
  183.                 obj[vehicleid] = CreateObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
  184.                 AttachObjectToVehicle(obj[vehicleid], vehicleid, 0.225000,0.750000,0.449999,0.000000,0.000000,0.000000);
  185.                 GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
  186.                 Flasher[vehicleid] = 1;
  187.             }
  188.             case 490://FBI
  189.             {
  190.                 obj[vehicleid] = CreateObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
  191.                 AttachObjectToVehicle(obj[vehicleid], vehicleid, 0.000000,1.125000,0.599999,0.000000,0.000000,0.000000);
  192.                 GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
  193.                 Flasher[vehicleid] = 1;
  194.             }
  195.             default:
  196.             {
  197.                 return SendClientMessage(playerid, -1, "You are not in a CODE 2 compatible police vehicle!");
  198.             }
  199.         }
  200.         return SendClientMessage(playerid, -1, "Lights on, you are now in a CODE 2 run!");
  201.     } else {
  202.         if (IsValidObject(obj[vehicleid]) || IsValidObject(obj2[vehicleid])) {
  203.             SendClientMessage(playerid, -1, "You switched off the lights."), DestroyObject(obj[vehicleid]), DestroyObject(obj2[vehicleid]);
  204.         }
  205.         GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
  206.         if(LightPwr[vehicleid] == 1)
  207.             UpdateVehicleDamageStatus(vehicleid, panels, doors, 0, tires);
  208.         else
  209.             UpdateVehicleDamageStatus(vehicleid, panels, doors, 5, tires);
  210.         Flasher[vehicleid] = 0;
  211.     }
  212.     return 1;
  213. }
  214.  
  215. public FlasherFunc() {
  216.     new panelsx,doorsx,lightsx,tiresx;
  217.     for (new p=0; p<MAX_VEHICLES; p++)
  218.     {
  219.         if (Flasher[p] == 1)
  220.         {
  221.             if (FlasherState[p] == 1)
  222.             {
  223.                 GetVehicleDamageStatus(p,panelsx,doorsx,lightsx,tiresx);
  224.                 UpdateVehicleDamageStatus(p, panelsx, doorsx, 4, tiresx);
  225.                 FlasherState[p] = 0;
  226.             }
  227.             else
  228.             {
  229.                 GetVehicleDamageStatus(p,panelsx,doorsx,lightsx,tiresx);
  230.                 UpdateVehicleDamageStatus(p, panelsx, doorsx, 1, tiresx);
  231.                 FlasherState[p] = 1;
  232.             }
  233.         }
  234.     }
  235.     return 1;
  236. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement