From 18f27dce8ef4059ea1cc325a266530b1ff5459de Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Wed, 19 Oct 2022 23:54:45 -0500 Subject: [PATCH] Use game feature util for scale --- scripts/client/sync.js | 46 +++++++++++++++++++++++++++++++++++------- 1 file changed, 39 insertions(+), 7 deletions(-) diff --git a/scripts/client/sync.js b/scripts/client/sync.js index d66f1cba..34cc7a78 100644 --- a/scripts/client/sync.js +++ b/scripts/client/sync.js @@ -111,7 +111,7 @@ function syncVehicleProperties(vehicle) { vehicle.setSuspensionHeight(suspensionHeight); } - if (getGame() == AGRP_GAME_GTA_SA) { + if (isGameFeatureSupported("vehicleUpgrades")) { //let allUpgrades = getGameConfig().vehicleUpgrades[getGame()]; //for(let i in allUpgrades) { // vehicle.removeUpgrade(i); @@ -146,7 +146,7 @@ function syncCivilianProperties(civilian) { return false; } - if (getGame() == AGRP_GAME_GTA_III) { + if (isGameFeatureSupported("pedScale")) { if (doesEntityDataExist(civilian, "agrp.scale")) { let scaleFactor = getEntityData(civilian, "agrp.scale"); let tempMatrix = civilian.matrix; @@ -165,7 +165,7 @@ function syncCivilianProperties(civilian) { } } - if (getGame() == AGRP_GAME_GTA_III) { + if (getGame() == AGRP_GAME_GTA_SA) { if (doesEntityDataExist(civilian, "agrp.walkStyle")) { let walkStyle = getEntityData(civilian, "agrp.walkStyle"); civilian.walkStyle = walkStyle; @@ -238,12 +238,32 @@ function syncCivilianProperties(civilian) { // =========================================================================== +function syncObjectProperties(object) { + if (!areServerElementsSupported()) { + return false; + } + + if (isGameFeatureSupported("objectScale")) { + if (doesEntityDataExist(object, "agrp.scale")) { + let scaleFactor = getEntityData(object, "agrp.scale"); + let tempMatrix = object.matrix; + tempMatrix.setScale(toVector3(scaleFactor.x, scaleFactor.y, scaleFactor.z)); + let tempPosition = object.position; + object.matrix = tempMatrix; + tempPosition.z += scaleFactor.z; + object.position = tempPosition; + } + } +} + +// =========================================================================== + function syncPlayerProperties(player) { if (!areServerElementsSupported()) { return false; } - if (getGame() == AGRP_GAME_GTA_III) { + if (isGameFeatureSupported("pedScale")) { if (doesEntityDataExist(player, "agrp.scale")) { let scaleFactor = getEntityData(player, "agrp.scale"); let tempMatrix = player.matrix; @@ -356,9 +376,17 @@ function syncElementProperties(element) { return false; } - if (doesEntityDataExist(element, "agrp.interior")) { - if (typeof element.interior != "undefined") { - element.interior = getEntityData(element, "agrp.interior"); + if (isGameFeatureSupported("interior")) { + if (doesEntityDataExist(element, "agrp.interior")) { + if (typeof element.interior != "undefined") { + element.interior = getEntityData(element, "agrp.interior"); + } + } + } + + if (isGameFeatureSupported("toggleCollision")) { + if (doesEntityDataExist(element, "agrp.collisions")) { + element.collisionsEnabled = getEntityData(element, "agrp.collisions"); } } @@ -393,6 +421,10 @@ function syncElementProperties(element) { syncPlayerProperties(element); break; + case ELEMENT_OBJECT: + syncObjectProperties(element); + break; + default: break; }