flash.pwn 7.3 KB

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