Merge branch 'gtaiv' into 1.4.0-prep

This commit is contained in:
Vortrex
2022-03-09 00:21:37 -06:00
46 changed files with 1192 additions and 941 deletions

View File

@@ -63,8 +63,7 @@ function listAccentsCommand(command, params, client) {
let chunkedList = splitArrayIntoChunks(accentList, 8);
messagePlayerInfo(client, `{clanOrange}== {jobYellow}Accents {clanOrange}==================================`);
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "AccentList")));
for(let i in chunkedList) {
messagePlayerInfo(client, chunkedList[i].join(", "));
}
@@ -112,7 +111,7 @@ function addAccentCommand(command, params, client) {
getGlobalConfig().accents.push(newAccentName);
saveAccentConfig();
messageAdmins(`${client.name} {MAINCOLOUR}added a new accent: ${newAccentName}`);
messageAdmins(`${client.name}{MAINCOLOUR} added a new accent: ${newAccentName}`);
}
// ===========================================================================
@@ -132,7 +131,7 @@ function removeAccentCommand(command, params, client) {
getGlobalConfig().accents.push(newAccentName);
saveAccentConfig();
messageAdmins(`${client.name} {MAINCOLOUR}added a new accent: ${newAccentName}`);
messageAdmins(`${client.name}{MAINCOLOUR} added a new accent: ${newAccentName}`);
}
// ===========================================================================

View File

@@ -599,7 +599,6 @@ function loginSuccess(client) {
getPlayerData(client).accountData.ipAddress = client.ip;
//sendRemovedWorldObjectsToPlayer(client);
sendPlayerChatScrollLines(client, getPlayerData(client).accountData.chatScrollLines);
messagePlayerNormal(null, `👋 ${getPlayerName(client)} has joined the server`, getColourByName("softYellow"));
@@ -1127,6 +1126,7 @@ function initClient(client) {
updatePlayerSnowState(client);
showConnectCameraToPlayer(client);
messageClient(`Please wait ...`, client, getColourByName("softGreen"));
setTimeout(function() {

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

@@ -9,57 +9,8 @@
function initAntiCheatScript() {
logToConsole(LOG_DEBUG, "[VRR.AntiCheat]: Initializing anticheat script ...");
getServerData().antiCheat.whiteListedGameScripts = loadAntiCheatGameScriptWhiteListFromDatabase();
getServerData().antiCheat.blackListedGameScripts = loadAntiCheatGameScriptBlackListFromDatabase();
logToConsole(LOG_DEBUG, "[VRR.AntiCheat]: Anticheat script initialized!");
}
// ===========================================================================
function loadAntiCheatGameScriptWhiteListFromDatabase() {
logToConsole(LOG_DEBUG, `[VRR.AntiCheat] Loading whitelisted game scripts ...`);
let dbConnection = connectToDatabase();
let tempWhiteListedGameScripts = [];
if(dbConnection) {
let dbQueryString = `SELECT * FROM ac_script_wl WHERE ac_script_wl_enabled = 1 AND ac_script_wl_server = ${getServerId()}`;
let dbQuery = queryDatabase(dbConnection, dbQueryString);
if(dbQuery) {
if(dbQuery.numRows > 0) {
let dbAssoc = fetchQueryAssoc(dbQuery);
let tempWhiteListedGameScriptData = new WhiteListedGameScriptData(dbAssoc);
tempWhiteListedGameScripts.push(tempWhiteListedGameScriptData);
logToConsole(LOG_DEBUG, `[VRR.AntiCheat] Whitelisted game script '${tempWhiteListedGameScriptData.scriptName}' loaded successfully!`);
}
}
disconnectFromDatabase(dbConnection);
}
logToConsole(LOG_DEBUG, `[VRR.AntiCheat] ${tempWhiteListedGameScripts.length} whitelisted game scripts loaded!`);
return tempWhiteListedGameScripts;
}
// ===========================================================================
function loadAntiCheatGameScriptBlackListFromDatabase() {
logToConsole(LOG_DEBUG, `[VRR.AntiCheat] Loading blacklisted game scripts ...`);
let dbConnection = connectToDatabase();
let tempBlackListedGameScripts = [];
if(dbConnection) {
let dbQueryString = `SELECT * FROM ac_script_bl WHERE ac_script_bl_enabled = 1 AND ac_script_bl_server = ${getServerId()}`;
let dbQuery = queryDatabase(dbConnection, dbQueryString);
if(dbQuery) {
if(dbQuery.numRows > 0) {
let dbAssoc = fetchQueryAssoc(dbQuery);
let tempBlackListedGameScriptData = new BlackListedGameScriptData(dbAssoc);
tempBlackListedGameScripts.push(tempBlackListedGameScriptData);
logToConsole(LOG_DEBUG, `[VRR.AntiCheat] Blacklisted game script '${tempBlackListedGameScriptData.scriptName}' loaded successfully!`);
}
}
disconnectFromDatabase(dbConnection);
}
logToConsole(LOG_DEBUG, `[VRR.AntiCheat] ${tempBlackListedGameScripts.length} blacklisted game scripts loaded!`);
return tempBlackListedGameScripts;
}
// ===========================================================================
@@ -76,170 +27,6 @@ function clearPlayerStateToEnterExitProperty(client) {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function addAntiCheatBlackListedScriptCommand(command, params, client) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
return false;
}
let scriptName = params;
let tempBlackListedGameScriptData = new BlackListedGameScriptData(false);
tempBlackListedGameScriptData.scriptName = scriptName;
tempBlackListedGameScriptData.serverId = getServerId();
tempBlackListedGameScriptData.enabled = true;
tempBlackListedGameScriptData.needsSaved = true;
getServerConfig().antiCheat.blackListedGameScripts.push(tempBlackListedGameScriptData);
if(getServerConfig().antiCheat.gameScriptBlackListEnabled) {
sendPlayerGameScriptState(null, scriptName, VRR_GAMESCRIPT_DENY);
}
messagePlayerSuccess(client, `You added {ALTCOLOUR}${scriptName} {MAINCOLOUR} to the anticheat game script blacklist`);
return true;
}
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function addAntiCheatWhiteListedScriptCommand(command, params, client) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
return false;
}
let scriptName = params;
let tempWhiteListedGameScriptData = new WhiteListedGameScriptData(false);
tempWhiteListedGameScriptData.scriptName = scriptName;
tempWhiteListedGameScriptData.serverId = getServerId();
tempWhiteListedGameScriptData.enabled = true;
tempWhiteListedGameScriptData.needsSaved = true;
getServerConfig().antiCheat.whiteListedGameScripts.push(tempWhiteListedGameScriptData);
if(getServerConfig().antiCheat.gameScriptWhiteListEnabled) {
sendPlayerGameScriptState(null, scriptName, VRR_GAMESCRIPT_ALLOW);
}
messagePlayerSuccess(client, `You added {ALTCOLOUR}${scriptName} {MAINCOLOUR} to the anticheat game script whitelist`);
return true;
}
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function removeAntiCheatWhiteListedScriptCommand(command, params, client) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
return false;
}
let whiteListScriptId = getAntiCheatWhiteListedScriptFromParams(params);
getServerConfig().antiCheat.whiteListedGameScripts.splice(whiteListScriptId, 1);
if(getServerConfig().antiCheat.gameScriptWhiteListEnabled) {
sendPlayerGameScriptState(null, scriptName, VRR_GAMESCRIPT_NONE);
}
messagePlayerSuccess(client, `You removed {ALTCOLOUR}${scriptName} {MAINCOLOUR} from the anticheat game script whitelist`);
return true;
}
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function removeAntiCheatBlackListedScriptCommand(command, params, client) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
return false;
}
let blackListScriptId = getAntiCheatBlackListedScriptFromParams(params);
getServerConfig().antiCheat.blackListedGameScripts.splice(blackListScriptId, 1);
if(getServerConfig().antiCheat.gameScriptBlackListEnabled) {
sendPlayerGameScriptState(null, scriptName, VRR_GAMESCRIPT_NONE);
}
messagePlayerSuccess(client, `You removed {ALTCOLOUR}${scriptName} {MAINCOLOUR} from the anticheat game script blacklist`);
return true;
}
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function toggleAntiCheatScriptWhiteListCommand(command, params, client) {
getServerConfig().antiCheat.gameScriptWhiteListEnabled = !getServerConfig().antiCheat.gameScriptWhiteListEnabled;
getServerConfig().needsSaved = true;
messageAdminAction(`${getPlayerName(client)} {MAINCOLOUR}turned anticheat game script whitelist ${getBoolRedGreenInlineColour(getServerConfig().antiCheat.gameScriptWhiteListEnabled)}${toUpperCase(getOnOffFromBool(getServerConfig().antiCheat.gameScriptWhiteListEnabled))}`);
updateServerRules();
return true;
}
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function toggleAntiCheatScriptBlackListCommand(command, params, client) {
getServerConfig().antiCheat.gameScriptBlackListEnabled = !getServerConfig().antiCheat.gameScriptBlackListEnabled;
getServerConfig().needsSaved = true;
messageAdminAction(`${getPlayerName(client)} {MAINCOLOUR}turned anticheat game script blacklist ${getBoolRedGreenInlineColour(getServerConfig().antiCheat.gameScriptBlackListEnabled)}${toUpperCase(getOnOffFromBool(getServerConfig().antiCheat.gameScriptBlackListEnabled))}`);
updateServerRules();
return true;
}
// ===========================================================================
function isPlayerExemptFromAntiCheat(client) {
if(hasBitFlag(getPlayerData(client).accountData.flags.moderation, getModerationFlagValue("ExemptFromAntiCheat"))) {
return true;

View File

@@ -58,7 +58,7 @@ function loadBusinessesFromDatabase() {
while(dbAssoc = fetchQueryAssoc(dbQuery)) {
let tempBusinessData = new BusinessData(dbAssoc);
tempBusinessData.locations = loadBusinessLocationsFromDatabase(tempBusinessData.databaseId);
tempBusinessData.gameScripts = loadBusinessGameScriptsFromDatabase(tempBusinessData.databaseId);
//tempBusinessData.gameScripts = loadBusinessGameScriptsFromDatabase(tempBusinessData.databaseId);
tempBusinesses.push(tempBusinessData);
logToConsole(LOG_INFO, `[VRR.Business]: Business '${tempBusinessData.name}' (ID ${tempBusinessData.databaseId}) loaded from database successfully!`);
}
@@ -105,6 +105,7 @@ function loadBusinessLocationsFromDatabase(businessId) {
// ===========================================================================
/*
function loadBusinessGameScriptsFromDatabase(businessId) {
logToConsole(LOG_VERBOSE, `[VRR.Business]: Loading business game scripts for business ${businessId} from database ...`);
@@ -133,6 +134,7 @@ function loadBusinessGameScriptsFromDatabase(businessId) {
logToConsole(LOG_VERBOSE, `[VRR.Business]: ${tempBusinessGameScripts.length} game scripts for business ${businessId} loaded from database successfully!`);
return tempBusinessGameScripts;
}
*/
// ===========================================================================
@@ -1335,7 +1337,7 @@ function createAllBusinessBlips() {
// ===========================================================================
function createBusinessEntrancePickup(businessId) {
function createBusinessEntrancePickup(businessId) {
if(!getServerConfig().createBusinessPickups) {
return false;
}
@@ -1348,18 +1350,26 @@ function createBusinessEntrancePickup(businessId) {
}
logToConsole(LOG_VERBOSE, `[VRR.Job]: Creating entrance pickup for business ${getBusinessData(businessId).name} (model ${pickupModelId})`);
getBusinessData(businessId).entrancePickup = createGamePickup(pickupModelId, getBusinessData(businessId).entrancePosition, getGameConfig().pickupTypes[getServerGame()].business);
setElementOnAllDimensions(getBusinessData(businessId).entrancePickup, false);
setElementDimension(getBusinessData(businessId).entrancePickup, getBusinessData(businessId).entranceDimension);
updateBusinessPickupLabelData(businessId);
addToWorld(getBusinessData(businessId).entrancePickup);
if(areServerElementsSupported()) {
getBusinessData(businessId).entrancePickup = createGamePickup(pickupModelId, getBusinessData(businessId).entrancePosition, getGameConfig().pickupTypes[getServerGame()].business);
setElementOnAllDimensions(getBusinessData(businessId).entrancePickup, false);
setElementDimension(getBusinessData(businessId).entrancePickup, getBusinessData(businessId).entranceDimension);
updateBusinessPickupLabelData(businessId);
addToWorld(getBusinessData(businessId).entrancePickup);
} else {
sendBusinessEntranceToPlayer(null, businessId, getBusinessData(businessId), getBusinessData(businessId).entrancePosition, getBusinessData(businessId).entranceBlipModel, getBusinessData(businessId).entrancePickupModel, getBusinessData(businessId).hasInterior, false);
}
}
}
// ===========================================================================
function createBusinessEntranceBlip(businessId) {
if(!areServerElementsSupported()) {
return false;
}
if(!getServerConfig().createBusinessBlips) {
return false;
}
@@ -1372,11 +1382,15 @@ function createBusinessEntranceBlip(businessId) {
}
logToConsole(LOG_VERBOSE, `[VRR.Job]: Creating entrance blip for business ${getBusinessData(businessId).name} (model ${blipModelId})`);
getBusinessData(businessId).entranceBlip = createGameBlip(getBusinessData(businessId).entrancePosition, blipModelId, 1, getColourByName("businessBlue"));
setElementOnAllDimensions(getBusinessData(businessId).entranceBlip, false);
setElementDimension(getBusinessData(businessId).entranceBlip, getBusinessData(businessId).entranceDimension);
addToWorld(getBusinessData(businessId).entranceBlip);
if(areServerElementsSupported()) {
getBusinessData(businessId).entranceBlip = createGameBlip(getBusinessData(businessId).entrancePosition, blipModelId, 1, getColourByName("businessBlue"));
setElementOnAllDimensions(getBusinessData(businessId).entranceBlip, false);
setElementDimension(getBusinessData(businessId).entranceBlip, getBusinessData(businessId).entranceDimension);
addToWorld(getBusinessData(businessId).entranceBlip);
} else {
sendBusinessEntranceToPlayer(null, businessId, getBusinessData(businessId).name, getBusinessData(businessId).entrancePosition, blipModelId, getBusinessData(businessId).entrancePickupModel, getBusinessData(businessId).hasInterior, false);
}
}
}
@@ -1396,12 +1410,14 @@ function createBusinessExitPickup(businessId) {
}
logToConsole(LOG_VERBOSE, `[VRR.Job]: Creating exit pickup for business ${getBusinessData(businessId).name} (model ${pickupModelId})`);
getBusinessData(businessId).exitPickup = createGamePickup(pickupModelId, getBusinessData(businessId).exitPosition, getGameConfig().pickupTypes[getServerGame()].business);
setElementDimension(getBusinessData(businessId).exitPickup, getBusinessData(businessId).exitDimension);
setElementOnAllDimensions(getBusinessData(businessId).exitPickup, false);
updateBusinessPickupLabelData(businessId);
addToWorld(getBusinessData(businessId).exitPickup);
if(areServerElementsSupported()) {
getBusinessData(businessId).exitPickup = createGamePickup(pickupModelId, getBusinessData(businessId).exitPosition, getGameConfig().pickupTypes[getServerGame()].business);
setElementDimension(getBusinessData(businessId).exitPickup, getBusinessData(businessId).exitDimension);
setElementOnAllDimensions(getBusinessData(businessId).exitPickup, false);
updateBusinessPickupLabelData(businessId);
addToWorld(getBusinessData(businessId).exitPickup);
}
}
}
}
@@ -1421,15 +1437,17 @@ function createBusinessExitBlip(businessId) {
blipModelId = getBusinessData(businessId).exitBlipModel;
}
logToConsole(LOG_VERBOSE, `[VRR.Job]: Creating exit blip for business ${getBusinessData(businessId).name} (model ${blipModelId})`);
if(areServerElementsSupported()) {
logToConsole(LOG_VERBOSE, `[VRR.Job]: Creating exit blip for business ${getBusinessData(businessId).name} (model ${blipModelId})`);
getBusinessData(businessId).exitBlip = createGameBlip(getBusinessData(businessId).exitPosition, blipModelId, 1, getColourByName("businessBlue"));
setElementDimension(getBusinessData(businessId).exitBlip, getBusinessData(businessId).entranceDimension);
setElementOnAllDimensions(getBusinessData(businessId).exitBlip, false);
//getBusinessData(businessId).exitBlip.interior = getBusinessData(businessId).exitInterior;
//setEntityData(getBusinessData(businessId).exitBlip, "vrr.owner.type", VRR_BLIP_BUSINESS_EXIT, false);
//setEntityData(getBusinessData(businessId).exitBlip, "vrr.owner.id", businessId, false);
addToWorld(getBusinessData(businessId).exitBlip);
getBusinessData(businessId).exitBlip = createGameBlip(getBusinessData(businessId).exitPosition, blipModelId, 1, getColourByName("businessBlue"));
setElementDimension(getBusinessData(businessId).exitBlip, getBusinessData(businessId).entranceDimension);
setElementOnAllDimensions(getBusinessData(businessId).exitBlip, false);
//getBusinessData(businessId).exitBlip.interior = getBusinessData(businessId).exitInterior;
//setEntityData(getBusinessData(businessId).exitBlip, "vrr.owner.type", VRR_BLIP_BUSINESS_EXIT, false);
//setEntityData(getBusinessData(businessId).exitBlip, "vrr.owner.id", businessId, false);
addToWorld(getBusinessData(businessId).exitBlip);
}
}
}
}
@@ -1535,6 +1553,10 @@ function doesBusinessHaveInterior(businessId) {
// ===========================================================================
function deleteBusinessEntrancePickup(businessId) {
if(!areServerElementsSupported()) {
return false;
}
if(getBusinessData(businessId).entrancePickup != null) {
//removeFromWorld(getBusinessData(businessId).entrancePickup);
deleteGameElement(getBusinessData(businessId).entrancePickup);
@@ -1545,6 +1567,10 @@ function deleteBusinessEntrancePickup(businessId) {
// ===========================================================================
function deleteBusinessExitPickup(businessId) {
if(!areServerElementsSupported()) {
return false;
}
if(getBusinessData(businessId).exitPickup != null) {
//removeFromWorld(getBusinessData(businessId).exitPickup);
deleteGameElement(getBusinessData(businessId).exitPickup);
@@ -1555,6 +1581,10 @@ function deleteBusinessExitPickup(businessId) {
// ===========================================================================
function deleteBusinessEntranceBlip(businessId) {
if(!areServerElementsSupported()) {
return false;
}
if(getBusinessData(businessId).entranceBlip != null) {
//removeFromWorld(getBusinessData(businessId).entranceBlip);
deleteGameElement(getBusinessData(businessId).entranceBlip);
@@ -1565,6 +1595,10 @@ function deleteBusinessEntranceBlip(businessId) {
// ===========================================================================
function deleteBusinessExitBlip(businessId) {
if(!areServerElementsSupported()) {
return false;
}
if(getBusinessData(businessId).exitBlip != null) {
//removeFromWorld(getBusinessData(businessId).exitBlip);
deleteGameElement(getBusinessData(businessId).exitBlip);
@@ -1907,6 +1941,10 @@ function getBusinessIdFromDatabaseId(databaseId) {
// ===========================================================================
function updateBusinessPickupLabelData(businessId) {
if(!areServerElementsSupported()) {
return false;
}
if(getBusinessData(businessId).exitPickup != null) {
setEntityData(getBusinessData(businessId).exitPickup, "vrr.owner.type", VRR_PICKUP_BUSINESS_EXIT, false);
setEntityData(getBusinessData(businessId).exitPickup, "vrr.owner.id", businessId, false);
@@ -2022,19 +2060,19 @@ function doesBusinessHaveAnyItemsToBuy(businessId) {
// ===========================================================================
function sendPlayerBusinessGameScripts(client, businessId) {
for(let i in getBusinessData(businessId).gameScripts) {
sendPlayerGameScriptState(client, getBusinessData(businessId).gameScripts[i].state);
}
}
//function sendPlayerBusinessGameScripts(client, businessId) {
// for(let i in getBusinessData(businessId).gameScripts) {
// sendPlayerGameScriptState(client, getBusinessData(businessId).gameScripts[i].state);
// }
//}
// ===========================================================================
function clearPlayerBusinessGameScripts(client, businessId) {
for(let i in getBusinessData(businessId).gameScripts) {
sendPlayerGameScriptState(client, VRR_GAMESCRIPT_DENY);
}
}
//function clearPlayerBusinessGameScripts(client, businessId) {
// for(let i in getBusinessData(businessId).gameScripts) {
// sendPlayerGameScriptState(client, VRR_GAMESCRIPT_DENY);
// }
//}
// ===========================================================================

View File

@@ -62,11 +62,11 @@ class ServerData {
this.antiCheat = {
enabled: false,
checkGameScripts: false,
gameScriptWhiteListEnabled: false,
gameScriptBlackListEnabled: false,
gameScriptWhiteList: [],
gameScriptBlackList: [],
//checkGameScripts: false,
//gameScriptWhiteListEnabled: false,
//gameScriptBlackListEnabled: false,
//gameScriptWhiteList: [],
//gameScriptBlackList: [],
};
this.discordBotToken = "";
@@ -113,38 +113,14 @@ class ServerData {
this.minute = toInteger(dbAssoc["svr_start_time_min"]);
this.minuteDuration = toInteger(dbAssoc["svr_time_min_duration"]);
this.weather = toInteger(dbAssoc["svr_start_weather"]);
this.fallingSnow = hasBitFlag(this.settings, getServerSettingsFlagValue("FallingSnow"));
this.groundSnow = hasBitFlag(this.settings, getServerSettingsFlagValue("GroundSnow"));
this.useGUI = hasBitFlag(this.settings, getServerSettingsFlagValue("GUI"));
this.guiColourPrimary = [toInteger(dbAssoc["svr_gui_col1_r"]), toInteger(dbAssoc["svr_gui_col1_g"]), toInteger(dbAssoc["svr_gui_col1_b"])];
this.guiColourSecondary = [toInteger(dbAssoc["svr_gui_col2_r"]), toInteger(dbAssoc["svr_gui_col2_g"]), toInteger(dbAssoc["svr_gui_col2_b"])];
this.guiTextColourPrimary = [toInteger(dbAssoc["svr_gui_textcol1_r"]), toInteger(dbAssoc["svr_gui_textcol1_g"]), toInteger(dbAssoc["svr_gui_textcol1_b"])];
//this.guiTextColourSecondary = [toInteger(dbAssoc["svr_gui_textcol2_r"]), toInteger(dbAssoc["svr_gui_textcol2_g"]), toInteger(dbAssoc["svr_gui_textcol2_b"])];
this.showLogo = hasBitFlag(this.settings, getServerSettingsFlagValue("Logo"));
this.inflationMultiplier = toFloat(dbAssoc["svr_inflation_multiplier"]);
this.testerOnly = hasBitFlag(this.settings, getServerSettingsFlagValue("Testing"));
this.antiCheat = {
enabled: hasBitFlag(this.settings, getServerSettingsFlagValue("Anticheat")),
checkGameScripts: hasBitFlag(this.settings, getServerSettingsFlagValue("CheckGameScripts")),
gameScriptBlackListEnabled: hasBitFlag(this.settings, getServerSettingsFlagValue("GameScriptBlackList")),
gameScriptWhiteListEnabled: hasBitFlag(this.settings, getServerSettingsFlagValue("GameScriptWhiteList")),
gameScriptWhiteList: [],
gameScriptBlackList: [],
};
this.discordBotToken = intToBool(dbAssoc["svr_discord_bot_token"]);
this.discordEnabled = hasBitFlag(this.settings, getServerSettingsFlagValue("DiscordBot"));
this.createJobPickups = hasBitFlag(this.settings, getServerSettingsFlagValue("JobPickups"));
this.createBusinessPickups = hasBitFlag(this.settings, getServerSettingsFlagValue("BusinessPickups"));
this.createHousePickups = hasBitFlag(this.settings, getServerSettingsFlagValue("HousePickups"));
this.createJobBlips = hasBitFlag(this.settings, getServerSettingsFlagValue("JobBlips"));
this.createBusinessBlips = hasBitFlag(this.settings, getServerSettingsFlagValue("BusinessBlips"));
this.createHouseBlips = hasBitFlag(this.settings, getServerSettingsFlagValue("HouseBlips"));
this.introMusicURL = dbAssoc["svr_intro_music"];
this.useRealTime = hasBitFlag(this.settings, getServerSettingsFlagValue("RealTime"));
this.realTimeZone = dbAssoc["svr_time_realtime_timezone"];
this.discordConfig = {
@@ -263,6 +239,8 @@ class ClientData {
this.locale = 0;
this.enteringVehicle = null;
this.pedId = -1;
}
};
@@ -672,7 +650,7 @@ class HouseData {
this.itemCache = [];
this.locations = [];
this.gameScripts = [];
//this.gameScripts = [];
this.entrancePosition = false;
this.entranceRotation = 0.0;

View File

@@ -74,6 +74,7 @@ function addAllNetworkHandlers() {
addNetworkEventHandler("vrr.skinSelected", playerFinishedSkinSelection);
addNetworkEventHandler("vrr.clientInfo", updateConnectionLogOnClientInfoReceive);
addNetworkEventHandler("vrr.vehBuyState", receiveVehiclePurchaseStateUpdateFromClient);
addNetworkEventHandler("vrr.playerPedId", receivePlayerPedNetworkId);
}
// ===========================================================================
@@ -223,29 +224,6 @@ function updatePlayerSnowState(client) {
// ===========================================================================
function sendExcludedModelsForGroundSnowToPlayer(client) {
if(getGameConfig().excludedGroundSnowModels[getServerGame()].length > 0) {
for(let i in getGameConfig().excludedGroundSnowModels[getServerGame()]) {
logToConsole(LOG_DEBUG, `[VRR.Misc] Sending excluded model ${i} for ground snow to ${getPlayerName(client)}`);
sendNetworkEventToPlayer("vrr.excludeGroundSnow", client, getGameConfig().excludedGroundSnowModels[getServerGame()][i]);
}
}
}
// ===========================================================================
function sendRemovedWorldObjectsToPlayer(client) {
if(getGameConfig().removedWorldObjects[getServerGame()].length > 0) {
for(let i in getGameConfig().removedWorldObjects[getServerGame()]) {
logToConsole(LOG_DEBUG, `[VRR.Client] Sending removed world object ${i} (${getGameConfig().removedWorldObjects[getServerGame()][i][0]}) to ${getPlayerName(client)}`);
sendNetworkEventToPlayer("vrr.removeWorldObject", client, getGameConfig().removedWorldObjects[getServerGame()][i][0], getGameConfig().removedWorldObjects[getServerGame()][i][1], getGameConfig().removedWorldObjects[getServerGame()][i][2]);
}
}
return true;
}
// ===========================================================================
function updatePlayerHotBar(client) {
logToConsole(LOG_DEBUG, `[VRR.Client] Sending updated hotbar data to ${getPlayerDisplayForConsole(client)}`);
let tempHotBarItems = [];
@@ -1053,12 +1031,6 @@ function setPlayerHeadLookPosition(client, position) {
// ===========================================================================
function sendPlayerGameScriptState(client, scriptName, state) {
sendNetworkEventToPlayer("vrr.gameScript", client, scriptName, state);
}
// ===========================================================================
function requestClientInfo(client) {
sendNetworkEventToPlayer("vrr.clientInfo", client);
}
@@ -1078,7 +1050,10 @@ function forcePlayerToSyncElementProperties(client, element) {
// ===========================================================================
function sendPlayerPedPartsAndProps(client) {
sendNetworkEventToPlayer("vrr.ped")
let bodyParts = getPlayerCurrentSubAccount(client).bodyParts;
let bodyProps = getPlayerCurrentSubAccount(client).bodyProps;
sendNetworkEventToPlayer("vrr.ped", client, [bodyParts.hair, bodyParts.head, bodyParts.upper, bodyParts.lower], [bodyProps.hair, bodyProps.eyes, bodyProps.head, bodyProps.leftHand, bodyProps.rightHand, bodyProps.leftWrist, bodyProps.rightWrist, bodyParts.hip, bodyProps.leftFoot, bodyProps.rightFoot]);
}
// ===========================================================================
@@ -1134,4 +1109,56 @@ function setPlayerInfiniteRun(client, state) {
sendNetworkEventToPlayer("vrr.infiniteRun", client, state);
}
// ==========================================================================
function sendBusinessEntranceToPlayer(client, businessId, name, entrancePosition, blipModel, pickupModel, hasInterior, hasItems) {
sendNetworkEventToPlayer("vrr.business", client, businessId, name, entrancePosition, blipModel, pickupModel, hasInterior, hasItems);
}
// ==========================================================================
function sendHouseEntranceToPlayer(client, houseId, entrancePosition, blipModel, pickupModel, hasInterior) {
sendNetworkEventToPlayer("vrr.house", client, houseId, entrancePosition, blipModel, pickupModel, hasInterior);
}
// ==========================================================================
function sendAllBusinessEntrancesToPlayer(client) {
let businesses = getServerData().businesses;
for(let i in businesses) {
if(businesses[i].entranceBlipModel > 0) {
sendBusinessEntranceToPlayer(client, businesses[i].index, businesses[i].name, businesses[i].entrancePosition, businesses[i].entranceBlipModel, businesses[i].entrancePickupModel, businesses[i].hasInterior, false);
}
}
}
// ==========================================================================
function sendAllHouseEntrancesToPlayer(client) {
let houses = getServerData().houses;
for(let i in houses) {
if(houses[i].entranceBlipModel > 0) {
sendBusinessEntranceToPlayer(client, businesses[i].index, houses[i].entrancePosition, houses[i].entranceBlipModel, houses[i].entrancePickupModel, houses[i].hasInterior);
}
}
}
// ==========================================================================
function makePlayerHoldObjectModel(client, modelIndex) {
sendNetworkEventToPlayer("vrr.holdObject", client, getPlayerData(client).pedId, modelIndex);
}
// ==========================================================================
function receivePlayerPedNetworkId(client, pedId) {
getPlayerData(client).pedId = pedId;
}
// ==========================================================================
function requestPlayerPedNetworkId(client) {
sendNetworkEventToPlayer("vrr.playerPedId", client);
}
// ==========================================================================

View File

@@ -68,12 +68,6 @@ function loadCommands() {
commandData("stopanim", stopPlayerAnimationCommand, "", getStaffFlagValue("None"), true, true, "Stops your current animation"),
],
antiCheat: [
commandData("addacscriptwl", addAntiCheatWhiteListedScriptCommand, "<script name>", getStaffFlagValue("ManageAntiCheat"), true, true),
commandData("delacscriptwl", removeAntiCheatWhiteListedScriptCommand, "<script name>", getStaffFlagValue("ManageAntiCheat"), true, true),
commandData("addacscriptbl", addAntiCheatBlackListedScriptCommand, "<script name>", getStaffFlagValue("ManageAntiCheat"), true, true),
commandData("delacscriptbl", removeAntiCheatBlackListedScriptCommand, "<script name>", getStaffFlagValue("ManageAntiCheat"), true, true),
commandData("setacscriptbl", toggleAntiCheatScriptBlackListCommand, "<0/1 state>", getStaffFlagValue("ManageAntiCheat"), true, true),
commandData("setacscriptwl", toggleAntiCheatScriptWhiteListCommand, "<0/1 state>", getStaffFlagValue("ManageAntiCheat"), true, true),
//commandData("setac", toggleGlobalAntiCheatCommand, "<0/1 state>", getStaffFlagValue("Developer"), true, true),
//commandData("ac", getGlobalAntiCheatStatusCommand, "<0/1 state>", getStaffFlagValue("Developer"), true, true),
],

View File

@@ -7,10 +7,10 @@
// TYPE: Server (JavaScript)
// ===========================================================================
let serverConfig = {};
let databaseConfig = {};
let emailConfig = {};
let gameConfig = {};
let serverConfig = false;
let databaseConfig = false;
let emailConfig = false;
let gameConfig = false;
// ===========================================================================
@@ -75,9 +75,38 @@ let globalConfig = {
// ===========================================================================
function loadGameConfig() {
return gameData;
};
function initConfigScript() {
logToConsole(LOG_INFO, "[VRR.Config]: Initializing config script ...");
logToConsole(LOG_DEBUG, "[VRR.Config]: Loading global config ...");
loadGlobalConfig();
logToConsole(LOG_DEBUG, "[VRR.Config]: Loading server config ...");
serverConfig = loadServerConfigFromGameAndPort(server.game, server.port, getMultiplayerMod());
logToConsole(LOG_DEBUG, "[VRR.Config]: Applying server config ...");
getServerConfig().fallingSnow = hasBitFlag(getServerConfig().settings, getServerSettingsFlagValue("FallingSnow"));
getServerConfig().groundSnow = hasBitFlag(getServerConfig().settings, getServerSettingsFlagValue("GroundSnow"));
getServerConfig().useGUI = hasBitFlag(getServerConfig().settings, getServerSettingsFlagValue("GUI"));
getServerConfig().showLogo = hasBitFlag(getServerConfig().settings, getServerSettingsFlagValue("Logo"));
getServerConfig().testerOnly = hasBitFlag(getServerConfig().settings, getServerSettingsFlagValue("Testing"));
getServerConfig().discordEnabled = hasBitFlag(getServerConfig().settings, getServerSettingsFlagValue("DiscordBot"));
getServerConfig().createJobPickups = hasBitFlag(getServerConfig().settings, getServerSettingsFlagValue("JobPickups"));
getServerConfig().createBusinessPickups = hasBitFlag(getServerConfig().settings, getServerSettingsFlagValue("BusinessPickups"));
getServerConfig().createHousePickups = hasBitFlag(getServerConfig().settings, getServerSettingsFlagValue("HousePickups"));
getServerConfig().createJobBlips = hasBitFlag(getServerConfig().settings, getServerSettingsFlagValue("JobBlips"));
getServerConfig().createBusinessBlips = hasBitFlag(getServerConfig().settings, getServerSettingsFlagValue("BusinessBlips"));
getServerConfig().createHouseBlips = hasBitFlag(getServerConfig().settings, getServerSettingsFlagValue("HouseBlips"));
getServerConfig().useRealTime = hasBitFlag(getServerConfig().settings, getServerSettingsFlagValue("RealTime"));
getServerConfig().antiCheat.enabled = hasBitFlag(getServerConfig().settings, getServerSettingsFlagValue("Anticheat"));
applyConfigToServer(serverConfig);
logToConsole(LOG_DEBUG, "[VRR.Config]: All config loaded and applied successfully!");
logToConsole(LOG_INFO, "[VRR.Config]: Config script initialized!");
}
// ===========================================================================
@@ -89,19 +118,6 @@ function loadGlobalConfig() {
// ===========================================================================
function initConfigScript() {
logToConsole(LOG_INFO, "[VRR.Config]: Initializing config script ...");
gameConfig = loadGameConfig();
serverConfig = loadServerConfigFromGameAndPort(server.game, server.port, getMultiplayerMod());
applyConfigToServer(serverConfig);
loadGlobalConfig();
logToConsole(LOG_INFO, "[VRR.Config]: Config script initialized!");
}
// ===========================================================================
function loadServerConfigFromGameAndPort(gameId, port, mpMod) {
let dbConnection = connectToDatabase();
if(dbConnection) {
@@ -144,10 +160,12 @@ function loadServerConfigFromId(tempServerId) {
function applyConfigToServer(tempServerConfig) {
if(isTimeSupported()) {
setGameTime(tempServerConfig.hour, tempServerConfig.minute, tempServerConfig.minuteDuration)
logToConsole(LOG_DEBUG, `[VRR.Config]: Setting time to to ${tempServerConfig.hour}:${tempServerConfig.minute} with minute duration of ${tempServerConfig.minuteDuration}`);
setGameTime(tempServerConfig.hour, tempServerConfig.minute, tempServerConfig.minuteDuration);
}
if(isWeatherSupported()) {
logToConsole(LOG_DEBUG, `[VRR.Config]: Setting weather to ${tempServerConfig.weather}`);
game.forceWeather(tempServerConfig.weather);
}
@@ -220,21 +238,15 @@ function saveServerConfigToDatabase() {
* @return {ServerData} - Server configuration data
*
*/
function getServerConfig(serverId = getServerId()) {
if(serverId != getServerId()) {
return loadServerConfigFromId(serverId);
}
function getServerConfig() {
//if(serverId != getServerId()) {
// return loadServerConfigFromId(serverId);
//}
return serverConfig;
}
// ===========================================================================
function getGameConfig() {
return gameConfig;
}
// ===========================================================================
function getGlobalConfig() {
return globalConfig;
}
@@ -351,7 +363,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;
}
@@ -380,18 +392,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;
@@ -449,13 +449,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);
@@ -477,13 +471,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`);
@@ -503,13 +491,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`);
@@ -529,13 +511,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`);
@@ -555,13 +531,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`);
@@ -581,13 +551,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`);
@@ -607,13 +571,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`);
@@ -633,13 +591,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;
@@ -660,17 +612,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;
@@ -803,67 +749,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

@@ -9,7 +9,7 @@
let scriptVersion = "1.0";
let serverStartTime = 0;
let logLevel = LOG_ERROR|LOG_WARN|LOG_INFO;
let logLevel = LOG_INFO;
// ===========================================================================
@@ -25,8 +25,8 @@ let serverData = {
itemTypes: [],
clans: [],
antiCheat: {
whiteListedGameScripts: [],
blackListedGameScripts: [],
//whiteListedGameScripts: [],
//blackListedGameScripts: [],
},
localeStrings: {},
cachedTranslations: [],

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);
@@ -596,6 +596,14 @@ function onPlayerSpawn(client) {
logToConsole(LOG_DEBUG, `[VRR.Event] Updating all player name tags`);
updateAllPlayerNameTags();
if(!areServerElementsSupported()) {
sendAllBusinessEntrancesToPlayer(client);
sendAllHouseEntrancesToPlayer(client);
//sendAllJobLocationsToPlayer(client);
}
requestPlayerPedNetworkId(client);
getPlayerData(client).payDayTickStart = sdl.ticks;
//}
}

View File

@@ -873,6 +873,7 @@ function createHouseEntrancePickup(houseId) {
pickupModelId = getHouseData(houseId).entrancePickupModel;
}
if(areServerElementsSupported()) {
getHouseData(houseId).entrancePickup = createGamePickup(pickupModelId, getHouseData(houseId).entrancePosition, getGameConfig().pickupTypes[getServerGame()].house);
setElementOnAllDimensions(getHouseData(houseId).entrancePickup, false);
setElementDimension(getHouseData(houseId).entrancePickup, getHouseData(houseId).entranceDimension);
@@ -897,15 +898,17 @@ function createHouseEntranceBlip(houseId) {
blipModelId = getHouseData(houseId).entranceBlipModel;
}
getHouseData(houseId).entranceBlip = createGameBlip(getHouseData(houseId).entrancePosition, blipModelId, 1, getColourByName("houseGreen"));
setElementDimension(getHouseData(houseId).entranceBlip, getHouseData(houseId).entranceDimension);
setElementOnAllDimensions(getHouseData(houseId).entranceBlip, false);
setElementStreamInDistance(getBusinessData(businessId).entranceBlip, getGlobalConfig().houseBlipStreamInDistance);
setElementStreamOutDistance(getBusinessData(businessId).entranceBlip, getGlobalConfig().houseBlipStreamOutDistance);
setElementTransient(getHouseData(houseId).entranceBlip, false);
setEntityData(getHouseData(houseId).entranceBlip, "vrr.owner.type", VRR_BLIP_HOUSE_ENTRANCE, false);
setEntityData(getHouseData(houseId).entranceBlip, "vrr.owner.id", houseId, false);
addToWorld(getHouseData(houseId).entranceBlip);
if(areServerElementsSupported()) {
getHouseData(houseId).entranceBlip = createGameBlip(getHouseData(houseId).entrancePosition, blipModelId, 1, getColourByName("houseGreen"));
setElementDimension(getHouseData(houseId).entranceBlip, getHouseData(houseId).entranceDimension);
setElementOnAllDimensions(getHouseData(houseId).entranceBlip, false);
setElementStreamInDistance(getBusinessData(businessId).entranceBlip, getGlobalConfig().houseBlipStreamInDistance);
setElementStreamOutDistance(getBusinessData(businessId).entranceBlip, getGlobalConfig().houseBlipStreamOutDistance);
setElementTransient(getHouseData(houseId).entranceBlip, false);
setEntityData(getHouseData(houseId).entranceBlip, "vrr.owner.type", VRR_BLIP_HOUSE_ENTRANCE, false);
setEntityData(getHouseData(houseId).entranceBlip, "vrr.owner.id", houseId, false);
addToWorld(getHouseData(houseId).entranceBlip);
}
}
}
@@ -924,13 +927,16 @@ function createHouseExitPickup(houseId) {
pickupModelId = getHouseData(houseId).exitPickupModel;
}
getHouseData(houseId).exitPickup = createGamePickup(pickupModelId, getHouseData(houseId).exitPosition, getGameConfig().pickupTypes[getServerGame()].house);
setElementDimension(getHouseData(houseId).exitPickup, getHouseData(houseId).exitDimension);
setElementOnAllDimensions(getHouseData(houseId).exitPickup, false);
setElementStreamInDistance(getBusinessData(businessId).exitPickup, getGlobalConfig().housePickupStreamInDistance);
setElementStreamOutDistance(getBusinessData(businessId).exitPickup, getGlobalConfig().housePickupStreamOutDistance);
setElementTransient(getHouseData(houseId).exitPickup, false);
addToWorld(getHouseData(houseId).exitPickup);
if(areServerElementsSupported()) {
getHouseData(houseId).exitPickup = createGamePickup(pickupModelId, getHouseData(houseId).exitPosition, getGameConfig().pickupTypes[getServerGame()].house);
setElementDimension(getHouseData(houseId).exitPickup, getHouseData(houseId).exitDimension);
setElementOnAllDimensions(getHouseData(houseId).exitPickup, false);
setElementStreamInDistance(getBusinessData(businessId).exitPickup, getGlobalConfig().housePickupStreamInDistance);
setElementStreamOutDistance(getBusinessData(businessId).exitPickup, getGlobalConfig().housePickupStreamOutDistance);
setElementTransient(getHouseData(houseId).exitPickup, false);
addToWorld(getHouseData(houseId).exitPickup);
}
updateHousePickupLabelData(houseId);
}
}
}
@@ -950,15 +956,17 @@ function createHouseExitBlip(houseId) {
blipModelId = getHouseData(houseId).exitBlipModel;
}
getHouseData(houseId).exitBlip = createGameBlip(blipModelId, getHouseData(houseId).exitPosition, 1, getColourByName("houseGreen"));
setElementDimension(getHouseData(houseId).exitBlip, getHouseData(houseId).entranceDimension);
setElementOnAllDimensions(getHouseData(houseId).exitBlip, false);
setElementStreamInDistance(getBusinessData(businessId).exitBlip, getGlobalConfig().houseBlipStreamInDistance);
setElementStreamOutDistance(getBusinessData(businessId).exitBlip, getGlobalConfig().houseBlipStreamOutDistance);
setElementTransient(getHouseData(houseId).exitBlip, false);
setEntityData(getHouseData(houseId).exitBlip, "vrr.owner.type", VRR_BLIP_HOUSE_EXIT, false);
setEntityData(getHouseData(houseId).exitBlip, "vrr.owner.id", houseId, false);
addToWorld(getHouseData(houseId).exitBlip);
if(areServerElementsSupported()) {
getHouseData(houseId).exitBlip = createGameBlip(blipModelId, getHouseData(houseId).exitPosition, 1, getColourByName("houseGreen"));
setElementDimension(getHouseData(houseId).exitBlip, getHouseData(houseId).entranceDimension);
setElementOnAllDimensions(getHouseData(houseId).exitBlip, false);
setElementStreamInDistance(getBusinessData(businessId).exitBlip, getGlobalConfig().houseBlipStreamInDistance);
setElementStreamOutDistance(getBusinessData(businessId).exitBlip, getGlobalConfig().houseBlipStreamOutDistance);
setElementTransient(getHouseData(houseId).exitBlip, false);
setEntityData(getHouseData(houseId).exitBlip, "vrr.owner.type", VRR_BLIP_HOUSE_EXIT, false);
setEntityData(getHouseData(houseId).exitBlip, "vrr.owner.id", houseId, false);
addToWorld(getHouseData(houseId).exitBlip);
}
}
}
}
@@ -1140,6 +1148,10 @@ function doesHouseHaveInterior(houseId) {
// ===========================================================================
function deleteHouseEntrancePickup(houseId) {
if(!areServerElementsSupported()) {
return false;
}
if(getHouseData(houseId).entrancePickup != null) {
//removeFromWorld(getHouseData(houseId).entrancePickup);
deleteGameElement(getHouseData(houseId).entrancePickup);
@@ -1150,6 +1162,10 @@ function deleteHouseEntrancePickup(houseId) {
// ===========================================================================
function deleteHouseExitPickup(houseId) {
if(!areServerElementsSupported()) {
return false;
}
if(getHouseData(houseId).exitPickup != null) {
//removeFromWorld(getHouseData(houseId).exitPickup);
deleteGameElement(getHouseData(houseId).exitPickup);
@@ -1160,6 +1176,10 @@ function deleteHouseExitPickup(houseId) {
// ===========================================================================
function deleteHouseEntranceBlip(houseId) {
if(!areServerElementsSupported()) {
return false;
}
if(getHouseData(houseId).entranceBlip != null) {
//removeFromWorld(getHouseData(houseId).entranceBlip);
deleteGameElement(getHouseData(houseId).entranceBlip);
@@ -1170,6 +1190,10 @@ function deleteHouseEntranceBlip(houseId) {
// ===========================================================================
function deleteHouseExitBlip(houseId) {
if(!areServerElementsSupported()) {
return false;
}
if(getHouseData(houseId).exitBlip != null) {
//removeFromWorld(getHouseData(houseId).exitBlip);
deleteGameElement(getHouseData(houseId).exitBlip);
@@ -1265,19 +1289,19 @@ function getHouseIdFromDatabaseId(databaseId) {
// ===========================================================================
function sendPlayerHouseGameScripts(client, houseId) {
for(let i in getHouseData(houseId).gameScripts) {
sendPlayerGameScriptState(client, getHouseData(houseId).gameScripts[i].state);
}
}
//function sendPlayerHouseGameScripts(client, houseId) {
// for(let i in getHouseData(houseId).gameScripts) {
// sendPlayerGameScriptState(client, getHouseData(houseId).gameScripts[i].state);
// }
//}
// ===========================================================================
function clearPlayerHouseGameScripts(client, houseId) {
for(let i in getHouseData(houseId).gameScripts) {
sendPlayerGameScriptState(client, VRR_GAMESCRIPT_DENY);
}
}
//function clearPlayerHouseGameScripts(client, houseId) {
// for(let i in getHouseData(houseId).gameScripts) {
// sendPlayerGameScriptState(client, VRR_GAMESCRIPT_DENY);
// }
//}
// ===========================================================================
@@ -1411,6 +1435,10 @@ function getHouseFromParams(params) {
// ===========================================================================
function updateHousePickupLabelData(houseId) {
if(!areServerElementsSupported()) {
return false;
}
let houseData = getHouseData(houseId);
if(houseData.entrancePickup != null) {

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

@@ -120,40 +120,70 @@ function enterExitPropertyCommand(command, params, client) {
let isEntrance = false;
let isBusiness = false;
if(!getPlayerData(client).currentPickup) {
return false;
}
let ownerType = getEntityData(getPlayerData(client).currentPickup, "vrr.owner.type");
let ownerId = getEntityData(getPlayerData(client).currentPickup, "vrr.owner.id");
switch(ownerType) {
case VRR_PICKUP_BUSINESS_ENTRANCE:
isBusiness = true;
isEntrance = true;
closestProperty = getServerData().businesses[ownerId];
break;
case VRR_PICKUP_BUSINESS_EXIT:
isBusiness = true;
isEntrance = false;
closestProperty = getServerData().businesses[ownerId];
break;
case VRR_PICKUP_HOUSE_ENTRANCE:
isBusiness = false;
isEntrance = true;
closestProperty = getServerData().houses[ownerId];
break;
case VRR_PICKUP_HOUSE_EXIT:
isBusiness = false;
isEntrance = false;
closestProperty = getServerData().houses[ownerId];
break;
default:
if(areServerElementsSupported()) {
if(!getPlayerData(client).currentPickup) {
return false;
}
let ownerType = getEntityData(getPlayerData(client).currentPickup, "vrr.owner.type");
let ownerId = getEntityData(getPlayerData(client).currentPickup, "vrr.owner.id");
switch(ownerType) {
case VRR_PICKUP_BUSINESS_ENTRANCE:
isBusiness = true;
isEntrance = true;
closestProperty = getServerData().businesses[ownerId];
break;
case VRR_PICKUP_BUSINESS_EXIT:
isBusiness = true;
isEntrance = false;
closestProperty = getServerData().businesses[ownerId];
break;
case VRR_PICKUP_HOUSE_ENTRANCE:
isBusiness = false;
isEntrance = true;
closestProperty = getServerData().houses[ownerId];
break;
case VRR_PICKUP_HOUSE_EXIT:
isBusiness = false;
isEntrance = false;
closestProperty = getServerData().houses[ownerId];
break;
default:
return false;
}
} else {
for(let i in getServerData().businesses) {
if(getPlayerDimension(client) == getGameConfig().mainWorldDimension[getGame()] && getPlayerInterior(client) == getGameConfig().mainWorldInterior[getGame()]) {
let businessId = getClosestBusinessEntrance(getPlayerPosition(client), getPlayerDimension(client));
isBusiness = true;
isEntrance = true;
closestProperty = getServerData().businesses[businessId];
} else {
let businessId = getClosestBusinessExit(getPlayerPosition(client), getPlayerDimension(client));
isBusiness = true;
isEntrance = false;
closestProperty = getServerData().businesses[businessId];
}
}
for(let j in getServerData().houses) {
if(getPlayerDimension(client) == getGameConfig().mainWorldDimension[getGame()] && getPlayerInterior(client) == getGameConfig().mainWorldInterior[getGame()]) {
let houseId = getClosestHouseEntrance(getPlayerPosition(client), getPlayerDimension(client));
isBusiness = false;
isEntrance = true;
closestProperty = getServerData().businesses[houseId];
} else {
let houseId = getClosestHouseExit(getPlayerPosition(client), getPlayerDimension(client));
isBusiness = false;
isEntrance = false;
closestProperty = getServerData().businesses[houseId];
}
}
}
if(closestProperty == null) {
@@ -451,7 +481,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 +578,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

@@ -207,11 +207,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];
}
}
@@ -429,7 +429,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);
}
// ===========================================================================
@@ -451,7 +451,7 @@ function destroyGameElement(element) {
// ===========================================================================
function isMeleeWeapon(weaponId, gameId = getServerGame()) {
return (getGameData().meleeWeapons[gameId].indexOf(weaponId) != -1);
return (getGameConfig().meleeWeapons[gameId].indexOf(weaponId) != -1);
}
// ===========================================================================
@@ -539,7 +539,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);
}
// ===========================================================================
@@ -590,7 +590,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

@@ -46,7 +46,7 @@ function setStaffTitleCommand(command, params, client) {
return false;
}
let splitParams = params.split("");
let splitParams = params.split(" ");
let targetClient = getPlayerFromParams(getParam(params, " ", 1));
let staffTitle = splitParams.slice(1).join(" ");
@@ -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]}`);
}
// ===========================================================================
@@ -999,7 +999,7 @@ function forcePlayerSkinCommand(command, params, client) {
// return false;
//}
let splitParams = params.split("");
let splitParams = params.split(" ");
let targetClient = getPlayerFromParams(splitParams[0]);
let skinIndex = getSkinModelIndexFromParams(splitParams.slice(1).join(" "), getGame());
@@ -1008,15 +1008,15 @@ function forcePlayerSkinCommand(command, params, client) {
return false;
}
if(skinIndex == false) {
messagePlayerError(client, "That skin is invalid!");
if(!skinIndex) {
messagePlayerError(client, getLocaleString(client, "InvalidSkin"));
return false;
}
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]}`);
}
// ===========================================================================
@@ -1032,7 +1032,7 @@ function setPlayerHealthCommand(command, params, client) {
// return false;
//}
let splitParams = params.split("");
let splitParams = params.split(" ");
let targetClient = getParam(params, " ", 1);
let health = getParam(params, " ", 2);
@@ -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

@@ -40,11 +40,12 @@ function initServerScripts() {
initLocaleScript();
initCommandScript();
initTimers();
serverStartTime = getCurrentUnixTimestamp();
initAllClients();
initTimers();
}
// ===========================================================================

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,16 @@ 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);
//setPlayerSkin(client, skin);
//setPlayerPosition(client, spawnPosition);
//setPlayerHeading(client, spawnHeading);
//setPlayerInterior(client, spawnInterior);
//setPlayerDimension(client, 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"));
@@ -481,6 +486,11 @@ function isPlayerCreatingCharacter(client) {
// ===========================================================================
/**
*
* @return {SubAccountData} - The player's current subaccount/character data
*
*/
function getPlayerCurrentSubAccount(client) {
if(!getPlayerData(client)) {
return false;
@@ -517,7 +527,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 +539,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 +572,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

@@ -11,14 +11,6 @@ let serverTimers = {};
// ===========================================================================
function updateTimeRule() {
if(isTimeSupported()) {
server.setRule("Time", makeReadableTime(game.time.hour, game.time.minute));
}
}
// ===========================================================================
function saveAllServerDataToDatabase() {
if(getServerConfig().pauseSavingToDatabase) {
return false;
@@ -136,14 +128,16 @@ function vehicleRentCheck() {
// Loop through players, not vehicles. Much more efficient (and doesn't consume resources when no players are connected)
let clients = getClients();
for(let i in clients) {
if(getPlayerData(clients[i]) != false) {
if(isPlayerLoggedIn(clients[i] && isPlayerSpawned(clients[i]))) {
if(getPlayerData(clients[i]).rentingVehicle != false) {
if(getPlayerCurrentSubAccount(clients[i]).cash < getServerData().vehicles[getPlayerData(clients[i]).rentingVehicle].rentPrice) {
messagePlayerAlert(clients[i], `You do not have enough money to continue renting this vehicle!`);
stopRentingVehicle(clients[i]);
} else {
takePlayerCash(clients[i], getServerData().vehicles[getPlayerData(clients[i]).rentingVehicle].rentPrice);
if(isClientInitialized(clients[i])) {
if(getPlayerData(clients[i]) != false) {
if(isPlayerLoggedIn(clients[i] && isPlayerSpawned(clients[i]))) {
if(getPlayerData(clients[i]).rentingVehicle != false) {
if(getPlayerCurrentSubAccount(clients[i]).cash < getServerData().vehicles[getPlayerData(clients[i]).rentingVehicle].rentPrice) {
messagePlayerAlert(clients[i], `You do not have enough money to continue renting this vehicle!`);
stopRentingVehicle(clients[i]);
} else {
takePlayerCash(clients[i], getServerData().vehicles[getPlayerData(clients[i]).rentingVehicle].rentPrice);
}
}
}
}
@@ -176,10 +170,12 @@ function vehicleRentCheck() {
function updatePings() {
let clients = getClients();
for(let i in clients) {
if(!clients[i].console) {
updatePlayerPing(clients[i]);
if(isPlayerSpawned(clients[i])) {
updatePlayerCash(clients[i]);
if(isClientInitialized(clients[i])) {
if(!clients[i].console) {
updatePlayerPing(clients[i]);
if(isPlayerSpawned(clients[i])) {
updatePlayerCash(clients[i]);
}
}
}
}
@@ -188,7 +184,7 @@ function updatePings() {
// ===========================================================================
function checkServerGameTime() {
if(!getServerConfig().useRealTime) {
//if(!getServerConfig().useRealTime) {
if(getServerConfig().minute >= 59) {
getServerConfig().minute = 0;
if(getServerConfig().hour >= 23) {
@@ -199,11 +195,11 @@ function checkServerGameTime() {
} else {
getServerConfig().minute = getServerConfig().minute + 1;
}
} else {
let dateTime = getCurrentTimeStampWithTimeZone(getServerConfig().realTimeZone);
getServerConfig().hour = dateTime.getHours();
getServerConfig().minute = dateTime.getMinutes();
}
//} else {
// let dateTime = getCurrentTimeStampWithTimeZone(getServerConfig().realTimeZone);
// getServerConfig().hour = dateTime.getHours();
// getServerConfig().minute = dateTime.getMinutes();
//}
updateTimeRule();
}
@@ -213,14 +209,16 @@ function checkServerGameTime() {
function checkPayDays() {
let clients = getClients();
for(let i in clients) {
if(isPlayerLoggedIn(clients[i]) && isPlayerSpawned(clients[i])) {
getPlayerData(clients[i]).payDayStart = sdl.ticks;
playerPayDay(clients[i]);
if(isClientInitialized(clients[i])) {
if(isPlayerLoggedIn(clients[i]) && isPlayerSpawned(clients[i])) {
getPlayerData(clients[i]).payDayStart = sdl.ticks;
playerPayDay(clients[i]);
//if(sdl.ticks-getPlayerData(clients[i]).payDayTickStart >= getGlobalConfig().payDayTickCount) {
// getPlayerData(clients[i]).payDayStart = sdl.ticks;
// playerPayDay(clients[i]);
//}
//if(sdl.ticks-getPlayerData(clients[i]).payDayTickStart >= getGlobalConfig().payDayTickCount) {
// getPlayerData(clients[i]).payDayStart = sdl.ticks;
// playerPayDay(clients[i]);
//}
}
}
}
@@ -238,9 +236,11 @@ function showRandomTipToAllPlayers() {
let clients = getClients();
for(let i in clients) {
if(isPlayerLoggedIn(clients[i]) && isPlayerSpawned(clients[i])) {
if(!doesPlayerHaveRandomTipsDisabled(clients[i])) {
messagePlayerTimedRandomTip(null, randomTips[tipId]);
if(isClientInitialized(clients[i])) {
if(isPlayerLoggedIn(clients[i]) && isPlayerSpawned(clients[i])) {
if(!doesPlayerHaveRandomTipsDisabled(clients[i])) {
messagePlayerTimedRandomTip(null, randomTips[tipId]);
}
}
}
}

View File

@@ -52,7 +52,7 @@ function getAreaName(position) {
// ===========================================================================
function getGameAreas(gameId) {
return getGameData().areas[gameId];
return getGameConfig().areas[gameId];
}
// ===========================================================================
@@ -63,7 +63,9 @@ function getGameAreas(gameId) {
*/
function getPlayerData(client) {
if(client != null) {
return getServerData().clients[client.index];
if(isClientInitialized(client)) {
return getServerData().clients[client.index];
}
}
return false;
}
@@ -79,30 +81,46 @@ function initAllClients() {
// ===========================================================================
function updateServerRules() {
logToConsole(LOG_DEBUG, `[VRR.Utilities]: Updating all server rules ...`);
logToConsole(LOG_DEBUG, `[VRR.Utilities]: Time support: ${isTimeSupported()}`);
if(isTimeSupported()) {
server.setRule("Time", makeReadableTime(getServerConfig().hour, getServerConfig().minute));
if(getServerConfig() != false) {
let value = makeReadableTime(getServerConfig().hour, getServerConfig().minute);
logToConsole(LOG_DEBUG, `[VRR.Utilities]: Setting server rule "Time" as ${value}`);
server.setRule("Time", value);
}
}
if(isWeatherSupported()) {
server.setRule("Weather", getGameData().weatherNames[getServerGame()][getServerConfig().weather]);
if(getServerConfig() != false) {
let value = getGameConfig().weatherNames[getServerGame()][getServerConfig().weather];
logToConsole(LOG_DEBUG, `[VRR.Utilities]: Setting server rule "Weather" as ${value}`);
server.setRule("Weather", value);
}
}
if(isSnowSupported()) {
server.setRule("Snowing", getYesNoFromBool(getServerConfig().fallingSnow));
if(getServerConfig() != false) {
let value = getYesNoFromBool(getServerConfig().fallingSnow);
logToConsole(LOG_DEBUG, `[VRR.Utilities]: Setting server rule "Snowing" as ${value}`);
server.setRule("Snowing", value);
}
}
logToConsole(LOG_DEBUG, `[VRR.Utilities]: All server rules updated successfully!`);
}
// ===========================================================================
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);
}
}
@@ -114,13 +132,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);
}
}
@@ -132,26 +150,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];
}
// ===========================================================================
@@ -190,8 +208,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;
}
}
@@ -265,6 +283,7 @@ function showConnectCameraToPlayer(client) {
//setPlayerDimension(client, 0);
setPlayerCameraLookAt(client, getServerConfig().connectCameraPosition, getServerConfig().connectCameraLookAt);
}
setPlayer2DRendering(client, false, false, false, false, false, false);
}
// ===========================================================================
@@ -429,4 +448,20 @@ function kickAllClients() {
getClients().forEach((client) => {
client.disconnect();
})
}
}
// ===========================================================================
function updateTimeRule() {
if(isTimeSupported()) {
server.setRule("Time", makeReadableTime(game.time.hour, game.time.minute));
}
}
// ===========================================================================
function isClientInitialized(client) {
return (typeof getServerData().clients[client.index] != "undefined");
}
// ===========================================================================