diff --git a/scripts/server/business.js b/scripts/server/business.js index 29944f8a..084b04f4 100644 --- a/scripts/server/business.js +++ b/scripts/server/business.js @@ -19,10 +19,10 @@ function initBusinessScript() { function loadBusinessFromId(businessId) { let dbConnection = connectToDatabase(); - if(dbConnection) { + if (dbConnection) { let dbQueryString = `SELECT * FROM biz_main WHERE biz_id = ${businessId} LIMIT 1;`; let dbQuery = queryDatabase(dbConnection, dbQueryString); - if(dbQuery) { + if (dbQuery) { let dbAssoc = fetchQueryAssoc(dbQuery); freeDatabaseQuery(dbQuery); return new BusinessData(dbAssoc); @@ -43,11 +43,11 @@ function loadBusinessesFromDatabase() { let dbQuery = null; let dbAssoc; - if(dbConnection) { + if (dbConnection) { dbQuery = queryDatabase(dbConnection, `SELECT * FROM biz_main WHERE biz_server = ${getServerId()}`); - if(dbQuery) { - if(dbQuery.numRows > 0) { - while(dbAssoc = fetchQueryAssoc(dbQuery)) { + if (dbQuery) { + if (dbQuery.numRows > 0) { + while (dbAssoc = fetchQueryAssoc(dbQuery)) { let tempBusinessData = new BusinessData(dbAssoc); //tempBusinessData.locations = loadBusinessLocationsFromDatabase(tempBusinessData.databaseId); //tempBusinessData.gameScripts = loadBusinessGameScriptsFromDatabase(tempBusinessData.databaseId); @@ -75,12 +75,12 @@ function loadBusinessLocationsFromDatabase(businessId) { let dbAssoc; let dbQueryString = ""; - if(dbConnection) { + if (dbConnection) { dbQueryString = `SELECT * FROM biz_loc WHERE biz_loc_biz = ${businessId}`; dbQuery = queryDatabase(dbConnection, dbQueryString); - if(dbQuery) { - if(dbQuery.numRows > 0) { - while(dbAssoc = fetchQueryAssoc(dbQuery)) { + if (dbQuery) { + if (dbQuery.numRows > 0) { + while (dbAssoc = fetchQueryAssoc(dbQuery)) { let tempBusinessLocationData = new BusinessLocationData(dbAssoc); tempBusinessLocations.push(tempBusinessLocationData); logToConsole(LOG_VERBOSE, `[VRR.Business]: Location '${tempBusinessLocationData.name}' loaded from database successfully!`); @@ -157,7 +157,7 @@ function createBusinessCommand(command, params, client) { * */ function createBusinessLocationCommand(command, params, client) { - if(!isPlayerSpawned(client)) { + if (!isPlayerSpawned(client)) { messagePlayerError(client, "You must be spawned to use this command!"); return false; } @@ -165,11 +165,11 @@ function createBusinessLocationCommand(command, params, client) { let locationType = toString(getParam(params, " ", 1)); let businessId = getPlayerBusiness(client); - if(!areParamsEmpty(params)) { + if (!areParamsEmpty(params)) { businessId = getBusinessFromParams(params); } - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } @@ -207,8 +207,8 @@ function createBusiness(name, entrancePosition, exitPosition, entrancePickupMode setBusinessDataIndexes(); saveAllBusinessesToDatabase(); - createBusinessPickups(businessId-1); - createBusinessBlips(businessId-1); + createBusinessPickups(businessId - 1); + createBusinessBlips(businessId - 1); return tempBusinessData; } @@ -227,11 +227,11 @@ function createBusiness(name, entrancePosition, exitPosition, entrancePickupMode function deleteBusinessCommand(command, params, client) { let businessId = getPlayerBusiness(client); - if(!areParamsEmpty(params)) { + if (!areParamsEmpty(params)) { businessId = getBusinessFromParams(params); } - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } @@ -273,12 +273,12 @@ function setBusinessNameCommand(command, params, client) { let businessId = getPlayerBusiness(client); - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } - if(!canPlayerManageBusiness(client, businessId)) { + if (!canPlayerManageBusiness(client, businessId)) { messagePlayerError(client, getLocaleString(client, "CantModifyBusiness")); return false; } @@ -302,7 +302,7 @@ function setBusinessNameCommand(command, params, client) { * */ function setBusinessOwnerCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -310,17 +310,17 @@ function setBusinessOwnerCommand(command, params, client) { let newBusinessOwner = getPlayerFromParams(params); let businessId = getPlayerBusiness(client); - if(!newBusinessOwner) { + if (!newBusinessOwner) { messagePlayerError(client, getLocaleString(client, "InvalidPlayer")); return false; } - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } - if(!canPlayerManageBusiness(client, businessId)) { + if (!canPlayerManageBusiness(client, businessId)) { messagePlayerError(client, getLocaleString(client, "CantModifyBusiness")); return false; } @@ -344,7 +344,7 @@ function setBusinessOwnerCommand(command, params, client) { * */ function setBusinessJobCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -352,17 +352,17 @@ function setBusinessJobCommand(command, params, client) { let jobId = getJobFromParams(params); let businessId = getPlayerBusiness(client); - if(!getJobData(jobId)) { + if (!getJobData(jobId)) { messagePlayerError(client, getLocaleString(client, "InvalidJob")); return false; } - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } - if(!canPlayerManageBusiness(client, businessId)) { + if (!canPlayerManageBusiness(client, businessId)) { messagePlayerError(client, getLocaleString(client, "CantModifyBusiness")); return false; } @@ -388,24 +388,24 @@ function setBusinessJobCommand(command, params, client) { function setBusinessClanCommand(command, params, client) { let businessId = getPlayerBusiness(client); - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(getLocaleString(client, "InvalidBusiness")); return false; } let clanId = getPlayerClan(client); - if(!getClanData(clanId)) { + if (!getClanData(clanId)) { messagePlayerError(client, getLocaleString(client, "InvalidClan")); return false; } - if(getBusinessData(business).ownerType != VRR_VEHOWNER_PLAYER) { + if (getBusinessData(business).ownerType != VRR_VEHOWNER_PLAYER) { messagePlayerError(client, getLocaleString(client, "MustOwnBusiness")); return false; } - if(getBusinessData(business).ownerId != getPlayerCurrentSubAccount(client).databaseId) { + if (getBusinessData(business).ownerId != getPlayerCurrentSubAccount(client).databaseId) { messagePlayerError(client, getLocaleString(client, "MustOwnBusiness")); return false; } @@ -432,28 +432,28 @@ function setBusinessClanCommand(command, params, client) { function setBusinessRankCommand(command, params, client) { let businessId = getPlayerBusiness(client); - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(getLocaleString(client, "InvalidBusiness")); return false; } let rankId = params; - if(!canPlayerManageBusiness(client, businessId)) { + if (!canPlayerManageBusiness(client, businessId)) { messagePlayerError(client, getLocaleString(client, "CantModifyBusiness")); return false; } - if(getVehicleData(vehicle).ownerType == VRR_VEHOWNER_CLAN) { + if (getVehicleData(vehicle).ownerType == VRR_VEHOWNER_CLAN) { let clanId = getClanIdFromDatabaseId(getBusinessData(businessId).ownerId); rankId = getClanRankFromParams(clanId, params); - if(!getClanRankData(clanId, rankId)) { + if (!getClanRankData(clanId, rankId)) { messagePlayerError(client, getLocaleString(client, "ClanRankInvalid")); return false; } getBusinessData(businessId).rank = getClanRankData(clanId, rankId).databaseId; messagePlayerSuccess(client, `{MAINCOLOUR}You set business {businessBlue}${getBusinessData(businessId).name} {MAINCOLOUR}rank to {ALTCOLOUR}${getClanRankData(clanId, rankId).name} {MAINCOLOUR}of the {clanOrange}${getClanData(clanId).name} {MAINCOLOUR}clan!`); - } else if(getBusinessData(businessId).ownerType == VRR_VEHOWNER_JOB) { + } else if (getBusinessData(businessId).ownerType == VRR_VEHOWNER_JOB) { getBusinessData(businessId).rank = rankId; messagePlayerSuccess(client, `{MAINCOLOUR}You set business {businessBlue}${getBusinessData(businessId).name} {MAINCOLOUR}rank to {ALTCOLOUR}${rankId} {MAINCOLOUR}of the {jobYellow}${getJobData(getJobIdFromDatabaseId(getBusinessData(businessId).ownerId)).name} {MAINCOLOUR}job!`); } @@ -472,39 +472,39 @@ function setBusinessRankCommand(command, params, client) { * @return {bool} Whether or not the command was successful * */ - function setBusinessRankCommand(command, params, client) { - if(areParamsEmpty(params)) { +function setBusinessRankCommand(command, params, client) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } let businessId = getPlayerBusiness(client); - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(getLocaleString(client, "InvalidBusiness")); return false; } let clanId = getPlayerClan(client); - if(!getClanData(clanId)) { + if (!getClanData(clanId)) { messagePlayerError(client, getLocaleString(client, "InvalidClan")); return false; } let clanRankId = getClanRankFromParams(clanId, params); - if(!getClanRankData(clanId, clanRankId)) { + if (!getClanRankData(clanId, clanRankId)) { messagePlayerError(client, getLocaleString(client, "ClanRankInvalid")); return false; } - if(!canPlayerManageBusiness(client, businessId)) { + if (!canPlayerManageBusiness(client, businessId)) { messagePlayerError(client, getLocaleString(client, "CantModifyBusiness")); return false; } - if(getClanRankData(clanId, clanRankId).level > getPlayerCurrentSubAccount(client).clanRank) { + if (getClanRankData(clanId, clanRankId).level > getPlayerCurrentSubAccount(client).clanRank) { messagePlayerError(client, "That rank is above your level!"); return false; } @@ -529,23 +529,23 @@ function setBusinessRankCommand(command, params, client) { function setBusinessJobCommand(command, params, client) { let businessId = getPlayerBusiness(client); - if(!areParamsEmpty(params)) { + if (!areParamsEmpty(params)) { businessId = getBusinessFromParams(params); } let closestJobLocation = getClosestJobLocation(getVehiclePosition(vehicle)); let jobId = closestJobLocation.job; - if(!areParamsEmpty(params)) { + if (!areParamsEmpty(params)) { jobId = getJobIdFromParams(params); } - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } - if(!getJobData(jobId)) { + if (!getJobData(jobId)) { messagePlayerError(client, getLocaleString(client, "InvalidJob")); return false; } @@ -571,11 +571,11 @@ function setBusinessJobCommand(command, params, client) { function setBusinessPublicCommand(command, params, client) { let businessId = getPlayerBusiness(client); - if(!areParamsEmpty(params)) { + if (!areParamsEmpty(params)) { businessId = getBusinessFromParams(params); } - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } @@ -601,11 +601,11 @@ function setBusinessPublicCommand(command, params, client) { function removeBusinessOwnerCommand(command, params, client) { let businessId = getPlayerBusiness(client); - if(!areParamsEmpty(params)) { + if (!areParamsEmpty(params)) { businessId = getBusinessFromParams(params); } - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } @@ -628,15 +628,15 @@ function removeBusinessOwnerCommand(command, params, client) { * @return {bool} Whether or not the command was successful * */ - function toggleBusinessInteriorLightsCommand(command, params, client) { +function toggleBusinessInteriorLightsCommand(command, params, client) { let businessId = getPlayerBusiness(client); - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } - if(!canPlayerManageBusiness(client, businessId)) { + if (!canPlayerManageBusiness(client, businessId)) { messagePlayerError(client, "You can't change the interior lights for this business!"); return false; } @@ -663,12 +663,12 @@ function setBusinessEntranceFeeCommand(command, params, client) { let entranceFee = toInteger(getParam(params, " ", 1)) || 0; let businessId = getPlayerBusiness(client); - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } - if(!canPlayerManageBusiness(client, businessId)) { + if (!canPlayerManageBusiness(client, businessId)) { messagePlayerError(client, getLocaleString(client, "CantModifyBusiness")); return false; } @@ -692,11 +692,11 @@ function setBusinessEntranceFeeCommand(command, params, client) { function getBusinessInfoCommand(command, params, client) { let businessId = getPlayerBusiness(client); - if(!areParamsEmpty(params)) { + if (!areParamsEmpty(params)) { businessId = getBusinessFromParams(params); } - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } @@ -704,7 +704,7 @@ function getBusinessInfoCommand(command, params, client) { let businessData = getBusinessData(businessId); let ownerName = "Unknown"; - switch(businessData.ownerType) { + switch (businessData.ownerType) { case VRR_BIZOWNER_CLAN: ownerName = getClanData(businessData.ownerId).name; break; @@ -755,7 +755,7 @@ function getBusinessInfoCommand(command, params, client) { messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderBusinessInfo", businessData.name))); let chunkedList = splitArrayIntoChunks(stats, 6); - for(let i in chunkedList) { + for (let i in chunkedList) { messagePlayerInfo(client, chunkedList[i].join(", ")); } @@ -776,11 +776,11 @@ function getBusinessInfoCommand(command, params, client) { function getBusinessFloorItemsCommand(command, params, client) { let businessId = getPlayerBusiness(client); - if(!areParamsEmpty(params)) { + if (!areParamsEmpty(params)) { businessId = getBusinessFromParams(params); } - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } @@ -802,11 +802,11 @@ function getBusinessFloorItemsCommand(command, params, client) { function getBusinessStorageItemsCommand(command, params, client) { let businessId = getPlayerBusiness(client); - if(!areParamsEmpty(params)) { + if (!areParamsEmpty(params)) { businessId = getBusinessFromParams(params); } - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } @@ -829,19 +829,19 @@ function setBusinessPickupCommand(command, params, client) { let typeParam = getParam(params, " ", 1) || "business"; let businessId = getPlayerBusiness(client); - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } - if(isNaN(typeParam)) { - if(isNull(getGameConfig().pickupModels[getGame()][typeParam])) { + if (isNaN(typeParam)) { + if (isNull(getGameConfig().pickupModels[getGame()][typeParam])) { messagePlayerError(client, "Invalid pickup type! Use a pickup type name or a model ID"); let pickupTypes = Object.keys(getGameConfig().pickupModels[getGame()]); let chunkedList = splitArrayIntoChunks(pickupTypes, 10); messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderPickupTypes"))); - for(let i in chunkedList) { + for (let i in chunkedList) { messagePlayerInfo(client, chunkedList[i].join(", ")); } return false; @@ -874,18 +874,18 @@ function setBusinessInteriorTypeCommand(command, params, client) { let typeParam = getParam(params, " ", 1) || "business"; let businessId = getPlayerBusiness(client); - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } - if(typeof getGameConfig().interiors[getGame()] == "undefined") { + if (typeof getGameConfig().interiors[getGame()] == "undefined") { messagePlayerError(client, `There are no interiors available for this game!`); return false; } - if(isNaN(typeParam)) { - if(toLowerCase(typeParam) == "None") { + if (isNaN(typeParam)) { + if (toLowerCase(typeParam) == "None") { getBusinessData(businessId).exitPosition = toVector3(0.0, 0.0, 0.0); getBusinessData(businessId).exitDimension = 0; getBusinessData(businessId).exitInterior = -1; @@ -897,13 +897,13 @@ function setBusinessInteriorTypeCommand(command, params, client) { return false; } - if(isNull(getGameConfig().interiors[getGame()][typeParam])) { + if (isNull(getGameConfig().interiors[getGame()][typeParam])) { messagePlayerError(client, "Invalid interior type! Use an interior type name"); let interiorTypesList = Object.keys(getGameConfig().interiors[getGame()]); let chunkedList = splitArrayIntoChunks(interiorTypesList, 10); messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderInteriorTypes"))); - for(let i in chunkedList) { + for (let i in chunkedList) { messagePlayerInfo(client, chunkedList[i].join(", ")); } return false; @@ -911,7 +911,7 @@ function setBusinessInteriorTypeCommand(command, params, client) { getBusinessData(businessId).exitPosition = getGameConfig().interiors[getGame()][typeParam][0]; getBusinessData(businessId).exitInterior = getGameConfig().interiors[getGame()][typeParam][1]; - getBusinessData(businessId).exitDimension = getBusinessData(businessId).databaseId+getGlobalConfig().businessDimensionStart; + getBusinessData(businessId).exitDimension = getBusinessData(businessId).databaseId + getGlobalConfig().businessDimensionStart; getBusinessData(businessId).exitPickupModel = getGameConfig().pickupModels[getGame()].Exit; getBusinessData(businessId).hasInterior = true; getBusinessData(businessId).customInterior = getGameConfig().interiors[getGame()][typeParam][2]; @@ -941,28 +941,28 @@ function setBusinessInteriorTypeCommand(command, params, client) { * @return {bool} Whether or not the command was successful * */ - function addBusinessPropertyTemplateEntities(command, params, client) { +function addBusinessPropertyTemplateEntities(command, params, client) { let propertyTemplateParam = getParam(params, " ", 1) || "business"; let businessId = getPlayerBusiness(client); - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } - if(typeof getGameConfig().interiors[getGame()] == "undefined") { + if (typeof getGameConfig().interiors[getGame()] == "undefined") { messagePlayerError(client, `There are no property templates available for this game!`); return false; } - if(isNaN(propertyTemplateParam)) { - if(isNull(getGameConfig().interiors[getGame()][typeParam])) { + if (isNaN(propertyTemplateParam)) { + if (isNull(getGameConfig().interiors[getGame()][typeParam])) { messagePlayerError(client, "Invalid interior type! Use an interior type name"); let interiorTypesList = Object.keys(getGameConfig().properties[getGame()]); let chunkedList = splitArrayIntoChunks(interiorTypesList, 10); messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderPropertyTemplateTypes"))); - for(let i in chunkedList) { + for (let i in chunkedList) { messagePlayerInfo(client, chunkedList[i].join(", ")); } return false; @@ -970,7 +970,7 @@ function setBusinessInteriorTypeCommand(command, params, client) { getBusinessData(businessId).exitPosition = getGameConfig().interiors[getGame()][typeParam][0]; getBusinessData(businessId).exitInterior = getGameConfig().interiors[getGame()][typeParam][1]; - getBusinessData(businessId).exitDimension = getBusinessData(businessId).databaseId+getGlobalConfig().businessDimensionStart; + getBusinessData(businessId).exitDimension = getBusinessData(businessId).databaseId + getGlobalConfig().businessDimensionStart; getBusinessData(businessId).exitPickupModel = getGameConfig().pickupModels[getGame()].Exit; getBusinessData(businessId).hasInterior = true; getBusinessData(businessId).customInterior = getGameConfig().interiors[getGame()][typeParam][2]; @@ -1004,20 +1004,20 @@ function setBusinessBlipCommand(command, params, client) { let typeParam = getParam(params, " ", 1) || "business"; let businessId = getPlayerBusiness(client); - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } - if(isNaN(typeParam)) { - if(isNull(getGameConfig().blipSprites[getGame()][typeParam])) { + if (isNaN(typeParam)) { + if (isNull(getGameConfig().blipSprites[getGame()][typeParam])) { messagePlayerError(client, "Invalid business type! Use a business type name or a blip image ID"); let blipTypes = Object.keys(getGameConfig().blipSprites[getGame()]); let chunkedList = splitArrayIntoChunks(blipTypes, 10); messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderBlipTypes"))); - for(let i in chunkedList) { + for (let i in chunkedList) { messagePlayerInfo(client, chunkedList[i].join(", ")); } return false; @@ -1049,34 +1049,34 @@ function giveDefaultItemsToBusinessCommand(command, params, client) { let typeParam = getParam(params, " ", 1) || "business"; let businessId = getPlayerBusiness(client); - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } - if(!isNaN(typeParam)) { + if (!isNaN(typeParam)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } - if(isNull(getGameConfig().defaultBusinessItems[getGame()][typeParam])) { + if (isNull(getGameConfig().defaultBusinessItems[getGame()][typeParam])) { messagePlayerError(client, "Invalid business items type! Use a business items type name"); let businessItemTypes = Object.keys(getGameConfig().defaultBusinessItems[getGame()]); let chunkedList = splitArrayIntoChunks(businessItemTypes, 10); messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderDefaultBusinessItemTypes"))); - for(let i in chunkedList) { + for (let i in chunkedList) { messagePlayerInfo(client, chunkedList[i].join(", ")); } return false; } - for(let i in getGameConfig().defaultBusinessItems[getGame()][typeParam]) { + for (let i in getGameConfig().defaultBusinessItems[getGame()][typeParam]) { let itemTypeId = getItemTypeFromParams(getGameConfig().defaultBusinessItems[getGame()][typeParam][i][0]); let itemTypeData = getItemTypeData(itemTypeId); - if(itemTypeData) { + if (itemTypeData) { let newItemIndex = createItem(itemTypeId, itemTypeData.orderValue, VRR_ITEM_OWNER_BIZFLOOR, getBusinessData(businessId).databaseId, getGameConfig().defaultBusinessItems[getGame()][typeParam][i][1]); - getItemData(newItemIndex).buyPrice = applyServerInflationMultiplier(itemTypeData.orderPrice)*getGameConfig().defaultBusinessItems[getGame()][typeParam][i][2]; + getItemData(newItemIndex).buyPrice = applyServerInflationMultiplier(itemTypeData.orderPrice) * getGameConfig().defaultBusinessItems[getGame()][typeParam][i][2]; } } @@ -1099,7 +1099,7 @@ function giveDefaultItemsToBusinessCommand(command, params, client) { function setBusinessEntranceLabelToDealershipCommand(command, params, client) { let businessId = getPlayerBusiness(client); - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } @@ -1123,13 +1123,13 @@ function setBusinessEntranceLabelToDealershipCommand(command, params, client) { function deleteBusinessFloorItemsCommand(command, params, client) { let businessId = getPlayerBusiness(client); - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } let tempCache = getBusinessData(businessId).floorItemCache; - for(let i in tempCache) { + for (let i in tempCache) { deleteItem(tempCache[i]); } @@ -1152,13 +1152,13 @@ function deleteBusinessFloorItemsCommand(command, params, client) { function deleteBusinessStorageItemsCommand(command, params, client) { let businessId = getPlayerBusiness(client); - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } let tempCache = getBusinessData(businessId).storageItemCache; - for(let i in tempCache) { + for (let i in tempCache) { deleteItem(tempCache[i]); } @@ -1179,7 +1179,7 @@ function deleteBusinessStorageItemsCommand(command, params, client) { * */ function withdrawFromBusinessCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -1187,17 +1187,17 @@ function withdrawFromBusinessCommand(command, params, client) { let amount = toInteger(getParam(params, " ", 1)) || 0; let businessId = getPlayerBusiness(client); - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } - if(!canPlayerManageBusiness(client, businessId)) { + if (!canPlayerManageBusiness(client, businessId)) { messagePlayerError(client, getLocaleString(client, "CantModifyBusiness")); return false; } - if(getBusinessData(businessId).till < amount) { + if (getBusinessData(businessId).till < amount) { messagePlayerError(client, `Business {businessBlue}${tempBusinessData.name} doesn't have that much money! Use /bizbalance.`); return false; } @@ -1222,7 +1222,7 @@ function withdrawFromBusinessCommand(command, params, client) { * */ function setBusinessBuyPriceCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -1230,17 +1230,17 @@ function setBusinessBuyPriceCommand(command, params, client) { let amount = toInteger(getParam(params, " ", 1)) || 0; let businessId = getPlayerBusiness(client); - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } - if(!canPlayerManageBusiness(client, businessId)) { + if (!canPlayerManageBusiness(client, businessId)) { messagePlayerError(client, getLocaleString(client, "CantModifyBusiness")); return false; } - if(amount < 0) { + if (amount < 0) { messagePlayerError(client, `The amount can't be less than 0!`); return false; } @@ -1264,7 +1264,7 @@ function setBusinessBuyPriceCommand(command, params, client) { * */ function depositIntoBusinessCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -1272,7 +1272,7 @@ function depositIntoBusinessCommand(command, params, client) { let amount = toInteger(getParam(params, " ", 1)) || 0; let businessId = getPlayerBusiness(client); - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } @@ -1283,7 +1283,7 @@ function depositIntoBusinessCommand(command, params, client) { // return false; //} - if(getPlayerCurrentSubAccount(client).cash < amount) { + if (getPlayerCurrentSubAccount(client).cash < amount) { messagePlayerError(client, `You don't have that much money! You only have $${getPlayerCurrentSubAccount(client).cash}`); return false; } @@ -1308,20 +1308,20 @@ function depositIntoBusinessCommand(command, params, client) { * */ function orderItemForBusinessCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } - if(!areThereEnoughParams(params, 3, " ")) { + if (!areThereEnoughParams(params, 3, " ")) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } let splitParams = params.split(" "); - let itemType = getItemTypeFromParams(splitParams.slice(0,-2).join(" ")); + let itemType = getItemTypeFromParams(splitParams.slice(0, -2).join(" ")); - if(!getItemTypeData(itemType)) { + if (!getItemTypeData(itemType)) { messagePlayerError(client, `Invalid item type name or ID!`); messagePlayerInfo(client, `Use {ALTCOLOUR}/itemtypes {MAINCOLOUR}for a list of items`); return false; @@ -1332,19 +1332,19 @@ function orderItemForBusinessCommand(command, params, client) { let value = toInteger(splitParams.slice(-1)) || getItemTypeData(itemType).capacity; let businessId = getPlayerBusiness(client); - logToConsole(LOG_DEBUG, `[VRR.Business] ${getPlayerDisplayForConsole(client)} is ordering ${amount} ${splitParams.slice(0,-2).join(" ")} (${value})`); + logToConsole(LOG_DEBUG, `[VRR.Business] ${getPlayerDisplayForConsole(client)} is ordering ${amount} ${splitParams.slice(0, -2).join(" ")} (${value})`); - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } - if(!canPlayerManageBusiness(client, businessId)) { + if (!canPlayerManageBusiness(client, businessId)) { messagePlayerError(client, getLocaleString(client, "CantModifyBusiness")); return false; } - let orderTotalCost = pricePerItem*amount; + let orderTotalCost = pricePerItem * amount; //getPlayerData(client).promptType = VRR_PROMPT_BIZORDER; getPlayerData(client).businessOrderAmount = amount; @@ -1370,8 +1370,8 @@ function orderItemForBusinessCommand(command, params, client) { * */ function orderItemForBusiness(businessId, itemType, amount) { - if(getBusinessData(businessId).till < orderTotalCost) { - let neededAmount = orderTotalCost-getBusinessData(businessId).till; + if (getBusinessData(businessId).till < orderTotalCost) { + let neededAmount = orderTotalCost - getBusinessData(businessId).till; //messagePlayerError(client, `The business doesn't have enough money (needs {ALTCOLOUR}$${neededAmount} {MAINCOLOUR}more)! Use {ALTCOLOUR}/bizdeposit {MAINCOLOUR}to add money to the business.`); return false; } @@ -1395,16 +1395,16 @@ function orderItemForBusiness(businessId, itemType, amount) { function viewBusinessTillAmountCommand(command, params, client) { let businessId = getPlayerBusiness(client); - if(!areParamsEmpty(params)) { + if (!areParamsEmpty(params)) { businessId = getBusinessFromParams(params); } - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } - if(!canPlayerManageBusiness(client, businessId)) { + if (!canPlayerManageBusiness(client, businessId)) { messagePlayerError(client, getLocaleString(client, "CantModifyBusiness")); return false; } @@ -1426,17 +1426,17 @@ function viewBusinessTillAmountCommand(command, params, client) { function buyBusinessCommand(command, params, client) { let businessId = getPlayerBusiness(client); - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } - if(getBusinessData(businessId).buyPrice <= 0) { + if (getBusinessData(businessId).buyPrice <= 0) { messagePlayerError(client, getLocaleString(client, "BusinessNotForSale")); return false; } - if(getPlayerCurrentSubAccount(client).cash < getBusinessData(businessId).buyPrice) { + if (getPlayerCurrentSubAccount(client).cash < getBusinessData(businessId).buyPrice) { messagePlayerError(client, getLocaleString(client, "BusinessPurchaseNotEnoughMoney")); return false; } @@ -1459,11 +1459,11 @@ function buyBusinessCommand(command, params, client) { function moveBusinessEntranceCommand(command, params, client) { let businessId = getPlayerBusiness(client); - if(!areParamsEmpty(params)) { + if (!areParamsEmpty(params)) { businessId = getBusinessFromParams(params); } - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } @@ -1499,11 +1499,11 @@ function moveBusinessEntranceCommand(command, params, client) { function moveBusinessExitCommand(command, params, client) { let businessId = getPlayerBusiness(client); - if(!areParamsEmpty(params)) { + if (!areParamsEmpty(params)) { businessId = getBusinessFromParams(params); } - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } @@ -1527,7 +1527,7 @@ function moveBusinessExitCommand(command, params, client) { function getBusinessDataFromDatabaseId(databaseId) { let matchingBusinesses = getServerData().businesses.filter(b => b.databaseId == businessId) - if(matchingBusinesses.length == 1) { + if (matchingBusinesses.length == 1) { return matchingBusinesses[0]; } return false; @@ -1545,9 +1545,9 @@ function getBusinessDataFromDatabaseId(databaseId) { */ function getClosestBusinessEntrance(position, dimension) { let closest = 0; - for(let i in getServerData().businesses) { - if(getServerData().businesses[i].entranceDimension == dimension) { - if(getDistance(position, getServerData().businesses[i].entrancePosition) <= getDistance(position, getServerData().businesses[closest].entrancePosition)) { + for (let i in getServerData().businesses) { + if (getServerData().businesses[i].entranceDimension == dimension) { + if (getDistance(position, getServerData().businesses[i].entrancePosition) <= getDistance(position, getServerData().businesses[closest].entrancePosition)) { closest = i; } } @@ -1567,9 +1567,9 @@ function getClosestBusinessEntrance(position, dimension) { */ function getClosestBusinessExit(position, dimension) { let closest = 0; - for(let i in getServerData().businesses) { - if(getServerData().businesses[i].hasInterior && getServerData().businesses[i].exitDimension == dimension) { - if(getDistance(position, getServerData().businesses[i].exitPosition) <= getDistance(position, getServerData().businesses[closest].exitPosition)) { + for (let i in getServerData().businesses) { + if (getServerData().businesses[i].hasInterior && getServerData().businesses[i].exitDimension == dimension) { + if (getDistance(position, getServerData().businesses[i].exitPosition) <= getDistance(position, getServerData().businesses[closest].exitPosition)) { closest = i; } } @@ -1587,8 +1587,8 @@ function getClosestBusinessExit(position, dimension) { * */ function isPlayerInAnyBusiness(client) { - for(let i in getServerData().businesses) { - if(getServerData().businesses[i].hasInterior && getServerData().businesses[i].exitDimension == getPlayerDimension(client)) { + for (let i in getServerData().businesses) { + if (getServerData().businesses[i].hasInterior && getServerData().businesses[i].exitDimension == getPlayerDimension(client)) { return i; } } @@ -1606,19 +1606,23 @@ function isPlayerInAnyBusiness(client) { * */ function getPlayerBusiness(client) { - if(getPlayerDimension(client) == getGameConfig().mainWorldDimension[getGame()]) { + if (getServerData().businesses.length == 0) { + return -1; + } + + if (getPlayerDimension(client) == getGameConfig().mainWorldDimension[getGame()]) { let closestEntrance = getClosestBusinessEntrance(getPlayerPosition(client), getPlayerDimension(client)); - if(getDistance(getPlayerPosition(client), getBusinessData(closestEntrance).entrancePosition) <= getGlobalConfig().enterPropertyDistance) { + if (getDistance(getPlayerPosition(client), getBusinessData(closestEntrance).entrancePosition) <= getGlobalConfig().enterPropertyDistance) { return getBusinessData(closestEntrance).index; } } else { let closestEntrance = getClosestBusinessEntrance(getPlayerPosition(client), getPlayerDimension(client)); - if(getDistance(getPlayerPosition(client), getBusinessData(closestEntrance).entrancePosition) <= getGlobalConfig().enterPropertyDistance) { + if (getDistance(getPlayerPosition(client), getBusinessData(closestEntrance).entrancePosition) <= getGlobalConfig().enterPropertyDistance) { return getBusinessData(closestEntrance).index; } - for(let i in getServerData().businesses) { - if(getServerData().businesses[i].hasInterior && getServerData().businesses[i].exitDimension == getPlayerDimension(client)) { + for (let i in getServerData().businesses) { + if (getServerData().businesses[i].hasInterior && getServerData().businesses[i].exitDimension == getPlayerDimension(client)) { return i; } } @@ -1635,12 +1639,12 @@ function getPlayerBusiness(client) { * */ function saveAllBusinessesToDatabase() { - if(getServerConfig().devServer) { + if (getServerConfig().devServer) { return false; } - for(let i in getServerData().businesses) { - if(getServerData().businesses[i].needsSaved) { + for (let i in getServerData().businesses) { + if (getServerData().businesses[i].needsSaved) { saveBusinessToDatabase(i); } } @@ -1660,13 +1664,13 @@ function saveAllBusinessesToDatabase() { function saveBusinessToDatabase(businessId) { let tempBusinessData = getServerData().businesses[businessId]; - if(!tempBusinessData.needsSaved) { + if (!tempBusinessData.needsSaved) { return false; } logToConsole(LOG_DEBUG, `[VRR.Business]: Saving business '${tempBusinessData.name}' to database ...`); let dbConnection = connectToDatabase(); - if(dbConnection) { + if (dbConnection) { let safeBusinessName = escapeDatabaseString(dbConnection, tempBusinessData.name); let data = [ @@ -1705,7 +1709,7 @@ function saveBusinessToDatabase(businessId) { ]; let dbQuery = null; - if(tempBusinessData.databaseId == 0) { + if (tempBusinessData.databaseId == 0) { let queryString = createDatabaseInsertQuery("biz_main", data); dbQuery = queryDatabase(dbConnection, queryString); getServerData().businesses[businessId].databaseId = getDatabaseInsertId(dbConnection); @@ -1734,11 +1738,15 @@ function saveBusinessToDatabase(businessId) { * */ function createAllBusinessPickups() { - if(!getServerConfig().createBusinessPickups) { + if (!getServerConfig().createBusinessPickups) { return false; } - for(let i in getServerData().businesses) { + if (!isGameFeatureSupported("pickups")) { + return false; + } + + for (let i in getServerData().businesses) { createBusinessEntrancePickup(i); createBusinessExitPickup(i); updateBusinessPickupLabelData(i); @@ -1756,11 +1764,15 @@ function createAllBusinessPickups() { * */ function createAllBusinessBlips() { - if(!getServerConfig().createBusinessBlips) { + if (!getServerConfig().createBusinessBlips) { return false; } - for(let i in getServerData().businesses) { + if (!isGameFeatureSupported("blips")) { + return false; + } + + for (let i in getServerData().businesses) { createBusinessEntranceBlip(i); createBusinessExitBlip(i); } @@ -1776,11 +1788,15 @@ function createAllBusinessBlips() { * */ function createBusinessEntrancePickup(businessId) { - if(!areServerElementsSupported()) { + if (!areServerElementsSupported()) { return false; } - if(!getServerConfig().createBusinessPickups) { + if (!getServerConfig().createBusinessPickups) { + return false; + } + + if (!isGameFeatureSupported("pickups")) { return false; } @@ -1790,29 +1806,29 @@ function createBusinessEntrancePickup(businessId) { // return false; //} - if(businessData.entrancePickupModel == -1) { + if (businessData.entrancePickupModel == -1) { return false; } let pickupModelId = getGameConfig().pickupModels[getGame()].Business; - if(businessData.entrancePickupModel != 0) { + if (businessData.entrancePickupModel != 0) { pickupModelId = businessData.entrancePickupModel; } logToConsole(LOG_VERBOSE, `[VRR.Job]: Creating entrance pickup for business ${businessData.name} (model ${pickupModelId})`); - if(areServerElementsSupported()) { + if (areServerElementsSupported()) { let entrancePickup = createGamePickup(pickupModelId, businessData.entrancePosition, getGameConfig().pickupTypes[getGame()].business); - if(entrancePickup != null) { - if(businessData.entranceDimension != -1) { + if (entrancePickup != null) { + if (businessData.entranceDimension != -1) { setElementDimension(entrancePickup, businessData.entranceDimension); setElementOnAllDimensions(entrancePickup, false); } else { setElementOnAllDimensions(entrancePickup, true); } - if(getGlobalConfig().businessPickupStreamInDistance == -1 || getGlobalConfig().businessPickupStreamOutDistance == -1) { + if (getGlobalConfig().businessPickupStreamInDistance == -1 || getGlobalConfig().businessPickupStreamOutDistance == -1) { entrancePickup.netFlags.distanceStreaming = false; } else { setElementStreamInDistance(entrancePickup, getGlobalConfig().businessPickupStreamInDistance); @@ -1825,7 +1841,7 @@ function createBusinessEntrancePickup(businessId) { } else { let pickupModelId = getGameConfig().pickupModels[getGame()].Business; - if(businessData.entrancePickupModel != 0) { + if (businessData.entrancePickupModel != 0) { pickupModelId = businessData.entrancePickupModel; } sendBusinessToPlayer(null, businessId, businessData.name, businessData.entrancePosition, blipModelId, pickupModelId, businessData.hasInterior, doesBusinessHaveAnyItemsToBuy(businessId)); @@ -1844,7 +1860,15 @@ function createBusinessEntrancePickup(businessId) { * */ function createBusinessEntranceBlip(businessId) { - if(!getServerConfig().createBusinessBlips) { + if (!areServerElementsSupported()) { + return false; + } + + if (!getServerConfig().createBusinessBlips) { + return false; + } + + if (!isGameFeatureSupported("blips")) { return false; } @@ -1854,29 +1878,29 @@ function createBusinessEntranceBlip(businessId) { // return false; //} - if(businessData.entranceBlipModel == -1) { + if (businessData.entranceBlipModel == -1) { return false; } let blipModelId = getGameConfig().blipSprites[getGame()].Business; - if(businessData.entranceBlipModel != 0) { + if (businessData.entranceBlipModel != 0) { blipModelId = businessData.entranceBlipModel; } logToConsole(LOG_VERBOSE, `[VRR.Job]: Creating entrance blip for business ${businessData.name} (model ${blipModelId})`); - if(areServerElementsSupported()) { + if (areServerElementsSupported()) { let entranceBlip = createGameBlip(businessData.entrancePosition, blipModelId, 1, getColourByType("businessBlue")); - if(entranceBlip != null) { - if(businessData.entranceDimension != -1) { + if (entranceBlip != null) { + if (businessData.entranceDimension != -1) { setElementDimension(entranceBlip, businessData.entranceDimension); setElementOnAllDimensions(entranceBlip, false); } else { setElementOnAllDimensions(entranceBlip, true); } - if(getGlobalConfig().businessBlipStreamInDistance == -1 || getGlobalConfig().businessBlipStreamOutDistance == -1) { + if (getGlobalConfig().businessBlipStreamInDistance == -1 || getGlobalConfig().businessBlipStreamOutDistance == -1) { entranceBlip.netFlags.distanceStreaming = false; } else { setElementStreamInDistance(entranceBlip, getGlobalConfig().businessBlipStreamInDistance); @@ -1898,11 +1922,15 @@ function createBusinessEntranceBlip(businessId) { * */ function createBusinessExitPickup(businessId) { - if(!areServerElementsSupported()) { + if (!areServerElementsSupported()) { return false; } - if(!getServerConfig().createBusinessPickups) { + if (!getServerConfig().createBusinessPickups) { + return false; + } + + if (!isGameFeatureSupported("pickups")) { return false; } @@ -1912,28 +1940,28 @@ function createBusinessExitPickup(businessId) { // return false; //} - if(businessData.exitPickupModel == -1) { + if (businessData.exitPickupModel == -1) { return false; } let pickupModelId = getGameConfig().pickupModels[getGame()].Exit; - if(businessData.exitPickupModel != 0) { + if (businessData.exitPickupModel != 0) { pickupModelId = businessData.exitPickupModel; } logToConsole(LOG_VERBOSE, `[VRR.Job]: Creating exit pickup for business ${businessData.name} (model ${pickupModelId})`); let exitPickup = createGamePickup(pickupModelId, businessData.exitPosition, getGameConfig().pickupTypes[getGame()].business); - if(exitPickup != null) { - if(businessData.exitDimension != -1) { + if (exitPickup != null) { + if (businessData.exitDimension != -1) { setElementDimension(exitPickup, businessData.exitDimension); setElementOnAllDimensions(exitPickup, false); } else { setElementOnAllDimensions(exitPickup, true); } - if(getGlobalConfig().businessPickupStreamInDistance == -1 || getGlobalConfig().businessPickupStreamOutDistance == -1) { + if (getGlobalConfig().businessPickupStreamInDistance == -1 || getGlobalConfig().businessPickupStreamOutDistance == -1) { exitPickup.netFlags.distanceStreaming = false; } else { setElementStreamInDistance(exitPickup, getGlobalConfig().businessPickupStreamInDistance); @@ -1955,11 +1983,15 @@ function createBusinessExitPickup(businessId) { * */ function createBusinessExitBlip(businessId) { - if(!areServerElementsSupported()) { + if (!areServerElementsSupported()) { return false; } - if(!getServerConfig().createBusinessBlips) { + if (!getServerConfig().createBusinessBlips) { + return false; + } + + if (!isGameFeatureSupported("blips")) { return false; } @@ -1969,28 +2001,28 @@ function createBusinessExitBlip(businessId) { // return false; //} - if(businessData.exitBlipModel == -1) { + if (businessData.exitBlipModel == -1) { return false; } let blipModelId = getGameConfig().blipSprites[getGame()].Business; - if(businessData.exitBlipModel != 0) { + if (businessData.exitBlipModel != 0) { blipModelId = businessData.exitBlipModel; } logToConsole(LOG_VERBOSE, `[VRR.Job]: Creating exit blip for business ${businessData.name} (model ${blipModelId})`); let exitBlip = createGameBlip(businessData.exitPosition, blipModelId, 1, getColourByName("businessBlue")); - if(exitBlip != null) { - if(businessData.exitDimension != -1) { + if (exitBlip != null) { + if (businessData.exitDimension != -1) { setElementDimension(exitBlip, businessData.exitDimension); setElementOnAllDimensions(exitBlip, false); } else { setElementOnAllDimensions(exitBlip, true); } - if(getGlobalConfig().businessBlipStreamInDistance == -1 || getGlobalConfig().businessBlipStreamOutDistance == -1) { + if (getGlobalConfig().businessBlipStreamInDistance == -1 || getGlobalConfig().businessBlipStreamOutDistance == -1) { exitBlip.netFlags.distanceStreaming = false; } else { setElementStreamInDistance(exitBlip, getGlobalConfig().businessBlipStreamInDistance); @@ -2010,7 +2042,7 @@ function createBusinessExitBlip(businessId) { * @return {Boolean} Whether or not the business was deleted * */ -function deleteBusiness(businessId, deletedBy = 0) { +function deleteBusiness(businessId, whoDeleted = 0) { let tempBusinessData = getServerData().businesses[businessId]; let dbConnection = connectToDatabase(); @@ -2019,9 +2051,9 @@ function deleteBusiness(businessId, deletedBy = 0) { deleteBusinessBlips(businessId); deleteBusinessPickups(businessId); - if(dbConnection) { - dbQuery = queryDatabase(dbConnection, `DELETE FROM biz_main WHERE biz_id = ${tempBusinessData.databaseId}`); - if(dbQuery) { + if (dbConnection) { + dbQuery = queryDatabase(dbConnection, `UPDATE biz_main WHERE biz_deleted = 1, biz_when_deleted = UNIX_TIMESTAMP(), biz_who_deleted = ${whoDeleted} WHERE biz_id ${tempBusinessData.databaseId}`); + if (dbQuery) { freeDatabaseQuery(dbQuery); } disconnectFromDatabase(dbConnection); @@ -2044,9 +2076,9 @@ function deleteBusiness(businessId, deletedBy = 0) { * */ function removePlayersFromBusiness(businessId) { - getClients().forEach(function(client) { - if(doesBusinessHaveInterior(businessId)) { - if(getPlayerBusiness(client) == businessId) { + getClients().forEach(function (client) { + if (doesBusinessHaveInterior(businessId)) { + if (getPlayerBusiness(client) == businessId) { exitBusiness(client); } } @@ -2081,11 +2113,11 @@ function removePlayerFromBusiness(client) { function exitBusiness(client) { let businessId = getPlayerBusiness(client); - if(businessId == false) { + if (businessId == false) { return false; } - if(isPlayerSpawned(client)) { + if (isPlayerSpawned(client)) { setPlayerInterior(client, getServerData().businesses[businessId].entranceInterior); setPlayerDimension(client, getServerData().businesses[businessId].entranceDimension); setPlayerPosition(client, getServerData().businesses[businessId].entrancePosition); @@ -2105,7 +2137,7 @@ function exitBusiness(client) { * */ function getBusinessOwnerTypeText(ownerType) { - switch(ownerType) { + switch (ownerType) { case VRR_BIZOWNER_CLAN: return "clan"; @@ -2131,7 +2163,7 @@ function getBusinessOwnerTypeText(ownerType) { * @return {BusinessData} The business's data (class instance) */ function getBusinessData(businessId) { - if(typeof getServerData().businesses[businessId] != null) { + if (typeof getServerData().businesses[businessId] != null) { return getServerData().businesses[businessId]; } return false; @@ -2156,11 +2188,15 @@ function doesBusinessHaveInterior(businessId) { * @returns {Boolean} Whether or not the entrance pickup of the business was deleted */ function deleteBusinessEntrancePickup(businessId) { - if(!areServerElementsSupported()) { + if (!areServerElementsSupported()) { return false; } - if(getBusinessData(businessId).entrancePickup != null) { + if (!isGameFeatureSupported("pickups")) { + return false; + } + + if (getBusinessData(businessId).entrancePickup != null) { //removeFromWorld(getBusinessData(businessId).entrancePickup); deleteGameElement(getBusinessData(businessId).entrancePickup); getBusinessData(businessId).entrancePickup = null; @@ -2179,11 +2215,15 @@ function deleteBusinessEntrancePickup(businessId) { * @returns {Boolean} Whether or not the exit pickup of the business was deleted */ function deleteBusinessExitPickup(businessId) { - if(!areServerElementsSupported()) { + if (!areServerElementsSupported()) { return false; } - if(getBusinessData(businessId).exitPickup != null) { + if (!isGameFeatureSupported("pickups")) { + return false; + } + + if (getBusinessData(businessId).exitPickup != null) { //removeFromWorld(getBusinessData(businessId).exitPickup); deleteGameElement(getBusinessData(businessId).exitPickup); getBusinessData(businessId).exitPickup = null; @@ -2198,11 +2238,15 @@ function deleteBusinessExitPickup(businessId) { * @returns {Boolean} Whether or not the entrance blip of the business was deleted */ function deleteBusinessEntranceBlip(businessId) { - if(!areServerElementsSupported()) { + if (!areServerElementsSupported()) { return false; } - if(getBusinessData(businessId).entranceBlip != null) { + if (!isGameFeatureSupported("blips")) { + return false; + } + + if (getBusinessData(businessId).entranceBlip != null) { //removeFromWorld(getBusinessData(businessId).entranceBlip); deleteGameElement(getBusinessData(businessId).entranceBlip); getBusinessData(businessId).entranceBlip = null; @@ -2217,11 +2261,15 @@ function deleteBusinessEntranceBlip(businessId) { * @returns {Boolean} Whether or not the exit blip of the business was deleted */ function deleteBusinessExitBlip(businessId) { - if(!areServerElementsSupported()) { + if (!areServerElementsSupported()) { return false; } - if(getBusinessData(businessId).exitBlip != null) { + if (!isGameFeatureSupported("blip")) { + return false; + } + + if (getBusinessData(businessId).exitBlip != null) { //removeFromWorld(getBusinessData(businessId).exitBlip); deleteGameElement(getBusinessData(businessId).exitBlip); getBusinessData(businessId).exitBlip = null; @@ -2241,11 +2289,11 @@ function deleteBusinessExitBlip(businessId) { */ function reloadAllBusinessesCommand(command, params, client) { let clients = getClients(); - for(let i in clients) { + for (let i in clients) { removePlayerFromBusiness(clients[i]); } - for(let i in getServerData().businesses) { + for (let i in getServerData().businesses) { deleteBusinessExitBlip(i); deleteBusinessEntranceBlip(i); deleteBusinessExitPickup(i); @@ -2271,7 +2319,7 @@ function reloadAllBusinessesCommand(command, params, client) { * @returns {Boolean} Whether or not the exit blip of the business was deleted */ function setBusinessDataIndexes() { - for(let i in getServerData().businesses) { + for (let i in getServerData().businesses) { getServerData().businesses[i].index = i; } } @@ -2291,7 +2339,7 @@ function addToBusinessInventory(businessId, itemType, amount, buyPrice) { saveItemToDatabase(tempItemData); getServerData().items.push(tempItemData); - let index = getServerData().items.length-1; + let index = getServerData().items.length - 1; getServerData().items[index].index = index; } @@ -2309,25 +2357,25 @@ function addToBusinessInventory(businessId, itemType, amount, buyPrice) { function buyFromBusinessCommand(command, params, client) { let businessId = getPlayerBusiness(client); - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { showBusinessFloorInventoryToPlayer(client, businessId); messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } - if(getBusinessData(businessId).locked) { + if (getBusinessData(businessId).locked) { messagePlayerError(client, `This business is closed!`); return false; } - if(getBusinessData(businessId).hasInterior) { - if(!getPlayerBusiness(client)) { - if(!doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForCommand(client, "enter")) { + if (getBusinessData(businessId).hasInterior) { + if (!getPlayerBusiness(client)) { + if (!doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForCommand(client, "enter")) { messagePlayerTip(client, getLocaleString(client, "NeedToEnterPropertyKeyPress", "business", `{ALTCOLOUR}${toUpperCase(getKeyNameFromId(getPlayerKeyBindForCommand(client, "enter")).key)}{MAINCOLOUR}`)); } else { messagePlayerNormal(client, getLocaleString(client, "NeedToEnterBusinessCommand", "business", "{ALTCOLOUR}/enter{MAINCOLOUR}")); @@ -2338,57 +2386,57 @@ function buyFromBusinessCommand(command, params, client) { let itemSlot = toInteger(getParam(params, " ", 1)) || 1; - if(typeof getBusinessData(businessId).floorItemCache[itemSlot-1] == "undefined") { + if (typeof getBusinessData(businessId).floorItemCache[itemSlot - 1] == "undefined") { messagePlayerError(client, `Item slot ${itemSlot} doesn't exist!`); return false; } - if(getBusinessData(businessId).floorItemCache[itemSlot-1] == -1) { + if (getBusinessData(businessId).floorItemCache[itemSlot - 1] == -1) { messagePlayerError(client, `Item slot ${itemSlot} slot is empty!`); return false; } let amount = 1; - if(areThereEnoughParams(params, 2, " ")) { + if (areThereEnoughParams(params, 2, " ")) { amount = toInteger(getParam(params, " ", 2)) || 1; - if(amount <= 0) { + if (amount <= 0) { messagePlayerError(client, getLocaleString(client, "AmountMustBeMoreThan", "0")); return false; } } - if(getItemData(getBusinessData(businessId).floorItemCache[itemSlot-1]).amount < amount) { - messagePlayerError(client, `There are only ${getItemData(getBusinessData(businessId).floorItemCache[itemSlot-1]).amount} ${getItemTypeData(getItemData(getBusinessData(businessId).floorItemCache[itemSlot-1]).itemTypeIndex).name} in slot ${itemSlot-1}`); + if (getItemData(getBusinessData(businessId).floorItemCache[itemSlot - 1]).amount < amount) { + messagePlayerError(client, `There are only ${getItemData(getBusinessData(businessId).floorItemCache[itemSlot - 1]).amount} ${getItemTypeData(getItemData(getBusinessData(businessId).floorItemCache[itemSlot - 1]).itemTypeIndex).name} in slot ${itemSlot - 1}`); return false; } let firstSlot = getPlayerFirstEmptyHotBarSlot(client); - if(firstSlot == -1) { + if (firstSlot == -1) { messagePlayerError(client, messagePlayerError(client, getLocaleString(client, "InventoryFullCantCarry"))); return false; } - let totalCost = getItemData(getBusinessData(businessId).floorItemCache[itemSlot-1]).buyPrice*amount; - let itemName = getItemTypeData(getItemData(getBusinessData(businessId).floorItemCache[itemSlot-1]).itemTypeIndex).name; + let totalCost = getItemData(getBusinessData(businessId).floorItemCache[itemSlot - 1]).buyPrice * amount; + let itemName = getItemTypeData(getItemData(getBusinessData(businessId).floorItemCache[itemSlot - 1]).itemTypeIndex).name; - if(getPlayerCurrentSubAccount(client).cash < totalCost) { - messagePlayerError(client, getLocaleString(client, "NotEnoughCashNeedAmountMore", `{ALTCOLOUR}${getBusinessData(businessId).floorItemCache[itemSlot-1].buyPrice*amount-getPlayerCurrentSubAccount(client).cash}{MAINCOLOUR}`)); + if (getPlayerCurrentSubAccount(client).cash < totalCost) { + messagePlayerError(client, getLocaleString(client, "NotEnoughCashNeedAmountMore", `{ALTCOLOUR}${getBusinessData(businessId).floorItemCache[itemSlot - 1].buyPrice * amount - getPlayerCurrentSubAccount(client).cash}{MAINCOLOUR}`)); return false; } takePlayerCash(client, totalCost); - createItem(getItemData(getBusinessData(businessId).floorItemCache[itemSlot-1]).itemTypeIndex, getItemData(getBusinessData(businessId).floorItemCache[itemSlot-1]).value, VRR_ITEM_OWNER_PLAYER, getPlayerCurrentSubAccount(client).databaseId, amount); + createItem(getItemData(getBusinessData(businessId).floorItemCache[itemSlot - 1]).itemTypeIndex, getItemData(getBusinessData(businessId).floorItemCache[itemSlot - 1]).value, VRR_ITEM_OWNER_PLAYER, getPlayerCurrentSubAccount(client).databaseId, amount); cachePlayerHotBarItems(client); getBusinessData(businessId).till = getBusinessData(businessId).till + totalCost; - getItemData(getBusinessData(businessId).floorItemCache[itemSlot-1]).amount = getItemData(getBusinessData(businessId).floorItemCache[itemSlot-1]).amount - amount; - if(getItemData(getBusinessData(businessId).floorItemCache[itemSlot-1]).amount == 0) { - destroyItem(getBusinessData(businessId).floorItemCache[itemSlot-1]); + getItemData(getBusinessData(businessId).floorItemCache[itemSlot - 1]).amount = getItemData(getBusinessData(businessId).floorItemCache[itemSlot - 1]).amount - amount; + if (getItemData(getBusinessData(businessId).floorItemCache[itemSlot - 1]).amount == 0) { + destroyItem(getBusinessData(businessId).floorItemCache[itemSlot - 1]); } - let useType = getItemTypeData(getItemData(getBusinessData(businessId).floorItemCache[itemSlot-1]).itemTypeIndex).useType; - if(useType == VRR_ITEM_USETYPE_WEAPON || VRR_ITEM_USETYPE_TAZER || useType == VRR_ITEM_USETYPE_AMMO_CLIP) { - if(isPlayerWeaponBanned(client) && !isPlayerExemptFromAntiCheat(client)) { + let useType = getItemTypeData(getItemData(getBusinessData(businessId).floorItemCache[itemSlot - 1]).itemTypeIndex).useType; + if (useType == VRR_ITEM_USETYPE_WEAPON || VRR_ITEM_USETYPE_TAZER || useType == VRR_ITEM_USETYPE_AMMO_CLIP) { + if (isPlayerWeaponBanned(client) && !isPlayerExemptFromAntiCheat(client)) { messagePlayerError(client, getLocaleString(client, "WeaponBanned")); return false; } @@ -2397,7 +2445,7 @@ function buyFromBusinessCommand(command, params, client) { //messagePlayerSuccess(client, `You bought ${amount} {ALTCOLOUR}${itemName} {MAINCOLOUR}for ${totalCost} ${priceEach}`); meActionToNearbyPlayers(client, `buys a ${itemName}`); - if(doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForCommand("inv")) { + if (doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForCommand("inv")) { let keyData = getPlayerKeyBindForCommand("inv"); messagePlayerNewbieTip(client, getLocaleString(client, "ViewInventoryKeyPressTip", `{ALTCOLOUR}${getKeyNameFromId(keyData.key)}{MAINCOLOUR}`)); } else { @@ -2419,33 +2467,33 @@ function buyFromBusinessCommand(command, params, client) { function setBusinessItemSellPriceCommand(command, params, client) { let businessId = getBusinessFromParams(getParam(params, " ", 3)) || getPlayerBusiness(client); - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } let itemSlot = toInteger(getParam(params, " ", 1)) || 0; - if(typeof getBusinessData(businessId).floorItemCache[itemSlot-1] == "undefined") { - messagePlayerError(client, `Item slot ${itemSlot-1} doesn't exist!`); + if (typeof getBusinessData(businessId).floorItemCache[itemSlot - 1] == "undefined") { + messagePlayerError(client, `Item slot ${itemSlot - 1} doesn't exist!`); return false; } - if(getBusinessData(businessId).floorItemCache[itemSlot-1] == -1) { - messagePlayerError(client, `Item slot ${itemSlot-1} slot is empty!`); + if (getBusinessData(businessId).floorItemCache[itemSlot - 1] == -1) { + messagePlayerError(client, `Item slot ${itemSlot - 1} slot is empty!`); return false; } - let oldPrice = getBusinessData(businessId).floorItemCache[itemSlot-1].buyPrice; + let oldPrice = getBusinessData(businessId).floorItemCache[itemSlot - 1].buyPrice; let newPrice = toInteger(getParam(params, " ", 2)) || oldPrice; - if(newPrice < 0) { + if (newPrice < 0) { messagePlayerError(client, "The price can't be negative!"); return false; } - getItemData(getBusinessData(businessId).floorItemCache[itemSlot-1]).buyPrice = newPrice; + getItemData(getBusinessData(businessId).floorItemCache[itemSlot - 1]).buyPrice = newPrice; - messagePlayerSuccess(client, `You changed the price of the {ALTCOLOUR}${getItemTypeData(getItemData(getBusinessData(businessId).floorItemCache[itemSlot-1]).itemTypeIndex).name}'s {MAINCOLOUR}in slot {ALTCOLOUR}${itemSlot} {MAINCOLOUR}from $${makeLargeNumberReadable(oldPrice)} to $${makeLargeNumberReadable(newprice)}`); + messagePlayerSuccess(client, `You changed the price of the {ALTCOLOUR}${getItemTypeData(getItemData(getBusinessData(businessId).floorItemCache[itemSlot - 1]).itemTypeIndex).name}'s {MAINCOLOUR}in slot {ALTCOLOUR}${itemSlot} {MAINCOLOUR}from $${makeLargeNumberReadable(oldPrice)} to $${makeLargeNumberReadable(newprice)}`); } // =========================================================================== @@ -2462,33 +2510,33 @@ function setBusinessItemSellPriceCommand(command, params, client) { function storeItemInBusinessStorageCommand(command, params, client) { let businessId = getBusinessFromParams(getParam(params, " ", 3)) || getPlayerBusiness(client); - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } let itemSlot = toInteger(getParam(params, " ", 1)) || 0; - if(typeof getBusinessData(businessId).floorItemCache[itemSlot-1] == "undefined") { + if (typeof getBusinessData(businessId).floorItemCache[itemSlot - 1] == "undefined") { messagePlayerError(client, `Item slot ${itemSlot} doesn't exist!`); return false; } - if(getBusinessData(businessId).floorItemCache[itemSlot-1] == -1) { + if (getBusinessData(businessId).floorItemCache[itemSlot - 1] == -1) { messagePlayerError(client, `Item slot ${itemSlot} slot is empty!`); return false; } let firstSlot = getBusinessStorageFirstFreeItemSlot(businessId); - if(firstSlot == -1) { + if (firstSlot == -1) { messagePlayerError(client, `There isn't any room in this business storage`); return false; } - getItemData(getBusinessData(businessId).floorItemCache[itemSlot-1]).ownerType = VRR_ITEM_OWNER_BIZSTORAGE; - getBusinessData(businessId).storageItemCache[firstSlot] = getBusinessData(businessId).floorItemCache[itemSlot-1]; - getBusinessData(businessId).storageItemCache[itemSlot-1] = -1; + getItemData(getBusinessData(businessId).floorItemCache[itemSlot - 1]).ownerType = VRR_ITEM_OWNER_BIZSTORAGE; + getBusinessData(businessId).storageItemCache[firstSlot] = getBusinessData(businessId).floorItemCache[itemSlot - 1]; + getBusinessData(businessId).storageItemCache[itemSlot - 1] = -1; messagePlayerSuccess(client, `You moved the ${getItemTypeData(getItemData(getBusinessData(businessId).storageItemCache[firstSlot]).itemTypeIndex).name}s in slot ${itemSlot} to the business storage in slot ${firstSlot}`); } @@ -2506,33 +2554,33 @@ function storeItemInBusinessStorageCommand(command, params, client) { function stockItemOnBusinessFloorCommand(command, params, client) { let businessId = getPlayerBusiness(client); - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } let itemSlot = toInteger(getParam(params, " ", 1)) || 0; - if(typeof getBusinessData(businessId).storageItemCache[itemSlot-1] == "undefined") { + if (typeof getBusinessData(businessId).storageItemCache[itemSlot - 1] == "undefined") { messagePlayerError(client, `Item slot ${itemSlot} doesn't exist!`); return false; } - if(getBusinessData(businessId).storageItemCache[itemSlot-1] == -1) { + if (getBusinessData(businessId).storageItemCache[itemSlot - 1] == -1) { messagePlayerError(client, `Item slot ${itemSlot} slot is empty!`); return false; } let firstSlot = getBusinessFloorFirstFreeItemSlot(businessId); - if(firstSlot == -1) { + if (firstSlot == -1) { messagePlayerError(client, `There isn't any room in this business storage`); return false; } - getItemData(getBusinessData(businessId).storageItemCache[itemSlot-1]).ownerType = VRR_ITEM_OWNER_BIZFLOOR; - getBusinessData(businessId).floorItemCache[firstSlot] = getBusinessData(businessId).storageItemCache[itemSlot-1]; - getBusinessData(businessId).storageItemCache[itemSlot-1] = -1; + getItemData(getBusinessData(businessId).storageItemCache[itemSlot - 1]).ownerType = VRR_ITEM_OWNER_BIZFLOOR; + getBusinessData(businessId).floorItemCache[firstSlot] = getBusinessData(businessId).storageItemCache[itemSlot - 1]; + getBusinessData(businessId).storageItemCache[itemSlot - 1] = -1; messagePlayerSuccess(client, `You moved the ${getItemTypeData(getItemData(getBusinessData(businessId).storageItemCache[firstSlot]).itemTypeIndex).name}s in slot ${itemSlot} of the business storage to the business floor slot ${firstSlot}`); } @@ -2555,7 +2603,7 @@ function getBusinessFloorFirstFreeItemSlot(businessId) { // Caches all items for all businesses function cacheAllBusinessItems() { logToConsole(LOG_DEBUG, "[VRR.Business] Caching all business items ..."); - for(let i in getServerData().businesses) { + for (let i in getServerData().businesses) { cacheBusinessItems(i); } logToConsole(LOG_DEBUG, "[VRR.Business] Cached all business items successfully!"); @@ -2574,10 +2622,10 @@ function cacheBusinessItems(businessId) { //getBusinessData(businessId).storageItemCache = getServerData().items.filter(item => item.ownerType == VRR_ITEM_OWNER_BIZSTORAGE && item.ownerId == businessData.databaseId); logToConsole(LOG_VERBOSE, `[VRR.Business] Caching business items for business ${businessId} (${getBusinessData(businessId).name}) ...`); - for(let i in getServerData().items) { - if(getItemData(i).ownerType == VRR_ITEM_OWNER_BIZFLOOR && getItemData(i).ownerId == getBusinessData(businessId).databaseId) { + for (let i in getServerData().items) { + if (getItemData(i).ownerType == VRR_ITEM_OWNER_BIZFLOOR && getItemData(i).ownerId == getBusinessData(businessId).databaseId) { getBusinessData(businessId).floorItemCache.push(i); - } else if(getItemData(i).ownerType == VRR_ITEM_OWNER_BIZSTORAGE && getItemData(i).ownerId == getBusinessData(businessId).databaseId) { + } else if (getItemData(i).ownerType == VRR_ITEM_OWNER_BIZSTORAGE && getItemData(i).ownerId == getBusinessData(businessId).databaseId) { getBusinessData(businessId).storageItemCache.push(i); } } @@ -2596,17 +2644,17 @@ function getBusinessIdFromDatabaseId(databaseId) { // Updates all pickup data for a business by businessId function updateBusinessPickupLabelData(businessId) { - if(!areServerElementsSupported()) { + if (!areServerElementsSupported()) { return false; } - if(getBusinessData(businessId).exitPickup != null) { + if (getBusinessData(businessId).exitPickup != null) { setEntityData(getBusinessData(businessId).exitPickup, "vrr.owner.type", VRR_PICKUP_BUSINESS_EXIT, false); setEntityData(getBusinessData(businessId).exitPickup, "vrr.owner.id", businessId, false); setEntityData(getBusinessData(businessId).exitPickup, "vrr.label.type", VRR_LABEL_EXIT, true); } - if(getBusinessData(businessId).entrancePickup != null) { + if (getBusinessData(businessId).entrancePickup != null) { setEntityData(getBusinessData(businessId).entrancePickup, "vrr.owner.type", VRR_PICKUP_BUSINESS_ENTRANCE, false); setEntityData(getBusinessData(businessId).entrancePickup, "vrr.owner.id", businessId, false); setEntityData(getBusinessData(businessId).entrancePickup, "vrr.label.type", VRR_LABEL_BUSINESS, true); @@ -2614,7 +2662,7 @@ function updateBusinessPickupLabelData(businessId) { setEntityData(getBusinessData(businessId).entrancePickup, "vrr.label.locked", getBusinessData(businessId).locked, true); setEntityData(getBusinessData(businessId).entrancePickup, "vrr.label.help", VRR_PROPLABEL_INFO_NONE, true); - switch(getBusinessData(businessId).labelHelpType) { + switch (getBusinessData(businessId).labelHelpType) { case VRR_PROPLABEL_INFO_ENTERVEHICLE: { setEntityData(getBusinessData(businessId).entrancePickup, "vrr.label.help", VRR_PROPLABEL_INFO_ENTERVEHICLE, true); break; @@ -2631,10 +2679,10 @@ function updateBusinessPickupLabelData(businessId) { } default: { - if(getBusinessData(businessId).hasInterior) { + if (getBusinessData(businessId).hasInterior) { setEntityData(getBusinessData(businessId).entrancePickup, "vrr.label.help", VRR_PROPLABEL_INFO_ENTER, true); } else { - if(doesBusinessHaveAnyItemsToBuy(businessId)) { + if (doesBusinessHaveAnyItemsToBuy(businessId)) { setEntityData(getBusinessData(businessId).entrancePickup, "vrr.label.help", VRR_PROPLABEL_INFO_BUY, true); } else { removeEntityData(getBusinessData(businessId).entrancePickup, "vrr.label.help"); @@ -2675,7 +2723,7 @@ function resetAllBusinessPickups(businessId) { // =========================================================================== function resetAllBusinessBlips() { - for(let i in getServerData().businesses) { + for (let i in getServerData().businesses) { deleteBusinessBlips(i); createBusinessBlips(i); } @@ -2691,7 +2739,7 @@ function createBusinessBlips(businessId) { // =========================================================================== function resetAllBusinessPickups() { - for(let i in getServerData().businesses) { + for (let i in getServerData().businesses) { deleteBusinessPickups(i); createBusinessPickups(i); } @@ -2730,8 +2778,8 @@ function doesBusinessHaveAnyItemsToBuy(businessId) { function updateBusinessInteriorLightsForOccupants(businessId) { let clients = getClients() - for(let i in clients) { - if(getPlayerBusiness(clients[i]) == businessId) { + for (let i in clients) { + if (getPlayerBusiness(clients[i]) == businessId) { updateInteriorLightsForPlayer(clients[i], getBusinessData(businessId).interiorLights); } } @@ -2740,16 +2788,16 @@ function updateBusinessInteriorLightsForOccupants(businessId) { // =========================================================================== function canPlayerWithdrawFromBusinessTill(client, businessId) { - if(doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageBusinesses"))) { + if (doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageBusinesses"))) { return true; } - if(getBusinessData(businessId).ownerType == VRR_BIZOWNER_PLAYER && getBusinessData(businessId).ownerId == getPlayerCurrentSubAccount(client).databaseId) { + if (getBusinessData(businessId).ownerType == VRR_BIZOWNER_PLAYER && getBusinessData(businessId).ownerId == getPlayerCurrentSubAccount(client).databaseId) { return true; } - if(getBusinessData(businessId).ownerType == VRR_BIZOWNER_CLAN && getBusinessData(businessId).ownerId == getClanData(getPlayerClan(client)).databaseId) { - if(doesPlayerHaveClanPermission(client, getClanFlagValue("ManageBusinesses"))) { + if (getBusinessData(businessId).ownerType == VRR_BIZOWNER_CLAN && getBusinessData(businessId).ownerId == getClanData(getPlayerClan(client)).databaseId) { + if (doesPlayerHaveClanPermission(client, getClanFlagValue("ManageBusinesses"))) { return true; } } @@ -2760,16 +2808,16 @@ function canPlayerWithdrawFromBusinessTill(client, businessId) { // =========================================================================== function canPlayerSetBusinessInteriorLights(client, businessId) { - if(doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageBusinesses"))) { + if (doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageBusinesses"))) { return true; } - if(getBusinessData(businessId).ownerType == VRR_BIZOWNER_PLAYER && getBusinessData(businessId).ownerId == getPlayerCurrentSubAccount(client).databaseId) { + if (getBusinessData(businessId).ownerType == VRR_BIZOWNER_PLAYER && getBusinessData(businessId).ownerId == getPlayerCurrentSubAccount(client).databaseId) { return true; } - if(getBusinessData(businessId).ownerType == VRR_BIZOWNER_CLAN && getBusinessData(businessId).ownerId == getClanData(getPlayerClan(client)).databaseId) { - if(doesPlayerHaveClanPermission(client, getClanFlagValue("ManageBusinesses"))) { + if (getBusinessData(businessId).ownerType == VRR_BIZOWNER_CLAN && getBusinessData(businessId).ownerId == getClanData(getPlayerClan(client)).databaseId) { + if (doesPlayerHaveClanPermission(client, getClanFlagValue("ManageBusinesses"))) { return true; } } @@ -2780,16 +2828,16 @@ function canPlayerSetBusinessInteriorLights(client, businessId) { // =========================================================================== function canPlayerLockUnlockBusiness(client, businessId) { - if(doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageBusinesses"))) { + if (doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageBusinesses"))) { return true; } - if(getBusinessData(businessId).ownerType == VRR_BIZOWNER_PLAYER && getBusinessData(businessId).ownerId == getPlayerCurrentSubAccount(client).databaseId) { + if (getBusinessData(businessId).ownerType == VRR_BIZOWNER_PLAYER && getBusinessData(businessId).ownerId == getPlayerCurrentSubAccount(client).databaseId) { return true; } - if(getBusinessData(businessId).ownerType == VRR_BIZOWNER_CLAN && getBusinessData(businessId).ownerId == getClanData(getPlayerClan(client)).databaseId) { - if(doesPlayerHaveClanPermission(client, getClanFlagValue("ManageBusinesses"))) { + if (getBusinessData(businessId).ownerType == VRR_BIZOWNER_CLAN && getBusinessData(businessId).ownerId == getClanData(getPlayerClan(client)).databaseId) { + if (doesPlayerHaveClanPermission(client, getClanFlagValue("ManageBusinesses"))) { return true; } } @@ -2800,19 +2848,19 @@ function canPlayerLockUnlockBusiness(client, businessId) { // =========================================================================== function canPlayerManageBusiness(client, businessId) { - if(doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageBusinesses"))) { + if (doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageBusinesses"))) { return true; } - if(getBusinessData(businessId).ownerType == VRR_BIZOWNER_PLAYER) { - if(getBusinessData(businessId).ownerId == getPlayerCurrentSubAccount(client).databaseId) { + if (getBusinessData(businessId).ownerType == VRR_BIZOWNER_PLAYER) { + if (getBusinessData(businessId).ownerId == getPlayerCurrentSubAccount(client).databaseId) { return true; } } - if(getBusinessData(businessId).ownerType == VRR_BIZOWNER_CLAN) { - if(getBusinessData(businessId).ownerId == getPlayerClan(client)) { - if(doesPlayerHaveClanPermission(client, getClanFlagValue("ManageBusinesses"))) { + if (getBusinessData(businessId).ownerType == VRR_BIZOWNER_CLAN) { + if (getBusinessData(businessId).ownerId == getPlayerClan(client)) { + if (doesPlayerHaveClanPermission(client, getClanFlagValue("ManageBusinesses"))) { return true; } @@ -2842,14 +2890,14 @@ function deleteBusinessPickups(business) { // =========================================================================== function getBusinessFromParams(params) { - if(isNaN(params)) { - for(let i in getServerData().businesses) { - if(toLowerCase(getServerData().businesses[i].name).indexOf(toLowerCase(params)) != -1) { + if (isNaN(params)) { + for (let i in getServerData().businesses) { + if (toLowerCase(getServerData().businesses[i].name).indexOf(toLowerCase(params)) != -1) { return i; } } } else { - if(typeof getServerData().businesses[params] != "undefined") { + if (typeof getServerData().businesses[params] != "undefined") { return toInteger(params); } } @@ -2859,7 +2907,7 @@ function getBusinessFromParams(params) { // =========================================================================== function deleteAllBusinessBlips() { - for(let i in getServerData().businesses) { + for (let i in getServerData().businesses) { deleteBusinessBlips(i); } } @@ -2867,7 +2915,7 @@ function deleteAllBusinessBlips() { // =========================================================================== function deleteAllBusinessPickups() { - for(let i in getServerData().businesses) { + for (let i in getServerData().businesses) { deleteBusinessPickups(i); } } @@ -2876,8 +2924,8 @@ function deleteAllBusinessPickups() { function getBusinessFromInteriorAndDimension(dimension, interior) { let businesses = getServerData().businesses; - for(let i in businesses) { - if(businesses[i].exitInterior == interior && businesses[i].exitDimension == dimension) { + for (let i in businesses) { + if (businesses[i].exitInterior == interior && businesses[i].exitDimension == dimension) { return i; } } @@ -2891,8 +2939,8 @@ function getClosestBusinessWithBuyableItemOfUseType(position, useType) { let availableBusinesses = getBusinessesWithBuyableItemOfUseType(useType); let closestBusiness = 0; - for(let i in availableBusinesses) { - if(getDistance(position, getBusinessData(availableBusinesses[i]).entrancePosition) < getDistance(position, getBusinessData(availableBusinesses[closestBusiness]).entrancePosition)) { + for (let i in availableBusinesses) { + if (getDistance(position, getBusinessData(availableBusinesses[i]).entrancePosition) < getDistance(position, getBusinessData(availableBusinesses[closestBusiness]).entrancePosition)) { closestBusiness = i; } } @@ -2903,8 +2951,8 @@ function getClosestBusinessWithBuyableItemOfUseType(position, useType) { function getBusinessesWithBuyableItemOfUseType(useType) { let businesses = getServerData().businesses; - for(let i in businesses) { - if(doesBusinessHaveBuyableItemOfUseType(i, useType)) { + for (let i in businesses) { + if (doesBusinessHaveBuyableItemOfUseType(i, useType)) { availableBusinesses.push(i); } } @@ -2916,10 +2964,10 @@ function getBusinessesWithBuyableItemOfUseType(useType) { function doesBusinessHaveBuyableItemOfUseType(businessId, useType) { let floorItems = getBusinessData(businessId).floorItemCache; - for(let i in floorItems) { - if(floorItems[i] != -1) { - if(getItemData(floorItems[i]) != false) { - if(getItemTypeData(getItemData(floorItems[i])).useType == useType) { + for (let i in floorItems) { + if (floorItems[i] != -1) { + if (getItemData(floorItems[i]) != false) { + if (getItemTypeData(getItemData(floorItems[i])).useType == useType) { return true; } }