Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mp.events.add("entityStreamIn", (entity) => {
- try {
- if (entity.type !== "vehicle") return;
- if (entity && mp.vehicles.exists(entity))
- {
- let typeor = typeof entity.getVariable('VehicleSyncData');
- let actualData = entity.getVariable('VehicleSyncData');
- //Needed to stop vehicles from freaking out
- mp.game.streaming.requestCollisionAtCoord(entity.position.x, entity.position.y, entity.position.z);
- //mp.game.invoke(getNative("REQUEST_ADDITIONAL_COLLISION_AT_COORD"), entity.position.x, entity.position.y, entity.position.z);
- entity.setLoadCollisionFlag(true);
- entity.trackVisibility();
- //Set doors unbreakable for a moment
- let x = 0;
- for (x = 0; x < 8; x++) {
- entity.setDoorBreakable(x, false);
- }
- //Do it anyway
- entity.setUndriveable(true);
- if (typeor !== 'undefined') {
- actualData = JSON.parse(actualData);
- entity.setEngineOn(actualData.Engine, true, false);
- entity.setUndriveable(true);
- if (actualData.Locked)
- entity.setDoorsLocked(2);
- else
- entity.setDoorsLocked(1);
- for (x = 0; x < 8; x++) {
- if (actualData.Door[x] === 1)
- entity.setDoorOpen(x, false, false);
- else if (actualData.Door[x] === 0)
- entity.setDoorShut(x, true);
- else
- entity.setDoorBroken(x, true);
- }
- if (typeof entity.getVariable('HeadlightsColor') !== 'undefined') {
- let headlightsColor = entity.getVariable('HeadlightsColor');
- if (headlightsColor > 0) {
- entity.setMod(22, 0);
- mp.game.invoke(global.getNative("_SET_VEHICLE_HEADLIGHTS_COLOUR"), entity.handle, headlightsColor);
- }
- else {
- entity.setMod(22, headlightsColor);
- }
- }
- if (typeof entity.getVariable('NeonColor') !== 'undefined') {
- let neonColors = entity.getVariable('NeonColor');
- entity.setNeonLightsColour(neonColors[0], neonColors[1], neonColors[2]);
- entity.setNeonLightEnabled(0, true);
- entity.setNeonLightEnabled(1, true);
- entity.setNeonLightEnabled(2, true);
- entity.setNeonLightEnabled(3, true);
- }
- }
- else
- mp.events.callRemote("VehStream_RequestFixStreamIn", entity);
- //Make doors breakable again
- setTimeout(() => {
- for (x = 0; x < 8; x++) {
- if (entity && mp.vehicles.exists(entity))
- entity.setDoorBreakable(x, true);
- }
- }, 1500);
- }
- } catch (e) { }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement