Rename game config util

This commit is contained in:
Vortrex
2022-03-06 01:17:37 -06:00
parent f1443f2945
commit d9ae395254
18 changed files with 136 additions and 195 deletions

View File

@@ -9,6 +9,7 @@
<script src="scripts/shared/gamedata.js" type="server" language="javascript" />
<script src="scripts/shared/gamedata.js" type="client" language="javascript" />
<!-- Multiplayer Mod (Wrapped Natives) -->
<script src="scripts/server/native/connected.js" type="server" language="javascript" />
<script src="scripts/client/native/connected.js" type="client" language="javascript" />
@@ -93,6 +94,7 @@
<file type="client" src="files/images/skins/none.png" />
<file type="client" src="files/images/mafiac-logo.png" />
<file type="client" src="files/images/gtac-logo.png" />
<file type="client" src="files/images/server-logo.png" />
<!-- GUI -->
<script src="scripts/client/gui/login.js" type="client" language="javascript" />
@@ -111,27 +113,27 @@
<script src="scripts/client/gui/list.js" type="client" language="javascript" />
<!-- Client Scripts -->
<script src="scripts/client/gui.js" type="client" language="javascript" />
<script src="scripts/client/main.js" type="client" language="javascript" />
<script src="scripts/client/nametag.js" type="client" language="javascript" />
<script src="scripts/client/sync.js" type="client" language="javascript" />
<script src="scripts/client/scoreboard.js" type="client" language="javascript" />
<script src="scripts/client/keybind.js" type="client" language="javascript" />
<script src="scripts/client/chatbox.js" type="client" language="javascript" />
<script src="scripts/client/label.js" type="client" language="javascript" />
<script src="scripts/client/skin-select.js" type="client" language="javascript" />
<script src="scripts/client/server.js" type="client" language="javascript" />
<script src="scripts/client/job.js" type="client" language="javascript" />
<script src="scripts/client/event.js" type="client" language="javascript" />
<script src="scripts/client/item.js" type="client" language="javascript" />
<script src="scripts/client/utilities.js" type="client" language="javascript" />
<script src="scripts/client/messaging.js" type="client" language="javascript" />
<script src="scripts/client/logo.js" type="client" language="javascript" />
<script src="scripts/client/afk.js" type="client" language="javascript" />
<script src="scripts/client/mousecam.js" type="client" language="javascript" />
<script src="scripts/client/radio.js" type="client" language="javascript" />
<script src="scripts/client/animation.js" type="client" language="javascript" />
<script src="scripts/client/chatbox.js" type="client" language="javascript" />
<script src="scripts/client/event.js" type="client" language="javascript" />
<script src="scripts/client/gui.js" type="client" language="javascript" />
<script src="scripts/client/item.js" type="client" language="javascript" />
<script src="scripts/client/job.js" type="client" language="javascript" />
<script src="scripts/client/keybind.js" type="client" language="javascript" />
<script src="scripts/client/label.js" type="client" language="javascript" />
<script src="scripts/client/logo.js" type="client" language="javascript" />
<script src="scripts/client/main.js" type="client" language="javascript" />
<script src="scripts/client/messaging.js" type="client" language="javascript" />
<script src="scripts/client/mousecam.js" type="client" language="javascript" />
<script src="scripts/client/nametag.js" type="client" language="javascript" />
<script src="scripts/client/radio.js" type="client" language="javascript" />
<script src="scripts/client/scoreboard.js" type="client" language="javascript" />
<script src="scripts/client/server.js" type="client" language="javascript" />
<script src="scripts/client/skin-select.js" type="client" language="javascript" />
<script src="scripts/client/sync.js" type="client" language="javascript" />
<script src="scripts/client/utilities.js" type="client" language="javascript" />
<!-- MexUI -->
<file type="client" src="third-party/mexui/Images/down-arrow.png" />
<script language="javascript" type="client" src="third-party/mexui/mexui.js" />

View File

@@ -8,7 +8,7 @@
// ===========================================================================
function getCustomImage(imageName) {
let contentResource = findResourceByName(getGameData().extraContentResource[getGame()]);
let contentResource = findResourceByName(getGameConfig().extraContentResource[getGame()]);
if(contentResource != null) {
if(contentResource.isStarted) {
let image = contentResource.exports.getCustomImage(imageName);
@@ -23,7 +23,7 @@ function getCustomImage(imageName) {
// ===========================================================================
function getCustomFont(fontName) {
let contentResource = findResourceByName(getGameData().extraContentResource[getGame()]);
let contentResource = findResourceByName(getGameConfig().extraContentResource[getGame()]);
if(contentResource != null) {
if(contentResource.isStarted) {
let font = contentResource.exports.getCustomFont(fontName);
@@ -38,7 +38,7 @@ function getCustomFont(fontName) {
// ===========================================================================
function getCustomAudio(audioName) {
let contentResource = findResourceByName(getGameData().extraContentResource[getGame()]);
let contentResource = findResourceByName(getGameConfig().extraContentResource[getGame()]);
if(contentResource != null) {
if(contentResource.isStarted) {
let audioFile = contentResource.exports.getCustomAudio(audioName);
@@ -53,7 +53,7 @@ function getCustomAudio(audioName) {
// ===========================================================================
function playCustomAudio(audioName, volume = 0.5, loop = false) {
let contentResource = findResourceByName(getGameData().extraContentResource[getGame()]);
let contentResource = findResourceByName(getGameConfig().extraContentResource[getGame()]);
if(contentResource != null) {
if(contentResource.isStarted) {
contentResource.exports.playCustomAudio(audioName, volume, loop);

View File

@@ -104,6 +104,7 @@ function closeAllWindows() {
listDialog.window.shown = false;
resetPassword.window.shown = false;
passwordChange.window.shown = false;
mexui.setInput(false);
mexui.focusedControl = false;
@@ -299,14 +300,22 @@ function processGUIKeyPress(keyCode) {
if(guiSubmitKey != false) {
guiSubmitKey();
}
} else if(keyCode == SDLK_LEFT) {
} else if(keyCode == getKeyIdFromParams("left") || keyCode == getKeyIdFromParams("a")) {
if(guiLeftKey != false) {
guiLeftKey();
}
} else if(keyCode == SDLK_RIGHT) {
} else if(keyCode == getKeyIdFromParams("right") || keyCode == getKeyIdFromParams("d")) {
if(guiRightKey != false) {
guiRightKey();
}
} else if(keyCode == getKeyIdFromParams("down") || keyCode == getKeyIdFromParams("s")) {
if(guiDownKey != false) {
guiDownKey();
}
} else if(keyCode == getKeyIdFromParams("up") || keyCode == getKeyIdFromParams("w")) {
if(guiUpKey != false) {
guiUpKey();
}
}
}

View File

@@ -15,4 +15,6 @@ let clanManager = {
vehiclesTab: null,
businessesTab: null,
housesTab: null,
};
};
// ===========================================================================

View File

@@ -168,4 +168,6 @@ function switchToPasswordResetGUI() {
logToConsole(LOG_DEBUG, `[VRR.GUI] Showing password reset dialog window`);
showResetPasswordGUI();
return false;
}
}
// ===========================================================================

View File

@@ -52,7 +52,7 @@ function deleteGameElement(element, position) {
// ===========================================================================
function createGameVehicle(modelIndex, position, heading) {
return game.createVehicle(getGameData().vehicles[getGame()][modelIndex][0], position, heading);
return game.createVehicle(getGameConfig().vehicles[getGame()][modelIndex][0], position, heading);
}
// ===========================================================================

View File

@@ -116,7 +116,7 @@ function syncVehicleProperties(vehicle) {
}
if(getGame() == VRR_GAME_GTA_SA) {
let allUpgrades = getGameData().vehicleUpgrades[getGame()];
let allUpgrades = getGameConfig().vehicleUpgrades[getGame()];
for(let i in allUpgrades) {
vehicle.removeUpgrade(i);
}

View File

@@ -70,7 +70,7 @@ function stopPlayerAnimationCommand(command, params, client) {
// ===========================================================================
function showAnimationListCommand(command, params, client) {
let animList = getGameData().animations[getServerGame()].map(function(x) { return x[0]; });
let animList = getGameConfig().animations[getServerGame()].map(function(x) { return x[0]; });
let chunkedList = splitArrayIntoChunks(animList, 10);
@@ -88,7 +88,7 @@ function showAnimationListCommand(command, params, client) {
* @return {Array} The animation's data (array)
*/
function getAnimationData(animationSlot, gameId = getServerGame()) {
return getGameData().animations[gameId][animationSlot];
return getGameConfig().animations[gameId][animationSlot];
}
// ===========================================================================
@@ -145,13 +145,13 @@ function makePlayerStopAnimation(client) {
function getAnimationFromParams(params) {
if(isNaN(params)) {
for(let i in getGameData().animations[getServerGame()]) {
if(toLowerCase(getGameData().animations[getServerGame()][i][0]).indexOf(toLowerCase(params)) != -1) {
for(let i in getGameConfig().animations[getServerGame()]) {
if(toLowerCase(getGameConfig().animations[getServerGame()][i][0]).indexOf(toLowerCase(params)) != -1) {
return i;
}
}
} else {
if(typeof getGameData().animations[getServerGame()][params] != "undefined") {
if(typeof getGameConfig().animations[getServerGame()][params] != "undefined") {
return toInteger(params);
}
}

View File

@@ -231,12 +231,6 @@ function getServerConfig() {
// ===========================================================================
function getGameConfig() {
return gameConfig;
}
// ===========================================================================
function getGlobalConfig() {
return globalConfig;
}
@@ -353,7 +347,7 @@ function setWeatherCommand(command, params, client) {
getServerConfig().needsSaved = true;
messageAdminAction(`${getPlayerName(client)} set the weather to {ALTCOLOUR}${getGameData().weatherNames[getServerGame()][toInteger(weatherId)]}`);
messageAdminAction(`${getPlayerName(client)} set the weather to {ALTCOLOUR}${getGameConfig().weatherNames[getServerGame()][toInteger(weatherId)]}`);
updateServerRules();
return true;
}
@@ -382,18 +376,6 @@ function setSnowingCommand(command, params, client) {
getServerConfig().fallingSnow = intToBool(falling);
getServerConfig().groundSnow = intToBool(ground);
if(falling == true && doesServerHaveFallingSnowEnabled()) {
getServerConfig().settings = removeBitFlag(getServerConfig().settings, getServerSettingsFlagValue("FallingSnow"));
} else if(falling == false && !doesServerHaveFallingSnowEnabled()) {
getServerConfig().settings = addBitFlag(getServerConfig().settings, getServerSettingsFlagValue("FallingSnow"));
}
if(ground == true && doesServerHaveGroundSnowEnabled()) {
getServerConfig().settings = removeBitFlag(getServerConfig().settings, getServerSettingsFlagValue("GroundSnow"));
} else if(ground == false && !doesServerHaveGroundSnowEnabled()) {
getServerConfig().settings = addBitFlag(getServerConfig().settings, getServerSettingsFlagValue("GroundSnow"));
}
updatePlayerSnowState(null);
getServerConfig().needsSaved = true;
@@ -451,13 +433,7 @@ function setServerGUIColoursCommand(command, params, client) {
*
*/
function toggleServerLogoCommand(command, params, client) {
if(doesServerHaveServerLogoEnabled()) {
getServerConfig().settings = removeBitFlag(getServerConfig().settings, getServerSettingsFlagValue("ServerLogo"));
getServerConfig().useLogo = false;
} else {
getServerConfig().settings = addBitFlag(getServerConfig().settings, getServerSettingsFlagValue("ServerLogo"));
getServerConfig().useLogo = true;
}
getServerConfig().useLogo = !getServerConfig().useLogo;
getServerConfig().needsSaved = true;
updatePlayerShowLogoState(null, getServerConfig().useLogo);
@@ -479,13 +455,7 @@ function toggleServerLogoCommand(command, params, client) {
*
*/
function toggleServerJobBlipsCommand(command, params, client) {
if(doesServerHaveJobBlipsEnabled()) {
getServerConfig().settings = removeBitFlag(getServerConfig().settings, getServerSettingsFlagValue("JobBlips"));
getServerConfig().createJobBlips = false;
} else {
getServerConfig().settings = addBitFlag(getServerConfig().settings, getServerSettingsFlagValue("JobBlips"));
getServerConfig().createJobBlips = true;
}
getServerConfig().createJobBlips = !getServerConfig().createJobBlips;
getServerConfig().needsSaved = true;
messageAdminAction(`${getPlayerName(client)} {MAINCOLOUR}turned ${getBoolRedGreenInlineColour(doesServerHaveJobBlipsEnabled())}${toUpperCase(getOnOffFromBool(getServerConfig().createJobBlips))} {MAINCOLOUR}all job blips`);
@@ -505,13 +475,7 @@ function toggleServerLogoCommand(command, params, client) {
*
*/
function toggleServerJobPickupsCommand(command, params, client) {
if(doesServerHaveJobPickupsEnabled()) {
getServerConfig().settings = removeBitFlag(getServerConfig().settings, getServerSettingsFlagValue("JobPickups"));
getServerConfig().createJobPickups = false;
} else {
getServerConfig().settings = addBitFlag(getServerConfig().settings, getServerSettingsFlagValue("JobPickups"));
getServerConfig().createJobPickups = true;
}
getServerConfig().createJobPickups = !getServerConfig().createJobPickups;
getServerConfig().needsSaved = true;
messageAdminAction(`${getPlayerName(client)} {MAINCOLOUR}turned ${getBoolRedGreenInlineColour(doesServerHaveJobPickupsEnabled())}${toUpperCase(getOnOffFromBool(getServerConfig().createJobPickups))} {MAINCOLOUR}all job pickups`);
@@ -531,13 +495,7 @@ function toggleServerLogoCommand(command, params, client) {
*
*/
function toggleServerBusinessBlipsCommand(command, params, client) {
if(doesServerHaveBusinessBlipsEnabled()) {
getServerConfig().settings = removeBitFlag(getServerConfig().settings, getServerSettingsFlagValue("BusinessBlips"));
getServerConfig().createBusinessBlips = false;
} else {
getServerConfig().settings = addBitFlag(getServerConfig().settings, getServerSettingsFlagValue("BusinessBlips"));
getServerConfig().createBusinessBlips = true;
}
getServerConfig().createBusinessBlips = !getServerConfig().createBusinessBlips;
getServerConfig().needsSaved = true;
messageAdminAction(`${getPlayerName(client)} {MAINCOLOUR}turned ${getBoolRedGreenInlineColour(doesServerHaveBusinessBlipsEnabled())}${toUpperCase(getOnOffFromBool(getServerConfig().createBusinessBlips))} {MAINCOLOUR}all business blips`);
@@ -557,13 +515,7 @@ function toggleServerLogoCommand(command, params, client) {
*
*/
function toggleServerBusinessPickupsCommand(command, params, client) {
if(doesServerHaveBusinessPickupsEnabled()) {
getServerConfig().settings = removeBitFlag(getServerConfig().settings, getServerSettingsFlagValue("BusinessPickups"));
getServerConfig().createBusinessPickups = false;
} else {
getServerConfig().settings = addBitFlag(getServerConfig().settings, getServerSettingsFlagValue("BusinessPickups"));
getServerConfig().createBusinessPickups = true;
}
getServerConfig().createBusinessPickups = !getServerConfig().createBusinessPickups;
getServerConfig().needsSaved = true;
messageAdminAction(`${getPlayerName(client)} {MAINCOLOUR}turned ${getBoolRedGreenInlineColour(doesServerHaveBusinessPickupsEnabled())}${toUpperCase(getOnOffFromBool(getServerConfig().createBusinessPickups))} {MAINCOLOUR}all business pickups`);
@@ -583,13 +535,7 @@ function toggleServerLogoCommand(command, params, client) {
*
*/
function toggleServerHouseBlipsCommand(command, params, client) {
if(doesServerHaveHouseBlipsEnabled()) {
getServerConfig().settings = removeBitFlag(getServerConfig().settings, getServerSettingsFlagValue("HousePickups"));
getServerConfig().createHouseBlips = false;
} else {
getServerConfig().settings = addBitFlag(getServerConfig().settings, getServerSettingsFlagValue("HouseBlips"));
getServerConfig().createHousePickups = true;
}
getServerConfig().createHouseBlips = !getServerConfig().createHouseBlips;
getServerConfig().needsSaved = true;
messageAdminAction(`${getPlayerName(client)} {MAINCOLOUR}turned ${getBoolRedGreenInlineColour(doesServerHaveHouseBlipsEnabled())}${toUpperCase(getOnOffFromBool(getServerConfig().createHouseBlips))} {MAINCOLOUR}all house blips`);
@@ -609,13 +555,7 @@ function toggleServerLogoCommand(command, params, client) {
*
*/
function toggleServerHousePickupsCommand(command, params, client) {
if(doesServerHaveHousePickupsEnabled()) {
getServerConfig().settings = removeBitFlag(getServerConfig().settings, getServerSettingsFlagValue("HousePickups"));
getServerConfig().createHousePickups = false;
} else {
getServerConfig().settings = addBitFlag(getServerConfig().settings, getServerSettingsFlagValue("HousePickups"));
getServerConfig().createHousePickups = true;
}
getServerConfig().createHousePickups = !getServerConfig().createHousePickups;
getServerConfig().needsSaved = true;
messageAdminAction(`${getPlayerName(client)} {MAINCOLOUR}turned ${getBoolRedGreenInlineColour(doesServerHaveHousePickupsEnabled())}${toUpperCase(getOnOffFromBool(getServerConfig().createHousePickups))} {MAINCOLOUR}all house pickups`);
@@ -635,13 +575,7 @@ function toggleServerLogoCommand(command, params, client) {
*
*/
function toggleServerGUICommand(command, params, client) {
if(doesServerHaveGUIEnabled()) {
getServerConfig().settings = removeBitFlag(getServerConfig().settings, getServerSettingsFlagValue("GUI"));
getServerConfig().useGUI = false;
} else {
getServerConfig().settings = addBitFlag(getServerConfig().settings, getServerSettingsFlagValue("GUI"));
getServerConfig().useGUI = true;
}
getServerConfig().useGUI = !getServerConfig().useGUI;
getServerConfig().needsSaved = true;
@@ -662,17 +596,11 @@ function toggleServerGUICommand(command, params, client) {
*
*/
function toggleServerUseRealWorldTimeCommand(command, params, client) {
if(doesServerHaveRealTimeEnabled()) {
getServerConfig().settings = removeBitFlag(getServerConfig().settings, getServerSettingsFlagValue("RealTime"));
getServerConfig().useRealTime = false;
} else {
getServerConfig().settings = addBitFlag(getServerConfig().settings, getServerSettingsFlagValue("RealTime"));
getServerConfig().useRealTime = true;
}
getServerConfig().useRealTime = !getServerConfig().useRealTime;
getServerConfig().needsSaved = true;
messageAdminAction(`${getPlayerName(client)} {MAINCOLOUR}turned real-world time ${toLowerCase(getOnOffFromBool(doesServerHaveRealTimeEnabled()))} for this server (GMT ${addPositiveNegativeSymbol(getServerConfig().realTimeZone)})`);
messageAdminAction(`${getPlayerName(client)} {MAINCOLOUR}turned real-world time ${getServerConfig().useRealTime} for this server (GMT ${addPositiveNegativeSymbol(getServerConfig().realTimeZone)})`);
updateServerGameTime();
updateServerRules();
return true;
@@ -805,67 +733,67 @@ function loadAccentConfig() {
// ===========================================================================
function doesServerHaveGUIEnabled() {
return hasBitFlag(getServerConfig().settings, getServerSettingsFlagValue("GUI"));
return getServerConfig().useGUI;
}
// ===========================================================================
function doesServerHaveTesterOnlyEnabled() {
return hasBitFlag(getServerConfig().settings, getServerSettingsFlagValue("Testing"));
return getServerConfig().testerOnly;
}
// ===========================================================================
function doesServerHaveRealTimeEnabled() {
return hasBitFlag(getServerConfig().settings, getServerSettingsFlagValue("RealTime"));
return getServerConfig().useRealTime;
}
// ===========================================================================
function doesServerHaveBusinessPickupsEnabled() {
return hasBitFlag(getServerConfig().settings, getServerSettingsFlagValue("BusinessPickups"));
return getServerConfig().createBusinessPickups
}
// ===========================================================================
function doesServerHaveHousePickupsEnabled() {
return hasBitFlag(getServerConfig().settings, getServerSettingsFlagValue("HousePickups"));
return getServerConfig().createHousePickups;
}
// ===========================================================================
function doesServerHaveJobPickupsEnabled() {
return hasBitFlag(getServerConfig().settings, getServerSettingsFlagValue("JobPickups"));
return getServerConfig().createJobPickups;
}
// ===========================================================================
function doesServerHaveBusinesBlipsEnabled() {
return hasBitFlag(getServerConfig().settings, getServerSettingsFlagValue("BusinessBlips"));
return getServerConfig().createBusinessBlips;
}
// ===========================================================================
function doesServerHaveHouseBlipsEnabled() {
return hasBitFlag(getServerConfig().settings, getServerSettingsFlagValue("HouseBlips"));
return getServerConfig().createHouseBlips;
}
// ===========================================================================
function doesServerHaveJobBlipsEnabled() {
return hasBitFlag(getServerConfig().settings, getServerSettingsFlagValue("JobBlips"));
return getServerConfig().createJobBlips;
}
// ===========================================================================
function doesServerHaveFallingSnowEnabled() {
return hasBitFlag(getServerConfig().settings, getServerSettingsFlagValue("FallingSnow"));
return getServerConfig().fallingSnow;
}
// ===========================================================================
function doesServerHaveGroundSnowEnabled() {
return hasBitFlag(getServerConfig().settings, getServerSettingsFlagValue("GroundSnow"));
return getServerConfig().groundSnow;
}
// ===========================================================================

View File

@@ -408,7 +408,7 @@ function onPlayerDeath(client, position) {
client.despawnPlayer();
getPlayerCurrentSubAccount(client).interior = closestJail.interior;
getPlayerCurrentSubAccount(client).dimension = closestJail.dimension;
spawnPlayer(client, closestJail.position, closestJail.heading, getGameData().skins[getGame()][getPlayerCurrentSubAccount(client).skin][0]);
spawnPlayer(client, closestJail.position, closestJail.heading, getGameConfig().skins[getGame()][getPlayerCurrentSubAccount(client).skin][0]);
if(isFadeCameraSupported()) {
fadeCamera(client, true, 1.0);
@@ -421,7 +421,7 @@ function onPlayerDeath(client, position) {
client.despawnPlayer();
getPlayerCurrentSubAccount(client).interior = closestHospital.interior;
getPlayerCurrentSubAccount(client).dimension = closestHospital.dimension;
spawnPlayer(client, closestHospital.position, closestHospital.heading, getGameData().skins[getGame()][getPlayerCurrentSubAccount(client).skin][0]);
spawnPlayer(client, closestHospital.position, closestHospital.heading, getGameConfig().skins[getGame()][getPlayerCurrentSubAccount(client).skin][0]);
if(isFadeCameraSupported()) {
fadeCamera(client, true, 1.0);

View File

@@ -1732,7 +1732,7 @@ function getItemValueDisplay(itemType, value) {
} else if(getItemTypeData(itemType).useType == VRR_ITEM_USETYPE_WALKIETALKIE) {
return toString(toString(value).slice(0,-2)+"."+toString(value).slice(-1)+"MHz");
} else if(getItemTypeData(itemType).useType == VRR_ITEM_USETYPE_VEHCOLOUR) {
return `[${getGameData().vehicleColourHex[value]}]SAMPLE[#FFFFFF]`;
return `[${getGameConfig().vehicleColourHex[value]}]SAMPLE[#FFFFFF]`;
} else {
return value;
}

View File

@@ -962,8 +962,8 @@ function createJob(name) {
tempJobData.name = name;
tempJobData.enabled = true;
tempJobData.needsSaved = true;
tempJobData.blipModel = getGameData().blipSprites[getGame()].job;
tempJobData.pickupModel = getGameData().pickupModels[getGame()].job;
tempJobData.blipModel = getGameConfig().blipSprites[getGame()].job;
tempJobData.pickupModel = getGameConfig().pickupModels[getGame()].job;
getServerData().jobs.push(tempJobData);
saveJobToDatabase(tempJobData);

View File

@@ -451,7 +451,7 @@ function gpsCommand(command, params, client) {
} else {
let gameLocationId = getGameLocationFromParams(params);
if(gameLocationId != false) {
position = getGameData().locations[getServerGame()][gameLocationId][1]
position = getGameConfig().locations[getServerGame()][gameLocationId][1]
}
}
}
@@ -548,8 +548,8 @@ function stuckPlayerCommand(command, params, client) {
}
} else {
setPlayerDimension(client, 1);
setPlayerDimension(client, getGameData().mainWorldDimension[getGame()]);
setPlayerInterior(client, getGameData().mainWorldInterior[getGame()]);
setPlayerDimension(client, getGameConfig().mainWorldDimension[getGame()]);
setPlayerInterior(client, getGameConfig().mainWorldInterior[getGame()]);
setPlayerPosition(client, getPosAbovePos(getPlayerPosition(client), 2.0));
}

View File

@@ -195,11 +195,11 @@ function removePlayerFromVehicle(client) {
// ===========================================================================
function setPlayerSkin(client, skinIndex) {
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s skin to ${getGameData().skins[getGame()][skinIndex][0]} (Index: ${skinIndex}, Name: ${getGameData().skins[getGame()][skinIndex][1]})`);
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s skin to ${getGameConfig().skins[getGame()][skinIndex][0]} (Index: ${skinIndex}, Name: ${getGameConfig().skins[getGame()][skinIndex][1]})`);
if(getGame() == VRR_GAME_GTA_IV) {
triggerNetworkEvent("vrr.localPlayerSkin", client, getGameData().skins[getGame()][skinIndex][0]);
triggerNetworkEvent("vrr.localPlayerSkin", client, getGameConfig().skins[getGame()][skinIndex][0]);
} else {
client.player.modelIndex = getGameData().skins[getGame()][skinIndex][0];
client.player.modelIndex = getGameConfig().skins[getGame()][skinIndex][0];
}
}
@@ -417,7 +417,7 @@ function createGameObject(modelIndex, position) {
if(!isGameFeatureSupported("objects")) {
return false;
}
return game.createObject(getGameData().objects[getGame()][modelIndex][0], position);
return game.createObject(getGameConfig().objects[getGame()][modelIndex][0], position);
}
// ===========================================================================
@@ -439,7 +439,7 @@ function destroyGameElement(element) {
// ===========================================================================
function isMeleeWeapon(weaponId, gameId = getServerGame()) {
return (getGameData().meleeWeapons[gameId].indexOf(weaponId) != -1);
return (getGameConfig().meleeWeapons[gameId].indexOf(weaponId) != -1);
}
// ===========================================================================
@@ -527,7 +527,7 @@ function setVehicleColours(vehicle, colour1, colour2, colour3 = -1, colour4 = -1
// ===========================================================================
function createGameVehicle(modelIndex, position, heading) {
return game.createVehicle(getGameData().vehicles[getGame()][modelIndex][0], position, heading);
return game.createVehicle(getGameConfig().vehicles[getGame()][modelIndex][0], position, heading);
}
// ===========================================================================
@@ -578,7 +578,7 @@ function setPlayerFightStyle(client, fightStyleId) {
return false;
}
setEntityData(getPlayerElement(client), "vrr.fightStyle", [getGameData().fightStyles[getServerGame()][fightStyleId][1][0], getGameData().fightStyles[getServerGame()][fightStyleId][1][1]]);
setEntityData(getPlayerElement(client), "vrr.fightStyle", [getGameConfig().fightStyles[getServerGame()][fightStyleId][1][0], getGameConfig().fightStyles[getServerGame()][fightStyleId][1][1]]);
forcePlayerToSyncElementProperties(null, getPlayerElement(client));
}

View File

@@ -374,19 +374,19 @@ function gotoGameLocationCommand(command, params, client) {
}
setPlayerVelocity(client, toVector3(0.0, 0.0, 0.0));
setPlayerPosition(client, getGameData().locations[getServerGame()][gameLocationId][1]);
setPlayerPosition(client, getGameConfig().locations[getServerGame()][gameLocationId][1]);
setPlayerInterior(client, 0);
setPlayerDimension(client, 0);
updateInteriorLightsForPlayer(client, true);
//setTimeout(function() {
// setPlayerPosition(client, getGameData().locations[getServerGame()][gameLocationId][1]);
// setPlayerPosition(client, getGameConfig().locations[getServerGame()][gameLocationId][1]);
// setPlayerInterior(client, 0);
// setPlayerDimension(client, 0);
// updateInteriorLightsForPlayer(client, true);
//}, 500);
messagePlayerSuccess(client, `You teleported to game location {ALTCOLOUR}${getGameData().locations[getServerGame()][gameLocationId][0]}`);
messagePlayerSuccess(client, `You teleported to game location {ALTCOLOUR}${getGameConfig().locations[getServerGame()][gameLocationId][0]}`);
}
// ===========================================================================
@@ -1016,7 +1016,7 @@ function forcePlayerSkinCommand(command, params, client) {
getPlayerCurrentSubAccount(targetClient).skin = skinIndex;
setPlayerSkin(targetClient, skinIndex);
messageAdmins(`${getPlayerName(client)} {MAINCOLOUR}set ${getPlayerName(targetClient)}'s{MAINCOLOUR} skin to {ALTCOLOUR}${getGameData().skins[getGame()][skinIndex][1]}`);
messageAdmins(`${getPlayerName(client)} {MAINCOLOUR}set ${getPlayerName(targetClient)}'s{MAINCOLOUR} skin to {ALTCOLOUR}${getGameConfig().skins[getGame()][skinIndex][1]}`);
}
// ===========================================================================
@@ -1112,7 +1112,7 @@ function forcePlayerWantedLevelCommand(command, params, client) {
forcePlayerWantedLevel(targetClient, wantedLevel);
//messageAdmins(`${getPlayerName(client)} {MAINCOLOUR}set ${getPlayerName(targetClient)}'s {MAINCOLOUR}skin to {ALTCOLOUR}${getGameData().skins[getGame()][skinIndex][1]}`);
//messageAdmins(`${getPlayerName(client)} {MAINCOLOUR}set ${getPlayerName(targetClient)}'s {MAINCOLOUR}skin to {ALTCOLOUR}${getGameConfig().skins[getGame()][skinIndex][1]}`);
}
// ===========================================================================

View File

@@ -237,7 +237,7 @@ function showCharacterSelectToClient(client) {
let tempSubAccount = getPlayerData(client).subAccounts[0];
let ClanName = (tempSubAccount.clan != 0) ? getClanData(getClanIdFromDatabaseId(tempSubAccount.clan)).name : "None";
let lastPlayedText = (tempSubAccount.lastLogin != 0) ? `${msToTime(getCurrentUnixTimestamp()-tempSubAccount.lastLogin)} ago` : "Never";
showPlayerCharacterSelectGUI(client, tempSubAccount.firstName, tempSubAccount.lastName, tempSubAccount.cash, ClanName, lastPlayedText, getGameData().skins[getGame()][tempSubAccount.skin][0]);
showPlayerCharacterSelectGUI(client, tempSubAccount.firstName, tempSubAccount.lastName, tempSubAccount.cash, ClanName, lastPlayedText, getGameConfig().skins[getGame()][tempSubAccount.skin][0]);
//spawnPlayer(client, getServerConfig().characterSelectPedPosition, getServerConfig().characterSelectPedHeading, getPlayerCurrentSubAccount(client).skin, getServerConfig().characterSelectInterior, getServerConfig().characterSelectDimension);
//setTimeout(function() {
@@ -321,7 +321,7 @@ function checkPreviousCharacter(client) {
let clanName = (tempSubAccount.clan != 0) ? getClanData(getClanIdFromDatabaseId(tempSubAccount.clan)).name : "None";
let lastPlayedText = (tempSubAccount.lastLogin != 0) ? `${msToTime(getCurrentUnixTimestamp()-tempSubAccount.lastLogin)} ago` : "Never";
showPlayerCharacterSelectGUI(client, tempSubAccount.firstName, tempSubAccount.lastName, tempSubAccount.cash, clanName, lastPlayedText, getGameData().skins[getGame()][tempSubAccount.skin][0]);
showPlayerCharacterSelectGUI(client, tempSubAccount.firstName, tempSubAccount.lastName, tempSubAccount.cash, clanName, lastPlayedText, getGameConfig().skins[getGame()][tempSubAccount.skin][0]);
logToConsole(LOG_DEBUG, `[VRR.SubAccount] Setting ${getPlayerDisplayForConsole(client)}'s character to ID ${getPlayerData(client).currentSubAccount}`);
}
@@ -342,7 +342,7 @@ function checkNextCharacter(client) {
let clanName = (tempSubAccount.clan != 0) ? getClanData(getClanIdFromDatabaseId(tempSubAccount.clan)).name : "None";
let lastPlayedText = (tempSubAccount.lastLogin != 0) ? `${msToTime(getCurrentUnixTimestamp()-tempSubAccount.lastLogin)} ago` : "Never";
showPlayerCharacterSelectGUI(client, tempSubAccount.firstName, tempSubAccount.lastName, tempSubAccount.cash, clanName, lastPlayedText, getGameData().skins[getGame()][tempSubAccount.skin][0]);
showPlayerCharacterSelectGUI(client, tempSubAccount.firstName, tempSubAccount.lastName, tempSubAccount.cash, clanName, lastPlayedText, getGameConfig().skins[getGame()][tempSubAccount.skin][0]);
logToConsole(LOG_DEBUG, `[VRR.SubAccount] Setting ${getPlayerDisplayForConsole(client)}'s character to ID ${getPlayerData(client).currentSubAccount}`);
}
@@ -372,11 +372,11 @@ function selectCharacter(client, characterId = -1) {
getPlayerData(client).pedState = VRR_PEDSTATE_SPAWNING;
if(getGame() < VRR_GAME_GTA_IV) {
spawnPlayer(client, spawnPosition, spawnHeading, getGameData().skins[getGame()][skin][0], spawnInterior, spawnDimension);
spawnPlayer(client, spawnPosition, spawnHeading, getGameConfig().skins[getGame()][skin][0], spawnInterior, spawnDimension);
} else if(getGame() == VRR_GAME_GTA_IV) {
spawnPlayer(client, spawnPosition, spawnHeading, getGameData().skins[getGame()][skin][0], spawnInterior, spawnDimension);
spawnPlayer(client, spawnPosition, spawnHeading, getGameConfig().skins[getGame()][skin][0], spawnInterior, spawnDimension);
} else if(getGame() >= VRR_GAME_MAFIA_ONE) {
spawnPlayer(client, getGameData().skins[getGame()][skin][0], spawnPosition, spawnHeading);
spawnPlayer(client, getGameConfig().skins[getGame()][skin][0], spawnPosition, spawnHeading);
}
removePlayerKeyBind(client, getKeyIdFromParams("insert"));
@@ -517,7 +517,7 @@ function setFightStyleCommand(command, params, client) {
if(!fightStyle) {
messagePlayerError(client, `That fight style doesn't exist!`);
messagePlayerError(client, `Fight styles: ${getGameData().fightStyles[getServerGame()].map(fs => fs[0]).join(", ")}`);
messagePlayerError(client, `Fight styles: ${getGameConfig().fightStyles[getServerGame()].map(fs => fs[0]).join(", ")}`);
return false;
}
@@ -529,7 +529,7 @@ function setFightStyleCommand(command, params, client) {
}
setPlayerFightStyle(client, fightStyleId);
messagePlayerSuccess(client, `Your fight style has been set to ${getGameData().fightStyles[getServerGame()][fightStyleId][0]}`)
messagePlayerSuccess(client, `Your fight style has been set to ${getGameConfig().fightStyles[getServerGame()][fightStyleId][0]}`)
return true;
}
@@ -562,13 +562,13 @@ function forceFightStyleCommand(command, params, client) {
if(!fightStyleId) {
messagePlayerError(client, `That fight style doesn't exist!`);
messagePlayerError(client, `Fight styles: ${getGameData().fightStyles[getServerGame()].map(fs => fs[0]).join(", ")}`);
messagePlayerError(client, `Fight styles: ${getGameConfig().fightStyles[getServerGame()].map(fs => fs[0]).join(", ")}`);
return false;
}
getPlayerCurrentSubAccount(client).fightStyle = fightStyleId;
setPlayerFightStyle(client, fightStyleId);
messagePlayerSuccess(client, `You set ${getCharacterFullName(targetClient)}'s fight style to ${getGameData().fightStyles[getServerGame()][fightStyleId][0]}`)
messagePlayerSuccess(client, `You set ${getCharacterFullName(targetClient)}'s fight style to ${getGameConfig().fightStyles[getServerGame()][fightStyleId][0]}`)
return true;
}

View File

@@ -52,7 +52,7 @@ function getAreaName(position) {
// ===========================================================================
function getGameAreas(gameId) {
return getGameData().areas[gameId];
return getGameConfig().areas[gameId];
}
// ===========================================================================
@@ -92,7 +92,7 @@ function updateServerRules() {
if(isWeatherSupported()) {
if(getServerConfig() != false) {
let value = getGameData().weatherNames[getServerGame()][getServerConfig().weather];
let value = getGameConfig().weatherNames[getServerGame()][getServerConfig().weather];
logToConsole(LOG_DEBUG, `[VRR.Utilities]: Setting server rule "Weather" as ${value}`);
server.setRule("Weather", value);
}
@@ -112,13 +112,13 @@ function updateServerRules() {
function getWeatherFromParams(params) {
if(isNaN(params)) {
for(let i in getGameData().weatherNames[getServerGame()]) {
if(toLowerCase(getGameData().weatherNames[getServerGame()][i]).indexOf(toLowerCase(params)) != -1) {
for(let i in getGameConfig().weatherNames[getServerGame()]) {
if(toLowerCase(getGameConfig().weatherNames[getServerGame()][i]).indexOf(toLowerCase(params)) != -1) {
return i;
}
}
} else {
if(typeof getGameData().weatherNames[getServerGame()][params] != "undefined") {
if(typeof getGameConfig().weatherNames[getServerGame()][params] != "undefined") {
return toInteger(params);
}
}
@@ -130,13 +130,13 @@ function getWeatherFromParams(params) {
function getFightStyleFromParams(params) {
if(isNaN(params)) {
for(let i in getGameData().fightStyles[getServerGame()]) {
if(toLowerCase(getGameData().fightStyles[getServerGame()][i][0]).indexOf(toLowerCase(params)) != -1) {
for(let i in getGameConfig().fightStyles[getServerGame()]) {
if(toLowerCase(getGameConfig().fightStyles[getServerGame()][i][0]).indexOf(toLowerCase(params)) != -1) {
return i;
}
}
} else {
if(typeof getGameData().fightStyles[getServerGame()][params] != "undefined") {
if(typeof getGameConfig().fightStyles[getServerGame()][params] != "undefined") {
return toInteger(params);
}
}
@@ -148,26 +148,26 @@ function getFightStyleFromParams(params) {
function getClosestHospital(position) {
let closest = 0;
for(let i in getGameData().hospitals[getServerGame()]) {
if(getDistance(getGameData().hospitals[getServerGame()][i].position, position) < getDistance(getGameData().hospitals[getServerGame()][closest].position, position)) {
for(let i in getGameConfig().hospitals[getServerGame()]) {
if(getDistance(getGameConfig().hospitals[getServerGame()][i].position, position) < getDistance(getGameConfig().hospitals[getServerGame()][closest].position, position)) {
closest = i;
}
}
return getGameData().hospitals[getServerGame()][closest];
return getGameConfig().hospitals[getServerGame()][closest];
}
// ===========================================================================
function getClosestPoliceStation(position) {
let closest = 0;
for(let i in getGameData().policeStations[getServerGame()]) {
if(getDistance(getGameData().policeStations[getServerGame()][i].position, position) < getDistance(getGameData().policeStations[getServerGame()][closest].position, position)) {
for(let i in getGameConfig().policeStations[getServerGame()]) {
if(getDistance(getGameConfig().policeStations[getServerGame()][i].position, position) < getDistance(getGameConfig().policeStations[getServerGame()][closest].position, position)) {
closest = i;
}
}
return getGameData().policeStations[getServerGame()][closest];
return getGameConfig().policeStations[getServerGame()][closest];
}
// ===========================================================================
@@ -206,8 +206,8 @@ function getPlayerIsland(client) {
// ===========================================================================
function isAtPayAndSpray(position) {
for(let i in getGameData().payAndSprays[getServerGame()]) {
if(getDistance(position, getGameData().payAndSprays[getServerGame()][i]) <= getGlobalConfig().payAndSprayDistance) {
for(let i in getGameConfig().payAndSprays[getServerGame()]) {
if(getDistance(position, getGameConfig().payAndSprays[getServerGame()][i]) <= getGlobalConfig().payAndSprayDistance) {
return true;
}
}

View File

@@ -1125,6 +1125,10 @@ let serverEmoji = [
// ===========================================================================
function getGameConfig() {
return gameData;
}
// ===========================================================================
function makeLargeNumberReadable(num) {
@@ -1537,13 +1541,7 @@ function isGameFeatureSupported(featureName) {
// ===========================================================================
function getAllowedSkins(gameId = getGame()) {
return getGameData().skins[gameId].filter(skin => skin[2] == true);
}
// ===========================================================================
function getGameData() {
return gameData;
return getGameConfig().skins[gameId].filter(skin => skin[2] == true);
}
// ===========================================================================
@@ -1561,7 +1559,7 @@ function getAllowedSkinIndexFromSkin(skin) {
// ===========================================================================
function getSkinIndexFromModel(model, gameId = getGame()) {
let skins = getGameData().skins[gameId];
let skins = getGameConfig().skins[gameId];
for(let i in skins) {
if(toLowerCase(skins[i][0]).indexOf(toLowerCase(model)) != -1) {
return i;
@@ -1574,7 +1572,7 @@ function getSkinIndexFromModel(model, gameId = getGame()) {
// ===========================================================================
function getSkinIndexFromName(name, gameId = getGame()) {
let skins = getGameData().skins[gameId];
let skins = getGameConfig().skins[gameId];
for(let i in skins) {
if(toLowerCase(skins[i][1]).indexOf(toLowerCase(name)) != -1) {
return i;
@@ -1587,7 +1585,7 @@ function getSkinIndexFromName(name, gameId = getGame()) {
// ===========================================================================
function getObjectModelIndexFromModel(model, gameId = getGame()) {
let objects = getGameData().objects[gameId];
let objects = getGameConfig().objects[gameId];
for(let i in objects) {
if(toLowerCase(objects[i][0]).indexOf(toLowerCase(model)) != -1) {
return i;
@@ -1600,7 +1598,7 @@ function getObjectModelIndexFromModel(model, gameId = getGame()) {
// ===========================================================================
function getGameName(gameId = getGame()) {
return getGameData().gameNames[gameId];
return getGameConfig().gameNames[gameId];
}
// ===========================================================================
@@ -1623,7 +1621,7 @@ function getVehicleModelIndexFromParams(params, gameId = getGame()) {
// ===========================================================================
function getVehicleModelIndexFromName(name, gameId = getGame()) {
let vehicles = getGameData().vehicles[gameId];
let vehicles = getGameConfig().vehicles[gameId];
for(let i in vehicles) {
if(toLowerCase(vehicles[i][1]).indexOf(toLowerCase(name)) != -1) {
return i;
@@ -1636,7 +1634,7 @@ function getVehicleModelIndexFromName(name, gameId = getGame()) {
// ===========================================================================
function getVehicleModelIndexFromModel(model, gameId = getGame()) {
let vehicles = getGameData().vehicles[gameId];
let vehicles = getGameConfig().vehicles[gameId];
for(let i in vehicles) {
if(isNaN(model)) {
if(toLowerCase(vehicles[i][0]).indexOf(toLowerCase(model)) != -1) {
@@ -1655,7 +1653,7 @@ function getVehicleModelIndexFromModel(model, gameId = getGame()) {
// ===========================================================================
function getVehicleModelFromName(name, gameId = getGame()) {
let vehicles = getGameData().vehicles[gameId];
let vehicles = getGameConfig().vehicles[gameId];
for(let i in vehicles) {
if(toLowerCase(vehicles[i][1]).indexOf(toLowerCase(name)) != -1) {
return vehicles[i][0];
@@ -1668,7 +1666,7 @@ function getVehicleModelFromName(name, gameId = getGame()) {
// ===========================================================================
function getVehicleNameFromModel(model, gameId = getGame()) {
let vehicles = getGameData().vehicles[gameId];
let vehicles = getGameConfig().vehicles[gameId];
for(let i in vehicles) {
if(isNaN(model)) {
if(toLowerCase(vehicles[i][0]).indexOf(toLowerCase(model)) != -1) {
@@ -1704,7 +1702,7 @@ function getSkinModelIndexFromParams(params, gameId = getServerGame()) {
// ===========================================================================
function getSkinNameFromModel(model, gameId = getServerGame()) {
let skins = getGameData().skins[gameId];
let skins = getGameConfig().skins[gameId];
for(let i in skins) {
if(toLowerCase(skins[i][0]).indexOf(toLowerCase(model)) != -1) {
return skins[i][1];
@@ -1717,7 +1715,7 @@ function getSkinNameFromModel(model, gameId = getServerGame()) {
// ===========================================================================
function getSkinModelFromName(name, gameId = getServerGame()) {
let skins = getGameData().skins[gameId];
let skins = getGameConfig().skins[gameId];
for(let i in skins) {
if(toLowerCase(skins[i][1]).indexOf(toLowerCase(name)) != -1) {
return skins[i][0];
@@ -1745,7 +1743,7 @@ function getObjectModelIndexFromParams(params, gameId = getServerGame()) {
// ===========================================================================
function getObjectNameFromModel(model, gameId = getServerGame()) {
let objects = getGameData().objects[gameId];
let objects = getGameConfig().objects[gameId];
for(let i in objects) {
if(toLowerCase(objects[i][0]).indexOf(toLowerCase(model)) != -1) {
return objects[i][1];
@@ -1758,7 +1756,7 @@ function getObjectNameFromModel(model, gameId = getServerGame()) {
// ===========================================================================
function getObjectModelFromName(name, gameId = getServerGame()) {
let objects = getGameData().objects[gameId];
let objects = getGameConfig().objects[gameId];
for(let i in objects) {
if(toLowerCase(objects[i][1]).indexOf(toLowerCase(name)) != -1) {
return objects[i][0];
@@ -2074,14 +2072,14 @@ async function waitUntil(condition) {
function getGameLocationFromParams(params) {
if(isNaN(params)) {
let locations = getGameData().locations[getGame()];
let locations = getGameConfig().locations[getGame()];
for(let i in locations) {
if(toLowerCase(locations[i][0]).indexOf(toLowerCase(params)) != -1) {
return i;
}
}
} else {
if(typeof getGameData().locations[getGame()][params] != "undefined") {
if(typeof getGameConfig().locations[getGame()][params] != "undefined") {
return toInteger(params);
}
}