Add bus route stuff, move route/stop data to array

This commit is contained in:
Vortrex
2020-12-16 08:00:32 -06:00
parent e9cc4bf0f1
commit f80406b907

View File

@@ -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) { function getNextStopOnBusRoute(client) {
if(getEntityData(client, "ag.busRoute") && getEntityData(client, "ag.lastBusStop")) { if(getClientData(client).busRoute && getClientData(client).lastBusStop) {
if(!isGoingToLastStopOnBusRoute(client)) { 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 { } else {
let slot = busRoutes[server.game][getEntityData(client, "ag.busRoute")].length-1; let slot = busRoutes[getServerGame()][getClientData(client).busRoute].length-1;
return busRoutes[server.game][getEntityData(client, "ag.busRoute")].positions[slot]; return busRoutes[getServerGame()][getClientData(client).busRoute].positions[slot];
} }
} }
} }
@@ -115,8 +123,8 @@ function getNextStopOnBusRoute(client) {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function isGoingToLastStopOnBusRoute(client) { function isGoingToLastStopOnBusRoute(client) {
if(getEntityData(client, "ag.busRoute") && getEntityData(client, "ag.lastBusStop")) { if(getClientData(client).busRoute && getClientData(client).lastBusStop) {
if(getEntityData(client, "ag.lastBusStop")+1 == busRoutes[server.game][getEntityData(client, "ag.busRoute")].length-1) { if(getClientData(client).lastBusStop+1 == busRoutes[getServerGame()][getClientData(client).busRoute].length-1) {
return true; return true;
} }
} }