From f80406b907e88af8910c039de7ba8f9923aa8f11 Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Wed, 16 Dec 2020 08:00:32 -0600 Subject: [PATCH] Add bus route stuff, move route/stop data to array --- scripts/server/job/bus.js | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/scripts/server/job/bus.js b/scripts/server/job/bus.js index cb7c0225..1feb3297 100644 --- a/scripts/server/job/bus.js +++ b/scripts/server/job/bus.js @@ -101,13 +101,21 @@ let busRoutes = [ // --------------------------------------------------------------------------- +function getRandomBusRoute(island) { + let islandBusRoutes = busRoutes[getServerGame()].filter(busRoute => busRoute.island == island); + let randomRoute = getRandom(0, islandBusRoutes.length-1); + return islandBusRoutes[randomRoute]; +} + +// --------------------------------------------------------------------------- + function getNextStopOnBusRoute(client) { - if(getEntityData(client, "ag.busRoute") && getEntityData(client, "ag.lastBusStop")) { + if(getClientData(client).busRoute && getClientData(client).lastBusStop) { if(!isGoingToLastStopOnBusRoute(client)) { - return busRoutes[server.game][getEntityData(client, "ag.busRoute")].positions[getEntityData(client, "ag.lastBusStop")+1]; + return busRoutes[getServerGame()][getClientData(client).busRoute].positions[getClientData(client).lastBusStop+1]; } else { - let slot = busRoutes[server.game][getEntityData(client, "ag.busRoute")].length-1; - return busRoutes[server.game][getEntityData(client, "ag.busRoute")].positions[slot]; + let slot = busRoutes[getServerGame()][getClientData(client).busRoute].length-1; + return busRoutes[getServerGame()][getClientData(client).busRoute].positions[slot]; } } } @@ -115,8 +123,8 @@ function getNextStopOnBusRoute(client) { // --------------------------------------------------------------------------- function isGoingToLastStopOnBusRoute(client) { - if(getEntityData(client, "ag.busRoute") && getEntityData(client, "ag.lastBusStop")) { - if(getEntityData(client, "ag.lastBusStop")+1 == busRoutes[server.game][getEntityData(client, "ag.busRoute")].length-1) { + if(getClientData(client).busRoute && getClientData(client).lastBusStop) { + if(getClientData(client).lastBusStop+1 == busRoutes[getServerGame()][getClientData(client).busRoute].length-1) { return true; } }