Advertisement
kemperrs

Untitled

Aug 24th, 2019
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.10 KB | None | 0 0
  1. mp.events.add("entityStreamIn", (entity) => {
  2. try {
  3. if (entity.type !== "vehicle") return;
  4. if (entity && mp.vehicles.exists(entity))
  5. {
  6. let typeor = typeof entity.getVariable('VehicleSyncData');
  7. let actualData = entity.getVariable('VehicleSyncData');
  8.  
  9. //Needed to stop vehicles from freaking out
  10. mp.game.streaming.requestCollisionAtCoord(entity.position.x, entity.position.y, entity.position.z);
  11. //mp.game.invoke(getNative("REQUEST_ADDITIONAL_COLLISION_AT_COORD"), entity.position.x, entity.position.y, entity.position.z);
  12. entity.setLoadCollisionFlag(true);
  13. entity.trackVisibility();
  14.  
  15. //Set doors unbreakable for a moment
  16. let x = 0;
  17. for (x = 0; x < 8; x++) {
  18. entity.setDoorBreakable(x, false);
  19. }
  20.  
  21. //Do it anyway
  22. entity.setUndriveable(true);
  23.  
  24. if (typeor !== 'undefined') {
  25. actualData = JSON.parse(actualData);
  26. entity.setEngineOn(actualData.Engine, true, false);
  27. entity.setUndriveable(true);
  28.  
  29. if (actualData.Locked)
  30. entity.setDoorsLocked(2);
  31. else
  32. entity.setDoorsLocked(1);
  33.  
  34. for (x = 0; x < 8; x++) {
  35. if (actualData.Door[x] === 1)
  36. entity.setDoorOpen(x, false, false);
  37. else if (actualData.Door[x] === 0)
  38. entity.setDoorShut(x, true);
  39. else
  40. entity.setDoorBroken(x, true);
  41. }
  42.  
  43. if (typeof entity.getVariable('HeadlightsColor') !== 'undefined') {
  44. let headlightsColor = entity.getVariable('HeadlightsColor');
  45. if (headlightsColor > 0) {
  46. entity.setMod(22, 0);
  47. mp.game.invoke(global.getNative("_SET_VEHICLE_HEADLIGHTS_COLOUR"), entity.handle, headlightsColor);
  48. }
  49. else {
  50. entity.setMod(22, headlightsColor);
  51. }
  52. }
  53.  
  54. if (typeof entity.getVariable('NeonColor') !== 'undefined') {
  55. let neonColors = entity.getVariable('NeonColor');
  56.  
  57. entity.setNeonLightsColour(neonColors[0], neonColors[1], neonColors[2]);
  58.  
  59. entity.setNeonLightEnabled(0, true);
  60. entity.setNeonLightEnabled(1, true);
  61. entity.setNeonLightEnabled(2, true);
  62. entity.setNeonLightEnabled(3, true);
  63. }
  64. }
  65. else
  66. mp.events.callRemote("VehStream_RequestFixStreamIn", entity);
  67.  
  68. //Make doors breakable again
  69. setTimeout(() => {
  70. for (x = 0; x < 8; x++) {
  71. if (entity && mp.vehicles.exists(entity))
  72. entity.setDoorBreakable(x, true);
  73. }
  74. }, 1500);
  75. }
  76. } catch (e) { }
  77. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement