Advertisement
Stefantjuh97

Police Flash V3.0

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