Rename getServerGame to getGame to match client

This commit is contained in:
Vortrex
2022-04-28 11:32:35 -05:00
parent f4ff54178c
commit b1256193ef
14 changed files with 157 additions and 154 deletions

View File

@@ -835,7 +835,7 @@ function checkLogin(client, password) {
} }
if(isAccountEmailVerified(getPlayerData(client).accountData) && isAccountSettingFlagEnabled(getPlayerData(client).accountData, getAccountSettingsFlagValue("AuthAttemptAlert"))) { if(isAccountEmailVerified(getPlayerData(client).accountData) && isAccountSettingFlagEnabled(getPlayerData(client).accountData, getAccountSettingsFlagValue("AuthAttemptAlert"))) {
sendAccountLoginFailedNotification(getPlayerData(client).accountData.emailAddress, getPlayerName(client), getPlayerIP(client), getServerGame()); sendAccountLoginFailedNotification(getPlayerData(client).accountData.emailAddress, getPlayerName(client), getPlayerIP(client), getGame());
} }
return false; return false;
} }
@@ -851,7 +851,7 @@ function checkLogin(client, password) {
} }
if(isAccountEmailVerified(getPlayerData(client).accountData) && isAccountSettingFlagEnabled(getPlayerData(client).accountData, getAccountSettingsFlagValue("AuthAttemptAlert"))) { if(isAccountEmailVerified(getPlayerData(client).accountData) && isAccountSettingFlagEnabled(getPlayerData(client).accountData, getAccountSettingsFlagValue("AuthAttemptAlert"))) {
sendAccountLoginFailedNotification(getPlayerData(client).accountData.emailAddress, getPlayerName(client), getPlayerIP(client), getServerGame()); sendAccountLoginFailedNotification(getPlayerData(client).accountData.emailAddress, getPlayerName(client), getPlayerIP(client), getGame());
} }
return false; return false;
} }
@@ -869,7 +869,7 @@ function checkLogin(client, password) {
loginSuccess(client); loginSuccess(client);
if(isAccountEmailVerified(getPlayerData(client).accountData) && isAccountSettingFlagEnabled(getPlayerData(client).accountData, getAccountSettingsFlagValue("AuthAttemptAlert"))) { if(isAccountEmailVerified(getPlayerData(client).accountData) && isAccountSettingFlagEnabled(getPlayerData(client).accountData, getAccountSettingsFlagValue("AuthAttemptAlert"))) {
sendAccountLoginSuccessNotification(getPlayerData(client).accountData.emailAddress, getPlayerName(client), getPlayerIP(client), getServerGame()); sendAccountLoginSuccessNotification(getPlayerData(client).accountData.emailAddress, getPlayerName(client), getPlayerIP(client), getGame());
} }
} }
@@ -1468,7 +1468,7 @@ function verifyAccountEmail(accountData, verificationCode) {
// =========================================================================== // ===========================================================================
function sendAccountLoginFailedNotification(emailAddress, name, ip, game = getServerGame()) { function sendAccountLoginFailedNotification(emailAddress, name, ip, game = getGame()) {
let countryName = module.geoip.getCountryName(getGlobalConfig().geoIPCountryDatabaseFilePath, ip); let countryName = module.geoip.getCountryName(getGlobalConfig().geoIPCountryDatabaseFilePath, ip);
let subDivisionName = module.geoip.getSubdivisionName(getGlobalConfig().geoIPCityDatabaseFilePath, ip); let subDivisionName = module.geoip.getSubdivisionName(getGlobalConfig().geoIPCityDatabaseFilePath, ip);
let cityName = module.geoip.getCityName(getGlobalConfig().geoIPCityDatabaseFilePath, ip); let cityName = module.geoip.getCityName(getGlobalConfig().geoIPCityDatabaseFilePath, ip);
@@ -1486,7 +1486,7 @@ function sendAccountLoginFailedNotification(emailAddress, name, ip, game = getSe
// =========================================================================== // ===========================================================================
function sendAccountLoginSuccessNotification(emailAddress, name, ip, game = getServerGame()) { function sendAccountLoginSuccessNotification(emailAddress, name, ip, game = getGame()) {
let countryName = module.geoip.getCountryName(getGlobalConfig().geoIPCountryDatabaseFilePath, ip); let countryName = module.geoip.getCountryName(getGlobalConfig().geoIPCountryDatabaseFilePath, ip);
let subDivisionName = module.geoip.getSubdivisionName(getGlobalConfig().geoIPCityDatabaseFilePath, ip); let subDivisionName = module.geoip.getSubdivisionName(getGlobalConfig().geoIPCityDatabaseFilePath, ip);
let cityName = module.geoip.getCityName(getGlobalConfig().geoIPCityDatabaseFilePath, ip); let cityName = module.geoip.getCityName(getGlobalConfig().geoIPCityDatabaseFilePath, ip);

View File

@@ -70,7 +70,7 @@ function stopPlayerAnimationCommand(command, params, client) {
// =========================================================================== // ===========================================================================
function showAnimationListCommand(command, params, client) { function showAnimationListCommand(command, params, client) {
let animList = getGameConfig().animations[getServerGame()].map(function(x) { return x.name; }); let animList = getGameConfig().animations[getGame()].map(function(x) { return x.name; });
let chunkedList = splitArrayIntoChunks(animList, 10); let chunkedList = splitArrayIntoChunks(animList, 10);
@@ -87,7 +87,7 @@ function showAnimationListCommand(command, params, client) {
* @param {number} animationSlot - The slot index of the animation * @param {number} animationSlot - The slot index of the animation
* @return {Array} The animation's data (array) * @return {Array} The animation's data (array)
*/ */
function getAnimationData(animationSlot, gameId = getServerGame()) { function getAnimationData(animationSlot, gameId = getGame()) {
return getGameConfig().animations[gameId][animationSlot]; return getGameConfig().animations[gameId][animationSlot];
} }
@@ -144,7 +144,7 @@ function makePlayerStopAnimation(client) {
// =========================================================================== // ===========================================================================
function getAnimationFromParams(params) { function getAnimationFromParams(params) {
let animations = getGameConfig().animations[getServerGame()]; let animations = getGameConfig().animations[getGame()];
if(isNaN(params)) { if(isNaN(params)) {
for(let i in animations) { for(let i in animations) {
if(toLowerCase(animations[i].name).indexOf(toLowerCase(params)) != -1) { if(toLowerCase(animations[i].name).indexOf(toLowerCase(params)) != -1) {
@@ -152,7 +152,7 @@ function getAnimationFromParams(params) {
} }
} }
} else { } else {
if(typeof getGameConfig().animations[getServerGame()][params] != "undefined") { if(typeof getGameConfig().animations[getGame()][params] != "undefined") {
return toInteger(params); return toInteger(params);
} }
} }

View File

@@ -140,7 +140,7 @@ function loadBusinessGameScriptsFromDatabase(businessId) {
* *
*/ */
function createBusinessCommand(command, params, client) { function createBusinessCommand(command, params, client) {
let tempBusinessData = createBusiness(params, getPlayerPosition(client), toVector3(0.0, 0.0, 0.0), getGameConfig().pickupModels[getServerGame()].Business, getGameConfig().blipSprites[getServerGame()].Business, getPlayerInterior(client), getPlayerDimension(client), getPlayerData(client).interiorCutscene); let tempBusinessData = createBusiness(params, getPlayerPosition(client), toVector3(0.0, 0.0, 0.0), getGameConfig().pickupModels[getGame()].Business, getGameConfig().blipSprites[getGame()].Business, getPlayerInterior(client), getPlayerDimension(client), getPlayerData(client).interiorCutscene);
tempBusinessData.needsSaved = true; tempBusinessData.needsSaved = true;
let businessId = getServerData().businesses.push(tempBusinessData); let businessId = getServerData().businesses.push(tempBusinessData);
setBusinessDataIndexes(); setBusinessDataIndexes();
@@ -796,9 +796,9 @@ function setBusinessPickupCommand(command, params, client) {
} }
if(isNaN(typeParam)) { if(isNaN(typeParam)) {
if(isNull(getGameConfig().pickupModels[getServerGame()][typeParam])) { if(isNull(getGameConfig().pickupModels[getGame()][typeParam])) {
messagePlayerError(client, "Invalid pickup type! Use a pickup type name or a model ID"); messagePlayerError(client, "Invalid pickup type! Use a pickup type name or a model ID");
let pickupTypes = Object.keys(getGameConfig().pickupModels[getServerGame()]); let pickupTypes = Object.keys(getGameConfig().pickupModels[getGame()]);
let chunkedList = splitArrayIntoChunks(pickupTypes, 10); let chunkedList = splitArrayIntoChunks(pickupTypes, 10);
messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderPickupTypes"))); messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderPickupTypes")));
@@ -808,7 +808,7 @@ function setBusinessPickupCommand(command, params, client) {
return false; return false;
} }
getBusinessData(businessId).entrancePickupModel = getGameConfig().pickupModels[getServerGame()][typeParam]; getBusinessData(businessId).entrancePickupModel = getGameConfig().pickupModels[getGame()][typeParam];
} else { } else {
getBusinessData(businessId).entrancePickupModel = toInteger(typeParam); getBusinessData(businessId).entrancePickupModel = toInteger(typeParam);
} }
@@ -857,9 +857,9 @@ function setBusinessInteriorTypeCommand(command, params, client) {
return false; return false;
} }
if(isNull(getGameConfig().interiors[getServerGame()][typeParam])) { if(isNull(getGameConfig().interiors[getGame()][typeParam])) {
messagePlayerError(client, "Invalid interior type! Use an interior type name"); messagePlayerError(client, "Invalid interior type! Use an interior type name");
let interiorTypesList = Object.keys(getGameConfig().interiors[getServerGame()]); let interiorTypesList = Object.keys(getGameConfig().interiors[getGame()]);
let chunkedList = splitArrayIntoChunks(interiorTypesList, 10); let chunkedList = splitArrayIntoChunks(interiorTypesList, 10);
messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderInteriorTypes"))); messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderInteriorTypes")));
@@ -869,12 +869,12 @@ function setBusinessInteriorTypeCommand(command, params, client) {
return false; return false;
} }
getBusinessData(businessId).exitPosition = getGameConfig().interiors[getServerGame()][typeParam][0]; getBusinessData(businessId).exitPosition = getGameConfig().interiors[getGame()][typeParam][0];
getBusinessData(businessId).exitInterior = getGameConfig().interiors[getServerGame()][typeParam][1]; 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[getServerGame()].Exit; getBusinessData(businessId).exitPickupModel = getGameConfig().pickupModels[getGame()].Exit;
if(getGameConfig().interiors[getServerGame()][typeParam].length == 3) { if(getGameConfig().interiors[getGame()][typeParam].length == 3) {
getBusinessData(businessId).interiorCutscene = getGameConfig().interiors[getServerGame()][typeParam][2]; getBusinessData(businessId).interiorCutscene = getGameConfig().interiors[getGame()][typeParam][2];
} }
getBusinessData(businessId).hasInterior = true; getBusinessData(businessId).hasInterior = true;
} }
@@ -912,10 +912,10 @@ function setBusinessBlipCommand(command, params, client) {
} }
if(isNaN(typeParam)) { if(isNaN(typeParam)) {
if(isNull(getGameConfig().blipSprites[getServerGame()][typeParam])) { if(isNull(getGameConfig().blipSprites[getGame()][typeParam])) {
messagePlayerError(client, "Invalid business type! Use a business type name or a blip image ID"); messagePlayerError(client, "Invalid business type! Use a business type name or a blip image ID");
let blipTypes = Object.keys(getGameConfig().blipSprites[getServerGame()]); let blipTypes = Object.keys(getGameConfig().blipSprites[getGame()]);
let chunkedList = splitArrayIntoChunks(blipTypes, 10); let chunkedList = splitArrayIntoChunks(blipTypes, 10);
messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderBlipTypes"))); messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderBlipTypes")));
@@ -925,7 +925,7 @@ function setBusinessBlipCommand(command, params, client) {
return false; return false;
} }
getBusinessData(businessId).entranceBlipModel = getGameConfig().blipSprites[getServerGame()][typeParam]; getBusinessData(businessId).entranceBlipModel = getGameConfig().blipSprites[getGame()][typeParam];
} else { } else {
getBusinessData(businessId).entranceBlipModel = toInteger(typeParam); getBusinessData(businessId).entranceBlipModel = toInteger(typeParam);
} }
@@ -961,9 +961,9 @@ function giveDefaultItemsToBusinessCommand(command, params, client) {
return false; return false;
} }
if(isNull(getGameConfig().defaultBusinessItems[getServerGame()][typeParam])) { if(isNull(getGameConfig().defaultBusinessItems[getGame()][typeParam])) {
messagePlayerError(client, "Invalid business items type! Use a business items type name"); messagePlayerError(client, "Invalid business items type! Use a business items type name");
let businessItemTypes = Object.keys(getGameConfig().defaultBusinessItems[getServerGame()]); let businessItemTypes = Object.keys(getGameConfig().defaultBusinessItems[getGame()]);
let chunkedList = splitArrayIntoChunks(businessItemTypes, 10); let chunkedList = splitArrayIntoChunks(businessItemTypes, 10);
messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderDefaultBusinessItemTypes"))); messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderDefaultBusinessItemTypes")));
@@ -973,12 +973,12 @@ function giveDefaultItemsToBusinessCommand(command, params, client) {
return false; return false;
} }
for(let i in getGameConfig().defaultBusinessItems[getServerGame()][typeParam]) { for(let i in getGameConfig().defaultBusinessItems[getGame()][typeParam]) {
let itemTypeId = getItemTypeFromParams(getGameConfig().defaultBusinessItems[getServerGame()][typeParam][i][0]); let itemTypeId = getItemTypeFromParams(getGameConfig().defaultBusinessItems[getGame()][typeParam][i][0]);
let itemTypeData = getItemTypeData(itemTypeId); let itemTypeData = getItemTypeData(itemTypeId);
if(itemTypeData) { if(itemTypeData) {
let newItemIndex = createItem(itemTypeId, itemTypeData.orderValue, VRR_ITEM_OWNER_BIZFLOOR, getBusinessData(businessId).databaseId, getGameConfig().defaultBusinessItems[getServerGame()][typeParam][i][1]); 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[getServerGame()][typeParam][i][2]; getItemData(newItemIndex).buyPrice = applyServerInflationMultiplier(itemTypeData.orderPrice)*getGameConfig().defaultBusinessItems[getGame()][typeParam][i][2];
} }
} }
@@ -1681,7 +1681,7 @@ function createBusinessEntrancePickup(businessId) {
} }
if(getBusinessData(businessId).entrancePickupModel != -1) { if(getBusinessData(businessId).entrancePickupModel != -1) {
let pickupModelId = getGameConfig().pickupModels[getServerGame()].Business; let pickupModelId = getGameConfig().pickupModels[getGame()].Business;
if(getServerData().businesses[businessId].entrancePickupModel != 0) { if(getServerData().businesses[businessId].entrancePickupModel != 0) {
pickupModelId = getBusinessData(businessId).entrancePickupModel; pickupModelId = getBusinessData(businessId).entrancePickupModel;
@@ -1690,7 +1690,7 @@ function createBusinessEntrancePickup(businessId) {
logToConsole(LOG_VERBOSE, `[VRR.Job]: Creating entrance pickup for business ${getBusinessData(businessId).name} (model ${pickupModelId})`); logToConsole(LOG_VERBOSE, `[VRR.Job]: Creating entrance pickup for business ${getBusinessData(businessId).name} (model ${pickupModelId})`);
if(areServerElementsSupported()) { if(areServerElementsSupported()) {
let entrancePickup = createGamePickup(pickupModelId, getBusinessData(businessId).entrancePosition, getGameConfig().pickupTypes[getServerGame()].business); let entrancePickup = createGamePickup(pickupModelId, getBusinessData(businessId).entrancePosition, getGameConfig().pickupTypes[getGame()].business);
if(entrancePickup != null) { if(entrancePickup != null) {
setElementOnAllDimensions(entrancePickup, false); setElementOnAllDimensions(entrancePickup, false);
setElementDimension(entrancePickup, getBusinessData(businessId).entranceDimension); setElementDimension(entrancePickup, getBusinessData(businessId).entranceDimension);
@@ -1732,7 +1732,7 @@ function createBusinessEntranceBlip(businessId) {
} }
if(getBusinessData(businessId).entranceBlipModel != -1) { if(getBusinessData(businessId).entranceBlipModel != -1) {
let blipModelId = getGameConfig().blipSprites[getServerGame()].Business; let blipModelId = getGameConfig().blipSprites[getGame()].Business;
if(getServerData().businesses[businessId].entranceBlipModel != 0) { if(getServerData().businesses[businessId].entranceBlipModel != 0) {
blipModelId = getBusinessData(businessId).entranceBlipModel; blipModelId = getBusinessData(businessId).entranceBlipModel;
@@ -1777,7 +1777,7 @@ function createBusinessExitPickup(businessId) {
if(getBusinessData(businessId).hasInterior) { if(getBusinessData(businessId).hasInterior) {
if(getBusinessData(businessId).exitPickupModel != -1) { if(getBusinessData(businessId).exitPickupModel != -1) {
let pickupModelId = getGameConfig().pickupModels[getServerGame()].Exit; let pickupModelId = getGameConfig().pickupModels[getGame()].Exit;
if(getServerData().businesses[businessId].exitPickupModel != 0) { if(getServerData().businesses[businessId].exitPickupModel != 0) {
pickupModelId = getBusinessData(businessId).exitPickupModel; pickupModelId = getBusinessData(businessId).exitPickupModel;
@@ -1786,7 +1786,7 @@ function createBusinessExitPickup(businessId) {
logToConsole(LOG_VERBOSE, `[VRR.Job]: Creating exit pickup for business ${getBusinessData(businessId).name} (model ${pickupModelId})`); logToConsole(LOG_VERBOSE, `[VRR.Job]: Creating exit pickup for business ${getBusinessData(businessId).name} (model ${pickupModelId})`);
if(areServerElementsSupported()) { if(areServerElementsSupported()) {
let exitPickup = createGamePickup(pickupModelId, getBusinessData(businessId).exitPosition, getGameConfig().pickupTypes[getServerGame()].business); let exitPickup = createGamePickup(pickupModelId, getBusinessData(businessId).exitPosition, getGameConfig().pickupTypes[getGame()].business);
if(exitPickup != null) { if(exitPickup != null) {
setElementDimension(exitPickup, getBusinessData(businessId).exitDimension); setElementDimension(exitPickup, getBusinessData(businessId).exitDimension);
setElementOnAllDimensions(exitPickup, false); setElementOnAllDimensions(exitPickup, false);
@@ -1819,7 +1819,7 @@ function createBusinessExitBlip(businessId) {
if(getBusinessData(businessId).hasInterior) { if(getBusinessData(businessId).hasInterior) {
if(getBusinessData(businessId).exitBlipModel != -1) { if(getBusinessData(businessId).exitBlipModel != -1) {
let blipModelId = getGameConfig().blipSprites[getServerGame()].Business; let blipModelId = getGameConfig().blipSprites[getGame()].Business;
if(getServerData().businesses[businessId].exitBlipModel != 0) { if(getServerData().businesses[businessId].exitBlipModel != 0) {
blipModelId = getBusinessData(businessId).exitBlipModel; blipModelId = getBusinessData(businessId).exitBlipModel;

View File

@@ -216,7 +216,7 @@ function syncPlayerProperties(client) {
// =========================================================================== // ===========================================================================
function updatePlayerSnowState(client) { function updatePlayerSnowState(client) {
if(isSnowSupported(getServerGame())) { if(isSnowSupported(getGame())) {
logToConsole(LOG_DEBUG, `[VRR.Client] Setting ${getPlayerDisplayForConsole(client)}'s snow state (Falling: ${toUpperCase(getOnOffFromBool(getServerConfig().fallingSnow))}, Ground: ${toUpperCase(getOnOffFromBool(getServerConfig().groundSnow))})`); logToConsole(LOG_DEBUG, `[VRR.Client] Setting ${getPlayerDisplayForConsole(client)}'s snow state (Falling: ${toUpperCase(getOnOffFromBool(getServerConfig().fallingSnow))}, Ground: ${toUpperCase(getOnOffFromBool(getServerConfig().groundSnow))})`);
sendNetworkEventToPlayer("vrr.snow", client, getServerConfig().fallingSnow, getServerConfig().groundSnow); sendNetworkEventToPlayer("vrr.snow", client, getServerConfig().fallingSnow, getServerConfig().groundSnow);
} }
@@ -729,16 +729,16 @@ function updateHeadingInVehicleData(client, vehicle, heading) {
// =========================================================================== // ===========================================================================
function forcePlayerIntoSkinSelect(client) { function forcePlayerIntoSkinSelect(client) {
if(typeof getGameConfig().skinChangePosition[getServerGame()] != "undefined") { if(typeof getGameConfig().skinChangePosition[getGame()] != "undefined") {
getPlayerData(client).returnToPosition = getPlayerPosition(client); getPlayerData(client).returnToPosition = getPlayerPosition(client);
getPlayerData(client).returnToHeading = getPlayerHeading(client); getPlayerData(client).returnToHeading = getPlayerHeading(client);
getPlayerData(client).returnToInterior = getPlayerInterior(client); getPlayerData(client).returnToInterior = getPlayerInterior(client);
getPlayerData(client).returnToDimension = getPlayerDimension(client); getPlayerData(client).returnToDimension = getPlayerDimension(client);
getPlayerData(client).returnToType = VRR_RETURNTO_TYPE_SKINSELECT; getPlayerData(client).returnToType = VRR_RETURNTO_TYPE_SKINSELECT;
setPlayerPosition(client, getGameConfig().skinChangePosition[getServerGame()][0]); setPlayerPosition(client, getGameConfig().skinChangePosition[getGame()][0]);
setPlayerHeading(client, getGameConfig().skinChangePosition[getServerGame()][1]); setPlayerHeading(client, getGameConfig().skinChangePosition[getGame()][1]);
setPlayerInterior(client, getGameConfig().skinChangePosition[getServerGame()][2]); setPlayerInterior(client, getGameConfig().skinChangePosition[getGame()][2]);
setPlayerDimension(client, getPlayerId(client)+500); setPlayerDimension(client, getPlayerId(client)+500);
} }
@@ -754,14 +754,14 @@ function updatePlayerCash(client) {
// =========================================================================== // ===========================================================================
function sendAllPoliceStationBlips(client) { function sendAllPoliceStationBlips(client) {
if(getGameConfig().blipSprites[getServerGame()].policeStation != -1) { if(getGameConfig().blipSprites[getGame()].policeStation != -1) {
let tempBlips = []; let tempBlips = [];
for(let i in getServerData().policeStations[getServerGame()]) { for(let i in getServerData().policeStations[getGame()]) {
tempBlips.push([ tempBlips.push([
getGameConfig().blipSprites[getServerGame()].policeStation, getGameConfig().blipSprites[getGame()].policeStation,
getServerData().policeStations[getServerGame()][i].position.x, getServerData().policeStations[getGame()][i].position.x,
getServerData().policeStations[getServerGame()][i].position.y, getServerData().policeStations[getGame()][i].position.y,
getServerData().policeStations[getServerGame()][i].position.z, getServerData().policeStations[getGame()][i].position.z,
3, 3,
getColourByName("policeBlue"), getColourByName("policeBlue"),
]); ]);
@@ -773,14 +773,14 @@ function sendAllPoliceStationBlips(client) {
// =========================================================================== // ===========================================================================
function sendAllFireStationBlips(client) { function sendAllFireStationBlips(client) {
if(getGameConfig().blipSprites[getServerGame()].fireStation != -1) { if(getGameConfig().blipSprites[getGame()].fireStation != -1) {
let tempBlips = []; let tempBlips = [];
for(let i in getServerData().fireStations[getServerGame()]) { for(let i in getServerData().fireStations[getGame()]) {
tempBlips.push([ tempBlips.push([
getGameConfig().blipSprites[getServerGame()].fireStation, getGameConfig().blipSprites[getGame()].fireStation,
getServerData().fireStations[getServerGame()][i].position.x, getServerData().fireStations[getGame()][i].position.x,
getServerData().fireStations[getServerGame()][i].position.y, getServerData().fireStations[getGame()][i].position.y,
getServerData().fireStations[getServerGame()][i].position.z, getServerData().fireStations[getGame()][i].position.z,
3, 3,
getColourByName("firefighterRed"), getColourByName("firefighterRed"),
]); ]);
@@ -792,14 +792,14 @@ function sendAllFireStationBlips(client) {
// =========================================================================== // ===========================================================================
function sendAllHospitalBlips(client) { function sendAllHospitalBlips(client) {
if(getGameConfig().blipSprites[getServerGame()].hospital != -1) { if(getGameConfig().blipSprites[getGame()].hospital != -1) {
let tempBlips = []; let tempBlips = [];
for(let i in getServerData().hospitals[getServerGame()]) { for(let i in getServerData().hospitals[getGame()]) {
tempBlips.push([ tempBlips.push([
getGameConfig().blipSprites[getServerGame()].hospital, getGameConfig().blipSprites[getGame()].hospital,
getServerData().hospitals[getServerGame()][i].position.x, getServerData().hospitals[getGame()][i].position.x,
getServerData().hospitals[getServerGame()][i].position.y, getServerData().hospitals[getGame()][i].position.y,
getServerData().hospitals[getServerGame()][i].position.z, getServerData().hospitals[getGame()][i].position.z,
3, 3,
getColourByName("medicPink"), getColourByName("medicPink"),
]); ]);
@@ -811,14 +811,14 @@ function sendAllHospitalBlips(client) {
// =========================================================================== // ===========================================================================
function sendAllAmmunationBlips(client) { function sendAllAmmunationBlips(client) {
if(getGameConfig().blipSprites[getServerGame()].ammunation != -1) { if(getGameConfig().blipSprites[getGame()].ammunation != -1) {
let tempBlips = []; let tempBlips = [];
for(let i in getServerData().ammunations[getServerGame()]) { for(let i in getServerData().ammunations[getGame()]) {
tempBlips.push([ tempBlips.push([
getGameConfig().blipSprites[getServerGame()].ammunation, getGameConfig().blipSprites[getGame()].ammunation,
getServerData().ammunations[getServerGame()][i].position.x, getServerData().ammunations[getGame()][i].position.x,
getServerData().ammunations[getServerGame()][i].position.y, getServerData().ammunations[getGame()][i].position.y,
getServerData().ammunations[getServerGame()][i].position.z, getServerData().ammunations[getGame()][i].position.z,
3, 3,
0 0
]); ]);
@@ -830,14 +830,14 @@ function sendAllAmmunationBlips(client) {
// =========================================================================== // ===========================================================================
function sendAllPayAndSprayBlips(client) { function sendAllPayAndSprayBlips(client) {
if(getGameConfig().blipSprites[getServerGame()].payAndSpray != -1) { if(getGameConfig().blipSprites[getGame()].payAndSpray != -1) {
let tempBlips = []; let tempBlips = [];
for(let i in getServerData().payAndSprays[getServerGame()]) { for(let i in getServerData().payAndSprays[getGame()]) {
tempBlips.push([ tempBlips.push([
getGameConfig().blipSprites[getServerGame()].payAndSpray, getGameConfig().blipSprites[getGame()].payAndSpray,
getServerData().payAndSprays[getServerGame()][i].position.x, getServerData().payAndSprays[getGame()][i].position.x,
getServerData().payAndSprays[getServerGame()][i].position.y, getServerData().payAndSprays[getGame()][i].position.y,
getServerData().payAndSprays[getServerGame()][i].position.z, getServerData().payAndSprays[getGame()][i].position.z,
3, 3,
0 0
]); ]);
@@ -849,14 +849,14 @@ function sendAllPayAndSprayBlips(client) {
// =========================================================================== // ===========================================================================
function sendAllFuelStationBlips(client) { function sendAllFuelStationBlips(client) {
if(getGameConfig().blipSprites[getServerGame()].fuelStation != -1) { if(getGameConfig().blipSprites[getGame()].fuelStation != -1) {
let tempBlips = []; let tempBlips = [];
for(let i in getServerData().fuelStations[getServerGame()]) { for(let i in getServerData().fuelStations[getGame()]) {
tempBlips.push([ tempBlips.push([
getGameConfig().blipSprites[getServerGame()].fuelStation, getGameConfig().blipSprites[getGame()].fuelStation,
getServerData().fuelStations[getServerGame()][i].position.x, getServerData().fuelStations[getGame()][i].position.x,
getServerData().fuelStations[getServerGame()][i].position.y, getServerData().fuelStations[getGame()][i].position.y,
getServerData().fuelStations[getServerGame()][i].position.z, getServerData().fuelStations[getGame()][i].position.z,
3, 3,
getColourByName("burntOrange"), getColourByName("burntOrange"),
]); ]);

View File

@@ -480,7 +480,7 @@ function onPlayerSpawn(client) {
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)}'s player data is valid. Continuing spawn processing ...`); logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)}'s player data is valid. Continuing spawn processing ...`);
if(getServerGame() == VRR_GAME_GTA_IV) { if(getGame() == VRR_GAME_GTA_IV) {
logToConsole(LOG_DEBUG, `[VRR.Event] Setting ${getPlayerDisplayForConsole(client)}'s ped body parts and props`); logToConsole(LOG_DEBUG, `[VRR.Event] Setting ${getPlayerDisplayForConsole(client)}'s ped body parts and props`);
setEntityData(getPlayerPed(client), "vrr.bodyParts", getPlayerCurrentSubAccount(client).bodyParts, true); setEntityData(getPlayerPed(client), "vrr.bodyParts", getPlayerCurrentSubAccount(client).bodyParts, true);
setEntityData(getPlayerPed(client), "vrr.bodyProps", getPlayerCurrentSubAccount(client).bodyProps, true); setEntityData(getPlayerPed(client), "vrr.bodyProps", getPlayerCurrentSubAccount(client).bodyProps, true);
@@ -538,7 +538,7 @@ function onPlayerSpawn(client) {
updatePlayerSnowState(client); updatePlayerSnowState(client);
} }
if(areServerElementsSupported() && getServerGame() == VRR_GAME_GTA_SA) { if(areServerElementsSupported() && getGame() == VRR_GAME_GTA_SA) {
logToConsole(LOG_DEBUG, `[VRR.Event] Setting player walk and fightstyle for ${getPlayerDisplayForConsole(client)}`); logToConsole(LOG_DEBUG, `[VRR.Event] Setting player walk and fightstyle for ${getPlayerDisplayForConsole(client)}`);
setEntityData(getPlayerPed(client), "vrr.walkStyle", getPlayerCurrentSubAccount(client).walkStyle, true); setEntityData(getPlayerPed(client), "vrr.walkStyle", getPlayerCurrentSubAccount(client).walkStyle, true);

View File

@@ -7,6 +7,13 @@
// TYPE: Server (JavaScript) // TYPE: Server (JavaScript)
// =========================================================================== // ===========================================================================
function initGateScript() {
logToConsole(LOG_INFO, `[VRR.Gate]: Initializing gate script ...`);
logToConsole(LOG_INFO, `[VRR.Gate]: Gate script initialized successfully!`);
}
// ===========================================================================
function doesPlayerHaveGateKeys(client, vehicle) { function doesPlayerHaveGateKeys(client, vehicle) {
let gateData = getGateData(vehicle); let gateData = getGateData(vehicle);
@@ -91,7 +98,7 @@ function getGateData(gateId) {
function getClosestGate(position) { function getClosestGate(position) {
let closest = 0; let closest = 0;
for(let i in getServerData().gates[getServerGame()]) { for(let i in getServerData().gates[getGame()]) {
if(getDistance(getServerData().gates[i].position, position) < getDistance(getServerData().gates[closest].position, position)) { if(getDistance(getServerData().gates[i].position, position) < getDistance(getServerData().gates[closest].position, position)) {
closest = i; closest = i;
} }
@@ -185,7 +192,7 @@ function saveGateToDatabase(gateId) {
} }
logToConsole(LOG_VERBOSE, `[VRR.Gate]: Saved gate ${gateDataId} to database!`); logToConsole(LOG_VERBOSE, `[VRR.Gate]: Saved gate ${gateDataId} to database!`);
return false; return true;
} }
// =========================================================================== // ===========================================================================

View File

@@ -54,14 +54,14 @@ function createHouseCommand(command, params, client) {
let entranceLocation = new HouseLocationData(false); let entranceLocation = new HouseLocationData(false);
entranceLocation.entrancePosition = getPlayerPosition(client); entranceLocation.entrancePosition = getPlayerPosition(client);
entranceLocation.entranceRotation = 0.0; entranceLocation.entranceRotation = 0.0;
entranceLocation.entrancePickupModel = getGameConfig().pickupModels[getServerGame()].House; entranceLocation.entrancePickupModel = getGameConfig().pickupModels[getGame()].House;
entranceLocation.entranceBlipModel = getGameConfig().blipSprites[getServerGame()].House; entranceLocation.entranceBlipModel = getGameConfig().blipSprites[getGame()].House;
entranceLocation.entranceInterior = 0; entranceLocation.entranceInterior = 0;
entranceLocation.entranceDimension = 0; entranceLocation.entranceDimension = 0;
entranceLocation.exitPosition = toVector3(0.0, 0.0, 0.0); entranceLocation.exitPosition = toVector3(0.0, 0.0, 0.0);
entranceLocation.exitRotation = 0.0; entranceLocation.exitRotation = 0.0;
entranceLocation.exitPickupModel = getGameConfig().pickupModels[getServerGame()].Exit; entranceLocation.exitPickupModel = getGameConfig().pickupModels[getGame()].Exit;
entranceLocation.exitBlipModel = -1; entranceLocation.exitBlipModel = -1;
entranceLocation.exitInterior = 0; entranceLocation.exitInterior = 0;
entranceLocation.exitDimension = 0; entranceLocation.exitDimension = 0;
@@ -297,9 +297,9 @@ function setHousePickupCommand(command, params, client) {
if(toLowerCase(typeParam) == "None") { if(toLowerCase(typeParam) == "None") {
getHouseData(houseId).entrancePickupModel = -1; getHouseData(houseId).entrancePickupModel = -1;
} else { } else {
if(isNull(getGameConfig().pickupModels[getServerGame()][typeParam])) { if(isNull(getGameConfig().pickupModels[getGame()][typeParam])) {
messagePlayerError(client, "Invalid pickup type! Use a pickup type name or a model ID"); messagePlayerError(client, "Invalid pickup type! Use a pickup type name or a model ID");
let pickupTypes = Object.keys(getGameConfig().pickupModels[getServerGame()]); let pickupTypes = Object.keys(getGameConfig().pickupModels[getGame()]);
let chunkedList = splitArrayIntoChunks(pickupTypes, 10); let chunkedList = splitArrayIntoChunks(pickupTypes, 10);
messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderPickupTypes"))); messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderPickupTypes")));
@@ -309,7 +309,7 @@ function setHousePickupCommand(command, params, client) {
return false; return false;
} }
getHouseData(houseId).entrancePickupModel = getGameConfig().pickupModels[getServerGame()][typeParam]; getHouseData(houseId).entrancePickupModel = getGameConfig().pickupModels[getGame()][typeParam];
} }
} else { } else {
getHouseData(houseId).entrancePickupModel = toInteger(typeParam); getHouseData(houseId).entrancePickupModel = toInteger(typeParam);
@@ -360,9 +360,9 @@ function setHouseInteriorTypeCommand(command, params, client) {
return false; return false;
} }
if(isNull(getGameConfig().interiors[getServerGame()][typeParam])) { if(isNull(getGameConfig().interiors[getGame()][typeParam])) {
messagePlayerError(client, "Invalid interior type! Use an interior type name"); messagePlayerError(client, "Invalid interior type! Use an interior type name");
let interiorTypesList = Object.keys(getGameConfig().interiors[getServerGame()]); let interiorTypesList = Object.keys(getGameConfig().interiors[getGame()]);
let chunkedList = splitArrayIntoChunks(interiorTypesList, 10); let chunkedList = splitArrayIntoChunks(interiorTypesList, 10);
messagePlayerNormal(client, makeChatBoxSectionHeader("InteriorTypes")); messagePlayerNormal(client, makeChatBoxSectionHeader("InteriorTypes"));
@@ -372,10 +372,10 @@ function setHouseInteriorTypeCommand(command, params, client) {
return false; return false;
} }
getHouseData(houseId).exitPosition = getGameConfig().interiors[getServerGame()][typeParam][0]; getHouseData(houseId).exitPosition = getGameConfig().interiors[getGame()][typeParam][0];
getHouseData(houseId).exitInterior = getGameConfig().interiors[getServerGame()][typeParam][1]; getHouseData(houseId).exitInterior = getGameConfig().interiors[getGame()][typeParam][1];
getHouseData(houseId).exitDimension = getHouseData(houseId).databaseId+getGlobalConfig().houseDimensionStart; getHouseData(houseId).exitDimension = getHouseData(houseId).databaseId+getGlobalConfig().houseDimensionStart;
getHouseData(houseId).exitPickupModel = getGameConfig().pickupModels[getServerGame()].Exit; getHouseData(houseId).exitPickupModel = getGameConfig().pickupModels[getGame()].Exit;
getHouseData(houseId).hasInterior = true; getHouseData(houseId).hasInterior = true;
} }
@@ -413,8 +413,8 @@ function setHouseBlipCommand(command, params, client) {
if(toLowerCase(typeParam) == "None") { if(toLowerCase(typeParam) == "None") {
getHouseData(houseId).entranceBlipModel = -1; getHouseData(houseId).entranceBlipModel = -1;
} else { } else {
if(isNull(getGameConfig().blipSprites[getServerGame()][typeParam])) { if(isNull(getGameConfig().blipSprites[getGame()][typeParam])) {
let blipTypes = Object.keys(getGameConfig().blipSprites[getServerGame()]); let blipTypes = Object.keys(getGameConfig().blipSprites[getGame()]);
let chunkedList = splitArrayIntoChunks(blipTypes, 10); let chunkedList = splitArrayIntoChunks(blipTypes, 10);
messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderBlipTypes"))); messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderBlipTypes")));
@@ -424,7 +424,7 @@ function setHouseBlipCommand(command, params, client) {
return false; return false;
} }
getHouseData(houseId).entranceBlipModel = getGameConfig().blipSprites[getServerGame()][typeParam]; getHouseData(houseId).entranceBlipModel = getGameConfig().blipSprites[getGame()][typeParam];
} }
} else { } else {
getHouseData(houseId).entranceBlipModel = toInteger(typeParam); getHouseData(houseId).entranceBlipModel = toInteger(typeParam);
@@ -835,14 +835,14 @@ function createHouseEntrancePickup(houseId) {
} }
if(getHouseData(houseId).entrancePickupModel != -1) { if(getHouseData(houseId).entrancePickupModel != -1) {
let pickupModelId = getGameConfig().pickupModels[getServerGame()].House; let pickupModelId = getGameConfig().pickupModels[getGame()].House;
if(getServerData().houses[houseId].entrancePickupModel != 0) { if(getServerData().houses[houseId].entrancePickupModel != 0) {
pickupModelId = getHouseData(houseId).entrancePickupModel; pickupModelId = getHouseData(houseId).entrancePickupModel;
} }
if(areServerElementsSupported()) { if(areServerElementsSupported()) {
let entrancePickup = createGamePickup(pickupModelId, getHouseData(houseId).entrancePosition, getGameConfig().pickupTypes[getServerGame()].house); let entrancePickup = createGamePickup(pickupModelId, getHouseData(houseId).entrancePosition, getGameConfig().pickupTypes[getGame()].house);
if(entrancePickup != null) { if(entrancePickup != null) {
setElementOnAllDimensions(entrancePickup, false); setElementOnAllDimensions(entrancePickup, false);
setElementDimension(entrancePickup, getHouseData(houseId).entranceDimension); setElementDimension(entrancePickup, getHouseData(houseId).entranceDimension);
@@ -866,7 +866,7 @@ function createHouseEntranceBlip(houseId) {
} }
if(getHouseData(houseId).entranceBlipModel != -1) { if(getHouseData(houseId).entranceBlipModel != -1) {
let blipModelId = getGameConfig().blipSprites[getServerGame()].House; let blipModelId = getGameConfig().blipSprites[getGame()].House;
if(getServerData().houses[houseId].entranceBlipModel != 0) { if(getServerData().houses[houseId].entranceBlipModel != 0) {
blipModelId = getHouseData(houseId).entranceBlipModel; blipModelId = getHouseData(houseId).entranceBlipModel;
@@ -899,14 +899,14 @@ function createHouseExitPickup(houseId) {
if(getHouseData(houseId).hasInterior) { if(getHouseData(houseId).hasInterior) {
if(getHouseData(houseId).exitPickupModel != -1) { if(getHouseData(houseId).exitPickupModel != -1) {
let pickupModelId = getGameConfig().pickupModels[getServerGame()].Exit; let pickupModelId = getGameConfig().pickupModels[getGame()].Exit;
if(getServerData().houses[houseId].exitPickupModel != 0) { if(getServerData().houses[houseId].exitPickupModel != 0) {
pickupModelId = getHouseData(houseId).exitPickupModel; pickupModelId = getHouseData(houseId).exitPickupModel;
} }
if(areServerElementsSupported()) { if(areServerElementsSupported()) {
let exitPickup = createGamePickup(pickupModelId, getHouseData(houseId).exitPosition, getGameConfig().pickupTypes[getServerGame()].house); let exitPickup = createGamePickup(pickupModelId, getHouseData(houseId).exitPosition, getGameConfig().pickupTypes[getGame()].house);
if(exitPickup != null) { if(exitPickup != null) {
setElementDimension(exitPickup, getHouseData(houseId).exitDimension); setElementDimension(exitPickup, getHouseData(houseId).exitDimension);
setElementOnAllDimensions(exitPickup, false); setElementOnAllDimensions(exitPickup, false);
@@ -932,7 +932,7 @@ function createHouseExitBlip(houseId) {
if(getHouseData(houseId).hasInterior) { if(getHouseData(houseId).hasInterior) {
if(getHouseData(houseId).exitBlipModel != -1) { if(getHouseData(houseId).exitBlipModel != -1) {
let blipModelId = getGameConfig().blipSprites[getServerGame()].House; let blipModelId = getGameConfig().blipSprites[getGame()].House;
if(getServerData().houses[houseId].exitBlipModel != 0) { if(getServerData().houses[houseId].exitBlipModel != 0) {
blipModelId = getHouseData(houseId).exitBlipModel; blipModelId = getHouseData(houseId).exitBlipModel;

View File

@@ -1071,7 +1071,7 @@ function setJobBlipCommand(command, params, client) {
if(toLowerCase(blipParam) == "none") { if(toLowerCase(blipParam) == "none") {
blipId = -1; blipId = -1;
} else { } else {
let blipTypes = Object.keys(getGameConfig().blipSprites[getServerGame()]).join(", "); let blipTypes = Object.keys(getGameConfig().blipSprites[getGame()]).join(", ");
let chunkedList = splitArrayIntoChunks(blipTypes, 10); let chunkedList = splitArrayIntoChunks(blipTypes, 10);
messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderBlipTypes"))); messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderBlipTypes")));
@@ -1079,7 +1079,7 @@ function setJobBlipCommand(command, params, client) {
messagePlayerInfo(client, chunkedList[i].join(", ")); messagePlayerInfo(client, chunkedList[i].join(", "));
} }
blipId = getGameConfig().blipSprites[getServerGame()][blipParam]; blipId = getGameConfig().blipSprites[getGame()][blipParam];
blipString = toString(blipParam); blipString = toString(blipParam);
} }
} else { } else {
@@ -1116,7 +1116,7 @@ function setJobPickupCommand(command, params, client) {
if(toLowerCase(pickupParam) == "none") { if(toLowerCase(pickupParam) == "none") {
pickupId = -1; pickupId = -1;
} else { } else {
let pickupTypes = Object.keys(getGameConfig().pickupModels[getServerGame()]).join(", "); let pickupTypes = Object.keys(getGameConfig().pickupModels[getGame()]).join(", ");
let chunkedList = splitArrayIntoChunks(pickupTypes, 10); let chunkedList = splitArrayIntoChunks(pickupTypes, 10);
messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderPickupTypes"))); messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderPickupTypes")));
@@ -1124,7 +1124,7 @@ function setJobPickupCommand(command, params, client) {
messagePlayerInfo(client, chunkedList[i].join(", ")); messagePlayerInfo(client, chunkedList[i].join(", "));
} }
pickupId = getGameConfig().pickupModels[getServerGame()][pickupParam]; pickupId = getGameConfig().pickupModels[getGame()][pickupParam];
pickupString = toString(pickupParam); pickupString = toString(pickupParam);
} }
} else { } else {
@@ -2287,7 +2287,7 @@ function createJobLocationPickup(jobId, locationId) {
let tempJobData = getJobData(jobId); let tempJobData = getJobData(jobId);
if(tempJobData.pickupModel != -1) { if(tempJobData.pickupModel != -1) {
let pickupModelId = getGameConfig().pickupModels[getServerGame()].Job; let pickupModelId = getGameConfig().pickupModels[getGame()].Job;
if(tempJobData.pickupModel != 0) { if(tempJobData.pickupModel != 0) {
pickupModelId = tempJobData.pickupModel; pickupModelId = tempJobData.pickupModel;
@@ -2296,7 +2296,7 @@ function createJobLocationPickup(jobId, locationId) {
logToConsole(LOG_VERBOSE, `[VRR.Job]: Creating pickup for location ${locationId} of the ${tempJobData.name} job`); logToConsole(LOG_VERBOSE, `[VRR.Job]: Creating pickup for location ${locationId} of the ${tempJobData.name} job`);
if(areServerElementsSupported()) { if(areServerElementsSupported()) {
let pickup = createGamePickup(pickupModelId, tempJobData.locations[locationId].position, getGameConfig().pickupTypes[getServerGame()].job); let pickup = createGamePickup(pickupModelId, tempJobData.locations[locationId].position, getGameConfig().pickupTypes[getGame()].job);
if(pickup != false) { if(pickup != false) {
tempJobData.locations[locationId].pickup = pickup; tempJobData.locations[locationId].pickup = pickup;
setElementDimension(pickup, tempJobData.locations[locationId].dimension); setElementDimension(pickup, tempJobData.locations[locationId].dimension);
@@ -2324,7 +2324,7 @@ function createJobLocationBlip(jobId, locationId) {
let tempJobData = getJobData(jobId); let tempJobData = getJobData(jobId);
if(getJobData(jobId).blipModel != -1) { if(getJobData(jobId).blipModel != -1) {
let blipModelId = getGameConfig().blipSprites[getServerGame()].Job; let blipModelId = getGameConfig().blipSprites[getGame()].Job;
if(getJobData(jobId).blipModel != 0) { if(getJobData(jobId).blipModel != 0) {
blipModelId = getJobData(jobId).blipModel; blipModelId = getJobData(jobId).blipModel;
@@ -2731,7 +2731,7 @@ function getClosestJobRouteLocation(position) {
// =========================================================================== // ===========================================================================
function getJobPointsInRange(position, distance) { function getJobPointsInRange(position, distance) {
return getServerData().jobs[getServerGame()].filter(x => x.position.distance(position) <= distance); return getServerData().jobs[getGame()].filter(x => x.position.distance(position) <= distance);
} }
// =========================================================================== // ===========================================================================

View File

@@ -517,7 +517,7 @@ function gpsCommand(command, params, client) {
} else { } else {
let gameLocationId = getGameLocationFromParams(params); let gameLocationId = getGameLocationFromParams(params);
if(gameLocationId != false) { if(gameLocationId != false) {
position = getGameConfig().locations[getServerGame()][gameLocationId][1] position = getGameConfig().locations[getGame()][gameLocationId][1]
} }
} }
} }
@@ -575,7 +575,7 @@ function stuckPlayerCommand(command, params, client) {
messagePlayerAlert(client, getLocaleString(client, "FixingStuck")); messagePlayerAlert(client, getLocaleString(client, "FixingStuck"));
if(getGameConfig().skinChangePosition[getServerGame()].length > 0) { if(getGameConfig().skinChangePosition[getGame()].length > 0) {
if(getPlayerData(client).returnToPosition != null && getPlayerData(client).returnToType == VRR_RETURNTO_TYPE_SKINSELECT) { if(getPlayerData(client).returnToPosition != null && getPlayerData(client).returnToType == VRR_RETURNTO_TYPE_SKINSELECT) {
messagePlayerAlert(client, "You canceled the skin change."); messagePlayerAlert(client, "You canceled the skin change.");
restorePlayerCamera(client); restorePlayerCamera(client);

View File

@@ -420,12 +420,6 @@ function givePlayerArmour(client, amount) {
// =========================================================================== // ===========================================================================
function getServerGame() {
return getGame();
}
// ===========================================================================
function consolePrint(text) { function consolePrint(text) {
console.log(text); console.log(text);
} }
@@ -495,7 +489,7 @@ function destroyGameElement(element) {
// =========================================================================== // ===========================================================================
function isMeleeWeapon(weaponId, gameId = getServerGame()) { function isMeleeWeapon(weaponId, gameId = getGame()) {
return (getGameConfig().meleeWeapons[gameId].indexOf(weaponId) != -1); return (getGameConfig().meleeWeapons[gameId].indexOf(weaponId) != -1);
} }
@@ -608,7 +602,7 @@ function createGameCivilian(modelIndex, position, heading, toClient = null) {
// =========================================================================== // ===========================================================================
function getIsland(position) { function getIsland(position) {
if(getServerGame() == VRR_GAME_GTA_III) { if(getGame() == VRR_GAME_GTA_III) {
if(position.x > 616) { if(position.x > 616) {
return VRR_ISLAND_PORTLAND; return VRR_ISLAND_PORTLAND;
} else if(position.x < -283) { } else if(position.x < -283) {
@@ -653,7 +647,7 @@ function setPlayerFightStyle(client, fightStyleId) {
return false; return false;
} }
setEntityData(getPlayerElement(client), "vrr.fightStyle", [getGameConfig().fightStyles[getServerGame()][fightStyleId][1][0], getGameConfig().fightStyles[getServerGame()][fightStyleId][1][1]]); setEntityData(getPlayerElement(client), "vrr.fightStyle", [getGameConfig().fightStyles[getGame()][fightStyleId][1][0], getGameConfig().fightStyles[getGame()][fightStyleId][1][1]]);
forcePlayerToSyncElementProperties(null, getPlayerElement(client)); forcePlayerToSyncElementProperties(null, getPlayerElement(client));
} }
@@ -750,24 +744,24 @@ function getPlayerWeapon(client) {
function connectToDatabase() { function connectToDatabase() {
if(getDatabaseConfig().usePersistentConnection) { if(getDatabaseConfig().usePersistentConnection) {
if(persistentDatabaseConnection == null) { if(persistentDatabaseConnection == null) {
logToConsole(LOG_DEBUG, "[VRR.Database] Initializing database connection ..."); logToConsole(LOG_DEBUG, `[VRR.Database] Initializing database connection ...`);
persistentDatabaseConnection = module.mysql.connect(getDatabaseConfig().host, getDatabaseConfig().user, getDatabaseConfig().pass, getDatabaseConfig().name, getDatabaseConfig().port); persistentDatabaseConnection = module.mysql.connect(getDatabaseConfig().host, getDatabaseConfig().user, getDatabaseConfig().pass, getDatabaseConfig().name, getDatabaseConfig().port);
if(persistentDatabaseConnection.error) { if(persistentDatabaseConnection.error) {
console.warn("[VRR.Database] Database connection error: " + toString(persistentDatabaseConnection.error)); console.warn(`[VRR.Database] Database connection error: ${persistentDatabaseConnection.error}`);
persistentDatabaseConnection = null; persistentDatabaseConnection = null;
return false; return false;
} }
logToConsole(LOG_DEBUG, "[VRR.Database] Database connection successful!"); logToConsole(LOG_DEBUG, `[VRR.Database] Database connection successful!`);
return persistentDatabaseConnection; return persistentDatabaseConnection;
} else { } else {
logToConsole(LOG_DEBUG, "[VRR.Database] Using existing database connection."); logToConsole(LOG_DEBUG, `[VRR.Database] Using existing database connection.`);
return persistentDatabaseConnection; return persistentDatabaseConnection;
} }
} else { } else {
let databaseConnection = module.mysql.connect(getDatabaseConfig().host, getDatabaseConfig().user, getDatabaseConfig().pass, getDatabaseConfig().name, getDatabaseConfig().port); let databaseConnection = module.mysql.connect(getDatabaseConfig().host, getDatabaseConfig().user, getDatabaseConfig().pass, getDatabaseConfig().name, getDatabaseConfig().port);
if(databaseConnection.error) { if(databaseConnection.error) {
console.warn("[VRR.Database] Database connection error: " + toString(persistentDatabaseConnection.error)); console.warn(`[VRR.Database] Database connection error: ${persistentDatabaseConnection.error}`);
return false; return false;
} else { } else {
return databaseConnection; return databaseConnection;

View File

@@ -500,19 +500,19 @@ function gotoGameLocationCommand(command, params, client) {
} }
setPlayerVelocity(client, toVector3(0.0, 0.0, 0.0)); setPlayerVelocity(client, toVector3(0.0, 0.0, 0.0));
setPlayerPosition(client, getGameConfig().locations[getServerGame()][gameLocationId][1]); setPlayerPosition(client, getGameConfig().locations[getGame()][gameLocationId][1]);
setPlayerInterior(client, 0); setPlayerInterior(client, 0);
setPlayerDimension(client, 0); setPlayerDimension(client, 0);
updateInteriorLightsForPlayer(client, true); updateInteriorLightsForPlayer(client, true);
//setTimeout(function() { //setTimeout(function() {
// setPlayerPosition(client, getGameConfig().locations[getServerGame()][gameLocationId][1]); // setPlayerPosition(client, getGameConfig().locations[getGame()][gameLocationId][1]);
// setPlayerInterior(client, 0); // setPlayerInterior(client, 0);
// setPlayerDimension(client, 0); // setPlayerDimension(client, 0);
// updateInteriorLightsForPlayer(client, true); // updateInteriorLightsForPlayer(client, true);
//}, 500); //}, 500);
messagePlayerSuccess(client, `You teleported to game location {ALTCOLOUR}${getGameConfig().locations[getServerGame()][gameLocationId][0]}`); messagePlayerSuccess(client, `You teleported to game location {ALTCOLOUR}${getGameConfig().locations[getGame()][gameLocationId][0]}`);
} }
// =========================================================================== // ===========================================================================
@@ -1714,13 +1714,13 @@ function forceFightStyleCommand(command, params, client) {
if(!fightStyleId) { if(!fightStyleId) {
messagePlayerError(client, `That fight style doesn't exist!`); messagePlayerError(client, `That fight style doesn't exist!`);
messagePlayerError(client, `Fight styles: ${getGameConfig().fightStyles[getServerGame()].map(fs => fs[0]).join(", ")}`); messagePlayerError(client, `Fight styles: ${getGameConfig().fightStyles[getGame()].map(fs => fs[0]).join(", ")}`);
return false; return false;
} }
getPlayerCurrentSubAccount(client).fightStyle = fightStyleId; getPlayerCurrentSubAccount(client).fightStyle = fightStyleId;
setPlayerFightStyle(client, fightStyleId); setPlayerFightStyle(client, fightStyleId);
messagePlayerSuccess(client, `You set ${getCharacterFullName(targetClient)}'s fight style to ${getGameConfig().fightStyles[getServerGame()][fightStyleId][0]}`) messagePlayerSuccess(client, `You set ${getCharacterFullName(targetClient)}'s fight style to ${getGameConfig().fightStyles[getGame()][fightStyleId][0]}`)
return true; return true;
} }

View File

@@ -531,7 +531,7 @@ function setFightStyleCommand(command, params, client) {
if(!fightStyle) { if(!fightStyle) {
messagePlayerError(client, `That fight style doesn't exist!`); messagePlayerError(client, `That fight style doesn't exist!`);
messagePlayerError(client, `Fight styles: ${getGameConfig().fightStyles[getServerGame()].map(fs => fs[0]).join(", ")}`); messagePlayerError(client, `Fight styles: ${getGameConfig().fightStyles[getGame()].map(fs => fs[0]).join(", ")}`);
return false; return false;
} }
@@ -543,7 +543,7 @@ function setFightStyleCommand(command, params, client) {
} }
setPlayerFightStyle(client, fightStyleId); setPlayerFightStyle(client, fightStyleId);
messagePlayerSuccess(client, `Your fight style has been set to ${getGameConfig().fightStyles[getServerGame()][fightStyleId][0]}`) messagePlayerSuccess(client, `Your fight style has been set to ${getGameConfig().fightStyles[getGame()][fightStyleId][0]}`)
return true; return true;
} }

View File

@@ -28,7 +28,7 @@ function getPositionArea(position) {
position = vec3ToVec2(position); position = vec3ToVec2(position);
} }
let gameAreas = getGameAreas(getServerGame()); let gameAreas = getGameAreas(getGame());
for(let i in gameAreas) { for(let i in gameAreas) {
if(isPositionInArea(position, gameAreas[i][1])) { if(isPositionInArea(position, gameAreas[i][1])) {
return i; return i;
@@ -94,9 +94,11 @@ function updateServerRules() {
if(isWeatherSupported()) { if(isWeatherSupported()) {
if(getServerConfig() != false) { if(getServerConfig() != false) {
let value = getGameConfig().weatherNames[getServerGame()][getServerConfig().weather]; if(typeof getGameConfig().weatherNames[getGame()] != "undefined") {
logToConsole(LOG_DEBUG, `[VRR.Utilities]: Setting server rule "Weather" as ${value}`); let value = getGameConfig().weatherNames[getGame()][getServerConfig().weather];
server.setRule("Weather", value); logToConsole(LOG_DEBUG, `[VRR.Utilities]: Setting server rule "Weather" as ${value}`);
server.setRule("Weather", value);
}
} }
} }
@@ -114,13 +116,13 @@ function updateServerRules() {
function getWeatherFromParams(params) { function getWeatherFromParams(params) {
if(isNaN(params)) { if(isNaN(params)) {
for(let i in getGameConfig().weatherNames[getServerGame()]) { for(let i in getGameConfig().weatherNames[getGame()]) {
if(toLowerCase(getGameConfig().weatherNames[getServerGame()][i]).indexOf(toLowerCase(params)) != -1) { if(toLowerCase(getGameConfig().weatherNames[getGame()][i]).indexOf(toLowerCase(params)) != -1) {
return i; return i;
} }
} }
} else { } else {
if(typeof getGameConfig().weatherNames[getServerGame()][params] != "undefined") { if(typeof getGameConfig().weatherNames[getGame()][params] != "undefined") {
return toInteger(params); return toInteger(params);
} }
} }
@@ -132,13 +134,13 @@ function getWeatherFromParams(params) {
function getFightStyleFromParams(params) { function getFightStyleFromParams(params) {
if(isNaN(params)) { if(isNaN(params)) {
for(let i in getGameConfig().fightStyles[getServerGame()]) { for(let i in getGameConfig().fightStyles[getGame()]) {
if(toLowerCase(getGameConfig().fightStyles[getServerGame()][i][0]).indexOf(toLowerCase(params)) != -1) { if(toLowerCase(getGameConfig().fightStyles[getGame()][i][0]).indexOf(toLowerCase(params)) != -1) {
return i; return i;
} }
} }
} else { } else {
if(typeof getGameConfig().fightStyles[getServerGame()][params] != "undefined") { if(typeof getGameConfig().fightStyles[getGame()][params] != "undefined") {
return toInteger(params); return toInteger(params);
} }
} }
@@ -149,34 +151,34 @@ function getFightStyleFromParams(params) {
// =========================================================================== // ===========================================================================
function getClosestHospital(position) { function getClosestHospital(position) {
if(typeof getGameConfig().hospitals[getServerGame()] == "undefined") { if(typeof getGameConfig().hospitals[getGame()] == "undefined") {
return {position: getServerConfig().newCharacter.spawnPosition}; return {position: getServerConfig().newCharacter.spawnPosition};
} else { } else {
let closest = 0; let closest = 0;
for(let i in getGameConfig().hospitals[getServerGame()]) { for(let i in getGameConfig().hospitals[getGame()]) {
if(getDistance(getGameConfig().hospitals[getServerGame()][i].position, position) < getDistance(getGameConfig().hospitals[getServerGame()][closest].position, position)) { if(getDistance(getGameConfig().hospitals[getGame()][i].position, position) < getDistance(getGameConfig().hospitals[getGame()][closest].position, position)) {
closest = i; closest = i;
} }
} }
return getGameConfig().hospitals[getServerGame()][closest]; return getGameConfig().hospitals[getGame()][closest];
} }
} }
// =========================================================================== // ===========================================================================
function getClosestPoliceStation(position) { function getClosestPoliceStation(position) {
if(typeof getGameConfig().policeStations[getServerGame()] == "undefined") { if(typeof getGameConfig().policeStations[getGame()] == "undefined") {
return {position: getServerConfig().newCharacter.spawnPosition}; return {position: getServerConfig().newCharacter.spawnPosition};
} else { } else {
let closest = 0; let closest = 0;
for(let i in getGameConfig().policeStations[getServerGame()]) { for(let i in getGameConfig().policeStations[getGame()]) {
if(getDistance(getGameConfig().policeStations[getServerGame()][i].position, position) < getDistance(getGameConfig().policeStations[getServerGame()][closest].position, position)) { if(getDistance(getGameConfig().policeStations[getGame()][i].position, position) < getDistance(getGameConfig().policeStations[getGame()][closest].position, position)) {
closest = i; closest = i;
} }
} }
return getGameConfig().policeStations[getServerGame()][closest]; return getGameConfig().policeStations[getGame()][closest];
} }
} }
@@ -216,8 +218,8 @@ function getPlayerIsland(client) {
// =========================================================================== // ===========================================================================
function isAtPayAndSpray(position) { function isAtPayAndSpray(position) {
for(let i in getGameConfig().payAndSprays[getServerGame()]) { for(let i in getGameConfig().payAndSprays[getGame()]) {
if(getDistance(position, getGameConfig().payAndSprays[getServerGame()][i]) <= getGlobalConfig().payAndSprayDistance) { if(getDistance(position, getGameConfig().payAndSprays[getGame()][i]) <= getGlobalConfig().payAndSprayDistance) {
return true; return true;
} }
} }

View File

@@ -39,7 +39,7 @@ function loadVehiclesFromDatabase() {
// =========================================================================== // ===========================================================================
function saveVehiclesToDatabase() { function saveAllVehiclesToDatabase() {
if(getServerConfig().devServer) { if(getServerConfig().devServer) {
return false; return false;
} }
@@ -1253,8 +1253,8 @@ function spawnVehicle(vehicleData) {
// =========================================================================== // ===========================================================================
function isVehicleAtPayAndSpray(vehicle) { function isVehicleAtPayAndSpray(vehicle) {
for(let i in getServerData().payAndSprays[getServerGame()]) { for(let i in getServerData().payAndSprays[getGame()]) {
if(getDistance(getVehiclePosition(vehicle), getServerData().payAndSprays[getServerGame()][i].position) <= getGlobalConfig().payAndSprayDistance) { if(getDistance(getVehiclePosition(vehicle), getServerData().payAndSprays[getGame()][i].position) <= getGlobalConfig().payAndSprayDistance) {
return true; return true;
} }
} }