Fixing issues from vehiclesync
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
//You don't need to worry about anything here
|
//You don't need to worry about anything here
|
||||||
|
|
||||||
mp.events.add("VehStream_SetEngineStatus", (veh, status) => {
|
mp.events.add("VehStream_SetEngineStatus", (veh, status) => {
|
||||||
if (veh === undefined || veh === null) return;
|
if (veh === undefined || veh === null || !veh.isAVehicle()) return;
|
||||||
if (veh !== undefined) {
|
if (veh !== undefined) {
|
||||||
if (veh.isSeatFree(-1)) //Turns engine on instantly if no driver, otherwise it will not turn on
|
if (veh.isSeatFree(-1)) //Turns engine on instantly if no driver, otherwise it will not turn on
|
||||||
{
|
{
|
||||||
@@ -17,7 +17,7 @@ mp.events.add("VehStream_SetEngineStatus", (veh, status) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
mp.events.add("VehStream_SetLockStatus", (veh, status) => {
|
mp.events.add("VehStream_SetLockStatus", (veh, status) => {
|
||||||
if (veh === undefined || veh === null) return;
|
if (veh === undefined || veh === null || !veh.isAVehicle()) return;
|
||||||
if (veh !== undefined) {
|
if (veh !== undefined) {
|
||||||
if (status)
|
if (status)
|
||||||
veh.setDoorsLocked(2);
|
veh.setDoorsLocked(2);
|
||||||
@@ -27,7 +27,7 @@ mp.events.add("VehStream_SetLockStatus", (veh, status) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
mp.events.add("VehStream_PlayerEnterVehicleAttempt", (entity, seat) => {
|
mp.events.add("VehStream_PlayerEnterVehicleAttempt", (entity, seat) => {
|
||||||
if (entity === undefined || entity === null) return;
|
if (entity === undefined || entity === null || !entity.isAVehicle()) return;
|
||||||
if (typeof entity.getVariable("VehicleSyncData") !== 'undefined') {
|
if (typeof entity.getVariable("VehicleSyncData") !== 'undefined') {
|
||||||
var toggle = entity.getVariable("VehicleSyncData");
|
var toggle = entity.getVariable("VehicleSyncData");
|
||||||
entity.setEngineOn(toggle.Engine, false, true);
|
entity.setEngineOn(toggle.Engine, false, true);
|
||||||
@@ -36,7 +36,7 @@ mp.events.add("VehStream_PlayerEnterVehicleAttempt", (entity, seat) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
mp.events.add("VehStream_PlayerExitVehicleAttempt", (entity) => {
|
mp.events.add("VehStream_PlayerExitVehicleAttempt", (entity) => {
|
||||||
if (entity === undefined || entity === null) return;
|
if (entity === undefined || entity === null || !entity.isAVehicle()) return;
|
||||||
if (entity !== undefined) {
|
if (entity !== undefined) {
|
||||||
if (typeof entity.getVariable("VehicleSyncData") !== 'undefined') {
|
if (typeof entity.getVariable("VehicleSyncData") !== 'undefined') {
|
||||||
var toggle = entity.getVariable("VehicleSyncData");
|
var toggle = entity.getVariable("VehicleSyncData");
|
||||||
@@ -50,177 +50,181 @@ mp.events.add("VehStream_PlayerExitVehicleAttempt", (entity) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
mp.events.add("VehStream_PlayerExitVehicle", (entity) => {
|
mp.events.add("VehStream_PlayerExitVehicle", (entity) => {
|
||||||
if (entity === undefined || entity === null) return;
|
try {
|
||||||
setTimeout(() => {
|
if (entity === undefined || entity === null || !entity.isAVehicle()) return;
|
||||||
var Status = [];
|
setTimeout(() => {
|
||||||
let y = 0;
|
var Status = [];
|
||||||
for (y = 0; y < 8; y++) {
|
let y = 0;
|
||||||
if (entity.isDoorDamaged(y)) {
|
for (y = 0; y < 8; y++) {
|
||||||
|
if (entity.isDoorDamaged(y)) {
|
||||||
|
Status.push(2);
|
||||||
|
}
|
||||||
|
else if (entity.getDoorAngleRatio(y) > 0.15) {
|
||||||
|
Status.push(1);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Status.push(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mp.events.callRemote("VehStream_SetDoorData", entity, Status[0], Status[1], Status[2], Status[3], Status[4], Status[5], Status[6], Status[7]);
|
||||||
|
|
||||||
|
Status = [];
|
||||||
|
if (entity.isWindowIntact(0)) {
|
||||||
|
if (entity.getBoneIndexByName("window_rf") === -1) {
|
||||||
|
Status.push(1);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Status.push(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
Status.push(2);
|
Status.push(2);
|
||||||
}
|
}
|
||||||
else if (entity.getDoorAngleRatio(y) > 0.15) {
|
if (entity.isWindowIntact(1)) {
|
||||||
|
if (entity.getBoneIndexByName("window_lf") === -1) {
|
||||||
|
Status.push(1);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Status.push(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Status.push(2);
|
||||||
|
}
|
||||||
|
if (entity.isWindowIntact(2)) {
|
||||||
|
if (entity.getBoneIndexByName("window_rr") === -1) {
|
||||||
|
Status.push(1);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Status.push(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Status.push(2);
|
||||||
|
}
|
||||||
|
if (entity.isWindowIntact(3)) {
|
||||||
|
if (entity.getBoneIndexByName("window_lr") === -1) {
|
||||||
|
Status.push(1);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Status.push(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Status.push(2);
|
||||||
|
}
|
||||||
|
mp.events.callRemote("VehStream_SetWindowData", entity, Status[0], Status[1], Status[2], Status[3]);
|
||||||
|
|
||||||
|
Status = [];
|
||||||
|
if (!entity.isTyreBurst(0, false)) {
|
||||||
|
Status.push(0);
|
||||||
|
}
|
||||||
|
else if (entity.isTyreBurst(0, false)) {
|
||||||
Status.push(1);
|
Status.push(1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
Status.push(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!entity.isTyreBurst(1, false)) {
|
||||||
Status.push(0);
|
Status.push(0);
|
||||||
}
|
}
|
||||||
}
|
else if (entity.isTyreBurst(1, false)) {
|
||||||
mp.events.callRemote("VehStream_SetDoorData", entity, Status[0], Status[1], Status[2], Status[3], Status[4], Status[5], Status[6], Status[7]);
|
|
||||||
|
|
||||||
Status = [];
|
|
||||||
if (entity.isWindowIntact(0)) {
|
|
||||||
if (entity.getBoneIndexByName("window_rf") === -1) {
|
|
||||||
Status.push(1);
|
Status.push(1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
Status.push(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!entity.isTyreBurst(2, false)) {
|
||||||
Status.push(0);
|
Status.push(0);
|
||||||
}
|
}
|
||||||
}
|
else if (entity.isTyreBurst(2, false)) {
|
||||||
else {
|
|
||||||
Status.push(2);
|
|
||||||
}
|
|
||||||
if (entity.isWindowIntact(1)) {
|
|
||||||
if (entity.getBoneIndexByName("window_lf") === -1) {
|
|
||||||
Status.push(1);
|
Status.push(1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
Status.push(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!entity.isTyreBurst(3, false)) {
|
||||||
Status.push(0);
|
Status.push(0);
|
||||||
}
|
}
|
||||||
}
|
else if (entity.isTyreBurst(3, false)) {
|
||||||
else {
|
|
||||||
Status.push(2);
|
|
||||||
}
|
|
||||||
if (entity.isWindowIntact(2)) {
|
|
||||||
if (entity.getBoneIndexByName("window_rr") === -1) {
|
|
||||||
Status.push(1);
|
Status.push(1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
Status.push(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!entity.isTyreBurst(4, false)) {
|
||||||
Status.push(0);
|
Status.push(0);
|
||||||
}
|
}
|
||||||
}
|
else if (entity.isTyreBurst(4, false)) {
|
||||||
else {
|
|
||||||
Status.push(2);
|
|
||||||
}
|
|
||||||
if (entity.isWindowIntact(3)) {
|
|
||||||
if (entity.getBoneIndexByName("window_lr") === -1) {
|
|
||||||
Status.push(1);
|
Status.push(1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
Status.push(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!entity.isTyreBurst(5, false)) {
|
||||||
Status.push(0);
|
Status.push(0);
|
||||||
}
|
}
|
||||||
}
|
else if (entity.isTyreBurst(5, false)) {
|
||||||
else {
|
Status.push(1);
|
||||||
Status.push(2);
|
}
|
||||||
}
|
else {
|
||||||
mp.events.callRemote("VehStream_SetWindowData", entity, Status[0], Status[1], Status[2], Status[3]);
|
Status.push(2);
|
||||||
|
}
|
||||||
|
|
||||||
Status = [];
|
if (!entity.isTyreBurst(6, false)) {
|
||||||
if (!entity.isTyreBurst(0, false)) {
|
Status.push(0);
|
||||||
Status.push(0);
|
}
|
||||||
}
|
else if (entity.isTyreBurst(6, false)) {
|
||||||
else if (entity.isTyreBurst(0, false)) {
|
Status.push(1);
|
||||||
Status.push(1);
|
}
|
||||||
}
|
else {
|
||||||
else {
|
Status.push(2);
|
||||||
Status.push(2);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!entity.isTyreBurst(1, false)) {
|
if (!entity.isTyreBurst(7, false)) {
|
||||||
Status.push(0);
|
Status.push(0);
|
||||||
}
|
}
|
||||||
else if (entity.isTyreBurst(1, false)) {
|
else if (entity.isTyreBurst(7, false)) {
|
||||||
Status.push(1);
|
Status.push(1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Status.push(2);
|
Status.push(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!entity.isTyreBurst(2, false)) {
|
if (!entity.isTyreBurst(45, false)) {
|
||||||
Status.push(0);
|
Status.push(0);
|
||||||
}
|
}
|
||||||
else if (entity.isTyreBurst(2, false)) {
|
else if (entity.isTyreBurst(45, false)) {
|
||||||
Status.push(1);
|
Status.push(1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Status.push(2);
|
Status.push(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!entity.isTyreBurst(3, false)) {
|
if (!entity.isTyreBurst(47, false)) {
|
||||||
Status.push(0);
|
Status.push(0);
|
||||||
}
|
}
|
||||||
else if (entity.isTyreBurst(3, false)) {
|
else if (entity.isTyreBurst(47, false)) {
|
||||||
Status.push(1);
|
Status.push(1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Status.push(2);
|
Status.push(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!entity.isTyreBurst(4, false)) {
|
mp.events.callRemote("VehStream_SetWheelData", entity, Status[0], Status[1], Status[2], Status[3], Status[4], Status[5], Status[6], Status[7], Status[8], Status[9]);
|
||||||
Status.push(0);
|
}, 2500);
|
||||||
}
|
} catch (e) {
|
||||||
else if (entity.isTyreBurst(4, false)) {
|
console.log("error: " + e);
|
||||||
Status.push(1);
|
}
|
||||||
}
|
|
||||||
else {
|
|
||||||
Status.push(2);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!entity.isTyreBurst(5, false)) {
|
|
||||||
Status.push(0);
|
|
||||||
}
|
|
||||||
else if (entity.isTyreBurst(5, false)) {
|
|
||||||
Status.push(1);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Status.push(2);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!entity.isTyreBurst(6, false)) {
|
|
||||||
Status.push(0);
|
|
||||||
}
|
|
||||||
else if (entity.isTyreBurst(6, false)) {
|
|
||||||
Status.push(1);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Status.push(2);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!entity.isTyreBurst(7, false)) {
|
|
||||||
Status.push(0);
|
|
||||||
}
|
|
||||||
else if (entity.isTyreBurst(7, false)) {
|
|
||||||
Status.push(1);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Status.push(2);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!entity.isTyreBurst(45, false)) {
|
|
||||||
Status.push(0);
|
|
||||||
}
|
|
||||||
else if (entity.isTyreBurst(45, false)) {
|
|
||||||
Status.push(1);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Status.push(2);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!entity.isTyreBurst(47, false)) {
|
|
||||||
Status.push(0);
|
|
||||||
}
|
|
||||||
else if (entity.isTyreBurst(47, false)) {
|
|
||||||
Status.push(1);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Status.push(2);
|
|
||||||
}
|
|
||||||
|
|
||||||
mp.events.callRemote("VehStream_SetWheelData", entity, Status[0], Status[1], Status[2], Status[3], Status[4], Status[5], Status[6], Status[7], Status[8], Status[9]);
|
|
||||||
}, 2500);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
mp.events.add("VehStream_PlayerEnterVehicleAttempt", (entity, seat) => {
|
mp.events.add("VehStream_PlayerEnterVehicleAttempt", (entity, seat) => {
|
||||||
if (entity === undefined || entity === null) return;
|
if (entity === undefined || entity === null || !entity.isAVehicle()) return;
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
var Status = [];
|
var Status = [];
|
||||||
let y = 0;
|
let y = 0;
|
||||||
@@ -287,14 +291,14 @@ mp.events.add("VehStream_PlayerEnterVehicleAttempt", (entity, seat) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
mp.events.add("VehStream_SetVehicleDirtLevel", (entity, dirt) => {
|
mp.events.add("VehStream_SetVehicleDirtLevel", (entity, dirt) => {
|
||||||
if (entity === undefined || entity === null) return;
|
if (entity === undefined || entity === null || !entity.isAVehicle()) return;
|
||||||
if (entity !== undefined) {
|
if (entity !== undefined) {
|
||||||
entity.setDirtLevel(dirt);
|
entity.setDirtLevel(dirt);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
mp.events.add("VehStream_SetVehicleDoorStatus_Single", (veh, door, state) => {
|
mp.events.add("VehStream_SetVehicleDoorStatus_Single", (veh, door, state) => {
|
||||||
if (veh === undefined || veh === null) return;
|
if (veh === undefined || veh === null || !veh.isAVehicle()) return;
|
||||||
if (veh !== undefined) {
|
if (veh !== undefined) {
|
||||||
if (state === 0) {
|
if (state === 0) {
|
||||||
veh.setDoorShut(door, false);
|
veh.setDoorShut(door, false);
|
||||||
@@ -309,7 +313,7 @@ mp.events.add("VehStream_SetVehicleDoorStatus_Single", (veh, door, state) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
mp.events.add("VehStream_SetVehicleDoorStatus", (...args) => {
|
mp.events.add("VehStream_SetVehicleDoorStatus", (...args) => {
|
||||||
if (args[0] !== undefined && args[0] !== null) {
|
if (args[0] !== undefined && args[0] !== null || !args[0].isAVehicle()) {
|
||||||
let y = 0;
|
let y = 0;
|
||||||
for (y = 1; y < args.length; y++) {
|
for (y = 1; y < args.length; y++) {
|
||||||
if (args[y] === 0) {
|
if (args[y] === 0) {
|
||||||
@@ -326,7 +330,7 @@ mp.events.add("VehStream_SetVehicleDoorStatus", (...args) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
mp.events.add("VehStream_SetVehicleWindowStatus_Single", (veh, windw, state) => {
|
mp.events.add("VehStream_SetVehicleWindowStatus_Single", (veh, windw, state) => {
|
||||||
if (veh === undefined || veh === null) return;
|
if (veh === undefined || veh === null || !veh.isAVehicle()) return;
|
||||||
if (veh !== undefined) {
|
if (veh !== undefined) {
|
||||||
if (state === 1) {
|
if (state === 1) {
|
||||||
veh.rollDownWindow(windw);
|
veh.rollDownWindow(windw);
|
||||||
@@ -342,7 +346,7 @@ mp.events.add("VehStream_SetVehicleWindowStatus_Single", (veh, windw, state) =>
|
|||||||
});
|
});
|
||||||
|
|
||||||
mp.events.add("VehStream_SetVehicleWindowStatus", (...args) => {
|
mp.events.add("VehStream_SetVehicleWindowStatus", (...args) => {
|
||||||
if (args[0] !== undefined && args[0] !== null) {
|
if (args[0] !== undefined && args[0] !== null || !args[0].isAVehicle()) {
|
||||||
let y = 0;
|
let y = 0;
|
||||||
for (y = 1; y < 4; y++) {
|
for (y = 1; y < 4; y++) {
|
||||||
if (args[y] === 1) {
|
if (args[y] === 1) {
|
||||||
@@ -360,7 +364,7 @@ mp.events.add("VehStream_SetVehicleWindowStatus", (...args) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
mp.events.add("VehStream_SetVehicleWheelStatus_Single", (veh, wheel, state) => {
|
mp.events.add("VehStream_SetVehicleWheelStatus_Single", (veh, wheel, state) => {
|
||||||
if (veh === undefined || veh === null) return;
|
if (veh === undefined || veh === null || !veh.isAVehicle()) return;
|
||||||
if (veh !== undefined) {
|
if (veh !== undefined) {
|
||||||
if (wheel === 9) {
|
if (wheel === 9) {
|
||||||
if (state === 1) {
|
if (state === 1) {
|
||||||
@@ -399,7 +403,7 @@ mp.events.add("VehStream_SetVehicleWheelStatus_Single", (veh, wheel, state) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
mp.events.add("VehStream_SetVehicleWheelStatus", (...args) => {
|
mp.events.add("VehStream_SetVehicleWheelStatus", (...args) => {
|
||||||
if (args[0] !== undefined && args[0] !== null) {
|
if (args[0] !== undefined && args[0] !== null || !args[0].isAVehicle()) {
|
||||||
let y = 0;
|
let y = 0;
|
||||||
for (y = 1; y < args.length; y++) {
|
for (y = 1; y < args.length; y++) {
|
||||||
if (y === 9) {
|
if (y === 9) {
|
||||||
@@ -441,7 +445,7 @@ mp.events.add("VehStream_SetVehicleWheelStatus", (...args) => {
|
|||||||
|
|
||||||
//Sync data on stream in
|
//Sync data on stream in
|
||||||
mp.events.add("entityStreamIn", (entity) => {
|
mp.events.add("entityStreamIn", (entity) => {
|
||||||
if (entity === undefined) return;
|
if (entity === undefined || entity === null || !entity.isAVehicle()) return;
|
||||||
if (entity.type === "vehicle") {
|
if (entity.type === "vehicle") {
|
||||||
let typeor = typeof entity.getVariable('VehicleSyncData');
|
let typeor = typeof entity.getVariable('VehicleSyncData');
|
||||||
let actualData = entity.getVariable('VehicleSyncData');
|
let actualData = entity.getVariable('VehicleSyncData');
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
||||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||||
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
|
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
|
||||||
|
<Platforms>AnyCPU;x64</Platforms>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Remove="meta.xml" />
|
<None Remove="meta.xml" />
|
||||||
@@ -31,6 +32,7 @@
|
|||||||
</Reference>
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Folder Include="Client\dlcpacks\polamggtr\" />
|
||||||
<Folder Include="Migrations\" />
|
<Folder Include="Migrations\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(ConfigurationName)' == 'Debug'">
|
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(ConfigurationName)' == 'Debug'">
|
||||||
|
|||||||
Reference in New Issue
Block a user