Use data table for some client stuff

This commit is contained in:
Vortrex
2022-04-05 23:58:10 -05:00
parent 36ca910651
commit 0b4bdd308a
4 changed files with 23 additions and 10 deletions

View File

@@ -81,7 +81,7 @@ function receiveBusinessFromServer(businessId, name, entrancePosition, blipModel
} else { } else {
logToConsole(LOG_DEBUG, `[VRR.Business] Business ${businessId} has no blip.`); logToConsole(LOG_DEBUG, `[VRR.Business] Business ${businessId} has no blip.`);
} }
businesses.push(tempBusinessData); getServerData().businesses.push(tempBusinessData);
setAllBusinessDataIndexes(); setAllBusinessDataIndexes();
} }
} }
@@ -96,6 +96,9 @@ function receiveBusinessFromServer(businessId, name, entrancePosition, blipModel
function getBusinessData(businessId) { function getBusinessData(businessId) {
//let tempBusinessData = businesses.find((b) => b.businessId == businessId); //let tempBusinessData = businesses.find((b) => b.businessId == businessId);
//return (typeof tempBusinessData != "undefined") ? tempBusinessData[0] : false; //return (typeof tempBusinessData != "undefined") ? tempBusinessData[0] : false;
let businesses = getServerData().businesses;
for(let i in businesses) { for(let i in businesses) {
if(businesses[i].businessId == businessId) { if(businesses[i].businessId == businessId) {
return businesses[i]; return businesses[i];
@@ -108,8 +111,8 @@ function getBusinessData(businessId) {
// =========================================================================== // ===========================================================================
function setAllBusinessDataIndexes() { function setAllBusinessDataIndexes() {
for(let i in businesses) { for(let i in getServerData().businesses) {
businesses[i].index = i; getServerData().businesses[i].index = i;
} }
} }

View File

@@ -75,7 +75,7 @@ function receiveHouseFromServer(houseId, entrancePosition, blipModel, pickupMode
} else { } else {
logToConsole(LOG_DEBUG, `[VRR.House] House ${houseId} has no blip.`); logToConsole(LOG_DEBUG, `[VRR.House] House ${houseId} has no blip.`);
} }
houses.push(tempHouseData); getServerData().houses.push(tempHouseData);
setAllHouseDataIndexes(); setAllHouseDataIndexes();
} }
} }
@@ -88,6 +88,7 @@ function receiveHouseFromServer(houseId, entrancePosition, blipModel, pickupMode
* @return {HouseData} The house's data (class instance) * @return {HouseData} The house's data (class instance)
*/ */
function getHouseData(houseId) { function getHouseData(houseId) {
let houses = getServerData().houses;
for(let i in houses) { for(let i in houses) {
if(houses[i].houseId == houseId) { if(houses[i].houseId == houseId) {
return houses[i]; return houses[i];
@@ -100,8 +101,8 @@ function receiveHouseFromServer(houseId, entrancePosition, blipModel, pickupMode
// =========================================================================== // ===========================================================================
function setAllHouseDataIndexes() { function setAllHouseDataIndexes() {
for(let i in houses) { for(let i in getServerData().houses) {
houses[i].index = i; getServerData().houses[i].index = i;
} }
} }

View File

@@ -69,9 +69,12 @@ let forceWantedLevel = 0;
// Pre-cache all allowed skins // Pre-cache all allowed skins
let allowedSkins = getAllowedSkins(getGame()); let allowedSkins = getAllowedSkins(getGame());
let businesses = []; let serverData = {
let houses = []; houses: [],
let jobs = []; businesses: [],
let vehicles = []; localeStrings: [],
vehicles: [],
jobs: [],
};
// =========================================================================== // ===========================================================================

View File

@@ -821,4 +821,10 @@ function processVehicleFires() {
} }
} }
// ===========================================================================
function getServerData() {
return serverData;
}
// =========================================================================== // ===========================================================================