Advertisement
Guest User

fix by bansilog create by XRVX Ps. im not owner i fix only

a guest
May 11th, 2018
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.67 KB | None | 0 0
  1. /*
  2. Vehicle Headlight's Filterscript
  3. Toggle you vehicles lights on/off :)
  4.  
  5. Created by: Anwix (http://forum.sa-mp.com/index.php?action=profile;u=12730)
  6.  
  7. Thanks to:
  8. ~ JernejL (RedShirt) - Encode Lights Script
  9. */
  10.  
  11. #include <a_samp>
  12.  
  13. new bool: VehicleLightsOn[MAX_VEHICLES];
  14. new panels, doors, lights, tires;
  15.  
  16. #define PRESSED(%0) \
  17. (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
  18.  
  19. public OnFilterScriptInit()
  20. {
  21. print("\n--------------------------------------");
  22. print(" Vehicle Lights Filterscript Loaded");
  23. print("--------------------------------------\n");
  24.  
  25. for (new x = 1; x < MAX_VEHICLES; x++)
  26. {
  27. VehicleLightsOn[x] = false;
  28. }
  29. return 1;
  30. }
  31.  
  32. public OnFilterScriptExit()
  33. {
  34. print("\n--------------------------------------");
  35. print(" Vehicle Lights Filterscript Unloaded");
  36. print("--------------------------------------\n");
  37. return 1;
  38. }
  39.  
  40. public OnPlayerStateChange(playerid, newstate, oldstate)
  41. {
  42. if (newstate == PLAYER_STATE_DRIVER)
  43. {
  44. if (VehicleLightsOn[GetPlayerVehicleID(playerid)] == false)
  45. {
  46. GetVehicleDamageStatus(GetPlayerVehicleID(playerid), panels, doors, lights, tires);
  47. UpdateVehicleDamageStatus(GetPlayerVehicleID(playerid), panels, doors, encode_lights(1, 1, 1, 1), tires);
  48. VehicleLightsOn[GetPlayerVehicleID(playerid)] = false;
  49. }
  50. else
  51. {
  52. GetVehicleDamageStatus(GetPlayerVehicleID(playerid), panels, doors, lights, tires);
  53. UpdateVehicleDamageStatus(GetPlayerVehicleID(playerid), panels, doors, encode_lights(0, 0, 0, 0), tires);
  54. VehicleLightsOn[GetPlayerVehicleID(playerid)] = true;
  55. }
  56. }
  57. }
  58.  
  59. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  60. {
  61. if (PRESSED(KEY_ACTION))
  62. {
  63. if (IsPlayerInAnyVehicle(playerid))
  64. {
  65. if (VehicleLightsOn[GetPlayerVehicleID(playerid)] == false)
  66. {
  67. GetVehicleDamageStatus(GetPlayerVehicleID(playerid), panels, doors, lights, tires);
  68. UpdateVehicleDamageStatus(GetPlayerVehicleID(playerid), panels, doors, encode_lights(0, 0, 0, 0), tires);
  69. VehicleLightsOn[GetPlayerVehicleID(playerid)] = true;
  70. }
  71. else
  72. {
  73. GetVehicleDamageStatus(GetPlayerVehicleID(playerid), panels, doors, lights, tires);
  74. UpdateVehicleDamageStatus(GetPlayerVehicleID(playerid), panels, doors, encode_lights(1, 1, 1, 1), tires);
  75. VehicleLightsOn[GetPlayerVehicleID(playerid)] = false;
  76. }
  77. }
  78. }
  79. return 1;
  80. }
  81.  
  82. /* Thanks to JernejL (RedShirt) for encode_lights */
  83. stock encode_lights(light1, light2, light3, light4)
  84. {
  85. return light1 | (light2 << 1) | (light3 << 2) | (light4 << 3);
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement