Merge branch 'nightly' into organizing

This commit is contained in:
Vortrex
2022-06-16 13:05:06 -05:00
13 changed files with 388 additions and 327 deletions

View File

@@ -66,25 +66,25 @@ function initLabelJobHelpFont() {
// ===========================================================================
function renderPropertyEntranceLabel(name, position, locked, isBusiness, price, rentPrice, labelInfoType) {
if(localPlayer == null) {
if (localPlayer == null) {
return false;
}
if(propertyLabelNameFont == null) {
if (propertyLabelNameFont == null) {
return false;
}
if(propertyLabelLockedFont == null) {
if (propertyLabelLockedFont == null) {
return false;
}
if(getGame() == VRR_GAME_GTA_IV) {
if(!natives.doesViewportExist(natives.getGameViewportId())) {
if (getGame() == VRR_GAME_GTA_IV) {
if (!natives.doesViewportExist(natives.getGameViewportId())) {
logToConsole(LOG_INFO, "[VRR.Label]: Game viewport does not exist!");
return false;
}
if(!natives.isViewportActive(natives.getGameViewportId())) {
if (!natives.isViewportActive(natives.getGameViewportId())) {
logToConsole(LOG_INFO, "[VRR.Label]: Game viewport is not active!");
return false;
}
@@ -93,45 +93,45 @@ function renderPropertyEntranceLabel(name, position, locked, isBusiness, price,
let tempPosition = position;
tempPosition.z = tempPosition.z + propertyLabelHeight;
let screenPosition = new Vec3(0.0, 0.0, 0.0);
if(getGame() == VRR_GAME_GTA_IV) {
if (getGame() == VRR_GAME_GTA_IV) {
screenPosition = natives.getViewportPositionOfCoord(tempPosition, natives.getGameViewportId());
} else {
screenPosition = getScreenFromWorldPosition(tempPosition);
}
if(screenPosition.x < 0 || screenPosition.x > game.width) {
if (screenPosition.x < 0 || screenPosition.x > game.width) {
return false;
}
let text = "";
if(price > "0") {
if (price > "0") {
text = getLocaleString("PropertyForSaleLabel", price);
let size = propertyLabelLockedFont.measure(text, game.width, 0.0, 0.0, propertyLabelLockedFont.size, true, true);
propertyLabelLockedFont.render(text, [screenPosition.x-size[0]/2, screenPosition.y-size[1]/2], game.width, 0.0, 0.0, propertyLabelLockedFont.size, toColour(200, 200, 200, 255), false, true, false, true);
propertyLabelLockedFont.render(text, [screenPosition.x - size[0] / 2, screenPosition.y - size[1] / 2], game.width, 0.0, 0.0, propertyLabelLockedFont.size, toColour(200, 200, 200, 255), false, true, false, true);
screenPosition.y -= propertyLabelPriceOffset;
}
text = "";
if(rentPrice != "0") {
if (rentPrice != "0") {
text = getLocaleString("PropertyForRentLabel", rentPrice);
let size = propertyLabelLockedFont.measure(text, game.width, 0.0, 0.0, propertyLabelLockedFont.size, true, true);
propertyLabelLockedFont.render(text, [screenPosition.x-size[0]/2, screenPosition.y-size[1]/2], game.width, 0.0, 0.0, propertyLabelLockedFont.size, toColour(200, 200, 200, 255), false, true, false, true);
propertyLabelLockedFont.render(text, [screenPosition.x - size[0] / 2, screenPosition.y - size[1] / 2], game.width, 0.0, 0.0, propertyLabelLockedFont.size, toColour(200, 200, 200, 255), false, true, false, true);
screenPosition.y -= propertyLabelPriceOffset;
}
if(isBusiness) {
if (isBusiness) {
text = (locked) ? toUpperCase(getLocaleString("Closed")) : toUpperCase(getLocaleString("Open"));
} else {
text = (locked) ? toUpperCase(getLocaleString("Locked")) : toUpperCase(getLocaleString("Unlocked"));
}
if(!locked && labelInfoType != VRR_PROPLABEL_INFO_NONE) {
if (!locked && labelInfoType != VRR_PROPLABEL_INFO_NONE) {
let infoText = "";
switch(labelInfoType) {
switch (labelInfoType) {
case VRR_PROPLABEL_INFO_ENTER: {
if(enterPropertyKey) {
if (enterPropertyKey) {
infoText = getLocaleString("PropertyEnterKeyPressLabel", toUpperCase(getKeyNameFromId(enterPropertyKey)));
} else {
infoText = getLocaleString("PropertyEnterCommandLabel", "/enter");
@@ -165,7 +165,7 @@ function renderPropertyEntranceLabel(name, position, locked, isBusiness, price,
}
default: {
if(enterPropertyKey) {
if (enterPropertyKey) {
infoText = getLocaleString("PropertyEnterKeyPressLabel", toUpperCase(getKeyNameFromId(enterPropertyKey)));
} else {
infoText = getLocaleString("PropertyEnterCommandLabel", "/enter");
@@ -173,45 +173,45 @@ function renderPropertyEntranceLabel(name, position, locked, isBusiness, price,
break;
}
}
if(getDistance(localPlayer.position, position) <= renderLabelDistance-2) {
if (getDistance(localPlayer.position, position) <= renderLabelDistance - 2) {
let size = propertyLabelLockedFont.measure(infoText, game.width, 0.0, 0.0, propertyLabelLockedFont.size, true, true);
propertyLabelLockedFont.render(infoText, [screenPosition.x-size[0]/2, screenPosition.y-size[1]/2], game.width, 0.0, 0.0, propertyLabelLockedFont.size, toColour(234, 198, 126, 255), false, true, false, true);
propertyLabelLockedFont.render(infoText, [screenPosition.x - size[0] / 2, screenPosition.y - size[1] / 2], game.width, 0.0, 0.0, propertyLabelLockedFont.size, toColour(234, 198, 126, 255), false, true, false, true);
screenPosition.y -= propertyLabelLockedOffset;
}
}
let size = propertyLabelLockedFont.measure(text, game.width, 0.0, 0.0, propertyLabelLockedFont.size, true, true);
propertyLabelLockedFont.render(text, [screenPosition.x-size[0]/2, screenPosition.y-size[1]/2], game.width, 0.0, 0.0, propertyLabelLockedFont.size, (locked) ? lockedColour : unlockedColour, false, true, false, true);
propertyLabelLockedFont.render(text, [screenPosition.x - size[0] / 2, screenPosition.y - size[1] / 2], game.width, 0.0, 0.0, propertyLabelLockedFont.size, (locked) ? lockedColour : unlockedColour, false, true, false, true);
screenPosition.y -= propertyLabelNameOffset;
text = name || " ";
size = propertyLabelNameFont.measure(text, game.width, 0.0, 0.0, propertyLabelNameFont.size, true, true);
propertyLabelNameFont.render(text, [screenPosition.x-size[0]/2, screenPosition.y-size[1]/2], game.width, 0.0, 0.0, propertyLabelNameFont.size, (isBusiness) ? toColour(0, 153, 255, 255) : toColour(17, 204, 17, 255), false, true, false, true);
propertyLabelNameFont.render(text, [screenPosition.x - size[0] / 2, screenPosition.y - size[1] / 2], game.width, 0.0, 0.0, propertyLabelNameFont.size, (isBusiness) ? toColour(0, 153, 255, 255) : toColour(17, 204, 17, 255), false, true, false, true);
}
// -------------------------------------------------------------------------
function renderPropertyExitLabel(position) {
if(localPlayer == null) {
if (localPlayer == null) {
return false;
}
if(propertyLabelNameFont == null) {
if (propertyLabelNameFont == null) {
return false;
}
if(propertyLabelLockedFont == null) {
if (propertyLabelLockedFont == null) {
return false;
}
if(getGame() == VRR_GAME_GTA_IV) {
if(!natives.doesViewportExist(natives.getGameViewportId())) {
if (getGame() == VRR_GAME_GTA_IV) {
if (!natives.doesViewportExist(natives.getGameViewportId())) {
logToConsole(LOG_INFO, "[VRR.Label]: Game viewport does not exist!");
return false;
}
if(!natives.isViewportActive(natives.getGameViewportId())) {
if (!natives.isViewportActive(natives.getGameViewportId())) {
logToConsole(LOG_INFO, "[VRR.Label]: Game viewport is not active!");
return false;
}
@@ -220,43 +220,43 @@ function renderPropertyExitLabel(position) {
let tempPosition = position;
tempPosition.z = tempPosition.z + propertyLabelHeight;
let screenPosition = new Vec3(0.0, 0.0, 0.0);
if(getGame() == VRR_GAME_GTA_IV) {
if (getGame() == VRR_GAME_GTA_IV) {
screenPosition = natives.getViewportPositionOfCoord(tempPosition, natives.getGameViewportId());
} else {
screenPosition = getScreenFromWorldPosition(tempPosition);
}
if(screenPosition.x < 0 || screenPosition.x > game.width) {
if (screenPosition.x < 0 || screenPosition.x > game.width) {
return false;
}
let text = "EXIT";
let size = propertyLabelNameFont.measure(text, game.width, 0.0, 0.0, propertyLabelNameFont.size, true, true);
propertyLabelNameFont.render(text, [screenPosition.x-size[0]/2, screenPosition.y-size[1]/2], game.width, 0.0, 0.0, propertyLabelNameFont.size, COLOUR_WHITE, false, true, false, true);
propertyLabelNameFont.render(text, [screenPosition.x - size[0] / 2, screenPosition.y - size[1] / 2], game.width, 0.0, 0.0, propertyLabelNameFont.size, COLOUR_WHITE, false, true, false, true);
}
// -------------------------------------------------------------------------
function renderJobLabel(name, position, jobType) {
if(localPlayer == null) {
if (localPlayer == null) {
return false;
}
if(jobNameLabelFont == null) {
if (jobNameLabelFont == null) {
return false;
}
if(jobHelpLabelFont == null) {
if (jobHelpLabelFont == null) {
return false;
}
if(getGame() == VRR_GAME_GTA_IV) {
if(!natives.doesViewportExist(natives.getGameViewportId())) {
if (getGame() == VRR_GAME_GTA_IV) {
if (!natives.doesViewportExist(natives.getGameViewportId())) {
logToConsole(LOG_INFO, "[VRR.Label]: Game viewport does not exist!");
return false;
}
if(!natives.isViewportActive(natives.getGameViewportId())) {
if (!natives.isViewportActive(natives.getGameViewportId())) {
logToConsole(LOG_INFO, "[VRR.Label]: Game viewport is not active!");
return false;
}
@@ -265,25 +265,25 @@ function renderJobLabel(name, position, jobType) {
let tempPosition = position;
tempPosition.z = tempPosition.z + propertyLabelHeight;
let screenPosition = new Vec3(0.0, 0.0, 0.0);
if(getGame() == VRR_GAME_GTA_IV) {
if (getGame() == VRR_GAME_GTA_IV) {
screenPosition = natives.getViewportPositionOfCoord(tempPosition, natives.getGameViewportId());
} else {
screenPosition = getScreenFromWorldPosition(tempPosition);
}
if(screenPosition.x < 0 || screenPosition.x > game.width) {
if (screenPosition.x < 0 || screenPosition.x > game.width) {
return false;
}
let text = "";
if(jobType == localPlayerJobType) {
if(localPlayerWorking) {
if (jobType == localPlayerJobType) {
if (localPlayerWorking) {
text = getLocaleString("JobEquipAndUniformLabel", "/equip", "/uniform", "/stopwork");
} else {
text = getLocaleString("StartWorkLabel", "/startwork");
}
} else {
if(localPlayerJobType == 0) {
if (localPlayerJobType == 0) {
text = getLocaleString("TakeJobLabel", "/takejob");
} else {
text = getLocaleString("NotYourJobLabel", "/quitjob");
@@ -291,37 +291,37 @@ function renderJobLabel(name, position, jobType) {
}
let size = jobHelpLabelFont.measure(text, game.width, 0.0, 0.0, jobHelpLabelFont.size, true, true);
jobHelpLabelFont.render(text, [screenPosition.x-size[0]/2, screenPosition.y-size[1]/2], game.width, 0.0, 0.0, jobHelpLabelFont.size, COLOUR_YELLOW, false, true, false, true);
jobHelpLabelFont.render(text, [screenPosition.x - size[0] / 2, screenPosition.y - size[1] / 2], game.width, 0.0, 0.0, jobHelpLabelFont.size, COLOUR_YELLOW, false, true, false, true);
screenPosition.y -= 18;
text = getLocaleString("JobLabel", name);
size = jobNameLabelFont.measure(text, game.width, 0.0, 0.0, jobNameLabelFont.size, true, true);
jobNameLabelFont.render(text, [screenPosition.x-size[0]/2, screenPosition.y-size[1]/2], game.width, 0.0, 0.0, jobNameLabelFont.size, COLOUR_WHITE, false, true, false, true);
jobNameLabelFont.render(text, [screenPosition.x - size[0] / 2, screenPosition.y - size[1] / 2], game.width, 0.0, 0.0, jobNameLabelFont.size, COLOUR_WHITE, false, true, false, true);
}
// -------------------------------------------------------------------------
function processLabelRendering() {
if(renderLabels) {
if(!areServerElementsSupported()) {
if(localPlayer != null) {
if (renderLabels) {
if (!areServerElementsSupported()) {
if (localPlayer != null) {
getServerData().businesses.forEach((business) => {
if(getDistance(localPlayer.position, business.entrancePosition) <= 75.0) {
if (getDistance(localPlayer.position, business.entrancePosition) <= 75.0) {
natives.drawColouredCylinder(getPosBelowPos(business.entrancePosition, 1.0), 0.0, 0.0, 0, 153, 255, 255);
//renderPropertyEntranceLabel(business.name, business.entrancePosition, business.locked, true, makeLargeNumberReadable(business.price), makeLargeNumberReadable(business.rentPrice), business.labelInfoType);
}
});
getServerData().houses.forEach((house) => {
if(getDistance(localPlayer.position, house.entrancePosition) <= 75.0) {
if (getDistance(localPlayer.position, house.entrancePosition) <= 75.0) {
natives.drawColouredCylinder(getPosBelowPos(house.entrancePosition, 1.0), 0.0, 0.0, 0, 200, 0, 255);
//renderPropertyEntranceLabel("House", house.entrancePosition, house.locked, true, makeLargeNumberReadable(house.price), makeLargeNumberReadable(house.rentPrice), 0);
}
});
getServerData().jobs.forEach((job) => {
if(getDistance(localPlayer.position, job.position) <= 75.0) {
if (getDistance(localPlayer.position, job.position) <= 75.0) {
natives.drawColouredCylinder(getPosBelowPos(job.position, 1.0), 0.0, 0.0, 255, 255, 0, 255);
//renderJobLabel(job.name, job.position, job.jobType);
}
@@ -329,29 +329,29 @@ function processLabelRendering() {
}
}
if(areWorldLabelsSupported()) {
if(localPlayer != null) {
if (areWorldLabelsSupported()) {
if (localPlayer != null) {
let pickups = getElementsByType(ELEMENT_PICKUP);
for(let i in pickups) {
if(pickups[i].getData("vrr.label.type") != null) {
if(getDistance(localPlayer.position, pickups[i].position) <= renderLabelDistance) {
if(!pickups[i].isOnScreen) {
for (let i in pickups) {
if (pickups[i].getData("vrr.label.type") != null) {
if (getDistance(localPlayer.position, pickups[i].position) <= renderLabelDistance) {
if (!pickups[i].isOnScreen) {
let price = "0";
let rentPrice = "0";
let labelInfoType = VRR_PROPLABEL_INFO_NONE;
if(pickups[i].getData("vrr.label.price") != null) {
if (pickups[i].getData("vrr.label.price") != null) {
price = makeLargeNumberReadable(pickups[i].getData("vrr.label.price"));
}
if(pickups[i].getData("vrr.label.rentprice") != null) {
if (pickups[i].getData("vrr.label.rentprice") != null) {
rentPrice = makeLargeNumberReadable(pickups[i].getData("vrr.label.rentprice"));
}
if(pickups[i].getData("vrr.label.help") != null) {
if (pickups[i].getData("vrr.label.help") != null) {
labelInfoType = pickups[i].getData("vrr.label.help");
}
switch(pickups[i].getData("vrr.label.type")) {
switch (pickups[i].getData("vrr.label.type")) {
case VRR_LABEL_BUSINESS: {
renderPropertyEntranceLabel(pickups[i].getData("vrr.label.name"), pickups[i].position, pickups[i].getData("vrr.label.locked"), true, price, rentPrice, labelInfoType);
break;

View File

@@ -37,7 +37,7 @@ function getPlayerPosition() {
// ===========================================================================
function setPlayerPosition(position) {
if(getGame() == VRR_GAME_GTA_IV) {
if (getGame() == VRR_GAME_GTA_IV) {
natives.setCharCoordinates(localPlayer, position);
} else {
localPlayer.position = position;
@@ -59,11 +59,11 @@ function getElementHeading(elementId) {
// ===========================================================================
function setElementPosition(elementId, position) {
if(getElementFromId(elementId) == null) {
if (getElementFromId(elementId) == null) {
return false;
}
if(!getElementFromId(elementId).isSyncer) {
if (!getElementFromId(elementId).isSyncer) {
return false;
}
@@ -73,7 +73,7 @@ function setElementPosition(elementId, position) {
// ===========================================================================
function deleteGameElement(elementId, position) {
if(!getElementFromId(elementId).isOwner) {
if (!getElementFromId(elementId).isOwner) {
return false;
}
@@ -110,8 +110,8 @@ function getElementId(element) {
function getClientFromIndex(index) {
let clients = getClients();
for(let i in clients) {
if(clients[i].index == index) {
for (let i in clients) {
if (clients[i].index == index) {
return clients[i];
}
}
@@ -170,8 +170,8 @@ function is2dPositionOnScreen(pos2d) {
function getVehiclesInRange(position, range) {
let vehicles = getElementsByType(ELEMENT_VEHICLE);
let inRangeVehicles = [];
for(let i in vehicles) {
if(getDistance(position, vehicles[i].position) <= range) {
for (let i in vehicles) {
if (getDistance(position, vehicles[i].position) <= range) {
inRangeVehicles.push(vehicles[i]);
}
}
@@ -181,13 +181,13 @@ function getVehiclesInRange(position, range) {
// ===========================================================================
function createGameBlip(blipModel, position, name = "") {
if(getGame() == VRR_GAME_GTA_IV) {
if (getGame() == VRR_GAME_GTA_IV) {
let blipId = natives.addBlipForCoord(position);
if(blipId) {
if (blipId) {
natives.changeBlipSprite(blipId, blipModel);
natives.setBlipMarkerLongDistance(blipId, false);
natives.setBlipAsShortRange(blipId, true);
natives.changeBlipNameFromAscii(blipId, `${name.substr(0, 24)}${(name.length > 24) ? " ...": ""}`);
natives.changeBlipNameFromAscii(blipId, `${name.substr(0, 24)}${(name.length > 24) ? " ..." : ""}`);
return blipId;
}
}
@@ -198,7 +198,7 @@ function createGameBlip(blipModel, position, name = "") {
// ===========================================================================
function setEntityData(entity, dataName, dataValue, syncToClients = true) {
if(entity != null) {
if (entity != null) {
return entity.setData(dataName, dataValue);
}
}
@@ -224,64 +224,64 @@ function repairVehicle(syncId) {
// ===========================================================================
function syncVehicleProperties(vehicle) {
if(doesEntityDataExist(vehicle, "vrr.lights")) {
if (doesEntityDataExist(vehicle, "vrr.lights")) {
let lightStatus = getEntityData(vehicle, "vrr.lights");
vehicle.lights = lightStatus;
}
if(doesEntityDataExist(vehicle, "vrr.invincible")) {
if (doesEntityDataExist(vehicle, "vrr.invincible")) {
let invincible = getEntityData(vehicle, "vrr.invincible");
element.setProofs(invincible, invincible, invincible, invincible, invincible);
}
if(doesEntityDataExist(vehicle, "vrr.panelStatus")) {
if (doesEntityDataExist(vehicle, "vrr.panelStatus")) {
let panelsStatus = getEntityData(vehicle, "vrr.panelStatus");
for(let i in panelsStatus) {
for (let i in panelsStatus) {
vehicle.setPanelStatus(i, panelsStatus[i]);
}
}
if(doesEntityDataExist(vehicle, "vrr.wheelStatus")) {
if (doesEntityDataExist(vehicle, "vrr.wheelStatus")) {
let wheelsStatus = getEntityData(vehicle, "vrr.wheelStatus");
for(let i in wheelsStatus) {
for (let i in wheelsStatus) {
vehicle.setWheelStatus(i, wheelsStatus[i]);
}
}
if(doesEntityDataExist(vehicle, "vrr.lightStatus")) {
if (doesEntityDataExist(vehicle, "vrr.lightStatus")) {
let lightStatus = getEntityData(vehicle, "vrr.lightStatus");
for(let i in lightStatus) {
for (let i in lightStatus) {
vehicle.setLightStatus(i, lightStatus[i]);
}
}
if(doesEntityDataExist(vehicle, "vrr.suspensionHeight")) {
if (doesEntityDataExist(vehicle, "vrr.suspensionHeight")) {
let suspensionHeight = getEntityData(vehicle, "vrr.suspensionHeight");
vehicle.setSuspensionHeight(suspensionHeight);
}
if(getGame() == VRR_GAME_GTA_SA) {
if (getGame() == VRR_GAME_GTA_SA) {
let allUpgrades = getGameConfig().vehicleUpgrades[getGame()];
for(let i in allUpgrades) {
for (let i in allUpgrades) {
vehicle.removeUpgrade(i);
}
if(doesEntityDataExist(vehicle, "vrr.upgrades")) {
if (doesEntityDataExist(vehicle, "vrr.upgrades")) {
let upgrades = getEntityData(vehicle, "vrr.upgrades");
for(let i in upgrades) {
if(upgrades[i] != 0) {
for (let i in upgrades) {
if (upgrades[i] != 0) {
vehicle.addUpgrade(upgrades[i]);
}
}
}
}
if(getGame() == VRR_GAME_GTA_SA || getGame() == VRR_GAME_GTA_IV) {
if(doesEntityDataExist(vehicle, "vrr.livery")) {
if (getGame() == VRR_GAME_GTA_SA || getGame() == VRR_GAME_GTA_IV) {
if (doesEntityDataExist(vehicle, "vrr.livery")) {
let livery = getEntityData(vehicle, "vrr.livery");
if(getGame() == VRR_GAME_GTA_SA) {
if (getGame() == VRR_GAME_GTA_SA) {
vehicle.setPaintJob(livery);
} else if(getGame() == VRR_GAME_GTA_IV) {
} else if (getGame() == VRR_GAME_GTA_IV) {
vehicle.livery = livery;
}
}
@@ -291,7 +291,7 @@ function syncVehicleProperties(vehicle) {
// ===========================================================================
function removeEntityData(entity, dataName) {
if(entity != null) {
if (entity != null) {
return entity.removeData(dataName);
}
return null;
@@ -300,7 +300,7 @@ function removeEntityData(entity, dataName) {
// ===========================================================================
function doesEntityDataExist(entity, dataName) {
if(entity != null) {
if (entity != null) {
return (entity.getData(dataName) != null);
}
return null;
@@ -309,8 +309,8 @@ function doesEntityDataExist(entity, dataName) {
// ===========================================================================
function syncCivilianProperties(civilian) {
if(getGame() == VRR_GAME_GTA_III) {
if(doesEntityDataExist(civilian, "vrr.scale")) {
if (getGame() == VRR_GAME_GTA_III) {
if (doesEntityDataExist(civilian, "vrr.scale")) {
let scaleFactor = getEntityData(civilian, "vrr.scale");
let tempMatrix = civilian.matrix;
tempMatrix.setScale(toVector3(scaleFactor.x, scaleFactor.y, scaleFactor.z));
@@ -321,78 +321,78 @@ function syncCivilianProperties(civilian) {
}
}
if(getGame() == VRR_GAME_GTA_SA) {
if(doesEntityDataExist(civilian, "vrr.fightStyle")) {
if (getGame() == VRR_GAME_GTA_SA) {
if (doesEntityDataExist(civilian, "vrr.fightStyle")) {
let fightStyle = getEntityData(civilian, "vrr.fightStyle");
civilian.setFightStyle(fightStyle[0], fightStyle[1]);
}
}
if(getGame() == VRR_GAME_GTA_III) {
if(doesEntityDataExist(civilian, "vrr.walkStyle")) {
if (getGame() == VRR_GAME_GTA_III) {
if (doesEntityDataExist(civilian, "vrr.walkStyle")) {
let walkStyle = getEntityData(civilian, "vrr.walkStyle");
civilian.walkStyle = walkStyle;
}
}
if(getGame() == VRR_GAME_GTA_IV) {
if(doesEntityDataExist(civilian, "vrr.bodyPropHair")) {
if (getGame() == VRR_GAME_GTA_IV) {
if (doesEntityDataExist(civilian, "vrr.bodyPropHair")) {
let bodyPropHair = getEntityData(civilian, "vrr.bodyPropHair");
civilian.changeBodyProp(0, bodyPropHair[0], bodyPropHair[1]);
}
if(doesEntityDataExist(civilian, "vrr.bodyPropHead")) {
if (doesEntityDataExist(civilian, "vrr.bodyPropHead")) {
let bodyPropHead = getEntityData(civilian, "vrr.bodyPropHead");
civilian.changeBodyProp(1, bodyPropHead[0], bodyPropHead[1]);
}
if(doesEntityDataExist(civilian, "vrr.bodyPropEyes")) {
if (doesEntityDataExist(civilian, "vrr.bodyPropEyes")) {
let bodyPropEyes = getEntityData(civilian, "vrr.bodyPropEyes");
civilian.changeBodyProp(1, bodyPropEyes[0], bodyPropEyes[1]);
}
if(doesEntityDataExist(civilian, "vrr.bodyPropLeftHand")) {
if (doesEntityDataExist(civilian, "vrr.bodyPropLeftHand")) {
let bodyPropLeftHand = getEntityData(civilian, "vrr.bodyPropLeftHand");
civilian.changeBodyProp(1, bodyPropLeftHand[0], bodyPropLeftHand[1]);
}
if(doesEntityDataExist(civilian, "vrr.bodyPropRightHand")) {
if (doesEntityDataExist(civilian, "vrr.bodyPropRightHand")) {
let bodyPropRightHand = getEntityData(civilian, "vrr.bodyPropRightHand");
civilian.changeBodyProp(1, bodyPropRightHand[0], bodyPropRightHand[1]);
}
if(doesEntityDataExist(civilian, "vrr.bodyPropLeftWrist")) {
if (doesEntityDataExist(civilian, "vrr.bodyPropLeftWrist")) {
let bodyPropLeftWrist = getEntityData(civilian, "vrr.bodyPropLeftWrist");
civilian.changeBodyProp(1, bodyPropLeftWrist[0], bodyPropLeftWrist[1]);
}
if(doesEntityDataExist(civilian, "vrr.bodyPropRightWrist")) {
if (doesEntityDataExist(civilian, "vrr.bodyPropRightWrist")) {
let bodyPropRightWrist = getEntityData(civilian, "vrr.bodyPropRightWrist");
civilian.changeBodyProp(1, bodyPropRightWrist[0], bodyPropRightWrist[1]);
}
if(doesEntityDataExist(civilian, "vrr.bodyPropRightWrist")) {
if (doesEntityDataExist(civilian, "vrr.bodyPropRightWrist")) {
let bodyPropRightWrist = getEntityData(civilian, "vrr.bodyPropRightWrist");
civilian.changeBodyProp(1, bodyPropRightWrist[0], bodyPropRightWrist[1]);
}
if(doesEntityDataExist(civilian, "vrr.bodyPropHip")) {
if (doesEntityDataExist(civilian, "vrr.bodyPropHip")) {
let bodyPropHip = getEntityData(civilian, "vrr.bodyPropHip");
civilian.changeBodyProp(1, bodyPropHip[0], bodyPropHip[1]);
}
if(doesEntityDataExist(civilian, "vrr.bodyPropLeftFoot")) {
if (doesEntityDataExist(civilian, "vrr.bodyPropLeftFoot")) {
let bodyPropLeftFoot = getEntityData(civilian, "vrr.bodyPropLeftFoot");
civilian.changeBodyProp(1, bodyPropLeftFoot[0], bodyPropLeftFoot[1]);
}
if(doesEntityDataExist(civilian, "vrr.bodyPropRightFoot")) {
if (doesEntityDataExist(civilian, "vrr.bodyPropRightFoot")) {
let bodyPropRightFoot = getEntityData(civilian, "vrr.bodyPropRightFoot");
civilian.changeBodyProp(1, bodyPropRightFoot[0], bodyPropRightFoot[1]);
}
}
if(doesEntityDataExist(civilian, "vrr.anim")) {
if (doesEntityDataExist(civilian, "vrr.anim")) {
let animData = getEntityData(vehicle, "vrr.anim");
civilian.addAnimation(animData[0], animData[1]);
}
@@ -407,8 +407,8 @@ function preventDefaultEventAction(event) {
// ===========================================================================
function syncPlayerProperties(player) {
if(getGame() == VRR_GAME_GTA_III) {
if(doesEntityDataExist(player, "vrr.scale")) {
if (getGame() == VRR_GAME_GTA_III) {
if (doesEntityDataExist(player, "vrr.scale")) {
let scaleFactor = getEntityData(player, "vrr.scale");
let tempMatrix = player.matrix;
tempMatrix.setScale(toVector3(scaleFactor.x, scaleFactor.y, scaleFactor.z));
@@ -419,8 +419,8 @@ function syncPlayerProperties(player) {
}
}
if(getGame() == VRR_GAME_GTA_SA) {
if(doesEntityDataExist(player, "vrr.fightStyle")) {
if (getGame() == VRR_GAME_GTA_SA) {
if (doesEntityDataExist(player, "vrr.fightStyle")) {
let fightStyle = getEntityData(player, "vrr.fightStyle");
player.setFightStyle(fightStyle[0], fightStyle[1]);
}
@@ -433,80 +433,80 @@ function syncPlayerProperties(player) {
// }
//}
if(getGame() == VRR_GAME_GTA_IV) {
if(doesEntityDataExist(player, "vrr.bodyPartHair")) {
if (getGame() == VRR_GAME_GTA_IV) {
if (doesEntityDataExist(player, "vrr.bodyPartHair")) {
let bodyPartHead = getEntityData(player, "vrr.bodyPartHair");
player.changeBodyPart(0, bodyPartHead[0], bodyPartHair[1]);
}
if(doesEntityDataExist(player, "vrr.bodyPartHead")) {
if (doesEntityDataExist(player, "vrr.bodyPartHead")) {
let bodyPartHead = getEntityData(player, "vrr.bodyPartHead");
player.changeBodyPart(1, bodyPartHead[0], bodyPartHead[1]);
}
if(doesEntityDataExist(player, "vrr.bodyPartUpper")) {
if (doesEntityDataExist(player, "vrr.bodyPartUpper")) {
let bodyPartUpper = getEntityData(player, "vrr.bodyPartUpper");
player.changeBodyPart(1, bodyPartUpper[0], bodyPartUpper[1]);
}
if(doesEntityDataExist(player, "vrr.bodyPartLower")) {
if (doesEntityDataExist(player, "vrr.bodyPartLower")) {
let bodyPartLower = getEntityData(player, "vrr.bodyPartLower");
player.changeBodyPart(1, bodyPartLower[0], bodyPartLower[1]);
}
}
if(getGame() == VRR_GAME_GTA_IV) {
if(doesEntityDataExist(player, "vrr.bodyPropHair")) {
if (getGame() == VRR_GAME_GTA_IV) {
if (doesEntityDataExist(player, "vrr.bodyPropHair")) {
let bodyPropHair = getEntityData(player, "vrr.bodyPropHair");
player.changeBodyProp(0, bodyPropHair[0], bodyPropHair[1]);
}
if(doesEntityDataExist(player, "vrr.bodyPropHead")) {
if (doesEntityDataExist(player, "vrr.bodyPropHead")) {
let bodyPropHead = getEntityData(player, "vrr.bodyPropHead");
player.changeBodyProp(1, bodyPropHead[0], bodyPropHead[1]);
}
if(doesEntityDataExist(player, "vrr.bodyPropEyes")) {
if (doesEntityDataExist(player, "vrr.bodyPropEyes")) {
let bodyPropEyes = getEntityData(player, "vrr.bodyPropEyes");
player.changeBodyProp(1, bodyPropEyes[0], bodyPropEyes[1]);
}
if(doesEntityDataExist(player, "vrr.bodyPropLeftHand")) {
if (doesEntityDataExist(player, "vrr.bodyPropLeftHand")) {
let bodyPropLeftHand = getEntityData(player, "vrr.bodyPropLeftHand");
player.changeBodyProp(1, bodyPropLeftHand[0], bodyPropLeftHand[1]);
}
if(doesEntityDataExist(player, "vrr.bodyPropRightHand")) {
if (doesEntityDataExist(player, "vrr.bodyPropRightHand")) {
let bodyPropRightHand = getEntityData(player, "vrr.bodyPropRightHand");
player.changeBodyProp(1, bodyPropRightHand[0], bodyPropRightHand[1]);
}
if(doesEntityDataExist(player, "vrr.bodyPropLeftWrist")) {
if (doesEntityDataExist(player, "vrr.bodyPropLeftWrist")) {
let bodyPropLeftWrist = getEntityData(player, "vrr.bodyPropLeftWrist");
player.changeBodyProp(1, bodyPropLeftWrist[0], bodyPropLeftWrist[1]);
}
if(doesEntityDataExist(player, "vrr.bodyPropRightWrist")) {
if (doesEntityDataExist(player, "vrr.bodyPropRightWrist")) {
let bodyPropRightWrist = getEntityData(player, "vrr.bodyPropRightWrist");
player.changeBodyProp(1, bodyPropRightWrist[0], bodyPropRightWrist[1]);
}
if(doesEntityDataExist(player, "vrr.bodyPropRightWrist")) {
if (doesEntityDataExist(player, "vrr.bodyPropRightWrist")) {
let bodyPropRightWrist = getEntityData(player, "vrr.bodyPropRightWrist");
player.changeBodyProp(1, bodyPropRightWrist[0], bodyPropRightWrist[1]);
}
if(doesEntityDataExist(player, "vrr.bodyPropHip")) {
if (doesEntityDataExist(player, "vrr.bodyPropHip")) {
let bodyPropHip = getEntityData(player, "vrr.bodyPropHip");
player.changeBodyProp(1, bodyPropHip[0], bodyPropHip[1]);
}
if(doesEntityDataExist(player, "vrr.bodyPropLeftFoot")) {
if (doesEntityDataExist(player, "vrr.bodyPropLeftFoot")) {
let bodyPropLeftFoot = getEntityData(player, "vrr.bodyPropLeftFoot");
player.changeBodyProp(1, bodyPropLeftFoot[0], bodyPropLeftFoot[1]);
}
if(doesEntityDataExist(player, "vrr.bodyPropRightFoot")) {
if (doesEntityDataExist(player, "vrr.bodyPropRightFoot")) {
let bodyPropRightFoot = getEntityData(player, "vrr.bodyPropRightFoot");
player.changeBodyProp(1, bodyPropRightFoot[0], bodyPropRightFoot[1]);
}
@@ -516,8 +516,8 @@ function syncPlayerProperties(player) {
// ===========================================================================
function syncObjectProperties(object) {
if(getGame() == VRR_GAME_GTA_III || getGame() == VRR_GAME_GTA_VC) {
if(doesEntityDataExist(object, "vrr.scale")) {
if (getGame() == VRR_GAME_GTA_III || getGame() == VRR_GAME_GTA_VC) {
if (doesEntityDataExist(object, "vrr.scale")) {
let scaleFactor = getEntityData(object, "vrr.scale");
let tempMatrix = object.matrix;
tempMatrix.setScale(toVector3(scaleFactor.x, scaleFactor.y, scaleFactor.z));
@@ -568,13 +568,13 @@ function getPlayerId(client) {
// ===========================================================================
function syncElementProperties(element) {
if(doesEntityDataExist(element, "vrr.interior")) {
if(typeof element.interior != "undefined") {
if (doesEntityDataExist(element, "vrr.interior")) {
if (typeof element.interior != "undefined") {
element.interior = getEntityData(element, "vrr.interior");
}
}
switch(element.type) {
switch (element.type) {
case ELEMENT_VEHICLE:
syncVehicleProperties(element);
break;
@@ -619,23 +619,23 @@ function getScreenHeight() {
// ===========================================================================
function openAllGarages() {
switch(getGame()) {
switch (getGame()) {
case VRR_GAME_GTA_III:
for(let i=0;i<=26;i++) {
for (let i = 0; i <= 26; i++) {
openGarage(i);
game.NO_SPECIAL_CAMERA_FOR_THIS_GARAGE(i);
}
break;
case VRR_GAME_GTA_VC:
for(let i=0;i<=32;i++) {
for (let i = 0; i <= 32; i++) {
openGarage(i);
game.NO_SPECIAL_CAMERA_FOR_THIS_GARAGE(i);
}
break;
case VRR_GAME_GTA_SA:
for(let i=0;i<=44;i++) {
for (let i = 0; i <= 44; i++) {
openGarage(i);
}
break;
@@ -648,23 +648,23 @@ function openAllGarages() {
// ===========================================================================
function closeAllGarages() {
switch(getGame()) {
switch (getGame()) {
case VRR_GAME_GTA_III:
for(let i=0;i<=26;i++) {
for (let i = 0; i <= 26; i++) {
closeGarage(i);
game.NO_SPECIAL_CAMERA_FOR_THIS_GARAGE(i);
}
break;
case VRR_GAME_GTA_VC:
for(let i=0;i<=32;i++) {
for (let i = 0; i <= 32; i++) {
closeGarage(i);
game.NO_SPECIAL_CAMERA_FOR_THIS_GARAGE(i);
}
break;
case VRR_GAME_GTA_SA:
for(let i=0;i<=44;i++) {
for (let i = 0; i <= 44; i++) {
closeGarage(i);
}
break;
@@ -683,7 +683,7 @@ function setPedInvincible(ped, state) {
// ===========================================================================
function setPedLookAt(ped, position) {
if(getGame() == VRR_GAME_GTA_SA) {
if (getGame() == VRR_GAME_GTA_SA) {
ped.lookAt(position, 10000);
return true;
} else {
@@ -697,4 +697,10 @@ function setElementHeading(elementId, heading) {
getElementFromId(elementId).heading = heading;
}
// ===========================================================================
function deleteLocalPlayerPed() {
destroyElement(localPlayer);
}
// ===========================================================================

View File

@@ -41,7 +41,7 @@ function addAllNetworkHandlers() {
addNetworkEventHandler("vrr.fadeCamera", fadeLocalCamera);
addNetworkEventHandler("vrr.removeFromVehicle", removeLocalPlayerFromVehicle);
addNetworkEventHandler("vrr.clearWeapons", clearLocalPlayerWeapons);
addNetworkEventHandler("vrr.giveWeapon", giveLocalPlayerWeapon);
addNetworkEventHandler("vrr.giveWeapon", giveLocalPlayerWeapon);
addNetworkEventHandler("vrr.position", setLocalPlayerPosition);
addNetworkEventHandler("vrr.heading", setLocalPlayerHeading);
addNetworkEventHandler("vrr.interior", setLocalPlayerInterior);
@@ -59,6 +59,7 @@ function addAllNetworkHandlers() {
addNetworkEventHandler("vrr.spawn", serverRequestedLocalPlayerSpawn);
addNetworkEventHandler("vrr.clearPedState", clearLocalPedState);
addNetworkEventHandler("vrr.drunkEffect", setLocalPlayerDrunkEffect);
addNetworkEventHandler("vrr.deleteLocalPlayerPed", deleteLocalPlayerPed);
// Vehicle
addNetworkEventHandler("vrr.vehicle", receiveVehicleFromServer);
@@ -166,7 +167,7 @@ function sendResourceStartedSignalToServer() {
// ===========================================================================
function sendResourceStoppedSignalToServer() {
if(isConnected) {
if (isConnected) {
sendNetworkEventToServer("vrr.clientStopped");
}
}
@@ -177,14 +178,14 @@ function set2DRendering(hudState, labelState, smallGameMessageState, scoreboardS
logToConsole(LOG_DEBUG, `[VRR.Main] Updating render states (HUD: ${hudState}, Labels: ${labelState}, Bottom Text: ${smallGameMessageState}, Scoreboard: ${scoreboardState}, HotBar: ${hotBarState}, Item Action Delay: ${itemActionDelayState})`);
renderHUD = hudState;
if(getGame() == VRR_GAME_GTA_IV) {
if (getGame() == VRR_GAME_GTA_IV) {
natives.displayCash(hudState);
natives.displayAmmo(hudState);
natives.displayHud(hudState);
natives.displayRadar(hudState);
natives.displayAreaName(hudState);
} else {
if(typeof setHUDEnabled != "undefined") {
if (typeof setHUDEnabled != "undefined") {
setHUDEnabled(hudState);
}
}
@@ -202,8 +203,8 @@ function onServerSpawnedLocalPlayer(state) {
logToConsole(LOG_DEBUG, `[VRR.Main] Setting spawned state to ${state}`);
isSpawned = state;
setUpInitialGame();
if(state) {
setTimeout(function() {
if (state) {
setTimeout(function () {
calledDeathEvent = false;
}, 1000);
@@ -243,7 +244,7 @@ function tellServerItemActionDelayComplete() {
function sendServerClientInfo() {
let clientVersion = "0.0.0.0";
if(typeof CLIENT_VERSION_MAJOR != "undefined") {
if (typeof CLIENT_VERSION_MAJOR != "undefined") {
clientVersion = `${CLIENT_VERSION_MAJOR}.${CLIENT_VERSION_MINOR}.${CLIENT_VERSION_PATCH}.${CLIENT_VERSION_BUILD}`;
}
sendNetworkEventToServer("vrr.clientInfo", clientVersion, game.width, game.height);
@@ -282,7 +283,7 @@ function updateInteriorLightsState(state) {
// ===========================================================================
function forceSyncElementProperties(elementId) {
if(getElementFromId(elementId) == null) {
if (getElementFromId(elementId) == null) {
return false;
}
@@ -292,7 +293,7 @@ function forceSyncElementProperties(elementId) {
// ===========================================================================
function setElementCollisionsEnabled(elementId, state) {
if(getElementFromId(elementId) == null) {
if (getElementFromId(elementId) == null) {
return false;
}
@@ -302,7 +303,7 @@ function setElementCollisionsEnabled(elementId, state) {
// ===========================================================================
function setLocalPlayerArmour(armour) {
if(typeof localPlayer.armour != "undefined") {
if (typeof localPlayer.armour != "undefined") {
localPlayer.armour = armour;
}
}
@@ -322,8 +323,8 @@ function setLogLevel(level) {
// ===========================================================================
function setLocalPlayerInfiniteRun(state) {
if(localPlayer != null) {
if(getGame() == VRR_GAME_GTA_III || getGame() == VRR_GAME_GTA_VC) {
if (localPlayer != null) {
if (getGame() == VRR_GAME_GTA_III || getGame() == VRR_GAME_GTA_VC) {
game.SET_PLAYER_NEVER_GETS_TIRED(game.GET_PLAYER_ID(), boolToInt(state));
}
}
@@ -333,7 +334,7 @@ function setLocalPlayerInfiniteRun(state) {
function setLocalPlayerSkin(skinId) {
logToConsole(LOG_INFO, `[VRR.Server] Setting locale player skin to ${skinId}`);
if(getGame() == VRR_GAME_GTA_IV) {
if (getGame() == VRR_GAME_GTA_IV) {
natives.changePlayerModel(natives.getPlayerId(), skinId);
} else {
localPlayer.skin = skinId;
@@ -343,7 +344,7 @@ function setLocalPlayerSkin(skinId) {
// ===========================================================================
function makePedHoldObject(pedId, modelIndex) {
if(getGame() == VRR_GAME_GTA_IV) {
if (getGame() == VRR_GAME_GTA_IV) {
natives.givePedAmbientObject(natives.getPedFromNetworkId(pedId), getGameConfig().objects[getGame()][modelIndex][1])
}
}
@@ -357,11 +358,11 @@ function sendLocalPlayerNetworkIdToServer() {
// ===========================================================================
function setCutsceneInterior(cutsceneName) {
if(getGame() == VRR_GAME_GTA_IV) {
if(cutsceneName == "") {
if (getGame() == VRR_GAME_GTA_IV) {
if (cutsceneName == "") {
natives.clearCutscene();
} else {
if(natives.isInteriorScene()) {
if (natives.isInteriorScene()) {
natives.clearCutscene();
}
natives.initCutscene(cutsceneName);
@@ -372,16 +373,16 @@ function setCutsceneInterior(cutsceneName) {
// ===========================================================================
function makeLocalPlayerPedSpeak(speechName) {
if(getGame() == VRR_GAME_GTA_IV) {
if (getGame() == VRR_GAME_GTA_IV) {
// if player is in vehicle, allow megaphone (if last arg is "1", it will cancel megaphone echo)
// Only speeches with _MEGAPHONE will have the bullhorn effect
// Afaik it only works on police voices anyway
if(localPlayer.vehicle != null) {
if (localPlayer.vehicle != null) {
natives.sayAmbientSpeech(localPlayer, speechName, true, false, 0);
} else {
natives.sayAmbientSpeech(localPlayer, speechName, true, false, 1);
}
} else if(getGame() == VRR_GAME_GTA_III || getGame() == VRR_GAME_GTA_VC) {
} else if (getGame() == VRR_GAME_GTA_III || getGame() == VRR_GAME_GTA_VC) {
// Don't have a way to get the ped ref ID and can't use ped in arg
//game.SET_CHAR_SAY(game.GET_PLAYER_ID(), int);
}
@@ -390,7 +391,7 @@ function makeLocalPlayerPedSpeak(speechName) {
// ===========================================================================
function setLocalPlayerAsCopState(state) {
if(getGame() == VRR_GAME_GTA_IV) {
if (getGame() == VRR_GAME_GTA_IV) {
natives.setPlayerAsCop(natives.getPlayerId(), state);
natives.setPoliceIgnorePlayer(natives.getPlayerId(), state);
}
@@ -399,7 +400,7 @@ function setLocalPlayerAsCopState(state) {
// ===========================================================================
function serverRequestedLocalPlayerSpawn(skinId, position) {
if(getGame() == VRR_GAME_GTA_IV) {
if (getGame() == VRR_GAME_GTA_IV) {
natives.createPlayer(skinId, position);
//if(isCustomCameraSupported()) {
// game.restoreCamera(true);