From 13defbeb638989dc49c92f96221539ed3ff79e63 Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Sun, 27 Dec 2020 21:24:44 -0600 Subject: [PATCH] Fix send biz labels to client --- scripts/server/business.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/scripts/server/business.js b/scripts/server/business.js index f34accc8..a534b9cd 100644 --- a/scripts/server/business.js +++ b/scripts/server/business.js @@ -769,11 +769,20 @@ function doesBusinessHaveInterior(businessId) { function sendAllBusinessLabelsToPlayer(client) { let tempBusinessLabels = []; - for(let i in getServerData().businesses) { - tempBusinessLabels.push([i, getServerData().businesses[i].entrancePosition, getGameConfig().propertyLabelHeight[getServerGame()], getServerData().businesses[i].name, getServerData().businesses[i].locked, false]); + let totalBusinesses = getServerData().businesses.length; + let businessesPerNetworkEvent = 100; + let totalNetworkEvents = Math.ceil(totalBusinesses/businessesPerNetworkEvent); + for(let i = 0 ; i < totalNetworkEvents ; i++) { + for(let j = 0 ; j < businessesPerNetworkEvent ; j++) { + let tempBusinessId = (i*businessesPerNetworkEvent)+j; + if(typeof getServerData().businesses[tempBusinessId] != "undefined") { + let tempBusinessLabels = []; + tempBusinessLabels.push([tempBusinessId, getServerData().businesses[tempBusinessId].entrancePosition, getGameConfig().propertyLabelHeight[getServerGame()], getServerData().businesses[tempBusinessId].description, getServerData().businesses[tempBusinessId].locked, false]); + } + } + triggerNetworkEvent("ag.bizlabel.all", client, tempBusinessLabels); + tempBusinessLabels = []; } - - triggerNetworkEvent("ag.bizlabel.all", client, tempBusinessLabels); } // ---------------------------------------------------------------------------