diff --git a/scripts/client/gui.js b/scripts/client/gui.js index 32012d77..c6f9847b 100644 --- a/scripts/client/gui.js +++ b/scripts/client/gui.js @@ -24,6 +24,8 @@ let windowTitleAlpha = 180; let buttonAlpha = 180; let textInputAlpha = 180; +let guiReady = false; + // =========================================================================== let login = { @@ -851,6 +853,8 @@ function initGUI() { logToConsole(LOG_DEBUG, `[VRR.GUI] All GUI created successfully!`); closeAllWindows(); + + guiReady = true; }; // =========================================================================== @@ -1140,40 +1144,42 @@ let switchCharacterSelect = function(firstName, lastName, cash, clan, lastPlayed } let isAnyGUIActive = function() { - if(infoDialog.window.shown) { - return true; - } + if(!guiReady) { + if(infoDialog.window.shown) { + return true; + } - if(yesNoDialog.window.shown) { - return true; - } + if(yesNoDialog.window.shown) { + return true; + } - if(errorDialog.window.shown) { - return true; - } + if(errorDialog.window.shown) { + return true; + } - if(register.window.shown) { - return true; - } + if(register.window.shown) { + return true; + } - if(login.window.shown) { - return true; - } + if(login.window.shown) { + return true; + } - if(newCharacter.window.shown) { - return true; - } + if(newCharacter.window.shown) { + return true; + } - if(characterSelect.window.shown) { - return true; - } + if(characterSelect.window.shown) { + return true; + } - if(twoFactorAuth.window.shown) { - return true; - } + if(twoFactorAuth.window.shown) { + return true; + } - if(listDialog.window.shown) { - return true; + if(listDialog.window.shown) { + return true; + } } return false; diff --git a/scripts/client/main.js b/scripts/client/main.js index c21ce06a..a8b93a66 100644 --- a/scripts/client/main.js +++ b/scripts/client/main.js @@ -55,4 +55,6 @@ let calledDeathEvent = false; let interiorLightsEnabled = true; let interiorLightsColour = toColour(0, 0, 0, 150); +let mouseCameraEnabled = false + // =========================================================================== \ No newline at end of file diff --git a/scripts/client/scoreboard.js b/scripts/client/scoreboard.js index 5007d78b..93248134 100644 --- a/scripts/client/scoreboard.js +++ b/scripts/client/scoreboard.js @@ -38,7 +38,7 @@ function initScoreBoardListFont() { // =========================================================================== function processScoreBoardRendering() { - if(isAnyGUIActive()) { + if(guiReady && isAnyGUIActive()) { return false; } diff --git a/scripts/client/server.js b/scripts/client/server.js index 6d71d88f..abe57e0e 100644 --- a/scripts/client/server.js +++ b/scripts/client/server.js @@ -51,7 +51,8 @@ function addAllNetworkHandlers() { addNetworkHandler("vrr.showItemActionDelay", showItemActionDelay); addNetworkHandler("vrr.set2DRendering", setPlayer2DRendering); addNetworkHandler("vrr.mouseCursor", toggleMouseCursor); - addNetworkHandler("vrr.mouseCamera", setMouseCameraState); + addNetworkHandler("vrr.mouseCamera", toggleMouseCamera); + addNetworkHandler("vrr.mouseCameraForce", setMouseCameraState); addNetworkHandler("vrr.weaponDamageEnabled", setPlayerWeaponDamageEnabled); addNetworkHandler("vrr.weaponDamageEvent", setPlayerWeaponDamageEvent); addNetworkHandler("vrr.spawned", onServerSpawnedPlayer); @@ -74,8 +75,8 @@ function addAllNetworkHandlers() { addNetworkHandler("vrr.stopRadioStream", stopStreamingRadio); addNetworkHandler("vrr.radioVolume", setStreamingRadioVolume); - addNetworkHandler("vrr.veh.lights", toggleVehicleLights); - addNetworkHandler("vrr.veh.engine", toggleVehicleEngine); + addNetworkHandler("vrr.veh.lights", setVehicleLights); + addNetworkHandler("vrr.veh.engine", setVehicleEngine); addNetworkHandler("vrr.veh.repair", repairVehicle); addNetworkHandler("vrr.pedAnim", makePedPlayAnimation); @@ -324,4 +325,13 @@ function makePedStopAnimation(pedId) { } } +// =========================================================================== + +function setLocalPlayerPedPartsAndProps(parts, props) { + for(let i in parts) { + localPlayer.changeBodyPart(parts[0], parts[1], parts[2]); + localPlayer.changeBodyProp(props[0], props[1]); + } +} + // =========================================================================== \ No newline at end of file diff --git a/scripts/client/sync.js b/scripts/client/sync.js index b1d3893a..7220d001 100644 --- a/scripts/client/sync.js +++ b/scripts/client/sync.js @@ -44,14 +44,18 @@ function processSync(event, deltaTime) { // =========================================================================== -function toggleVehicleEngine(vehicle, state) { - vehicle.engine = state; +function setVehicleEngine(vehicleId, state) { + getElementFromId(vehicleId).engine = state; } // =========================================================================== -function toggleVehicleLights(vehicle, state) { - getElementFromId(vehicle).lights = state; +function setVehicleLights(vehicleId, state) { + if(!state) { + getElementFromId(vehicleId).lightStatus = 2; + } else { + getElementFromId(vehicleId).lightStatus = 1; + } } // =========================================================================== @@ -65,7 +69,11 @@ function repairVehicle(syncId) { function syncVehicleProperties(vehicle) { if(doesEntityDataExist(vehicle, "vrr.lights")) { let lightStatus = getEntityData(vehicle, "vrr.lights"); - vehicle.lights = lightStatus; + if(!lightStatus) { + vehicle.lightStatus = 2; + } else { + vehicle.lightStatus = 1; + } } if(doesEntityDataExist(vehicle, "vrr.panelStatus")) { @@ -339,6 +347,10 @@ function syncObjectProperties(object) { // =========================================================================== function syncElementProperties(element) { + if(doesEntityDataExist(element, "vrr.interior")) { + element.interior = getEntityData(element, "vrr.interior"); + } + switch(element.type) { case ELEMENT_VEHICLE: syncVehicleProperties(element); diff --git a/scripts/client/utilities.js b/scripts/client/utilities.js index 70cb2a18..8e2612c0 100644 --- a/scripts/client/utilities.js +++ b/scripts/client/utilities.js @@ -334,8 +334,10 @@ function setLocalPlayerHeading(heading) { function setLocalPlayerInterior(interior) { logToConsole(LOG_DEBUG, `[VRR.Utilities] Setting interior to ${interior}`); if(getMultiplayerMod() == VRR_MPMOD_GTAC) { - localPlayer.interior = interior; - gta.cameraInterior = interior; + if(!isGTAIV()) { + localPlayer.interior = interior; + gta.cameraInterior = interior; + } } } @@ -437,7 +439,7 @@ function clearSelfOwnedVehicles() { function setMouseCameraState(state) { logToConsole(LOG_DEBUG, `[VRR.Utilities] ${(state)?"Enabled":"Disabled"} mouse camera`); - mouseCameraEnabled = !mouseCameraEnabled; + mouseCameraEnabled = state; SetStandardControlsEnabled(!mouseCameraEnabled); } @@ -450,6 +452,13 @@ function toggleMouseCursor() { // =========================================================================== +function toggleMouseCursor() { + logToConsole(LOG_DEBUG, `[VRR.Utilities] ${(!gui.cursorEnabled)?"Enabled":"Disabled"} mouse cursor`); + setMouseCameraState(!mouseCameraEnabled); +} + +// =========================================================================== + function setPlayerWeaponDamageEvent(clientName, eventType) { logToConsole(LOG_DEBUG, `[VRR.Utilities] Set ${clientName} damage event type to ${eventType}`); weaponDamageEvent[clientName] = eventType; @@ -696,4 +705,25 @@ function processInteriorLightsRendering() { } } +// =========================================================================== + +function getPlayerFromParams(params) { + let clients = getClients(); + if(isNaN(params)) { + for(let i in clients) { + if(!clients[i].console) { + if(toLowerCase(clients[i].name).indexOf(toLowerCase(params)) != -1) { + return clients[i]; + } + } + } + } else { + if(typeof clients[toInteger(params)] != "undefined") { + return clients[toInteger(params)]; + } + } + + return false; +} + // =========================================================================== \ No newline at end of file diff --git a/scripts/server/account.js b/scripts/server/account.js index 3192a42e..8d035ca5 100644 --- a/scripts/server/account.js +++ b/scripts/server/account.js @@ -376,7 +376,7 @@ function loadAccountFromName(accountName, fullLoad = false) { if(dbQuery) { if(dbQuery.numRows > 0) { let dbAssoc = fetchQueryAssoc(dbQuery); - let tempAccountData = new serverClasses.accountData(dbAssoc); + let tempAccountData = new AccountData(dbAssoc); if(fullLoad) { tempAccountData.keyBinds = loadAccountKeybindsFromDatabase(tempAccountData.databaseId); tempAccountData.messages = loadAccountMessagesFromDatabase(tempAccountData.databaseId); @@ -402,7 +402,7 @@ function loadAccountFromId(accountId, fullLoad = false) { let dbQuery = queryDatabase(dbConnection, dbQueryString); if(dbQuery) { let dbAssoc = fetchQueryAssoc(dbQuery); - let tempAccountData = new serverClasses.accountData(dbAssoc); + let tempAccountData = new AccountData(dbAssoc); freeDatabaseQuery(dbQuery); if(fullLoad) { tempAccountData.keyBinds = loadAccountKeybindsFromDatabase(tempAccountData.databaseId); @@ -542,11 +542,6 @@ function saveAccountToDatabase(accountData) { ["acct_ip", accountData.ipAddress], ]; - let dbQuery = null; - let queryString = createDatabaseUpdateQuery("acct_main", data, `acct_id=${accountData.databaseId}`); - dbQuery = queryDatabase(dbConnection, queryString); - freeDatabaseQuery(dbQuery); - let data2 = [ ["acct_svr_settings", accountData.settings], ["acct_svr_staff_title", safeStaffTitle], @@ -555,11 +550,14 @@ function saveAccountToDatabase(accountData) { ["acct_svr_chat_scroll_lines", accountData.chatScrollLines], ]; - dbQuery = null; - queryString = ""; - queryString = createDatabaseUpdateQuery("acct_svr", data2, `acct_svr_acct=${accountData.databaseId} AND acct_svr_svr = ${getServerId()}`); - dbQuery = queryDatabase(dbConnection, queryString); - freeDatabaseQuery(dbQuery); + let queryString1 = createDatabaseUpdateQuery("acct_main", data, `acct_id=${accountData.databaseId}`); + let dbQuery1 = queryDatabase(dbConnection, queryString1); + freeDatabaseQuery(dbQuery1); + + let queryString2 = createDatabaseUpdateQuery("acct_svr", data2, `acct_svr_acct=${accountData.databaseId} AND acct_svr_svr=${getServerId()}`); + let dbQuery2 = queryDatabase(dbConnection, queryString2); + freeDatabaseQuery(dbQuery2); + disconnectFromDatabase(dbConnection); return true; } @@ -568,6 +566,11 @@ function saveAccountToDatabase(accountData) { // =========================================================================== function saveAccountKeyBindToDatabase(keyBindData) { + if(keyBindData.databaseId == -1) { + // Keybind is a default keybind, don't save + return false; + } + let dbConnection = connectToDatabase(); if(dbConnection) { let safeCommandString = escapeDatabaseString(dbConnection, keyBindData.commandString); @@ -575,6 +578,7 @@ function saveAccountKeyBindToDatabase(keyBindData) { let data = [ ["acct_hotkey_acct", keyBindData.account], ["acct_hotkey_enabled", keyBindData.enabled], + ["acct_hotkey_deleted", keyBindData.deleted], ["acct_hotkey_cmdstr", safeCommandString], ["acct_hotkey_key", keyBindData.key], ["acct_hotkey_down", boolToInt(keyBindData.keyState)], @@ -630,7 +634,7 @@ function saveAccountStaffNotesDatabase(staffNoteData) { // =========================================================================== /* -function saveAccountContactsDatabase(accountContactData) { +function saveAccountContactsToDatabase(accountContactData) { let dbConnection = connectToDatabase(); if(dbConnection) { let safeNoteContent = escapeDatabaseString(dbConnection, accountContactData.note); @@ -663,7 +667,6 @@ function createAccount(name, password, email = "") { let dbQuery = queryDatabase(dbConnection, `INSERT INTO acct_main (acct_name, acct_pass, acct_email, acct_when_registered) VALUES ('${safeName}', '${hashedPassword}', '${safeEmail}', UNIX_TIMESTAMP())`); if(getDatabaseInsertId(dbConnection) > 0) { let tempAccountData = loadAccountFromId(getDatabaseInsertId(dbConnection), false); - createDefaultKeybindsForAccount(tempAccountData.databaseId); createDefaultAccountServerData(tempAccountData.databaseId); tempAccountData.keyBinds = loadAccountKeybindsFromDatabase(tempAccountData.databaseId); tempAccountData.messages = loadAccountMessagesFromDatabase(tempAccountData.databaseId); @@ -880,7 +883,7 @@ function savePlayerToDatabase(client) { if(client.player != null) { if(getPlayerData(client).returnToPosition != null) { getPlayerCurrentSubAccount(client).spawnPosition = getPlayerData(client).returnToPosition; - getPlayerCurrentSubAccount(client).spawnHeading = getPlayerData(client).returnToHeading; + getPlayerCurrentSubAccount(client).spawnHeading = getPlayerData(client).returnToHeading.z; getPlayerCurrentSubAccount(client).interior = getPlayerData(client).returnToInterior; getPlayerCurrentSubAccount(client).dimension = getPlayerData(client).returnToDimension; } else { @@ -920,7 +923,7 @@ function initClient(client) { let tempAccountData = loadAccountFromName(getPlayerName(client), true); let tempSubAccounts = loadSubAccountsFromAccount(tempAccountData.databaseId); - getServerData().clients[client.index] = new serverClasses.clientData(client, tempAccountData, tempSubAccounts); + getServerData().clients[client.index] = new ClientData(client, tempAccountData, tempSubAccounts); let sessionId = saveConnectionToDatabase(client); getServerData().clients[client.index].session = sessionId; @@ -971,23 +974,6 @@ function saveConnectionToDatabase(client) { // =========================================================================== -function createDefaultKeybindsForAccount(accountDatabaseId) { - logToConsole(LOG_DEBUG, `[VRR.Account]: Creating default keybinds for account ${accountDatabaseId} ...`); - for(let j = 1 ; j <= 4 ; j++) { - logToConsole(LOG_DEBUG, `[VRR.Account]: Creating default keybinds for account ${accountDatabaseId} on server ${j} ...`); - for(let i in getGlobalConfig().keyBind.defaultKeyBinds) { - logToConsole(LOG_DEBUG, `[VRR.Account]: Creating default keybind ${i} for account ${accountDatabaseId} on server ${j} with key ${getKeyIdFromParams(getGlobalConfig().keyBind.defaultKeyBinds[i].keyName.toLowerCase())} ...`); - let dbQueryString = `INSERT INTO acct_hotkey (acct_hotkey_acct, acct_hotkey_server, acct_hotkey_key, acct_hotkey_cmdstr, acct_hotkey_when_added, acct_hotkey_down) VALUES (${accountDatabaseId}, ${j}, ${getKeyIdFromParams(getGlobalConfig().keyBind.defaultKeyBinds[i].keyName.toLowerCase())}, '${getGlobalConfig().keyBind.defaultKeyBinds[i].commandString}', UNIX_TIMESTAMP(), ${getGlobalConfig().keyBind.defaultKeyBinds[i].keyState})`; - quickDatabaseQuery(dbQueryString); - logToConsole(LOG_DEBUG, `[VRR.Account]: Created default keybind ${i} for account ${accountDatabaseId} on server ${j} with key ${getKeyIdFromParams(getGlobalConfig().keyBind.defaultKeyBinds[i].keyName.toLowerCase())}!`); - } - logToConsole(LOG_DEBUG, `[VRR.Account]: Create default keybinds for account ${accountDatabaseId} on server ${j}!`); - } - logToConsole(LOG_DEBUG, `[VRR.Account]: Created default keybinds for account ${accountDatabaseId} successfully!`); -} - -// =========================================================================== - function createDefaultAccountServerData(accountDatabaseId) { for(let i = 1 ; i <= 5 ; i++) { let dbQueryString = `INSERT INTO acct_svr (acct_svr_acct, acct_svr_svr) VALUES (${accountDatabaseId}, ${i})`; @@ -1005,12 +991,21 @@ function loadAccountKeybindsFromDatabase(accountDatabaseID) { let dbQuery = null; let dbAssoc; + for(let i in getGlobalConfig().keyBind.defaultKeyBinds) { + let tempKeyBindData = new KeyBindData(false); + tempKeyBindData.databaseId = -1; + tempKeyBindData.key = getKeyIdFromParams(getGlobalConfig().keyBind.defaultKeyBinds[i].keyName); + tempKeyBindData.commandString = getGlobalConfig().keyBind.defaultKeyBinds[i].commandString; + tempKeyBindData.keyState = getGlobalConfig().keyBind.defaultKeyBinds[i].keyState; + tempAccountKeybinds.push(tempKeyBindData); + } + if(dbConnection) { dbQuery = queryDatabase(dbConnection, `SELECT * FROM acct_hotkey WHERE acct_hotkey_enabled = 1 AND acct_hotkey_acct = ${accountDatabaseID} AND acct_hotkey_server = ${getServerId()}`); if(dbQuery) { if(dbQuery.numRows > 0) { while(dbAssoc = fetchQueryAssoc(dbQuery)) { - let tempAccountKeyBindData = new serverClasses.keyBindData(dbAssoc); + let tempAccountKeyBindData = new KeyBindData(dbAssoc); tempAccountKeybinds.push(tempAccountKeyBindData); logToConsole(LOG_DEBUG, `[VRR.Account]: Account keybind '${tempAccountKeyBindData.databaseId}' (Key ${tempAccountKeyBindData.key} '${toUpperCase(getKeyNameFromId(tempAccountKeyBindData.key))}') loaded from database successfully!`); } @@ -1039,7 +1034,7 @@ function loadAccountStaffNotesFromDatabase(accountDatabaseID) { if(dbQuery) { if(dbQuery.numRows > 0) { while(dbAssoc = fetchQueryAssoc(dbQuery)) { - let tempAccountStaffNoteData = new serverClasses.accountStaffNoteData(dbAssoc); + let tempAccountStaffNoteData = new AccountStaffNoteData(dbAssoc); tempAccountStaffNotes.push(tempAccountStaffNoteData); logToConsole(LOG_DEBUG, `[VRR.Account]: Account staff note '${tempAccountStaffNoteData.databaseId}' loaded from database successfully!`); } @@ -1068,7 +1063,7 @@ function loadAccountContactsFromDatabase(accountDatabaseID) { if(dbQuery) { if(dbQuery.numRows > 0) { while(dbAssoc = fetchQueryAssoc(dbQuery)) { - let tempAccountContactData = new serverClasses.accountContactData(dbAssoc); + let tempAccountContactData = new AccountContactData(dbAssoc); tempAccountContacts.push(tempAccountContactData); logToConsole(LOG_DEBUG, `[VRR.Account]: Account contact '${tempAccountContactData.databaseId}' loaded from database successfully!`); } @@ -1097,7 +1092,7 @@ function loadAccountMessagesFromDatabase(accountDatabaseID) { if(dbQuery) { if(dbQuery.numRows > 0) { while(dbAssoc = fetchQueryAssoc(dbQuery)) { - let tempAccountMessageData = new serverClasses.accountContactData(dbAssoc); + let tempAccountMessageData = new AccountContactData(dbAssoc); tempAccountMessages.push(tempAccountMessageData); logToConsole(LOG_DEBUG, `[VRR.Account]: Account contact '${tempAccountMessageData.databaseId}' loaded from database successfully!`); } diff --git a/scripts/server/animation.js b/scripts/server/animation.js index 00d56ffc..7d0e3fde 100644 --- a/scripts/server/animation.js +++ b/scripts/server/animation.js @@ -22,7 +22,7 @@ function playPlayerAnimationCommand(command, params, client) { let splitParams = params.split(" "); let animationSlot = getAnimationFromParams(splitParams[0]); - let animationPositionOffset = getAnimationFromParams(splitParams[1]); + let animationPositionOffset = getAnimationFromParams(splitParams[1]) || 1; if(!animationSlot) { messagePlayerError(client, "That animation doesn't exist!"); @@ -30,12 +30,18 @@ function playPlayerAnimationCommand(command, params, client) { return false; } + if(toInteger(animationPositionOffset) < 0 || toInteger(animationPositionOffset) > 3) { + messagePlayerError(client, "The offset must be between 0 and 3!") + return false; + } + getPlayerData(client).currentAnimation = animationSlot; getPlayerData(client).currentAnimationPositionOffset = animationSlot; getPlayerData(client).currentAnimationPositionReturnTo = getPlayerPosition(client); getPlayerData(client).animationStart = getCurrentUnixTimestamp(); //setEntityData(getPlayerData(client).ped, "vrr.animation", animationSlot, true); makePedPlayAnimation(getPlayerData(client).ped, animationSlot, animationPositionOffset); + setPlayerMouseCameraState(client, true); } // =========================================================================== @@ -43,6 +49,7 @@ function playPlayerAnimationCommand(command, params, client) { function stopPlayerAnimationCommand(command, params, client) { setPlayerPosition(client, getPlayerData(client).currentAnimationPositionReturnTo); makePedStopAnimation(getPlayerData(client).ped); + setPlayerMouseCameraState(client, false); } // =========================================================================== diff --git a/scripts/server/anticheat.js b/scripts/server/anticheat.js index 2c7453ed..8f197d0e 100644 --- a/scripts/server/anticheat.js +++ b/scripts/server/anticheat.js @@ -26,7 +26,7 @@ function loadAntiCheatGameScriptWhiteListFromDatabase() { if(dbQuery) { if(dbQuery.numRows > 0) { let dbAssoc = fetchQueryAssoc(dbQuery); - let tempWhiteListedGameScriptData = new serverClasses.whiteListedGameScriptData(dbAssoc); + let tempWhiteListedGameScriptData = new WhiteListedGameScriptData(dbAssoc); tempWhiteListedGameScripts.push(tempWhiteListedGameScriptData); logToConsole(LOG_DEBUG, `[VRR.AntiCheat] Whitelisted game script '${tempWhiteListedGameScriptData.scriptName}' loaded successfully!`); } @@ -50,7 +50,7 @@ function loadAntiCheatGameScriptBlackListFromDatabase() { if(dbQuery) { if(dbQuery.numRows > 0) { let dbAssoc = fetchQueryAssoc(dbQuery); - let tempBlackListedGameScriptData = new serverClasses.blackListedGameScriptData(dbAssoc); + let tempBlackListedGameScriptData = new BlackListedGameScriptData(dbAssoc); tempBlackListedGameScripts.push(tempBlackListedGameScriptData); logToConsole(LOG_DEBUG, `[VRR.AntiCheat] Blacklisted game script '${tempBlackListedGameScriptData.scriptName}' loaded successfully!`); } diff --git a/scripts/server/business.js b/scripts/server/business.js index c4351c53..8b8c7205 100644 --- a/scripts/server/business.js +++ b/scripts/server/business.js @@ -37,7 +37,7 @@ function loadBusinessFromId(businessId) { if(dbQuery) { let dbAssoc = fetchQueryAssoc(dbQuery); freeDatabaseQuery(dbQuery); - return new serverClasses.businessData(dbAssoc); + return new BusinessData(dbAssoc); } disconnectFromDatabase(dbConnection); } @@ -60,7 +60,7 @@ function loadBusinessesFromDatabase() { if(dbQuery) { if(dbQuery.numRows > 0) { while(dbAssoc = fetchQueryAssoc(dbQuery)) { - let tempBusinessData = new serverClasses.businessData(dbAssoc); + let tempBusinessData = new BusinessData(dbAssoc); tempBusinessData.locations = loadBusinessLocationsFromDatabase(tempBusinessData.databaseId); tempBusinessData.gameScripts = loadBusinessGameScriptsFromDatabase(tempBusinessData.databaseId); tempBusinesses.push(tempBusinessData); @@ -93,7 +93,7 @@ function loadBusinessLocationsFromDatabase(businessId) { if(dbQuery) { if(dbQuery.numRows > 0) { while(dbAssoc = fetchQueryAssoc(dbQuery)) { - let tempBusinessLocationData = new serverClasses.businessLocationData(dbAssoc); + let tempBusinessLocationData = new BusinessLocationData(dbAssoc); tempBusinessLocations.push(tempBusinessLocationData); logToConsole(LOG_VERBOSE, `[VRR.Business]: Location '${tempBusinessLocationData.name}' loaded from database successfully!`); } @@ -124,7 +124,7 @@ function loadBusinessGameScriptsFromDatabase(businessId) { if(dbQuery) { if(dbQuery.numRows > 0) { while(dbAssoc = fetchQueryAssoc(dbQuery)) { - let tempBusinessGameScriptData = new serverClasses.businessGameScriptData(dbAssoc); + let tempBusinessGameScriptData = new BusinessGameScriptData(dbAssoc); tempBusinessGameScripts.push(tempBusinessGameScriptData); logToConsole(LOG_VERBOSE, `[VRR.Business]: Game script '${tempBusinessGameScriptData.name}' loaded from database successfully!`); } @@ -185,7 +185,7 @@ function createBusinessLocationCommand(command, params, client) { // =========================================================================== function createBusiness(name, entrancePosition, exitPosition, entrancePickupModel = -1, entranceBlipModel = -1, entranceInteriorId = 0, entranceVirtualWorld = 0, exitInteriorId = -1, exitVirtualWorld = -1, exitPickupModel = -1, exitBlipModel = -1) { - let tempBusinessData = new serverClasses.businessData(false); + let tempBusinessData = new BusinessData(false); tempBusinessData.name = name; tempBusinessData.entrancePosition = entrancePosition; @@ -253,6 +253,8 @@ function setBusinessNameCommand(command, params, client) { let oldBusinessName = getBusinessData(businessId).name; getBusinessData(businessId).name = newBusinessName; setEntityData(getBusinessData(businessId).entrancePickup, "vrr.label.name", getBusinessData(businessId).name, true); + + getBusinessData(businessId).needsSaved = true; messageAdmins(`${getInlineChatColourByName("lightGrey")}${getPlayerName(client)} ${getInlineChatColourByName("white")}renamed business ${getInlineChatColourByType("businessBlue")}${oldBusinessName} ${getInlineChatColourByName("white")}to ${getInlineChatColourByType("businessBlue")}${newBusinessName}`); } @@ -281,6 +283,8 @@ function setBusinessOwnerCommand(command, params, client) { getBusinessData(businessId).ownerType = VRR_BIZOWNER_PLAYER; getBusinessData(businessId).ownerId = getServerData().clients[newBusinessOwner.index].accountData.databaseId; + + getBusinessData(businessId).needsSaved = true; messagePlayerSuccess(`${getInlineChatColourByName("white")}You gave business ${getInlineChatColourByType("businessBlue")}${getBusinessData(businessId).name} ${getInlineChatColourByName("white")}to ${getInlineChatColourByName("lightGrey")}${newBusinessOwner.name}`); } @@ -308,10 +312,10 @@ function setBusinessClanCommand(command, params, client) { } } - getBusinessData(businessId).needsSaved = true; - getBusinessData(businessId).ownerType = VRR_BIZOWNER_CLAN; getBusinessData(businessId).ownerId = getClanData(clanId).databaseId; + + getBusinessData(businessId).needsSaved = true; messagePlayerSuccess(`${getInlineChatColourByName("white")}You gave business ${getInlineChatColourByType("businessBlue")}${getBusinessData(businessId).name} ${getInlineChatColourByName("white")}to the ${getInlineChatColourByType("clanOrange")}${getClanData(clanId).name} ${getInlineChatColourByName("white")}clan!`); } @@ -359,6 +363,7 @@ function setBusinessClanCommand(command, params, client) { } getBusinessData(businessId).clanRank = getClanRankData(clanId, clanRankId).level; + getBusinessData(businessId).needsSaved = true; messagePlayerSuccess(`${getInlineChatColourByName("white")}You set business ${getInlineChatColourByType("businessBlue")}${getBusinessData(businessId).name}${getInlineChatColourByName("white")}'s clan rank to ${getInlineChatColourByType("clanOrange")}${getClanRankData(clanId, clanRankId).name} ${getInlineChatColourByName("white")}(level ${getClanRankData(clanId, clanRankId).level}) and above!`); } @@ -391,6 +396,8 @@ function setBusinessJobCommand(command, params, client) { getBusinessData(businessId).ownerType = VRR_BIZOWNER_JOB; getBusinessData(businessId).ownerId = getJobData(jobId).databaseId; + + getBusinessData(businessId).needsSaved = true; messageAdmins(`${getInlineChatColourByName("lightGrey")}${getPlayerName(client)} ${getInlineChatColourByName("white")}set business ${getInlineChatColourByType("businessBlue")}${getBusinessData(businessId).name} ${getInlineChatColourByName("white")}owner to the ${getInlineChatColourByType("jobYellow")}${getJobData(jobId).name} ${getInlineChatColourByName("white")}job`); } @@ -410,6 +417,8 @@ function setBusinessPublicCommand(command, params, client) { getBusinessData(businessId).ownerType = VRR_BIZOWNER_PUBLIC; getBusinessData(businessId).ownerId = 0; + + getBusinessData(businessId).needsSaved = true; messageAdmins(`${getInlineChatColourByName("lightGrey")}${getPlayerName(client)} ${getInlineChatColourByName("white")}set business ${getInlineChatColourByType("businessBlue")}${getBusinessData(businessId).name} ${getInlineChatColourByName("white")}owner set to ${getInlineChatColourByName("lightGrey")}public`); } @@ -436,6 +445,8 @@ function lockUnlockBusinessCommand(command, params, client) { getBusinessData(businessId).locked = !getBusinessData(businessId).locked; setEntityData(getBusinessData(businessId).entrancePickup, "vrr.label.locked", getBusinessData(businessId).locked, true); + + getBusinessData(businessId).needsSaved = true; messagePlayerSuccess(client, `${getLockedUnlockedEmojiFromBool((getBusinessData(businessId).locked))} Business ${getInlineChatColourByType("businessBlue")}${getBusinessData(businessId).name} ${getInlineChatColourByName("white")}${getLockedUnlockedTextFromBool((getBusinessData(businessId).locked))}!`); } @@ -466,10 +477,9 @@ function lockUnlockBusinessCommand(command, params, client) { } getBusinessData(businessId).interiorLights = !getBusinessData(businessId).interiorLights; + updateBusinessInteriorLightsForOccupants(businessId); getBusinessData(businessId).needsSaved = true; - - updateBusinessInteriorLightsForOccupants(businessId); meActionToNearbyPlayers(client, `turns ${toLowerCase(getOnOffFromBool(getBusinessData(businessId).interiorLights))} the business lights`); } @@ -493,6 +503,7 @@ function setBusinessEntranceFeeCommand(command, params, client) { } getBusinessData(businessId).entranceFee = entranceFee; + getBusinessData(businessId).needsSaved = true; messageAdmins(`${getInlineChatColourByName("lightGrey")}${getPlayerName(client)} ${getInlineChatColourByName("white")}set business ${getInlineChatColourByType("businessBlue")}${getBusinessData(businessId).name} ${getInlineChatColourByName("white")}entrance fee to [#AAAAAAA]$${entranceFee}`); } @@ -566,6 +577,8 @@ function setBusinessPickupCommand(command, params, client) { createBusinessEntrancePickup(businessId); createBusinessExitPickup(businessId); + getBusinessData(businessId).needsSaved = true; + messageAdmins(`${getInlineChatColourByName("lightGrey")}${getPlayerName(client)} ${getInlineChatColourByName("white")}set business ${getInlineChatColourByType("businessBlue")}${getBusinessData(businessId).name} ${getInlineChatColourByName("white")}pickup display to ${getInlineChatColourByName("lightGrey")}${toLowerCase(typeParam)}'!`); } @@ -582,7 +595,7 @@ function setBusinessInteriorTypeCommand(command, params, client) { } if(isNaN(typeParam)) { - let tempBusinessLocation = new serverClasses.businessLocationData(false); + let tempBusinessLocation = new BusinessLocationData(false); if(toLowerCase(typeParam) == "none") { tempBusinessLocation.exitPosition = toVector3(0.0, 0.0, 0.0); @@ -641,6 +654,7 @@ function setBusinessBlipCommand(command, params, client) { } resetBusinessBlips(); + getBusinessData(businessId).needsSaved = true; messageAdmins(`${getInlineChatColourByName("lightGrey")}${getPlayerName(client)} ${getInlineChatColourByName("white")}set business ${getInlineChatColourByType("businessBlue")}${getBusinessData(businessId).name} ${getInlineChatColourByName("white")}blip display to ${getInlineChatColourByName("lightGrey")}${toLowerCase(typeParam)}`); } @@ -758,6 +772,8 @@ function withdrawFromBusinessCommand(command, params, client) { getBusinessData(businessId).till -= amount; givePlayerCash(client, amount); updatePlayerCash(client); + getBusinessData(businessId).needsSaved = true; + messagePlayerSuccess(client, `You withdrew $${amount} from business ${getInlineChatColourByType("businessBlue")}${getBusinessData(businessId).name} till`); } @@ -786,6 +802,8 @@ function setBusinessBuyPriceCommand(command, params, client) { getBusinessData(businessId).buyPrice = amount; setEntityData(getBusinessData(businessId).entrancePickup, "vrr.label.price", getBusinessData(businessId).buyPrice, true); + + getBusinessData(businessId).needsSaved = true; messagePlayerSuccess(client, `${getInlineChatColourByName("white")}You set business ${getInlineChatColourByType("businessBlue")}${getBusinessData(businessId).name}'s ${getInlineChatColourByName("white")}for-sale price to ${getInlineChatColourByName("lightGrey")}$${makeLargeNumberReadable(amount)}`); } @@ -815,6 +833,8 @@ function depositIntoBusinessCommand(command, params, client) { getBusinessData(businessId).till += amount; takePlayerCash(client, amount); updatePlayerCash(client); + + getBusinessData(businessId).needsSaved = true; messagePlayerSuccess(client, `You deposited $${amount} into business ${getInlineChatColourByType("businessBlue")}${getBusinessData(businessId).name} ${getInlineChatColourByName("white")}till`); } @@ -861,6 +881,7 @@ function orderItemForBusinessCommand(command, params, client) { getPlayerData(client).businessOrderValue = value; getPlayerData(client).businessOrderCost = orderTotalCost; + getBusinessData(businessId).needsSaved = true; showPlayerPrompt(client, VRR_PROMPT_BIZORDER, `Ordering ${amount} ${getPluralForm(getItemTypeData(itemType).name)} (${getItemValueDisplay(itemType, value)}) at $${makeLargeNumberReadable(pricePerItem)} each will cost a total of $${makeLargeNumberReadable(orderTotalCost)}`, "Business Order Cost"); } @@ -920,6 +941,7 @@ function buyBusinessCommand(command, params, client) { getBusinessData(businessId).buyPrice = 0; updateBusinessPickupLabelData(businessId); + getBusinessData(businessId).needsSaved = true; messagePlayerSuccess(client, `You are now the owner of ${getInlineChatColourByType("businessBlue")}${getBusinessData(businessId).name}`); } @@ -948,6 +970,8 @@ function moveBusinessEntranceCommand(command, params, client) { createBusinessEntranceBlip(businessId); createBusinessEntrancePickup(businessId); + getBusinessData(businessId).needsSaved = true; + messageAdmins(`${getInlineChatColourByName("lightGrey")}${getPlayerName(client)} ${getInlineChatColourByName("white")}moved business ${getInlineChatColourByType("businessBlue")}${getBusinessData(businessId).name} ${getInlineChatColourByName("white")}entrance to their position`); } @@ -975,6 +999,8 @@ function moveBusinessExitCommand(command, params, client) { createBusinessExitBlip(businessId); createBusinessExitPickup(businessId); + getBusinessData(businessId).needsSaved = true; + messageAdmins(`${getInlineChatColourByName("lightGrey")}${getPlayerName(client)} ${getInlineChatColourByName("white")}moved business ${getInlineChatColourByType("businessBlue")}${getBusinessData(businessId).name} ${getInlineChatColourByName("white")}exit to their position`); } @@ -1240,7 +1266,7 @@ function deleteBusiness(businessId, deletedBy = 0) { removePlayersFromBusiness(businessId); - getServerData().businesses.splice(businessId, 1); + getServerData().businesses[businessId] = false; } // =========================================================================== @@ -1401,7 +1427,7 @@ function setAllBusinessIndexes() { // =========================================================================== function addToBusinessInventory(businessId, itemType, amount, buyPrice) { - let tempItemData = new serverClasses.itemData(false); + let tempItemData = new ItemData(false); tempItemData.amount = amount; tempItemData.buyPrice = buyPrice; tempItemData.itemType = getItemTypeData(itemType).databaseId; diff --git a/scripts/server/clan.js b/scripts/server/clan.js index 23be34e9..86b33899 100644 --- a/scripts/server/clan.js +++ b/scripts/server/clan.js @@ -29,7 +29,7 @@ function loadClansFromDatabase() { if(dbQuery) { if(dbQuery.numRows > 0) { while(dbAssoc = fetchQueryAssoc(dbQuery)) { - let tempClanData = new serverClasses.clanData(dbAssoc); + let tempClanData = new ClanData(dbAssoc); //tempClanData.members = loadClanMembersFromDatabase(tempClanData.databaseId); tempClanData.ranks = loadClanRanksFromDatabase(tempClanData.databaseId); tempClans.push(tempClanData); @@ -59,7 +59,7 @@ function loadClanMembersFromDatabase() { if(dbQuery) { if(dbQuery.numRows > 0) { while(dbAssoc = fetchQueryAssoc(dbQuery)) { - let tempClanData = new serverClasses.clanData(dbAssoc); + let tempClanData = new ClanData(dbAssoc); tempClans.push(tempClanData); logToConsole(LOG_VERBOSE, `[VRR.Clan]: Clan '${tempClanData.name}' loaded from database successfully!`); } @@ -87,7 +87,7 @@ function loadClanRanksFromDatabase(clanDatabaseId) { if(dbQuery) { if(dbQuery.numRows > 0) { while(dbAssoc = fetchQueryAssoc(dbQuery)) { - let tempClanRankData = new serverClasses.clanRankData(dbAssoc); + let tempClanRankData = new ClanRankData(dbAssoc); tempClanRanks.push(tempClanRankData); logToConsole(LOG_VERBOSE, `[VRR.Clan]: Clan rank '${tempClanRankData.name}' loaded from database successfully!`); } @@ -104,7 +104,7 @@ function loadClanRanksFromDatabase(clanDatabaseId) { // =========================================================================== function createClanRank(clanId, rankId, rankName) { - let tempClanRankData = new serverClasses.clanRankData(false); + let tempClanRankData = new ClanRankData(false); tempClanRankData.level = rankId; tempClanRankData.name = rankName; tempClanRankData.clan = getClanData(clanId).databaseId; @@ -770,7 +770,7 @@ function createClan(name) { escapedName = escapeDatabaseString(dbConnection, escapedName) queryDatabase(dbConnection, `INSERT INTO clan_main (clan_server, clan_name) VALUES (${getServerId()}, '${escapedName}')`); - let tempClan = new serverClasses.clanData(false); + let tempClan = new ClanData(false); tempClan.databaseId = getDatabaseInsertId(dbConnection); tempClan.name = name; getServerData().clans.push(tempClan); diff --git a/scripts/server/class.js b/scripts/server/class.js index 9099792a..9b8ded02 100644 --- a/scripts/server/class.js +++ b/scripts/server/class.js @@ -7,1529 +7,1594 @@ // TYPE: Server (JavaScript) // =========================================================================== -let serverClasses = {}; - // =========================================================================== function initClassScript() { logToConsole(LOG_INFO, "[VRR.Class]: Initializing class script ..."); - serverClasses = initClassTable(); logToConsole(LOG_INFO, "[VRR.Class]: Class script initialized successfully!"); } // =========================================================================== -function initClassTable() { - let tempClasses = { - /** @class serverConfigData Representing server configuration loaded/saved in database */ - serverConfigData: class { - constructor(dbAssoc) { - this.databaseId = 0; - this.name = ""; - this.password = ""; - this.needsSaved = false; - - this.newCharacter = { - spawnPosition: false, - spawnHeading: 0.0, - spawnInterior: 0, - spawnDimension: 0, - money: 0, - bank: 0, - skin: 0, - }; - - this.connectCameraPosition = false; - this.connectCameraLookAt = false; - - this.characterSelectCameraPosition = false; - this.characterSelectCameraLookAt = false; - this.characterSelectPedPosition = false; - this.characterSelectPedHeading = false; - this.characterSelectInterior = false; - this.characterSelectDimension = false; - - this.hour = 0; - this.minute = 0 - this.minuteDuration = 1000; - this.weather = 0 - this.fallingSnow = false; - this.groundSnow = false; - this.useGUI = true; - this.guiColour = [200, 200, 200]; - this.showLogo = true; - this.inflationMultiplier = 1; - - this.antiCheat = { - enabled: false, - checkGameScripts: false, - gameScriptWhiteListEnabled: false, - gameScriptBlackListEnabled: false, - gameScriptWhiteList: [], - gameScriptBlackList: [], - }; - - this.discordBotToken = ""; - this.discordEnabled = false; - - this.createJobPickups = false; - this.createBusinessPickups = false; - this.createHousePickups = false; - this.createJobBlips = false; - this.createBusinessBlips = false; - this.createHouseBlips = false; - - this.introMusicURL = ""; - - this.pauseSavingToDatabase = false; - - this.useRealTime = false; - this.realTimeZone = 0; - - if(dbAssoc) { - this.databaseId = dbAssoc["svr_id"]; - console.log("1"); - this.newCharacter = { - spawnPosition: toVector3(dbAssoc["svr_newchar_pos_x"], dbAssoc["svr_newchar_pos_y"], dbAssoc["svr_newchar_pos_z"]), - spawnHeading: dbAssoc["svr_newchar_rot_z"], - money: dbAssoc["svr_newchar_money"], - bank: dbAssoc["svr_newchar_bank"], - skin: dbAssoc["svr_newchar_skin"], - }, - this.connectCameraPosition = toVector3(dbAssoc["svr_connectcam_pos_x"], dbAssoc["svr_connectcam_pos_y"], dbAssoc["svr_connectcam_pos_z"]); - this.connectCameraLookAt = toVector3(dbAssoc["svr_connectcam_lookat_x"], dbAssoc["svr_connectcam_lookat_y"], dbAssoc["svr_connectcam_lookat_z"]); - - //this.characterSelectCameraPosition = toVector3(dbAssoc["svr_charselect_cam_pos_x"], dbAssoc["svr_charselect_cam_pos_y"], dbAssoc["svr_charselect_cam_pos_z"]); - //this.characterSelectCameraLookAt = toVector3(dbAssoc["svr_charselect_cam_lookat_x"], dbAssoc["svr_charselect_cam_lookat_y"], dbAssoc["svr_charselect_cam_lookat_z"]); - - //this.characterSelectPedPosition = toVector3(dbAssoc["svr_charselect_ped_pos_x"], dbAssoc["svr_charselect_ped_pos_y"], dbAssoc["svr_charselect_ped_pos_z"]); - //this.characterSelectPedHeading = toFloat(dbAssoc["svr_charselect_ped_rot_z"]); - //this.characterSelectInterior = toInteger(dbAssoc["svr_charselect_int"]); - //this.characterSelectDimension = toInteger(dbAssoc["svr_charselect_int"]); - - this.hour = toInteger(dbAssoc["svr_start_time_hour"]); - 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 = intToBool(dbAssoc["svr_start_snow_falling"]); - this.groundSnow = intToBool(dbAssoc["svr_start_snow_ground"]); - this.useGUI = intToBool(dbAssoc["svr_gui"]); - this.guiColour = [toInteger(dbAssoc["svr_gui_col1_r"]), toInteger(dbAssoc["svr_gui_col1_g"]), toInteger(dbAssoc["svr_gui_col1_b"])]; - this.showLogo = intToBool(dbAssoc["svr_logo"]); - this.inflationMultiplier = toFloat(dbAssoc["svr_inflation_multiplier"]); - - this.antiCheat = { - enabled: intToBool(dbAssoc["svr_ac_enabled"]), - checkGameScripts: intToBool(dbAssoc["svr_ac_check_scripts"]), - gameScriptBlackListEnabled: intToBool(dbAssoc["svr_ac_script_bl"]), - gameScriptWhiteListEnabled: intToBool(dbAssoc["svr_ac_script_wl"]), - gameScriptWhiteList: [], - gameScriptBlackList: [], - }; - - this.discordBotToken = intToBool(dbAssoc["svr_discord_bot_token"]); - this.discordEnabled = intToBool(dbAssoc["svr_discord_bot_enabled"]); - - this.createJobPickups = intToBool(dbAssoc["svr_job_pickups"]); - this.createBusinessPickups = intToBool(dbAssoc["svr_biz_pickups"]); - this.createHousePickups = intToBool(dbAssoc["svr_house_pickups"]); - this.createJobBlips = intToBool(dbAssoc["svr_job_blips"]); - this.createBusinessBlips = intToBool(dbAssoc["svr_biz_blips"]); - this.createHouseBlips = intToBool(dbAssoc["svr_house_blips"]); - - this.introMusicURL = dbAssoc["svr_intro_music"]; - this.useRealTime = intToBool(dbAssoc["svr_time_realtime_enabled"]); - this.realTimeZone = dbAssoc["svr_time_realtime_timezone"]; - } - } - }, - - /** @class clientData Representing extra data for a client */ - clientData: class { - constructor(client, accountData, subAccounts) { - this.accountData = accountData; - this.subAccounts = subAccounts; // Characters - this.client = client; - this.currentSubAccount = -1; - this.loggedIn = false; - this.index = -1; - this.connectTime = 0; - this.clientVersion = "0.0.0"; - this.loginAttemptsRemaining = 3; - - this.jobRoute = false; - this.jobRouteStop = false; - this.jobRouteIsland = false; - this.jobRouteVehicle = false; - - this.spawned = false; - - this.rentingVehicle = false; - this.buyingVehicle = false; - - this.lastVehicle = false; - - this.returnToJobVehicleTick = 0; - this.returnToJobVehicleTimer = null; - - this.switchingCharacter = false; - - this.tutorialStep = -1; - this.tutorialItem = null; - this.tutorialVehicle = null; - - this.hotBarItems = new Array(9).fill(-1); - this.activeHotBarSlot = -1; - this.toggleUseItem = false; - - this.jobLockerCache = new Array(9).fill(-1); - this.jobEquipmentCache = []; - this.jobUniform = 0; - - this.itemActionState = VRR_ITEM_ACTION_NONE; - this.itemActionItem = -1; - - this.alcoholLevel = 0; - - this.pedState = VRR_PEDSTATE_NONE; - - this.promptType = VRR_PROMPT_NONE; - - this.businessOrderAmount = 0; - this.businessOrderBusiness = -1; - this.businessOrderItem = -1; - this.businessOrderValue = -1; - - this.syncPosition = null; - this.syncHeading = null; - this.syncVehicle = null; - this.syncVehicleSeat = null; - - this.twoFactorAuthenticationState = VRR_2FA_STATE_NONE; - this.twoFactorAuthenticationCode = 0; - - this.payDayAmount = 0; - this.payDayTickStart = 0; - - this.creatingCharacter = false; - this.creatingCharacterSkin = -1; - - this.streamingRadioStation = -1; - this.streamingRadioElement = false; - - this.returnToPosition = null; - this.returnToHeading = null; - this.returnToInterior = null; - this.returnToDimension = null; - this.returnToHouse = null; - this.returnToBusiness = null; - - this.changingCharacterName = false; - } - }, - - /** @class clientData Representing an account, loaded/saved in the database */ - accountData: class { - constructor(dbAssoc) { - this.databaseId = 0; - this.name = ""; - this.password = ""; - this.registerDate = 0; - this.flags = { - moderation: 0, - settings: 0, - admin: 0, - }; - this.staffTitle = ""; - this.ircAccount = ""; - this.discordAccount = 0, - this.settings = 0, - this.emailAddress = ""; - this.ipAddress = 0, - - this.notes = []; - this.messages = []; - this.keyBinds = []; - this.contacts = []; - this.subAccounts = []; - - this.emailVerificationCode = ""; - this.twoFactorAuthVerificationCode = ""; - - this.chatScrollLines = 1; - - this.streamingRadioVolume = 20; - - if(dbAssoc) { - this.databaseId = dbAssoc["acct_id"]; - this.name = dbAssoc["acct_name"]; - this.password = dbAssoc["acct_pass"]; - this.registerDate = dbAssoc["acct_when_made"]; - this.flags = { - moderation: dbAssoc["acct_svr_mod_flags"], - settings: dbAssoc["acct_svr_settings"], - admin: dbAssoc["acct_svr_staff_flags"], - }; - this.staffTitle = dbAssoc["acct_svr_staff_title"]; - this.ircAccount = dbAssoc["acct_irc"]; - this.discordAccount = dbAssoc["acct_discord"]; - this.settings = dbAssoc["acct_svr_settings"]; - this.emailAddress = dbAssoc["acct_email"]; - this.whenRegistered = dbAssoc["acct_when_registered"]; - this.ipAddress = dbAssoc["ipstring"]; - - this.notes = []; - this.messages = []; - this.keyBinds = []; - this.contacts = []; - this.subAccounts = []; - - this.emailVerificationCode = dbAssoc["acct_code_verifyemail"]; - this.twoFactorAuthVerificationCode = dbAssoc["acct_code_2fa"]; - this.chatScrollLines = toInteger(dbAssoc["acct_svr_chat_scroll_lines"]); - this.streamingRadioVolume = toInteger(dbAssoc["acct_streaming_radio_volume"]); - } - } - }, - /** @class accountContactData Representing an account's contact list, loaded/saved in the database */ - accountContactData: class { - constructor(dbAssoc) { - this.databaseId = 0; - this.accountId = 0; - this.contactAccountId = 0; - this.type = 0; - this.whenAdded = 0; - this.needsSaved = false; - - if(dbAssoc) { - this.databaseId = dbAssoc["acct_contact_id"]; - this.accountId = dbAssoc["acct_contact_acct"]; - this.contactAccountId = dbAssoc["acct_contact_contact"]; - this.type = dbAssoc["acct_contact_type"]; - this.whenAdded = dbAssoc["acct_contact_when_added"]; - } - } - }, - /** @class accountMessageData Representing an account's messages, loaded/saved in the database */ - accountMessageData: class { - constructor(dbAssoc) { - this.databaseId = 0; - this.account = 0; - this.whoSent = 0; - this.whenSent = 0; - this.whenRead = 0; - this.deleted = false; - this.whenDeleted = 0; - this.folder = 0; - this.message = ""; - this.needsSaved = false; - - if(dbAssoc) { - this.databaseId = dbAssoc["acct_msg_id"]; - this.account = dbAssoc["acct_msg_acct"]; - this.whoSent = dbAssoc["acct_msg_who_sent"]; - this.whenSent = dbAssoc["acct_msg_when_sent"]; - this.whenRead = dbAssoc["acct_msg_when_read"]; - this.deleted = intToBool(dbAssoc["acct_msg_deleted"]); - this.whenDeleted = dbAssoc["acct_msg_when_deleted"]; - this.folder = dbAssoc["acct_msg_folder"]; - this.message = dbAssoc["acct_msg_message"]; - } - } - }, - /** @class accountStaffNoteData Representing an account's staff notes. Visible only to staff and loaded/saved in the database */ - accountStaffNoteData: class { - constructor(dbAssoc) { - this.databaseId = 0; - this.account = 0; - this.whoAdded = 0; - this.whenAdded = 0; - this.deleted = false; - this.whenDeleted = 0; - this.server = 0; - this.note = ""; - this.needsSaved = false; - - if(dbAssoc) { - this.databaseId = dbAssoc["acct_note_id"]; - this.account = dbAssoc["acct_note_acct"]; - this.whoAdded = dbAssoc["acct_note_who_added"]; - this.whenAdded = dbAssoc["acct_note_when_added"]; - this.deleted = intToBool(dbAssoc["acct_note_deleted"]); - this.whenDeleted = dbAssoc["acct_note_when_deleted"]; - this.server = dbAssoc["acct_note_server"]; - this.note = dbAssoc["acct_note_message"]; - } - } - }, - /** @class subAccountData Representing a character's (subaccount) data. Loaded and saved in the database */ - subAccountData: class { - constructor(dbAssoc) { - this.databaseId = 0; - this.server = 0; - this.firstName = "John"; - this.lastName = "Doe"; - this.middleName = "Q"; - this.account = 0; - this.skin = 0; - this.cash = 0; - this.spawnPosition = toVector3(0.0, 0.0, 0.0); - this.spawnHeading = 0.0; - this.lastLogin = 0; - this.clan = 0; - this.clanFlags = 0; - this.clanRank = 0; - this.clanTitle = 0; - this.isWorking = false; - this.jobUniform = this.skin; - this.lastJobVehicle = null; - this.job = 0; - this.weapons = []; - this.inJail = false; - this.interior = 0; - this.dimension = 0; - this.pedScale = toVector3(1.0, 1.0, 1.0); - this.walkStyle = 0; - this.fightStyle = 0; - this.health = 100; - this.armour = 100; - this.inHouse = 0; - this.inBusiness = 0; - - this.bodyParts = { - hair: [0,0], - head: [0,0], - upper: [0,0], - lower: [0,0], - }; - - this.bodyProps = { - hair: [0,0], - eyes: [0,0], - head: [0,0], - leftHand: [0,0], - rightHand: [0,0], - leftWrist: [0,0], - rightWrist: [0,0], - hip: [0,0], - leftFoot: [0,0], - rightFoot: [0,0], - }; - - if(dbAssoc) { - this.databaseId = dbAssoc["sacct_id"]; - this.server = toInteger(dbAssoc["sacct_server"]); - this.firstName = dbAssoc["sacct_name_first"]; - this.lastName = dbAssoc["sacct_name_last"]; - this.middleName = dbAssoc["sacct_name_middle"] || ""; - this.account = toInteger(dbAssoc["sacct_acct"]); - this.skin = toInteger(dbAssoc["sacct_svr_skin"]); - this.cash = toInteger(dbAssoc["sacct_cash"]); - this.spawnPosition = toVector3(toFloat(dbAssoc["sacct_pos_x"]), toFloat(dbAssoc["sacct_pos_y"]), toFloat(dbAssoc["sacct_pos_z"])); - this.spawnHeading = toFloat(dbAssoc["sacct_rot_z"]); - this.lastLogin = toInteger(dbAssoc["sacct_when_lastlogin"]); - this.clan = toInteger(dbAssoc["sacct_svr_clan"]); - this.clanFlags = toInteger(dbAssoc["sacct_svr_clan_flags"]); - this.clanRank = toInteger(dbAssoc["sacct_svr_clan_rank"]); - this.clanTitle = toInteger(dbAssoc["sacct_svr_clan_title"]); - this.job = toInteger(dbAssoc["sacct_svr_job"]); - this.interior = toInteger(dbAssoc["sacct_int"]); - this.dimension = toInteger(dbAssoc["sacct_vw"]); - this.pedScale = toVector3(toFloat(dbAssoc["sacct_svr_scale_x"]), toFloat(dbAssoc["sacct_svr_scale_y"]), toFloat(dbAssoc["sacct_svr_scale_z"])); - this.walkStyle = toInteger(dbAssoc["sacct_svr_walkstyle"]); - this.fightStyle = toInteger(dbAssoc["sacct_svr_fightstyle"]); - this.health = toInteger(dbAssoc["sacct_health"]); - this.armour = toInteger(dbAssoc["sacct_armour"]); - this.inHouse = toInteger(dbAssoc["sacct_inhouse"]); - this.inBusiness = toInteger(dbAssoc["sacct_inbusiness"]); - - this.bodyParts = { - hair: [toInteger(dbAssoc["sacct_svr_hd_part_hair_model"]) || 0, toInteger(dbAssoc["sacct_svr_hd_part_hair_texture"]) || 0], - head: [toInteger(dbAssoc["sacct_svr_hd_part_head_model"]) || 0, toInteger(dbAssoc["sacct_svr_hd_part_head_texture"]) || 0], - upper: [toInteger(dbAssoc["sacct_svr_hd_part_upper_model"]) || 0, toInteger(dbAssoc["sacct_svr_hd_part_upper_texture"]) || 0], - lower: [toInteger(dbAssoc["sacct_svr_hd_part_lower_model"]) || 0, toInteger(dbAssoc["sacct_svr_hd_part_lower_texture"]) || 0], - }; - - this.bodyProps = { - hair: [toInteger(dbAssoc["sacct_svr_hd_prop_hair_model"]) || 0, toInteger(dbAssoc["sacct_svr_hd_prop_hair_texture"]) || 0], - eyes: [toInteger(dbAssoc["sacct_svr_hd_prop_eyes_model"]) || 0, toInteger(dbAssoc["sacct_svr_hd_prop_eyes_texture"]) || 0], - head: [toInteger(dbAssoc["sacct_svr_hd_prop_head_model"]) || 0, toInteger(dbAssoc["sacct_svr_hd_prop_head_texture"]) || 0], - leftHand: [toInteger(dbAssoc["sacct_svr_hd_prop_lefthand_model"]) || 0, toInteger(dbAssoc["sacct_svr_hd_prop_lefthand_texture"]) || 0], - rightHand: [toInteger(dbAssoc["sacct_svr_hd_prop_righthand_model"]) || 0, toInteger(dbAssoc["sacct_svr_hd_prop_righthand_texture"]) || 0], - leftWrist: [toInteger(dbAssoc["sacct_svr_hd_prop_leftwrist_model"]) || 0, toInteger(dbAssoc["sacct_svr_hd_prop_leftwrist_texture"]) || 0], - rightWrist: [toInteger(dbAssoc["sacct_svr_hd_prop_rightwrist_model"]) || 0, toInteger(dbAssoc["sacct_svr_hd_prop_rightwrist_texture"]) || 0], - hip: [toInteger(dbAssoc["sacct_svr_hd_prop_hip_model"]) || 0, toInteger(dbAssoc["sacct_svr_hd_prop_hip_texture"]) || 0], - leftFoot: [toInteger(dbAssoc["sacct_svr_hd_prop_leftfoot_model"]) || 0, toInteger(dbAssoc["sacct_svr_hd_prop_leftfoot_texture"]) || 0], - rightFoot: [toInteger(dbAssoc["sacct_svr_hd_prop_rightfoot_model"]) || 0, toInteger(dbAssoc["sacct_svr_hd_prop_rightfoot_texture"]) || 0], - }; - } - } - }, - /** @class businessData Representing a businesses' data. Loaded and saved in the database */ - businessData: class { - constructor(dbAssoc) { - this.databaseId = 0; - this.name = ""; - this.ownerType = VRR_BIZOWNER_NONE; - this.ownerId = 0; - this.buyPrice = 0; - this.locked = false; - this.hasInterior = false; - this.index = -1; - this.needsSaved = false; - this.interiorLights = true; - - this.floorItemCache = []; - this.storageItemCache = []; - this.locations = []; - this.gameScripts = []; - - this.entrancePosition = false; - this.entranceRotation = 0.0; - this.entranceInterior = 0; - this.entranceDimension = 0; - this.entrancePickupModel = -1; - this.entranceBlipModel = -1; - this.entrancePickup = null; - this.entranceBlip = null; - - this.exitPosition = false; - this.exitRotation = 0.0; - this.exitInterior = 0; - this.exitDimension = 0; - this.exitPickupModel = -1; - this.exitBlipModel = -1; - this.exitPickup = null; - this.exitBlip = null; - - this.entranceFee = 0; - this.till = 0; - - this.streamingRadioStation = -1; - - if(dbAssoc) { - this.databaseId = toInteger(dbAssoc["biz_id"]); - this.name = toString(dbAssoc["biz_name"]); - this.ownerType = toInteger(dbAssoc["biz_owner_type"]); - this.ownerId = toInteger(dbAssoc["biz_owner_id"]); - this.buyPrice = toInteger(dbAssoc["biz_buy_price"]); - this.locked = intToBool(toInteger(dbAssoc["biz_locked"])); - this.hasInterior = intToBool(toInteger(dbAssoc["biz_has_interior"])); - this.interiorLights = intToBool(toInteger(dbAssoc["biz_interior_lights"])); - - this.entrancePosition = toVector3(toFloat(dbAssoc["biz_entrance_pos_x"]), toFloat(dbAssoc["biz_entrance_pos_y"]), toFloat(dbAssoc["biz_entrance_pos_z"])); - this.entranceRotation = toInteger(dbAssoc["biz_entrance_rot_z"]); - this.entranceInterior = toInteger(dbAssoc["biz_entrance_int"]); - this.entranceDimension = toInteger(dbAssoc["biz_entrance_vw"]); - this.entrancePickupModel = toInteger(dbAssoc["biz_entrance_pickup"]); - this.entranceBlipModel = toInteger(dbAssoc["biz_entrance_blip"]); - - this.exitPosition = toVector3(dbAssoc["biz_exit_pos_x"], dbAssoc["biz_exit_pos_y"], dbAssoc["biz_exit_pos_z"]); - this.exitRotation = toInteger(dbAssoc["biz_exit_rot_z"]); - this.exitInterior = toInteger(dbAssoc["biz_exit_int"]); - this.exitDimension = toInteger(dbAssoc["biz_exit_vw"]); - this.exitPickupModel = toInteger(dbAssoc["biz_exit_pickup"]); - this.exitBlipModel = toInteger(dbAssoc["biz_exit_blip"]); - - this.entranceFee = toInteger(dbAssoc["biz_entrance_fee"]); - this.till = toInteger(dbAssoc["biz_till"]); - } - } - }, - /** @class businessLocationData Representing a business's location data. Multiple can be used for a single business. Used for things like doors, fuel pumps, drive thru positions, etc. Loaded and saved in the database */ - businessLocationData: class { - constructor(dbAssoc) { - this.databaseId = 0; - this.name = ""; - this.type = 0; - this.business = 0; - this.enabled = false; - this.index = -1; - this.businessIndex = -1; - this.needsSaved = false; - - this.position = toVector3(0.0, 0.0, 0.0); - this.interior = 0; - this.dimension = 0; - - if(dbAssoc) { - this.databaseId = toInteger(dbAssoc["biz_loc_id"]); - this.name = toString(dbAssoc["biz_loc_name"]); - this.type = toInteger(dbAssoc["biz_loc_type"]); - this.business = toInteger(dbAssoc["biz_loc_biz"]); - this.enabled = intToBool(toInteger(dbAssoc["biz_loc_enabled"])); - - this.position = toVector3(toFloat(dbAssoc["biz_loc_pos_x"]), toFloat(dbAssoc["biz_loc_pos_y"]), toFloat(dbAssoc["biz_loc_pos_z"])); - this.interior = toInteger(dbAssoc["biz_loc_int"]); - this.dimension = toInteger(dbAssoc["biz_loc_vw"]); - } - } - }, - /** @class businessGameScriptData Representing a business's game scripts. Multiple can be used for a single business. Used for things like bar and club NPCs and other actions */ - businessGameScriptData: class { - constructor(dbAssoc) { - this.databaseId = 0; - this.name = ""; - this.business = 0; - this.enabled = false; - this.index = -1; - this.businessIndex = -1; - this.needsSaved = false; - - if(dbAssoc) { - this.databaseId = toInteger(dbAssoc["biz_script_id"]); - this.name = toString(dbAssoc["biz_script_name"]); - this.state = toInteger(dbAssoc["biz_script_state"]); - this.business = toInteger(dbAssoc["biz_script_biz"]); - } - } - }, - /** @class houseData Representing a house's data. Loaded and saved in the database */ - houseData: class { - constructor(dbAssoc) { - this.databaseId = 0 - this.description = ""; - this.ownerType = VRR_HOUSEOWNER_NONE; - this.ownerId = 0; - this.buyPrice = 0; - this.rentPrice = 0; - this.renter = 0; - this.locked = false; - this.hasInterior = false; - this.index = -1; - this.needsSaved = false; - this.interiorLights = true; - - this.itemCache = []; - this.locations = []; - this.gameScripts = []; - - this.entrancePosition = false; - this.entranceRotation = 0.0; - this.entranceInterior = 0; - this.entranceDimension = 0; - this.entrancePickupModel = -1; - this.entranceBlipModel = -1; - this.entrancePickup = null; - this.entranceBlip = null; - - this.exitPosition = false; - this.exitRotation = 0.0; - this.exitInterior = 0; - this.exitDimension = -1; - this.exitPickupModel = -1; - this.exitBlipModel = -1; - this.exitPickup = null; - this.exitBlip = null; - - this.streamingRadioStation = -1; - - if(dbAssoc) { - this.databaseId = toInteger(dbAssoc["house_id"]); - this.description = toString(dbAssoc["house_description"]); - this.ownerType = toInteger(dbAssoc["house_owner_type"]); - this.ownerId = toInteger(dbAssoc["house_owner_id"]); - this.buyPrice = toInteger(dbAssoc["house_buy_price"]); - this.rentPrice = toInteger(dbAssoc["house_rent_price"]); - this.renter = toInteger(dbAssoc["house_renter"]); - this.locked = intToBool(toInteger(dbAssoc["house_locked"])); - this.hasInterior = intToBool(toInteger(dbAssoc["house_has_interior"])); - this.interiorLights = intToBool(toInteger(dbAssoc["house_interior_lights"])); - - this.entrancePosition = toVector3(toFloat(dbAssoc["house_entrance_pos_x"]), toFloat(dbAssoc["house_entrance_pos_y"]), toFloat(dbAssoc["house_entrance_pos_z"])); - this.entranceRotation = toFloat(dbAssoc["house_entrance_rot_z"]); - this.entranceInterior = toInteger(dbAssoc["house_entrance_int"]); - this.entranceDimension = toInteger(dbAssoc["house_entrance_vw"]); - this.entrancePickupModel = toInteger(dbAssoc["house_entrance_pickup"]); - this.entranceBlipModel = toInteger(dbAssoc["house_entrance_blip"]); - - this.exitPosition = toVector3(toFloat(dbAssoc["house_exit_pos_x"]), toFloat(dbAssoc["house_exit_pos_y"]), toFloat(dbAssoc["house_exit_pos_z"])); - this.exitRotation = toFloat(dbAssoc["house_exit_rot_z"]); - this.exitInterior = toInteger(dbAssoc["house_exit_int"]); - this.exitDimension = toInteger(dbAssoc["house_exit_vw"]); - this.exitPickupModel = toInteger(dbAssoc["house_exit_pickup"]); - this.exitBlipModel = toInteger(dbAssoc["house_exit_blip"]); - } - } - }, - /** @class houseLocationData Representing a houses's location data. Multiple can be used for a single house. Used for things like doors, garage entry/exit/vehspawn, gates, etc. Loaded and saved in the database */ - houseLocationData: class { - constructor(dbAssoc) { - this.databaseId = 0; - this.name = ""; - this.type = 0; - this.house = 0; - this.enabled = false; - this.index = -1; - this.houseIndex = -1; - this.needsSaved = false; - - this.position = toVector3(0.0, 0.0, 0.0); - this.interior = 0; - this.dimension = 0; - - if(dbAssoc) { - this.databaseId = toInteger(dbAssoc["house_loc_id"]); - this.name = toString(dbAssoc["house_loc_name"]); - this.type = toInteger(dbAssoc["house_loc_type"]); - this.house = toInteger(dbAssoc["house_loc_house"]); - this.enabled = intToBool(toInteger(dbAssoc["house_loc_enabled"])); - this.index = -1; - - this.position = toVector3(toFloat(dbAssoc["house_loc_pos_x"]), toFloat(dbAssoc["house_loc_pos_y"]), toFloat(dbAssoc["house_loc_pos_z"])); - this.interior = toInteger(dbAssoc["house_loc_int"]); - this.dimension = toInteger(dbAssoc["house_loc_vw"]); - } +/** + * @class Representing data for server configuration + */ +class ServerConfigData { + constructor(dbAssoc) { + this.databaseId = 0; + this.name = ""; + this.password = ""; + this.needsSaved = false; + + this.newCharacter = { + spawnPosition: toVector3(0.0, 0.0, 0.0), + spawnHeading: 0.0, + spawnInterior: 0, + spawnDimension: 0, + money: 0, + bank: 0, + skin: 0, + }; + + this.connectCameraPosition = toVector3(0.0, 0.0, 0.0); + this.connectCameraLookAt = toVector3(0.0, 0.0, 0.0); + + this.characterSelectCameraPosition = toVector3(0.0, 0.0, 0.0); + this.characterSelectCameraLookAt = toVector3(0.0, 0.0, 0.0); + this.characterSelectPedPosition = toVector3(0.0, 0.0, 0.0); + this.characterSelectPedHeading = 0.0; + this.characterSelectInterior = 0; + this.characterSelectDimension = 0; + + this.hour = 0; + this.minute = 0 + this.minuteDuration = 1000; + this.weather = 0 + this.fallingSnow = false; + this.groundSnow = false; + this.useGUI = true; + this.guiColour = [200, 200, 200]; + this.showLogo = true; + this.inflationMultiplier = 1; + + this.antiCheat = { + enabled: false, + checkGameScripts: false, + gameScriptWhiteListEnabled: false, + gameScriptBlackListEnabled: false, + gameScriptWhiteList: [], + gameScriptBlackList: [], + }; + + this.discordBotToken = ""; + this.discordEnabled = false; + + this.createJobPickups = false; + this.createBusinessPickups = false; + this.createHousePickups = false; + this.createJobBlips = false; + this.createBusinessBlips = false; + this.createHouseBlips = false; + + this.introMusicURL = ""; + + this.pauseSavingToDatabase = false; + + this.useRealTime = false; + this.realTimeZone = 0; + + if(dbAssoc) { + this.databaseId = dbAssoc["svr_id"]; + console.log("1"); + this.newCharacter = { + spawnPosition: toVector3(dbAssoc["svr_newchar_pos_x"], dbAssoc["svr_newchar_pos_y"], dbAssoc["svr_newchar_pos_z"]), + spawnHeading: dbAssoc["svr_newchar_rot_z"], + money: dbAssoc["svr_newchar_money"], + bank: dbAssoc["svr_newchar_bank"], + skin: dbAssoc["svr_newchar_skin"], + }, + this.connectCameraPosition = toVector3(dbAssoc["svr_connectcam_pos_x"], dbAssoc["svr_connectcam_pos_y"], dbAssoc["svr_connectcam_pos_z"]); + this.connectCameraLookAt = toVector3(dbAssoc["svr_connectcam_lookat_x"], dbAssoc["svr_connectcam_lookat_y"], dbAssoc["svr_connectcam_lookat_z"]); + + //this.characterSelectCameraPosition = toVector3(dbAssoc["svr_charselect_cam_pos_x"], dbAssoc["svr_charselect_cam_pos_y"], dbAssoc["svr_charselect_cam_pos_z"]); + //this.characterSelectCameraLookAt = toVector3(dbAssoc["svr_charselect_cam_lookat_x"], dbAssoc["svr_charselect_cam_lookat_y"], dbAssoc["svr_charselect_cam_lookat_z"]); + + //this.characterSelectPedPosition = toVector3(dbAssoc["svr_charselect_ped_pos_x"], dbAssoc["svr_charselect_ped_pos_y"], dbAssoc["svr_charselect_ped_pos_z"]); + //this.characterSelectPedHeading = toFloat(dbAssoc["svr_charselect_ped_rot_z"]); + //this.characterSelectInterior = toInteger(dbAssoc["svr_charselect_int"]); + //this.characterSelectDimension = toInteger(dbAssoc["svr_charselect_int"]); + + this.hour = toInteger(dbAssoc["svr_start_time_hour"]); + 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 = intToBool(dbAssoc["svr_start_snow_falling"]); + this.groundSnow = intToBool(dbAssoc["svr_start_snow_ground"]); + this.useGUI = intToBool(dbAssoc["svr_gui"]); + this.guiColour = [toInteger(dbAssoc["svr_gui_col1_r"]), toInteger(dbAssoc["svr_gui_col1_g"]), toInteger(dbAssoc["svr_gui_col1_b"])]; + this.showLogo = intToBool(dbAssoc["svr_logo"]); + this.inflationMultiplier = toFloat(dbAssoc["svr_inflation_multiplier"]); + + this.antiCheat = { + enabled: intToBool(dbAssoc["svr_ac_enabled"]), + checkGameScripts: intToBool(dbAssoc["svr_ac_check_scripts"]), + gameScriptBlackListEnabled: intToBool(dbAssoc["svr_ac_script_bl"]), + gameScriptWhiteListEnabled: intToBool(dbAssoc["svr_ac_script_wl"]), + gameScriptWhiteList: [], + gameScriptBlackList: [], }; - //saveToDatabase = () => { - // saveHouseLocationToDatabase(this.houseIndex, this.index); - //} - }, - /** @class houseGameScriptData Representing a house's game scripts. Multiple can be used for a single house. */ - houseGameScriptData: class { - constructor(dbAssoc) { - this.databaseId = 0; - this.name = ""; - this.business = 0; - this.state = false; - this.index = -1; - this.houseIndex = -1; - this.needsSaved = false; + this.discordBotToken = intToBool(dbAssoc["svr_discord_bot_token"]); + this.discordEnabled = intToBool(dbAssoc["svr_discord_bot_enabled"]); - if(dbAssoc) { - this.databaseId = toInteger(dbAssoc["house_script_id"]); - this.name = toString(dbAssoc["house_script_name"]); - this.state = toInteger(dbAssoc["house_script_state"]); - this.business = toInteger(dbAssoc["house_script_biz"]); - } - } - }, - /** @class clanData Representing a clan's data. Loaded and saved in the database */ - clanData: class { - constructor(dbAssoc) { - this.databaseId = 0; - this.name = ""; - this.ownerId = 0; - this.tag = ""; - this.enabled = false; - this.index = -1; - this.colour = COLOUR_WHITE; - this.colours = []; - this.initialRank = 0; - this.members = []; - this.ranks = []; - this.needsSaved = false; - this.motd = false; + this.createJobPickups = intToBool(dbAssoc["svr_job_pickups"]); + this.createBusinessPickups = intToBool(dbAssoc["svr_biz_pickups"]); + this.createHousePickups = intToBool(dbAssoc["svr_house_pickups"]); + this.createJobBlips = intToBool(dbAssoc["svr_job_blips"]); + this.createBusinessBlips = intToBool(dbAssoc["svr_biz_blips"]); + this.createHouseBlips = intToBool(dbAssoc["svr_house_blips"]); - if(dbAssoc) { - this.databaseId = toInteger(dbAssoc["clan_id"]); - this.name = dbAssoc["clan_name"]; - this.owner = toInteger(dbAssoc["clan_owner"]); - this.tag = dbAssoc["clan_tag"]; - this.enabled = intToBool(toInteger(dbAssoc["clan_enabled"])); - this.colour = toColour(toInteger(dbAssoc["clan_col_r"]), toInteger(dbAssoc["clan_col_g"]), toInteger(dbAssoc["clan_col_b"])); - this.colours = [toInteger(dbAssoc["clan_col_r"]), toInteger(dbAssoc["clan_col_g"]), toInteger(dbAssoc["clan_col_b"])]; - this.motd = dbAssoc["clan_motd"]; - } - } - }, - /** @class clanRankData Representing a clan rank's data. Loaded and saved in the database */ - clanRankData: class { - constructor(dbAssoc) { - this.databaseId = 0; - this.clan = 0; - this.name = ""; - this.level = 0; - this.flags = 0; - this.customTag = ""; - this.enabled = true; - this.index = -1; - this.clanIndex = -1; - this.needsSaved = false; - - if(dbAssoc) { - this.databaseId = toInteger(dbAssoc["clan_rank_id"]); - this.clan = toInteger(dbAssoc["clan_rank_clan"]); - this.name = dbAssoc["clan_rank_name"]; - this.level = toInteger(dbAssoc["clan_rank_level"]); - this.flags = toInteger(dbAssoc["clan_rank_flags"]); - this.tag = dbAssoc["clan_rank_tag"]; - this.enabled = intToBool(toInteger(dbAssoc["clan_enabled"])); - this.colour = toColour(toInteger(dbAssoc["clan_colour_r"]), toInteger(dbAssoc["clan_colour_g"]), toInteger(dbAssoc["clan_colour_b"])); - } - } - }, - /** @class clanMemberData Representing a clan member's data. Loaded and saved in the database */ - clanMemberData: class { - constructor(dbAssoc) { - this.databaseId = 0; - this.clan = 0; - this.subAccount = 0; - this.flags = 0; - this.customTitle = ""; - this.customTag = ""; - this.rank = 0; - this.enabled = false; - this.index = -1; - this.clanIndex = -1; - this.rankIndex = -1; - this.needsSaved = false; - - if(dbAssoc) { - this.databaseId = toInteger(dbAssoc["clan_member_id"]); - this.subAccount = toInteger(dbAssoc["clan_member_sacct"]); - this.clan = toInteger(dbAssoc["clan_member_clan"]); - this.name = dbAssoc["clan_member_name"]; - this.rank = toInteger(dbAssoc["clan_member_rank"]); - this.flags = toInteger(dbAssoc["clan_member_flags"]); - this.customTag = dbAssoc["clan_member_tag"]; - this.customTitle = dbAssoc["clan_member_title"]; - } - } - }, - /** @class vehicleData Representing a vehicle's data. Loaded and saved in the database */ - vehicleData: class { - constructor(dbAssoc = false, vehicle = false) { - // General Info - this.databaseId = 0; - this.server = getServerId(); - this.model = (vehicle != false) ? vehicle.modelIndex : 0; - this.vehicle = vehicle; - this.index = -1; - this.needsSaved = false; - - // Ownership - this.ownerType = VRR_VEHOWNER_NONE; - this.ownerId = 0; - this.buyPrice = 0; - this.rentPrice = 0; - this.rentedBy = false; - this.rentStart = 0; - - // Position and Rotation - this.spawnPosition = (vehicle) ? vehicle.position : toVector3(0.0, 0.0, 0.0); - this.spawnRotation = (vehicle) ? vehicle.heading : 0.0; - this.spawnLocked = false; - - // Colour Info - this.colour1IsRGBA = 0; - this.colour2IsRGBA = 0; - this.colour3IsRGBA = 0; - this.colour4IsRGBA = 0; - this.colour1RGBA = toColour(255, 255, 255, 255); - this.colour2RGBA = toColour(255, 255, 255, 255); - this.colour3RGBA = toColour(255, 255, 255, 255); - this.colour4RGBA = toColour(255, 255, 255, 255); - this.colour1 = (vehicle) ? vehicle.colour1 : 1; - this.colour2 = (vehicle) ? vehicle.colour2 : 1; - this.colour3 = (vehicle) ? vehicle.colour3 : 1; - this.colour4 = (vehicle) ? vehicle.colour4 : 1; - this.livery = 3; - - this.extras = [ - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - ]; - - // Vehicle Attributes - this.locked = false; - this.engine = false; - this.lights = false; - this.health = 1000; - this.engineDamage = 0; - this.visualDamage = 0; - this.dirtLevel = 0; - - this.trunkItemCache = []; - this.dashItemCache = []; - - this.streamingRadioStation = -1; - - // Other/Misc - this.insuranceAccount = 0; - this.fuel = 0; - this.flags = 0; - this.needsSaved = false; - this.whoAdded = 0; - this.whenAdded = 0; - - if(dbAssoc) { - // General Info - this.databaseId = toInteger(dbAssoc["veh_id"]); - this.server = toInteger(dbAssoc["veh_server"]); - this.model = toInteger(dbAssoc["veh_model"]); - - // Ownership - this.ownerType = toInteger(dbAssoc["veh_owner_type"]); - this.ownerId = toInteger(dbAssoc["veh_owner_id"]); - this.buyPrice = toInteger(dbAssoc["veh_buy_price"]); - this.rentPrice = toInteger(dbAssoc["veh_rent_price"]); - - // Position and Rotation - this.spawnPosition = toVector3(dbAssoc["veh_pos_x"], dbAssoc["veh_pos_y"], dbAssoc["veh_pos_z"]); - this.spawnRotation = toInteger(dbAssoc["veh_rot_z"]); - this.spawnLocked = intToBool(toInteger(dbAssoc["veh_spawn_lock"])); - - // Colour Info - this.colour1IsRGBA = intToBool(toInteger(dbAssoc["veh_col1_isrgba"])); - this.colour2IsRGBA = intToBool(toInteger(dbAssoc["veh_col2_isrgba"])); - this.colour3IsRGBA = intToBool(toInteger(dbAssoc["veh_col3_isrgba"])); - this.colour4IsRGBA = intToBool(toInteger(dbAssoc["veh_col4_isrgba"])); - this.colour1RGBA = toColour(toInteger(dbAssoc["veh_col1_r"]), toInteger(dbAssoc["veh_col1_g"]), toInteger(dbAssoc["veh_col1_b"]), toInteger(dbAssoc["veh_col1_a"])); - this.colour2RGBA = toColour(toInteger(dbAssoc["veh_col2_r"]), toInteger(dbAssoc["veh_col2_g"]), toInteger(dbAssoc["veh_col2_b"]), toInteger(dbAssoc["veh_col2_a"])); - this.colour3RGBA = toColour(toInteger(dbAssoc["veh_col3_r"]), toInteger(dbAssoc["veh_col3_g"]), toInteger(dbAssoc["veh_col3_b"]), toInteger(dbAssoc["veh_col3_a"])); - this.colour4RGBA = toColour(toInteger(dbAssoc["veh_col4_r"]), toInteger(dbAssoc["veh_col4_g"]), toInteger(dbAssoc["veh_col4_b"]), toInteger(dbAssoc["veh_col4_a"])); - this.colour1 = toInteger(dbAssoc["veh_col1"]); - this.colour2 = toInteger(dbAssoc["veh_col2"]); - this.colour3 = toInteger(dbAssoc["veh_col3"]); - this.colour4 = toInteger(dbAssoc["veh_col4"]); - this.livery = toInteger(dbAssoc["veh_livery"]); - - // Extras (components on SA, extras on IV+) - this.extras = [ - toInteger(dbAssoc["veh_extra1"]), - toInteger(dbAssoc["veh_extra2"]), - toInteger(dbAssoc["veh_extra3"]), - toInteger(dbAssoc["veh_extra4"]), - toInteger(dbAssoc["veh_extra5"]), - toInteger(dbAssoc["veh_extra6"]), - toInteger(dbAssoc["veh_extra7"]), - toInteger(dbAssoc["veh_extra8"]), - toInteger(dbAssoc["veh_extra9"]), - toInteger(dbAssoc["veh_extra10"]), - toInteger(dbAssoc["veh_extra11"]), - toInteger(dbAssoc["veh_extra12"]), - toInteger(dbAssoc["veh_extra13"]), - ]; - - // Vehicle Attributes - this.locked = intToBool(toInteger(dbAssoc["veh_locked"])); - this.engine = intToBool(toInteger(dbAssoc["veh_engine"])); - this.lights = intToBool(toInteger(dbAssoc["veh_lights"])); - this.health = toInteger(dbAssoc["veh_damage_normal"]); - this.engineDamage = toInteger(dbAssoc["veh_damage_engine"]); - this.visualDamage = toInteger(dbAssoc["veh_damage_visual"]); - this.dirtLevel = toInteger(dbAssoc["veh_dirt_level"]); - - // Other/Misc - this.insuranceAccount = toInteger(0); - this.fuel = toInteger(0); - this.flags = toInteger(0); - this.needsSaved = false; - this.whoAdded = toInteger(dbAssoc["veh_who_added"]); - this.whenAdded = toInteger(dbAssoc["veh_when_added"]); - } - } - }, - /** @class commandData Representing a command's data. Loaded and saved in the database */ - commandData: class { - enable() { - this.enabled = true; - } - - disable() { - this.enabled = false; - } - - toggleEnabled() { - this.enabled = !this.enabled; - } - - constructor(command, handlerFunction, syntaxString, requiredStaffFlags, requireLogin, allowOnDiscord, helpDescription) { - this.command = command; - this.handlerFunction = handlerFunction; - this.syntaxString = syntaxString; - this.requiredStaffFlags = requiredStaffFlags; - this.enabled = true; - this.requireLogin = requireLogin; - this.allowOnDiscord = allowOnDiscord; - this.helpDescription = helpDescription; - this.aliases = []; - } - }, - /** @class crimeData Representing a crime's data. Loaded and saved in the database */ - crimeData: class { - constructor(suspectId, crimeType, reporterId = 0) { - this.crimeType = crimeType; - this.suspectId = suspectId; - this.reporterId = reporterId; - this.whenCommitted = 0; - this.whenReported = 0; - this.databaseId = 0; - } - }, - /** @class jobData Representing a job's data. Loaded and saved in the database */ - jobData: class { - constructor(dbAssoc = false) { - this.databaseId = 0; - this.type = VRR_JOB_NONE; - this.name = "Unnamed"; - this.enabled = true; - this.blipModel = -1 - this.pickupModel = -1 - this.colour = toColour(0, 0, 0, 255); - this.whiteListEnabled = false; - this.blackListEnabled = false; - this.walkieTalkieFrequency = 0; - this.index = -1; - this.needsSaved = false; - - this.equipment = []; - this.uniforms = []; - this.locations = []; - this.whiteList = []; - this.blackList = []; - - if(dbAssoc) { - this.databaseId = dbAssoc["job_id"]; - this.type = dbAssoc["job_type"]; - this.name = dbAssoc["job_name"]; - this.enabled = dbAssoc["job_enabled"]; - this.blipModel = dbAssoc["job_blip"]; - this.pickupModel = dbAssoc["job_pickup"]; - this.colour = toColour(dbAssoc["job_colour_r"], dbAssoc["job_colour_g"], dbAssoc["job_colour_b"], 255); - this.whiteListEnabled = dbAssoc["job_wl"]; - this.blackListEnabled = dbAssoc["job_bl"]; - this.walkieTalkieFrequency = dbAssoc["job_walkietalkiefreq"]; - - this.equipment = []; - this.uniforms = []; - this.locations = []; - this.whiteList = []; - this.blackList = []; - } - } - }, - /** @class jobEquipmentData Representing a job equipment set's data. Loaded and saved in the database */ - jobEquipmentData: class { - constructor(dbAssoc = false) { - this.databaseId = 0; - this.job = 0; - this.name = "Unnamed"; - this.requiredRank = 0; - this.enabled = false; - this.index = -1; - this.jobIndex = -1; - this.needsSaved = false; - this.items = []; - - if(dbAssoc) { - this.databaseId = dbAssoc["job_equip_id"]; - this.job = dbAssoc["job_equip_job"]; - this.name = dbAssoc["job_equip_name"]; - this.requiredRank = dbAssoc["job_equip_minrank"]; - this.enabled = dbAssoc["job_equip_enabled"]; - } - } - }, - /** @class jobEquipmentItemData Representing a job equipment set item's data. Loaded and saved in the database */ - jobEquipmentItemData: class { - constructor(dbAssoc = false) { - this.databaseId = 0; - this.equipmentId = 0; - this.itemType = 0; - this.value = 0; - this.enabled = false; - this.index = -1; - this.jobIndex = -1; - this.needsSaved = false; - - if(dbAssoc) { - this.databaseId = dbAssoc["job_equip_item_id"]; - this.equipmentId = dbAssoc["job_equip_item_equip"]; - this.itemType = dbAssoc["job_equip_item_type"]; - this.value = dbAssoc["job_equip_item_value"]; - this.enabled = dbAssoc["job_equip_item_enabled"]; - } - } - }, - /** @class jobUniformData Representing a job uniform's data. Loaded and saved in the database */ - jobUniformData: class { - constructor(dbAssoc = false) { - this.databaseId = 0; - this.job = 0; - this.name = "Unnamed"; - this.requiredRank = 0 - this.skin = -1; - this.enabled = false; - this.index = -1; - this.jobIndex = -1; - this.needsSaved = false; - - this.bodyParts = { - hair: [0,0], - head: [0,0], - upper: [0,0], - lower: [0,0], - }; - - this.bodyProps = { - hair: [0,0], - eyes: [0,0], - head: [0,0], - leftHand: [0,0], - rightHand: [0,0], - leftWrist: [0,0], - rightWrist: [0,0], - hip: [0,0], - leftFoot: [0,0], - rightFoot: [0,0], - }; - - if(dbAssoc) { - this.databaseId = dbAssoc["job_uniform_id"]; - this.job = dbAssoc["job_uniform_job"]; - this.name = dbAssoc["job_uniform_name"]; - this.requiredRank = dbAssoc["job_uniform_minrank"]; - this.skin = dbAssoc["job_uniform_skin"]; - this.enabled = intToBool(dbAssoc["job_uniform_enabled"]); - - this.bodyParts = { - hair: [toInteger(dbAssoc["job_uniform_hd_part_hair_model"]) || 0, toInteger(dbAssoc["job_uniform_hd_part_hair_texture"]) || 0], - head: [toInteger(dbAssoc["job_uniform_hd_part_head_model"]) || 0, toInteger(dbAssoc["job_uniform_hd_part_head_texture"]) || 0], - upper: [toInteger(dbAssoc["job_uniform_hd_part_upper_model"]) || 0, toInteger(dbAssoc["job_uniform_hd_part_upper_texture"]) || 0], - lower: [toInteger(dbAssoc["job_uniform_hd_part_lower_model"]) || 0, toInteger(dbAssoc["job_uniform_hd_part_lower_texture"]) || 0], - }; - - this.bodyProps = { - hair: [toInteger(dbAssoc["job_uniform_hd_prop_hair_model"]) || 0, toInteger(dbAssoc["job_uniform_hd_prop_hair_texture"]) || 0], - eyes: [toInteger(dbAssoc["job_uniform_hd_prop_eyes_model"]) || 0, toInteger(dbAssoc["job_uniform_hd_prop_eyes_texture"]) || 0], - head: [toInteger(dbAssoc["job_uniform_hd_prop_head_model"]) || 0, toInteger(dbAssoc["job_uniform_hd_prop_head_texture"]) || 0], - leftHand: [toInteger(dbAssoc["job_uniform_hd_prop_lefthand_model"]) || 0, toInteger(dbAssoc["job_uniform_hd_prop_lefthand_texture"]) || 0], - rightHand: [toInteger(dbAssoc["job_uniform_hd_prop_righthand_model"]) || 0, toInteger(dbAssoc["job_uniform_hd_prop_righthand_texture"]) || 0], - leftWrist: [toInteger(dbAssoc["job_uniform_hd_prop_leftwrist_model"]) || 0, toInteger(dbAssoc["job_uniform_hd_prop_leftwrist_texture"]) || 0], - rightWrist: [toInteger(dbAssoc["job_uniform_hd_prop_rightwrist_model"]) || 0, toInteger(dbAssoc["job_uniform_hd_prop_rightwrist_texture"]) || 0], - hip: [toInteger(dbAssoc["job_uniform_hd_prop_hip_model"]) || 0, toInteger(dbAssoc["job_uniform_hd_prop_hip_texture"]) || 0], - leftFoot: [toInteger(dbAssoc["job_uniform_hd_prop_leftfoot_model"]) || 0, toInteger(dbAssoc["job_uniform_hd_prop_leftfoot_texture"]) || 0], - rightFoot: [toInteger(dbAssoc["job_uniform_hd_prop_rightfoot_model"]) || 0, toInteger(dbAssoc["job_uniform_hd_prop_rightfoot_texture"]) || 0], - }; - } - } - }, - jobLocationData: class { - constructor(dbAssoc = false) { - this.databaseId = 0; - this.job = 0; - this.position = toVector3(0.0, 0.0, 0.0); - this.blip = false; - this.pickup = false; - this.enabled = false; - this.interior = 0; - this.dimension = 0; - this.index = -1; - this.jobIndex = -1; - this.needsSaved = false; - - if(dbAssoc) { - this.databaseId = dbAssoc["job_loc_id"]; - this.job = dbAssoc["job_loc_job"]; - this.position = toVector3(dbAssoc["job_loc_pos_x"], dbAssoc["job_loc_pos_y"], dbAssoc["job_loc_pos_z"]); - this.blip = false; - this.pickup = false; - this.enabled = dbAssoc["job_loc_enabled"]; - this.interior = dbAssoc["job_loc_int"]; - this.dimension = dbAssoc["job_loc_vw"]; - } - } - }, - jobWhiteListData: class { - constructor(dbAssoc = false) { - this.databaseId = 0; - this.job = 0; - this.subAccount = 0 - this.enabled = false; - this.index = -1; - this.jobIndex = -1; - this.needsSaved = false; - - if(dbAssoc) { - this.databaseId = dbAssoc["job_wl_id"]; - this.job = dbAssoc["job_wl_job"]; - this.subAccount = dbAssoc["job_wl_sacct"] - this.enabled = dbAssoc["job_wl_enabled"]; - } - } - }, - jobBlackListData: class { - constructor(dbAssoc = false) { - this.databaseId = 0; - this.job = 0; - this.subAccount = 0 - this.enabled = false; - this.index = -1; - this.jobIndex = -1; - this.needsSaved = false; - - if(dbAssoc) { - this.databaseId = dbAssoc["job_bl_id"]; - this.job = dbAssoc["job_bl_job"]; - this.subAccount = dbAssoc["job_bl_sacct"] - this.enabled = dbAssoc["job_bl_enabled"]; - } - } - }, - keyBindData: class { - constructor(dbAssoc = false, key = 0, commandString = "", keyState = VRR_KEYSTATE_UP) { - this.databaseId = 0; - this.key = key; - this.account = 0; - this.commandString = commandString; - this.whenAdded = 0; - this.enabled = true; - this.keyState = false; - this.index = -1; - this.needsSaved = false; - - if(dbAssoc) { - this.databaseId = dbAssoc["acct_hotkey_id"]; - this.key = toInteger(dbAssoc["acct_hotkey_key"]); - this.account = toInteger(dbAssoc["acct_hotkey_acct"]); - this.commandString = dbAssoc["acct_hotkey_cmdstr"]; - this.whenAdded = dbAssoc["acct_hotkey_when_added"]; - this.enabled = intToBool(dbAssoc["acct_hotkey_enabled"]); - this.keyState = intToBool(dbAssoc["acct_hotkey_down"]); - } - } - }, - blackListedGameScriptData: class { - constructor(dbAssoc = false) { - this.databaseId = 0; - this.enabled = false - this.server = 0; - this.scriptName = ""; - this.index = -1; - this.needsSaved = false; - - if(dbAssoc) { - this.databaseId = dbAssoc["ac_script_bl_id"]; - this.enabled = intToBool(dbAssoc["ac_script_bl_enabled"]); - this.server = dbAssoc["ac_script_bl_server"]; - this.scriptName = dbAssoc["ac_script_bl_name"]; - } - } - }, - whiteListedGameScriptData: class { - constructor(dbAssoc = false) { - this.databaseId = 0; - this.enabled = false - this.server = 0; - this.scriptName = ""; - this.index = -1; - this.needsSaved = false; - - if(dbAssoc) { - this.databaseId = dbAssoc["ac_script_wl_id"]; - this.enabled = intToBool(dbAssoc["ac_script_wl_enabled"]); - this.server = dbAssoc["ac_script_wl_server"]; - this.scriptName = dbAssoc["ac_script_wl_name"]; - } - } - }, - removedWorldObjectData: class { - constructor(model, position, range) { - this.model = model; - this.position = position; - this.range = range; - } - }, - excludedGroundSnowModel: class { - constructor(model) { - this.model = model; - } - }, - interiorTemplateData: class { - constructor(exitPosition, exitInterior) { - this.exitPosition = exitPosition; - this.exitInterior = exitInterior; - } - }, - radioStationData: class { - constructor(dbAssoc) { - this.databaseId = 0; - this.name = ""; - this.url = ""; - this.genre = ""; - this.codec = ""; - this.index = -1; - - if(dbAssoc) { - this.databaseId = dbAssoc["radio_id"]; - this.name = dbAssoc["radio_name"]; - this.url = dbAssoc["radio_url"]; - this.genre = dbAssoc["radio_genre"]; - this.codec = dbAssoc["radio_codec"]; - } - } - }, - itemData: class { - constructor(dbAssoc = false) { - this.databaseId = 0; - this.index = 0; - this.itemTypeIndex = 0; - this.itemType = 0; - this.ownerType = VRR_ITEM_OWNER_NONE; - this.ownerId = 0; - this.ownerIndex = -1; - this.position = toVector3(0.0, 0.0, 0.0); - this.interior = 0; - this.dimension = 0; - this.object = null; - this.buyPrice = 0; - this.needsSaved = false; - this.amount = 0; - this.value = 0; - this.enabled = false; - this.extra = false; - - if(dbAssoc) { - this.databaseId = toInteger(dbAssoc["item_id"]); - this.index = 0; - this.itemTypeIndex = 0; - this.itemType = toInteger(dbAssoc["item_type"]); - this.ownerType = toInteger(dbAssoc["item_owner_type"]);; - this.ownerId = toInteger(dbAssoc["item_owner_id"]); - this.position = toVector3(toFloat(dbAssoc["item_pos_x"]), toFloat(dbAssoc["item_pos_y"]), toFloat(dbAssoc["item_pos_z"])); - this.interior = toInteger(dbAssoc["item_int"]); - this.dimension = toInteger(dbAssoc["item_vw"]); - this.buyPrice = toInteger(dbAssoc["item_buy_price"]); - this.amount = toInteger(dbAssoc["item_amount"]); - this.value = toInteger(dbAssoc["item_value"]); - this.enabled = intToBool(toInteger(dbAssoc["item_enabled"])); - } - } - }, - itemTypeData: class { - constructor(dbAssoc = false) { - this.databaseId = 0; - this.index = 0; - this.name = "Unknown"; - this.enabled = false; - this.useType = VRR_ITEM_USETYPE_NONE; - this.useId = 0; - this.useValue = 0; - this.maxValue = 0; - this.dropType = VRR_ITEM_DROPTYPE_NONE; - this.useId = 0; - this.dropPosition = toVector3(0.0, 0.0, 0.0); - this.dropRotation = toVector3(0.0, 0.0, 0.0); - this.dropScale = toVector3(0.0, 0.0, 0.0); - this.dropModel = 0; - this.orderPrice = 0; - this.orderValue = 0; - this.demandMultiplier = 1; - this.supplyMultiplier = 1; - this.riskMultiplier = 1; - this.needsSaved = false; - this.useDelay = 0; - this.switchDelay = 0; - this.pickupDelay = 0; - this.putDelay = 0; - this.takeDelay = 0; - this.giveDelay = 0; - this.dropDelay = 0; - - if(dbAssoc) { - this.databaseId = toInteger(dbAssoc["item_type_id"]); - this.name = dbAssoc["item_type_name"]; - this.enabled = intToBool(toInteger(dbAssoc["item_type_enabled"])); - this.useType = toInteger(dbAssoc["item_type_use_type"]); - this.dropType = toInteger(dbAssoc["item_type_drop_type"]); - this.useId = toInteger(dbAssoc["item_type_use_id"]); - this.dropPosition = toVector3(toFloat(dbAssoc["item_type_drop_pos_x"]), toFloat(dbAssoc["item_type_drop_pos_y"]), toFloat(dbAssoc["item_type_drop_pos_z"])); - this.dropRotation = toVector3(toFloat(dbAssoc["item_type_drop_rot_x"]), toFloat(dbAssoc["item_type_drop_rot_y"]), toFloat(dbAssoc["item_type_drop_rot_z"])); - this.dropScale = toVector3(toFloat(dbAssoc["item_type_drop_scale_x"]), toFloat(dbAssoc["item_type_drop_scale_y"]), toFloat(dbAssoc["item_type_drop_scale_z"])); - this.dropModel = toInteger(dbAssoc["item_type_drop_model"]); - this.useId = toInteger(dbAssoc["item_type_use_id"]); - this.useValue = toInteger(dbAssoc["item_type_use_value"]); - this.maxValue = toInteger(dbAssoc["item_type_max_value"]); - this.orderPrice = toInteger(dbAssoc["item_type_order_price"]); - this.orderValue = toInteger(dbAssoc["item_type_order_value"]); - this.demandMultiplier = toFloat(dbAssoc["item_type_demand_multiplier"]); - this.supplyMultiplier = toFloat(dbAssoc["item_type_supply_multiplier"]); - this.riskMultiplier = toFloat(dbAssoc["item_type_risk_multiplier"]); - this.size = toInteger(dbAssoc["item_type_size"]); - this.capacity = toInteger(dbAssoc["item_type_capacity"]); - this.useDelay = toInteger(dbAssoc["item_type_delay_use"]); - this.switchDelay = toInteger(dbAssoc["item_type_delay_switch"]); - this.pickupDelay = toInteger(dbAssoc["item_type_delay_pickup"]); - this.putDelay = toInteger(dbAssoc["item_type_delay_put"]); - this.takeDelay = toInteger(dbAssoc["item_type_delay_take"]); - this.giveDelay = toInteger(dbAssoc["item_type_delay_give"]); - this.dropDelay = toInteger(dbAssoc["item_type_delay_drop"]); - } - } - }, - npcData: class { - constructor(dbAssoc) { - this.databaseId = 0; - this.server = 0; - this.firstName = "John"; - this.lastName = "Doe"; - this.middleName = "Q"; - this.skin = 0; - this.cash = 0; - this.spawnPosition = toVector3(0.0, 0.0, 0.0); - this.spawnHeading = 0.0; - this.clan = 0; - this.isWorking = false; - this.jobUniform = this.skin; - this.lastJobVehicle = null; - this.job = 0; - this.weapons = []; - this.interior = 0; - this.dimension = 0; - this.pedScale = toVector3(1.0, 1.0, 1.0); - this.walkStyle = 0; - this.fightStyle = 0; - this.health = 100; - this.armour = 100; - this.currentAction = VRR_NPCACTION_NONE; - this.triggers = []; - - this.bodyParts = { - hair: [0,0], - head: [0,0], - upper: [0,0], - lower: [0,0], - }; - - this.bodyProps = { - hair: [0,0], - eyes: [0,0], - head: [0,0], - leftHand: [0,0], - rightHand: [0,0], - leftWrist: [0,0], - rightWrist: [0,0], - hip: [0,0], - leftFoot: [0,0], - rightFoot: [0,0], - }; - - if(dbAssoc) { - this.databaseId = toInteger(dbAssoc["npc_id"]); - this.server = toInteger(dbAssoc["npc_server"]); - this.firstName = dbAssoc["npc_name_first"]; - this.lastName = dbAssoc["npc_name_last"]; - this.middleName = dbAssoc["npc_name_middle"] || ""; - this.skin = toInteger(dbAssoc["npc_skin"]); - this.cash = toInteger(dbAssoc["npc_cash"]); - this.spawnPosition = toVector3(toFloat(dbAssoc["npc_pos_x"]), toFloat(dbAssoc["npc_pos_y"]), toFloat(dbAssoc["npc_pos_z"])); - this.spawnHeading = toFloat(dbAssoc["npc_angle"]); - this.lastLogin = toInteger(dbAssoc["npc_when_lastlogin"]); - this.clan = toInteger(dbAssoc["npc_clan"]); - this.clanFlags = toInteger(dbAssoc["npc_clan_flags"]); - this.clanRank = toInteger(dbAssoc["npc_clan_rank"]); - this.clanTitle = toInteger(dbAssoc["npc_clan_title"]); - this.job = toInteger(dbAssoc["npc_job"]); - this.interior = toInteger(dbAssoc["npc_int"]); - this.dimension = toInteger(dbAssoc["npc_vw"]); - this.pedScale = toVector3(toFloat(dbAssoc["npc_scale_x"]), toFloat(dbAssoc["npc_scale_y"]), toFloat(dbAssoc["npc_scale_z"])); - this.walkStyle = toInteger(dbAssoc["npc_walkstyle"]); - this.fightStyle = toInteger(dbAssoc["npc_fightstyle"]); - this.health = toInteger(dbAssoc["npc_health"]); - this.armour = toInteger(dbAssoc["npc_armour"]); - - this.bodyParts = { - hair: [toInteger(dbAssoc["npc_hd_part_hair_model"]) || 0, toInteger(dbAssoc["npc_hd_part_hair_texture"]) || 0], - head: [toInteger(dbAssoc["npc_hd_part_head_model"]) || 0, toInteger(dbAssoc["npc_hd_part_head_texture"]) || 0], - upper: [toInteger(dbAssoc["npc_hd_part_upper_model"]) || 0, toInteger(dbAssoc["npc_hd_part_upper_texture"]) || 0], - lower: [toInteger(dbAssoc["npc_hd_part_lower_model"]) || 0, toInteger(dbAssoc["npc_hd_part_lower_texture"]) || 0], - }; - - this.bodyProps = { - hair: [toInteger(dbAssoc["npc_hd_prop_hair_model"]) || 0, toInteger(dbAssoc["npc_hd_prop_hair_texture"]) || 0], - eyes: [toInteger(dbAssoc["npc_hd_prop_eyes_model"]) || 0, toInteger(dbAssoc["npc_hd_prop_eyes_texture"]) || 0], - head: [toInteger(dbAssoc["npc_hd_prop_head_model"]) || 0, toInteger(dbAssoc["npc_hd_prop_head_texture"]) || 0], - leftHand: [toInteger(dbAssoc["npc_hd_prop_lefthand_model"]) || 0, toInteger(dbAssoc["npc_hd_prop_lefthand_texture"]) || 0], - rightHand: [toInteger(dbAssoc["npc_hd_prop_righthand_model"]) || 0, toInteger(dbAssoc["npc_hd_prop_righthand_texture"]) || 0], - leftWrist: [toInteger(dbAssoc["npc_hd_prop_leftwrist_model"]) || 0, toInteger(dbAssoc["npc_hd_prop_leftwrist_texture"]) || 0], - rightWrist: [toInteger(dbAssoc["npc_hd_prop_rightwrist_model"]) || 0, toInteger(dbAssoc["npc_hd_prop_rightwrist_texture"]) || 0], - hip: [toInteger(dbAssoc["npc_hd_prop_hip_model"]) || 0, toInteger(dbAssoc["npc_hd_prop_hip_texture"]) || 0], - leftFoot: [toInteger(dbAssoc["npc_hd_prop_leftfoot_model"]) || 0, toInteger(dbAssoc["npc_hd_prop_leftfoot_texture"]) || 0], - rightFoot: [toInteger(dbAssoc["npc_hd_prop_rightfoot_model"]) || 0, toInteger(dbAssoc["npc_hd_prop_rightfoot_texture"]) || 0], - }; - } - } - }, - npcTriggerData: class { - constructor(dbAssoc) { - this.databaseId = 0; - this.npcId = 0; - this.index = 0; - this.npc = 0; - this.triggerType = 0; - this.conditions = []; - this.responses = []; - - if(dbAssoc) { - this.databaseId = toInteger(dbAssoc["npc_trig_id"]); - this.npc = toInteger(dbAssoc["npc_trig_npc"]); - this.triggerType = toInteger(dbAssoc["npc_trig_type"]); - } - } - }, - npcTriggerConditionData: class { - constructor(dbAssoc) { - this.databaseId = 0; - this.triggerId = 0; - this.index = 0; - this.conditionType = 0; - this.conditionValue = false; - this.matchType = false; - - if(dbAssoc) { - this.databaseId = toInteger(dbAssoc["npc_trig_cond_id"]); - this.npc = toInteger(dbAssoc["npc_trig_cond_trig"]); - this.conditionType = toInteger(dbAssoc["npc_trig_cond_type"]); - this.conditionValue = toInteger(dbAssoc["npc_trig_cond_val"]); - this.matchType = toInteger(dbAssoc["npc_trig_cond_val"]); - } - } - }, - npcTriggerResponseData: class { - constructor(dbAssoc) { - this.databaseId = 0; - this.triggerId = 0; - this.index = 0; - this.responseType = 0; - this.responseValue = false; - - if(dbAssoc) { - this.databaseId = toInteger(dbAssoc["npc_trig_resp_id"]); - this.npc = toInteger(dbAssoc["npc_trig_resp_trig"]); - this.responseType = toInteger(dbAssoc["npc_trig_resp_type"]); - this.responseValue = toInteger(dbAssoc["npc_trig_resp_val"]); - } - } + this.introMusicURL = dbAssoc["svr_intro_music"]; + this.useRealTime = intToBool(dbAssoc["svr_time_realtime_enabled"]); + this.realTimeZone = dbAssoc["svr_time_realtime_timezone"]; } } +}; - return tempClasses; -} +/** + * @class Representing extra data for a client + */ +class ClientData { + constructor(client, accountData, subAccounts) { + this.accountData = accountData; + this.subAccounts = subAccounts; // Characters + this.client = client; + this.currentSubAccount = -1; + this.loggedIn = false; + this.index = -1; + this.connectTime = 0; + this.clientVersion = "0.0.0"; + this.loginAttemptsRemaining = 3; -// =========================================================================== + this.jobRoute = false; + this.jobRouteStop = false; + this.jobRouteIsland = false; + this.jobRouteVehicle = false; -function getClasses() { - return serverClasses; -} + this.spawned = false; -// =========================================================================== + this.rentingVehicle = false; + this.buyingVehicle = false; -function getClass(className) { - return serverClasses[className]; -} + this.lastVehicle = false; -// =========================================================================== + this.returnToJobVehicleTick = 0; + this.returnToJobVehicleTimer = null; + + this.switchingCharacter = false; + + this.tutorialStep = -1; + this.tutorialItem = null; + this.tutorialVehicle = null; + + this.hotBarItems = new Array(9).fill(-1); + this.activeHotBarSlot = -1; + this.toggleUseItem = false; + + this.jobLockerCache = new Array(9).fill(-1); + this.jobEquipmentCache = []; + this.jobUniform = 0; + + this.itemActionState = VRR_ITEM_ACTION_NONE; + this.itemActionItem = -1; + + this.alcoholLevel = 0; + + this.pedState = VRR_PEDSTATE_NONE; + + this.promptType = VRR_PROMPT_NONE; + + this.businessOrderAmount = 0; + this.businessOrderBusiness = -1; + this.businessOrderItem = -1; + this.businessOrderValue = -1; + + this.syncPosition = null; + this.syncHeading = null; + this.syncVehicle = null; + this.syncVehicleSeat = null; + + this.twoFactorAuthenticationState = VRR_2FA_STATE_NONE; + this.twoFactorAuthenticationCode = 0; + + this.payDayAmount = 0; + this.payDayTickStart = 0; + + this.creatingCharacter = false; + this.creatingCharacterSkin = -1; + + this.streamingRadioStation = -1; + this.streamingRadioElement = false; + + this.returnToPosition = null; + this.returnToHeading = null; + this.returnToInterior = null; + this.returnToDimension = null; + this.returnToHouse = null; + this.returnToBusiness = null; + + this.changingCharacterName = false; + } +}; + +/** + * @class Representing an account, loaded/saved in the database + */ +class AccountData { + constructor(dbAssoc) { + this.databaseId = 0; + this.name = ""; + this.password = ""; + this.registerDate = 0; + this.flags = { + moderation: 0, + admin: 0, + }; + this.staffTitle = ""; + this.ircAccount = ""; + this.discordAccount = 0, + this.settings = 0, + this.emailAddress = ""; + this.ipAddress = 0, + + this.notes = []; + this.messages = []; + this.keyBinds = []; + this.contacts = []; + this.subAccounts = []; + + this.emailVerificationCode = ""; + this.twoFactorAuthVerificationCode = ""; + + this.chatScrollLines = 1; + + this.streamingRadioVolume = 20; + + if(dbAssoc) { + this.databaseId = dbAssoc["acct_id"]; + this.name = dbAssoc["acct_name"]; + this.password = dbAssoc["acct_pass"]; + this.registerDate = dbAssoc["acct_when_made"]; + this.flags = { + moderation: dbAssoc["acct_svr_mod_flags"], + admin: dbAssoc["acct_svr_staff_flags"], + }; + this.staffTitle = dbAssoc["acct_svr_staff_title"]; + this.ircAccount = dbAssoc["acct_irc"]; + this.discordAccount = dbAssoc["acct_discord"]; + this.settings = dbAssoc["acct_svr_settings"]; + this.emailAddress = dbAssoc["acct_email"]; + this.whenRegistered = dbAssoc["acct_when_registered"]; + this.ipAddress = dbAssoc["acct_ip"]; + + this.notes = []; + this.messages = []; + this.keyBinds = []; + this.contacts = []; + this.subAccounts = []; + + this.emailVerificationCode = dbAssoc["acct_code_verifyemail"]; + this.twoFactorAuthVerificationCode = dbAssoc["acct_code_2fa"]; + this.chatScrollLines = toInteger(dbAssoc["acct_svr_chat_scroll_lines"]); + this.streamingRadioVolume = toInteger(dbAssoc["acct_streaming_radio_volume"]); + } + } +}; + +/** + * @class Representing an account's contact list, loaded/saved in the database + */ +class AccountContactData { + constructor(dbAssoc) { + this.databaseId = 0; + this.accountId = 0; + this.contactAccountId = 0; + this.type = 0; + this.whenAdded = 0; + this.needsSaved = false; + + if(dbAssoc) { + this.databaseId = dbAssoc["acct_contact_id"]; + this.accountId = dbAssoc["acct_contact_acct"]; + this.contactAccountId = dbAssoc["acct_contact_contact"]; + this.type = dbAssoc["acct_contact_type"]; + this.whenAdded = dbAssoc["acct_contact_when_added"]; + } + } +}; + +/** + * @class Representing an account's messages, loaded/saved in the database + */ +class AccountMessageData { + constructor(dbAssoc) { + this.databaseId = 0; + this.account = 0; + this.whoSent = 0; + this.whenSent = 0; + this.whenRead = 0; + this.deleted = false; + this.whenDeleted = 0; + this.folder = 0; + this.message = ""; + this.needsSaved = false; + + if(dbAssoc) { + this.databaseId = dbAssoc["acct_msg_id"]; + this.account = dbAssoc["acct_msg_acct"]; + this.whoSent = dbAssoc["acct_msg_who_sent"]; + this.whenSent = dbAssoc["acct_msg_when_sent"]; + this.whenRead = dbAssoc["acct_msg_when_read"]; + this.deleted = intToBool(dbAssoc["acct_msg_deleted"]); + this.whenDeleted = dbAssoc["acct_msg_when_deleted"]; + this.folder = dbAssoc["acct_msg_folder"]; + this.message = dbAssoc["acct_msg_message"]; + } + } +}; + +/** + * @class Representing an account's staff notes. Visible only to staff and loaded/saved in the database + */ +class AccountStaffNoteData { + constructor(dbAssoc) { + this.databaseId = 0; + this.account = 0; + this.whoAdded = 0; + this.whenAdded = 0; + this.deleted = false; + this.whenDeleted = 0; + this.server = 0; + this.note = ""; + this.needsSaved = false; + + if(dbAssoc) { + this.databaseId = dbAssoc["acct_note_id"]; + this.account = dbAssoc["acct_note_acct"]; + this.whoAdded = dbAssoc["acct_note_who_added"]; + this.whenAdded = dbAssoc["acct_note_when_added"]; + this.deleted = intToBool(dbAssoc["acct_note_deleted"]); + this.whenDeleted = dbAssoc["acct_note_when_deleted"]; + this.server = dbAssoc["acct_note_server"]; + this.note = dbAssoc["acct_note_message"]; + } + } +}; + +/** + * @class Representing a character's (subaccount) data. Loaded and saved in the database + */ +class SubAccountData { + constructor(dbAssoc) { + this.databaseId = 0; + this.server = 0; + this.firstName = "John"; + this.lastName = "Doe"; + this.middleName = "Q"; + this.account = 0; + this.skin = 0; + this.cash = 0; + this.spawnPosition = toVector3(0.0, 0.0, 0.0); + this.spawnHeading = 0.0; + this.lastLogin = 0; + this.clan = 0; + this.clanFlags = 0; + this.clanRank = 0; + this.clanTitle = 0; + this.isWorking = false; + this.jobUniform = this.skin; + this.lastJobVehicle = null; + this.job = 0; + this.weapons = []; + this.inJail = false; + this.interior = 0; + this.dimension = 0; + this.pedScale = toVector3(1.0, 1.0, 1.0); + this.walkStyle = 0; + this.fightStyle = 0; + this.health = 100; + this.armour = 100; + this.inHouse = 0; + this.inBusiness = 0; + + this.bodyParts = { + hair: [0,0], + head: [0,0], + upper: [0,0], + lower: [0,0], + }; + + this.bodyProps = { + hair: [0,0], + eyes: [0,0], + head: [0,0], + leftHand: [0,0], + rightHand: [0,0], + leftWrist: [0,0], + rightWrist: [0,0], + hip: [0,0], + leftFoot: [0,0], + rightFoot: [0,0], + }; + + if(dbAssoc) { + this.databaseId = dbAssoc["sacct_id"]; + this.server = toInteger(dbAssoc["sacct_server"]); + this.firstName = dbAssoc["sacct_name_first"]; + this.lastName = dbAssoc["sacct_name_last"]; + this.middleName = dbAssoc["sacct_name_middle"] || ""; + this.account = toInteger(dbAssoc["sacct_acct"]); + this.skin = toInteger(dbAssoc["sacct_svr_skin"]); + this.cash = toInteger(dbAssoc["sacct_cash"]); + this.spawnPosition = toVector3(toFloat(dbAssoc["sacct_pos_x"]), toFloat(dbAssoc["sacct_pos_y"]), toFloat(dbAssoc["sacct_pos_z"])); + this.spawnHeading = toFloat(dbAssoc["sacct_rot_z"]); + this.lastLogin = toInteger(dbAssoc["sacct_when_lastlogin"]); + this.clan = toInteger(dbAssoc["sacct_svr_clan"]); + this.clanFlags = toInteger(dbAssoc["sacct_svr_clan_flags"]); + this.clanRank = toInteger(dbAssoc["sacct_svr_clan_rank"]); + this.clanTitle = toInteger(dbAssoc["sacct_svr_clan_title"]); + this.job = toInteger(dbAssoc["sacct_svr_job"]); + this.interior = toInteger(dbAssoc["sacct_int"]); + this.dimension = toInteger(dbAssoc["sacct_vw"]); + this.pedScale = toVector3(toFloat(dbAssoc["sacct_svr_scale_x"]), toFloat(dbAssoc["sacct_svr_scale_y"]), toFloat(dbAssoc["sacct_svr_scale_z"])); + this.walkStyle = toInteger(dbAssoc["sacct_svr_walkstyle"]); + this.fightStyle = toInteger(dbAssoc["sacct_svr_fightstyle"]); + this.health = toInteger(dbAssoc["sacct_health"]); + this.armour = toInteger(dbAssoc["sacct_armour"]); + this.inHouse = toInteger(dbAssoc["sacct_inhouse"]); + this.inBusiness = toInteger(dbAssoc["sacct_inbusiness"]); + + this.bodyParts = { + hair: [toInteger(dbAssoc["sacct_svr_hd_part_hair_model"]) || 0, toInteger(dbAssoc["sacct_svr_hd_part_hair_texture"]) || 0], + head: [toInteger(dbAssoc["sacct_svr_hd_part_head_model"]) || 0, toInteger(dbAssoc["sacct_svr_hd_part_head_texture"]) || 0], + upper: [toInteger(dbAssoc["sacct_svr_hd_part_upper_model"]) || 0, toInteger(dbAssoc["sacct_svr_hd_part_upper_texture"]) || 0], + lower: [toInteger(dbAssoc["sacct_svr_hd_part_lower_model"]) || 0, toInteger(dbAssoc["sacct_svr_hd_part_lower_texture"]) || 0], + }; + + this.bodyProps = { + hair: [toInteger(dbAssoc["sacct_svr_hd_prop_hair_model"]) || 0, toInteger(dbAssoc["sacct_svr_hd_prop_hair_texture"]) || 0], + eyes: [toInteger(dbAssoc["sacct_svr_hd_prop_eyes_model"]) || 0, toInteger(dbAssoc["sacct_svr_hd_prop_eyes_texture"]) || 0], + head: [toInteger(dbAssoc["sacct_svr_hd_prop_head_model"]) || 0, toInteger(dbAssoc["sacct_svr_hd_prop_head_texture"]) || 0], + leftHand: [toInteger(dbAssoc["sacct_svr_hd_prop_lefthand_model"]) || 0, toInteger(dbAssoc["sacct_svr_hd_prop_lefthand_texture"]) || 0], + rightHand: [toInteger(dbAssoc["sacct_svr_hd_prop_righthand_model"]) || 0, toInteger(dbAssoc["sacct_svr_hd_prop_righthand_texture"]) || 0], + leftWrist: [toInteger(dbAssoc["sacct_svr_hd_prop_leftwrist_model"]) || 0, toInteger(dbAssoc["sacct_svr_hd_prop_leftwrist_texture"]) || 0], + rightWrist: [toInteger(dbAssoc["sacct_svr_hd_prop_rightwrist_model"]) || 0, toInteger(dbAssoc["sacct_svr_hd_prop_rightwrist_texture"]) || 0], + hip: [toInteger(dbAssoc["sacct_svr_hd_prop_hip_model"]) || 0, toInteger(dbAssoc["sacct_svr_hd_prop_hip_texture"]) || 0], + leftFoot: [toInteger(dbAssoc["sacct_svr_hd_prop_leftfoot_model"]) || 0, toInteger(dbAssoc["sacct_svr_hd_prop_leftfoot_texture"]) || 0], + rightFoot: [toInteger(dbAssoc["sacct_svr_hd_prop_rightfoot_model"]) || 0, toInteger(dbAssoc["sacct_svr_hd_prop_rightfoot_texture"]) || 0], + }; + } + } +}; + +/** + * @class Representing a businesses' data. Loaded and saved in the database + */ +class BusinessData { + constructor(dbAssoc) { + this.databaseId = 0; + this.name = ""; + this.ownerType = VRR_BIZOWNER_NONE; + this.ownerId = 0; + this.buyPrice = 0; + this.locked = false; + this.hasInterior = false; + this.index = -1; + this.needsSaved = false; + this.interiorLights = true; + + this.floorItemCache = []; + this.storageItemCache = []; + this.locations = []; + this.gameScripts = []; + + this.entrancePosition = false; + this.entranceRotation = 0.0; + this.entranceInterior = 0; + this.entranceDimension = 0; + this.entrancePickupModel = -1; + this.entranceBlipModel = -1; + this.entrancePickup = null; + this.entranceBlip = null; + + this.exitPosition = false; + this.exitRotation = 0.0; + this.exitInterior = 0; + this.exitDimension = 0; + this.exitPickupModel = -1; + this.exitBlipModel = -1; + this.exitPickup = null; + this.exitBlip = null; + + this.entranceFee = 0; + this.till = 0; + + this.streamingRadioStation = -1; + + if(dbAssoc) { + this.databaseId = toInteger(dbAssoc["biz_id"]); + this.name = toString(dbAssoc["biz_name"]); + this.ownerType = toInteger(dbAssoc["biz_owner_type"]); + this.ownerId = toInteger(dbAssoc["biz_owner_id"]); + this.buyPrice = toInteger(dbAssoc["biz_buy_price"]); + this.locked = intToBool(toInteger(dbAssoc["biz_locked"])); + this.hasInterior = intToBool(toInteger(dbAssoc["biz_has_interior"])); + this.interiorLights = intToBool(toInteger(dbAssoc["biz_interior_lights"])); + + this.entrancePosition = toVector3(toFloat(dbAssoc["biz_entrance_pos_x"]), toFloat(dbAssoc["biz_entrance_pos_y"]), toFloat(dbAssoc["biz_entrance_pos_z"])); + this.entranceRotation = toInteger(dbAssoc["biz_entrance_rot_z"]); + this.entranceInterior = toInteger(dbAssoc["biz_entrance_int"]); + this.entranceDimension = toInteger(dbAssoc["biz_entrance_vw"]); + this.entrancePickupModel = toInteger(dbAssoc["biz_entrance_pickup"]); + this.entranceBlipModel = toInteger(dbAssoc["biz_entrance_blip"]); + + this.exitPosition = toVector3(dbAssoc["biz_exit_pos_x"], dbAssoc["biz_exit_pos_y"], dbAssoc["biz_exit_pos_z"]); + this.exitRotation = toInteger(dbAssoc["biz_exit_rot_z"]); + this.exitInterior = toInteger(dbAssoc["biz_exit_int"]); + this.exitDimension = toInteger(dbAssoc["biz_exit_vw"]); + this.exitPickupModel = toInteger(dbAssoc["biz_exit_pickup"]); + this.exitBlipModel = toInteger(dbAssoc["biz_exit_blip"]); + + this.entranceFee = toInteger(dbAssoc["biz_entrance_fee"]); + this.till = toInteger(dbAssoc["biz_till"]); + } + } +}; + +/** + * @class Representing a business's location data. Multiple can be used for a single business. Used for things like doors, fuel pumps, drive thru positions, etc. Loaded and saved in the database + */ +class BusinessLocationData { + constructor(dbAssoc) { + this.databaseId = 0; + this.name = ""; + this.type = 0; + this.business = 0; + this.enabled = false; + this.index = -1; + this.businessIndex = -1; + this.needsSaved = false; + + this.position = toVector3(0.0, 0.0, 0.0); + this.interior = 0; + this.dimension = 0; + + if(dbAssoc) { + this.databaseId = toInteger(dbAssoc["biz_loc_id"]); + this.name = toString(dbAssoc["biz_loc_name"]); + this.type = toInteger(dbAssoc["biz_loc_type"]); + this.business = toInteger(dbAssoc["biz_loc_biz"]); + this.enabled = intToBool(toInteger(dbAssoc["biz_loc_enabled"])); + + this.position = toVector3(toFloat(dbAssoc["biz_loc_pos_x"]), toFloat(dbAssoc["biz_loc_pos_y"]), toFloat(dbAssoc["biz_loc_pos_z"])); + this.interior = toInteger(dbAssoc["biz_loc_int"]); + this.dimension = toInteger(dbAssoc["biz_loc_vw"]); + } + } +}; + +/** + * @class Representing a business's game scripts. Multiple can be used for a single business. Used for things like bar and club NPCs and other actions + */ +class BusinessGameScriptData { + constructor(dbAssoc) { + this.databaseId = 0; + this.name = ""; + this.business = 0; + this.enabled = false; + this.index = -1; + this.businessIndex = -1; + this.needsSaved = false; + + if(dbAssoc) { + this.databaseId = toInteger(dbAssoc["biz_script_id"]); + this.name = toString(dbAssoc["biz_script_name"]); + this.state = toInteger(dbAssoc["biz_script_state"]); + this.business = toInteger(dbAssoc["biz_script_biz"]); + } + } +}; + +/** + * @class Representing a house's data. Loaded and saved in the database + */ +class HouseData { + constructor(dbAssoc) { + this.databaseId = 0 + this.description = ""; + this.ownerType = VRR_HOUSEOWNER_NONE; + this.ownerId = 0; + this.buyPrice = 0; + this.rentPrice = 0; + this.renter = 0; + this.locked = false; + this.hasInterior = false; + this.index = -1; + this.needsSaved = false; + this.interiorLights = true; + + this.itemCache = []; + this.locations = []; + this.gameScripts = []; + + this.entrancePosition = false; + this.entranceRotation = 0.0; + this.entranceInterior = 0; + this.entranceDimension = 0; + this.entrancePickupModel = -1; + this.entranceBlipModel = -1; + this.entrancePickup = null; + this.entranceBlip = null; + + this.exitPosition = false; + this.exitRotation = 0.0; + this.exitInterior = 0; + this.exitDimension = -1; + this.exitPickupModel = -1; + this.exitBlipModel = -1; + this.exitPickup = null; + this.exitBlip = null; + + this.streamingRadioStation = -1; + + if(dbAssoc) { + this.databaseId = toInteger(dbAssoc["house_id"]); + this.description = toString(dbAssoc["house_description"]); + this.ownerType = toInteger(dbAssoc["house_owner_type"]); + this.ownerId = toInteger(dbAssoc["house_owner_id"]); + this.buyPrice = toInteger(dbAssoc["house_buy_price"]); + this.rentPrice = toInteger(dbAssoc["house_rent_price"]); + this.renter = toInteger(dbAssoc["house_renter"]); + this.locked = intToBool(toInteger(dbAssoc["house_locked"])); + this.hasInterior = intToBool(toInteger(dbAssoc["house_has_interior"])); + this.interiorLights = intToBool(toInteger(dbAssoc["house_interior_lights"])); + + this.entrancePosition = toVector3(toFloat(dbAssoc["house_entrance_pos_x"]), toFloat(dbAssoc["house_entrance_pos_y"]), toFloat(dbAssoc["house_entrance_pos_z"])); + this.entranceRotation = toFloat(dbAssoc["house_entrance_rot_z"]); + this.entranceInterior = toInteger(dbAssoc["house_entrance_int"]); + this.entranceDimension = toInteger(dbAssoc["house_entrance_vw"]); + this.entrancePickupModel = toInteger(dbAssoc["house_entrance_pickup"]); + this.entranceBlipModel = toInteger(dbAssoc["house_entrance_blip"]); + + this.exitPosition = toVector3(toFloat(dbAssoc["house_exit_pos_x"]), toFloat(dbAssoc["house_exit_pos_y"]), toFloat(dbAssoc["house_exit_pos_z"])); + this.exitRotation = toFloat(dbAssoc["house_exit_rot_z"]); + this.exitInterior = toInteger(dbAssoc["house_exit_int"]); + this.exitDimension = toInteger(dbAssoc["house_exit_vw"]); + this.exitPickupModel = toInteger(dbAssoc["house_exit_pickup"]); + this.exitBlipModel = toInteger(dbAssoc["house_exit_blip"]); + } + } +}; + +/** + * @class Representing a houses's location data. Multiple can be used for a single house. Used for things like doors, garage entry/exit/vehspawn, gates, etc. Loaded and saved in the database + */ +class HouseLocationData { + constructor(dbAssoc) { + this.databaseId = 0; + this.name = ""; + this.type = 0; + this.house = 0; + this.enabled = false; + this.index = -1; + this.houseIndex = -1; + this.needsSaved = false; + + this.position = toVector3(0.0, 0.0, 0.0); + this.interior = 0; + this.dimension = 0; + + if(dbAssoc) { + this.databaseId = toInteger(dbAssoc["house_loc_id"]); + this.name = toString(dbAssoc["house_loc_name"]); + this.type = toInteger(dbAssoc["house_loc_type"]); + this.house = toInteger(dbAssoc["house_loc_house"]); + this.enabled = intToBool(toInteger(dbAssoc["house_loc_enabled"])); + this.index = -1; + + this.position = toVector3(toFloat(dbAssoc["house_loc_pos_x"]), toFloat(dbAssoc["house_loc_pos_y"]), toFloat(dbAssoc["house_loc_pos_z"])); + this.interior = toInteger(dbAssoc["house_loc_int"]); + this.dimension = toInteger(dbAssoc["house_loc_vw"]); + } + }; + + //saveToDatabase = () => { + // saveHouseLocationToDatabase(this.houseIndex, this.index); + //} +}; + +/** + * @class Representing a house's game scripts. Multiple can be used for a single house + */ +class HouseGameScriptData { + constructor(dbAssoc) { + this.databaseId = 0; + this.name = ""; + this.business = 0; + this.state = false; + this.index = -1; + this.houseIndex = -1; + this.needsSaved = false; + + if(dbAssoc) { + this.databaseId = toInteger(dbAssoc["house_script_id"]); + this.name = toString(dbAssoc["house_script_name"]); + this.state = toInteger(dbAssoc["house_script_state"]); + this.business = toInteger(dbAssoc["house_script_biz"]); + } + } +}; + +/** + * @class Representing a clan's data. Loaded and saved in the database + */ +class ClanData { + constructor(dbAssoc) { + this.databaseId = 0; + this.name = ""; + this.ownerId = 0; + this.tag = ""; + this.enabled = false; + this.index = -1; + this.colour = COLOUR_WHITE; + this.colours = []; + this.initialRank = 0; + this.members = []; + this.ranks = []; + this.needsSaved = false; + this.motd = false; + + if(dbAssoc) { + this.databaseId = toInteger(dbAssoc["clan_id"]); + this.name = dbAssoc["clan_name"]; + this.owner = toInteger(dbAssoc["clan_owner"]); + this.tag = dbAssoc["clan_tag"]; + this.enabled = intToBool(toInteger(dbAssoc["clan_enabled"])); + this.colour = toColour(toInteger(dbAssoc["clan_col_r"]), toInteger(dbAssoc["clan_col_g"]), toInteger(dbAssoc["clan_col_b"])); + this.colours = [toInteger(dbAssoc["clan_col_r"]), toInteger(dbAssoc["clan_col_g"]), toInteger(dbAssoc["clan_col_b"])]; + this.motd = dbAssoc["clan_motd"]; + } + } +}; + +/** + * @class Representing a clan rank's data. Loaded and saved in the database + */ +class ClanRankData { + constructor(dbAssoc) { + this.databaseId = 0; + this.clan = 0; + this.name = ""; + this.level = 0; + this.flags = 0; + this.customTag = ""; + this.enabled = true; + this.index = -1; + this.clanIndex = -1; + this.needsSaved = false; + + if(dbAssoc) { + this.databaseId = toInteger(dbAssoc["clan_rank_id"]); + this.clan = toInteger(dbAssoc["clan_rank_clan"]); + this.name = dbAssoc["clan_rank_name"]; + this.level = toInteger(dbAssoc["clan_rank_level"]); + this.flags = toInteger(dbAssoc["clan_rank_flags"]); + this.tag = dbAssoc["clan_rank_tag"]; + this.enabled = intToBool(toInteger(dbAssoc["clan_enabled"])); + this.colour = toColour(toInteger(dbAssoc["clan_colour_r"]), toInteger(dbAssoc["clan_colour_g"]), toInteger(dbAssoc["clan_colour_b"])); + } + } +}; + +/** + * @class Representing a clan member's data. Loaded and saved in the database + */ +class ClanMemberData { + constructor(dbAssoc) { + this.databaseId = 0; + this.clan = 0; + this.subAccount = 0; + this.flags = 0; + this.customTitle = ""; + this.customTag = ""; + this.rank = 0; + this.enabled = false; + this.index = -1; + this.clanIndex = -1; + this.rankIndex = -1; + this.needsSaved = false; + + if(dbAssoc) { + this.databaseId = toInteger(dbAssoc["clan_member_id"]); + this.subAccount = toInteger(dbAssoc["clan_member_sacct"]); + this.clan = toInteger(dbAssoc["clan_member_clan"]); + this.name = dbAssoc["clan_member_name"]; + this.rank = toInteger(dbAssoc["clan_member_rank"]); + this.flags = toInteger(dbAssoc["clan_member_flags"]); + this.customTag = dbAssoc["clan_member_tag"]; + this.customTitle = dbAssoc["clan_member_title"]; + } + } +}; + +/** + * @class Representing a vehicle's data. Loaded and saved in the database + */ +class VehicleData { + constructor(dbAssoc = false, vehicle = false) { + // General Info + this.databaseId = 0; + this.server = getServerId(); + this.model = (vehicle != false) ? vehicle.modelIndex : 0; + this.vehicle = vehicle; + this.index = -1; + this.needsSaved = false; + + // Ownership + this.ownerType = VRR_VEHOWNER_NONE; + this.ownerId = 0; + this.buyPrice = 0; + this.rentPrice = 0; + this.rentedBy = false; + this.rentStart = 0; + + // Position and Rotation + this.spawnPosition = (vehicle) ? vehicle.position : toVector3(0.0, 0.0, 0.0); + this.spawnRotation = (vehicle) ? vehicle.heading : 0.0; + this.spawnLocked = false; + + // Colour Info + this.colour1IsRGBA = 0; + this.colour2IsRGBA = 0; + this.colour3IsRGBA = 0; + this.colour4IsRGBA = 0; + this.colour1RGBA = toColour(255, 255, 255, 255); + this.colour2RGBA = toColour(255, 255, 255, 255); + this.colour3RGBA = toColour(255, 255, 255, 255); + this.colour4RGBA = toColour(255, 255, 255, 255); + this.colour1 = (vehicle) ? vehicle.colour1 : 1; + this.colour2 = (vehicle) ? vehicle.colour2 : 1; + this.colour3 = (vehicle) ? vehicle.colour3 : 1; + this.colour4 = (vehicle) ? vehicle.colour4 : 1; + this.livery = 3; + + this.extras = [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ]; + + // Vehicle Attributes + this.locked = false; + this.engine = false; + this.lights = false; + this.health = 1000; + this.engineDamage = 0; + this.visualDamage = 0; + this.dirtLevel = 0; + + this.trunkItemCache = []; + this.dashItemCache = []; + + this.streamingRadioStation = -1; + + // Other/Misc + this.insuranceAccount = 0; + this.fuel = 0; + this.flags = 0; + this.needsSaved = false; + this.whoAdded = 0; + this.whenAdded = 0; + + this.interior = 0; + this.dimension = 0; + + if(dbAssoc) { + // General Info + this.databaseId = toInteger(dbAssoc["veh_id"]); + this.server = toInteger(dbAssoc["veh_server"]); + this.model = toInteger(dbAssoc["veh_model"]); + + // Ownership + this.ownerType = toInteger(dbAssoc["veh_owner_type"]); + this.ownerId = toInteger(dbAssoc["veh_owner_id"]); + this.buyPrice = toInteger(dbAssoc["veh_buy_price"]); + this.rentPrice = toInteger(dbAssoc["veh_rent_price"]); + + // Position and Rotation + this.spawnPosition = toVector3(dbAssoc["veh_pos_x"], dbAssoc["veh_pos_y"], dbAssoc["veh_pos_z"]); + this.spawnRotation = toInteger(dbAssoc["veh_rot_z"]); + this.spawnLocked = intToBool(toInteger(dbAssoc["veh_spawn_lock"])); + + // Colour Info + this.colour1IsRGBA = intToBool(toInteger(dbAssoc["veh_col1_isrgba"])); + this.colour2IsRGBA = intToBool(toInteger(dbAssoc["veh_col2_isrgba"])); + this.colour3IsRGBA = intToBool(toInteger(dbAssoc["veh_col3_isrgba"])); + this.colour4IsRGBA = intToBool(toInteger(dbAssoc["veh_col4_isrgba"])); + this.colour1RGBA = toColour(toInteger(dbAssoc["veh_col1_r"]), toInteger(dbAssoc["veh_col1_g"]), toInteger(dbAssoc["veh_col1_b"]), toInteger(dbAssoc["veh_col1_a"])); + this.colour2RGBA = toColour(toInteger(dbAssoc["veh_col2_r"]), toInteger(dbAssoc["veh_col2_g"]), toInteger(dbAssoc["veh_col2_b"]), toInteger(dbAssoc["veh_col2_a"])); + this.colour3RGBA = toColour(toInteger(dbAssoc["veh_col3_r"]), toInteger(dbAssoc["veh_col3_g"]), toInteger(dbAssoc["veh_col3_b"]), toInteger(dbAssoc["veh_col3_a"])); + this.colour4RGBA = toColour(toInteger(dbAssoc["veh_col4_r"]), toInteger(dbAssoc["veh_col4_g"]), toInteger(dbAssoc["veh_col4_b"]), toInteger(dbAssoc["veh_col4_a"])); + this.colour1 = toInteger(dbAssoc["veh_col1"]); + this.colour2 = toInteger(dbAssoc["veh_col2"]); + this.colour3 = toInteger(dbAssoc["veh_col3"]); + this.colour4 = toInteger(dbAssoc["veh_col4"]); + this.livery = toInteger(dbAssoc["veh_livery"]); + + // Extras (components on SA, extras on IV+) + this.extras = [ + toInteger(dbAssoc["veh_extra1"]), + toInteger(dbAssoc["veh_extra2"]), + toInteger(dbAssoc["veh_extra3"]), + toInteger(dbAssoc["veh_extra4"]), + toInteger(dbAssoc["veh_extra5"]), + toInteger(dbAssoc["veh_extra6"]), + toInteger(dbAssoc["veh_extra7"]), + toInteger(dbAssoc["veh_extra8"]), + toInteger(dbAssoc["veh_extra9"]), + toInteger(dbAssoc["veh_extra10"]), + toInteger(dbAssoc["veh_extra11"]), + toInteger(dbAssoc["veh_extra12"]), + toInteger(dbAssoc["veh_extra13"]), + ]; + + // Vehicle Attributes + this.locked = intToBool(toInteger(dbAssoc["veh_locked"])); + this.engine = intToBool(toInteger(dbAssoc["veh_engine"])); + this.lights = intToBool(toInteger(dbAssoc["veh_lights"])); + this.health = toInteger(dbAssoc["veh_damage_normal"]); + this.engineDamage = toInteger(dbAssoc["veh_damage_engine"]); + this.visualDamage = toInteger(dbAssoc["veh_damage_visual"]); + this.dirtLevel = toInteger(dbAssoc["veh_dirt_level"]); + + // Other/Misc + this.insuranceAccount = toInteger(0); + this.fuel = toInteger(0); + this.flags = toInteger(0); + this.needsSaved = false; + this.whoAdded = toInteger(dbAssoc["veh_who_added"]); + this.whenAdded = toInteger(dbAssoc["veh_when_added"]); + + this.interior = toInteger(dbAssoc["veh_int"]); + this.dimension = toInteger(dbAssoc["veh_vw"]); + } + } +}; + +/** + * @class Representing a command's data. Loaded and saved in the database + */ +class CommandData { + enable() { + this.enabled = true; + } + + disable() { + this.enabled = false; + } + + toggleEnabled() { + this.enabled = !this.enabled; + } + + constructor(command, handlerFunction, syntaxString, requiredStaffFlags, requireLogin, allowOnDiscord, helpDescription) { + this.command = command; + this.handlerFunction = handlerFunction; + this.syntaxString = syntaxString; + this.requiredStaffFlags = requiredStaffFlags; + this.enabled = true; + this.requireLogin = requireLogin; + this.allowOnDiscord = allowOnDiscord; + this.helpDescription = helpDescription; + this.aliases = []; + } +}; + +/** + * @class Representing a crime's data. Loaded and saved in the database + */ +class CrimeData { + constructor(suspectId, crimeType, reporterId = 0) { + this.crimeType = crimeType; + this.suspectId = suspectId; + this.reporterId = reporterId; + this.whenCommitted = 0; + this.whenReported = 0; + this.databaseId = 0; + } +}; + +/** + * @class Representing a job's data. Loaded and saved in the database + */ +class JobData { + constructor(dbAssoc = false) { + this.databaseId = 0; + this.type = VRR_JOB_NONE; + this.name = "Unnamed"; + this.enabled = true; + this.blipModel = -1 + this.pickupModel = -1 + this.colour = toColour(0, 0, 0, 255); + this.whiteListEnabled = false; + this.blackListEnabled = false; + this.walkieTalkieFrequency = 0; + this.index = -1; + this.needsSaved = false; + + this.equipment = []; + this.uniforms = []; + this.locations = []; + this.whiteList = []; + this.blackList = []; + + if(dbAssoc) { + this.databaseId = dbAssoc["job_id"]; + this.type = dbAssoc["job_type"]; + this.name = dbAssoc["job_name"]; + this.enabled = dbAssoc["job_enabled"]; + this.blipModel = dbAssoc["job_blip"]; + this.pickupModel = dbAssoc["job_pickup"]; + this.colour = toColour(dbAssoc["job_colour_r"], dbAssoc["job_colour_g"], dbAssoc["job_colour_b"], 255); + this.whiteListEnabled = dbAssoc["job_wl"]; + this.blackListEnabled = dbAssoc["job_bl"]; + this.walkieTalkieFrequency = dbAssoc["job_walkietalkiefreq"]; + + this.equipment = []; + this.uniforms = []; + this.locations = []; + this.whiteList = []; + this.blackList = []; + } + } +}; + +/** + * @class Representing a job equipment set's data. Loaded and saved in the database + */ +class JobEquipmentData { + constructor(dbAssoc = false) { + this.databaseId = 0; + this.job = 0; + this.name = "Unnamed"; + this.requiredRank = 0; + this.enabled = false; + this.index = -1; + this.jobIndex = -1; + this.needsSaved = false; + this.items = []; + + if(dbAssoc) { + this.databaseId = dbAssoc["job_equip_id"]; + this.job = dbAssoc["job_equip_job"]; + this.name = dbAssoc["job_equip_name"]; + this.requiredRank = dbAssoc["job_equip_minrank"]; + this.enabled = dbAssoc["job_equip_enabled"]; + } + } +}; + +/** + * @class Representing a job equipment set item's data. Loaded and saved in the database + */ +class JobEquipmentItemData { + constructor(dbAssoc = false) { + this.databaseId = 0; + this.equipmentId = 0; + this.itemType = 0; + this.value = 0; + this.enabled = false; + this.index = -1; + this.jobIndex = -1; + this.needsSaved = false; + + if(dbAssoc) { + this.databaseId = dbAssoc["job_equip_item_id"]; + this.equipmentId = dbAssoc["job_equip_item_equip"]; + this.itemType = dbAssoc["job_equip_item_type"]; + this.value = dbAssoc["job_equip_item_value"]; + this.enabled = dbAssoc["job_equip_item_enabled"]; + } + } +}; + +/** + * @class Representing a job uniform's data. Loaded and saved in the database + */ +class JobUniformData { + constructor(dbAssoc = false) { + this.databaseId = 0; + this.job = 0; + this.name = "Unnamed"; + this.requiredRank = 0 + this.skin = -1; + this.enabled = false; + this.index = -1; + this.jobIndex = -1; + this.needsSaved = false; + + this.bodyParts = { + hair: [0,0], + head: [0,0], + upper: [0,0], + lower: [0,0], + }; + + this.bodyProps = { + hair: [0,0], + eyes: [0,0], + head: [0,0], + leftHand: [0,0], + rightHand: [0,0], + leftWrist: [0,0], + rightWrist: [0,0], + hip: [0,0], + leftFoot: [0,0], + rightFoot: [0,0], + }; + + if(dbAssoc) { + this.databaseId = dbAssoc["job_uniform_id"]; + this.job = dbAssoc["job_uniform_job"]; + this.name = dbAssoc["job_uniform_name"]; + this.requiredRank = dbAssoc["job_uniform_minrank"]; + this.skin = dbAssoc["job_uniform_skin"]; + this.enabled = intToBool(dbAssoc["job_uniform_enabled"]); + + this.bodyParts = { + hair: [toInteger(dbAssoc["job_uniform_hd_part_hair_model"]) || 0, toInteger(dbAssoc["job_uniform_hd_part_hair_texture"]) || 0], + head: [toInteger(dbAssoc["job_uniform_hd_part_head_model"]) || 0, toInteger(dbAssoc["job_uniform_hd_part_head_texture"]) || 0], + upper: [toInteger(dbAssoc["job_uniform_hd_part_upper_model"]) || 0, toInteger(dbAssoc["job_uniform_hd_part_upper_texture"]) || 0], + lower: [toInteger(dbAssoc["job_uniform_hd_part_lower_model"]) || 0, toInteger(dbAssoc["job_uniform_hd_part_lower_texture"]) || 0], + }; + + this.bodyProps = { + hair: [toInteger(dbAssoc["job_uniform_hd_prop_hair_model"]) || 0, toInteger(dbAssoc["job_uniform_hd_prop_hair_texture"]) || 0], + eyes: [toInteger(dbAssoc["job_uniform_hd_prop_eyes_model"]) || 0, toInteger(dbAssoc["job_uniform_hd_prop_eyes_texture"]) || 0], + head: [toInteger(dbAssoc["job_uniform_hd_prop_head_model"]) || 0, toInteger(dbAssoc["job_uniform_hd_prop_head_texture"]) || 0], + leftHand: [toInteger(dbAssoc["job_uniform_hd_prop_lefthand_model"]) || 0, toInteger(dbAssoc["job_uniform_hd_prop_lefthand_texture"]) || 0], + rightHand: [toInteger(dbAssoc["job_uniform_hd_prop_righthand_model"]) || 0, toInteger(dbAssoc["job_uniform_hd_prop_righthand_texture"]) || 0], + leftWrist: [toInteger(dbAssoc["job_uniform_hd_prop_leftwrist_model"]) || 0, toInteger(dbAssoc["job_uniform_hd_prop_leftwrist_texture"]) || 0], + rightWrist: [toInteger(dbAssoc["job_uniform_hd_prop_rightwrist_model"]) || 0, toInteger(dbAssoc["job_uniform_hd_prop_rightwrist_texture"]) || 0], + hip: [toInteger(dbAssoc["job_uniform_hd_prop_hip_model"]) || 0, toInteger(dbAssoc["job_uniform_hd_prop_hip_texture"]) || 0], + leftFoot: [toInteger(dbAssoc["job_uniform_hd_prop_leftfoot_model"]) || 0, toInteger(dbAssoc["job_uniform_hd_prop_leftfoot_texture"]) || 0], + rightFoot: [toInteger(dbAssoc["job_uniform_hd_prop_rightfoot_model"]) || 0, toInteger(dbAssoc["job_uniform_hd_prop_rightfoot_texture"]) || 0], + }; + } + } +}; + +/** + * @class JobLocationData Representing a job uniform's data. Loaded and saved in the database + */ +class JobLocationData { + constructor(dbAssoc = false) { + this.databaseId = 0; + this.job = 0; + this.position = toVector3(0.0, 0.0, 0.0); + this.blip = false; + this.pickup = false; + this.enabled = false; + this.interior = 0; + this.dimension = 0; + this.index = -1; + this.jobIndex = -1; + this.needsSaved = false; + + if(dbAssoc) { + this.databaseId = dbAssoc["job_loc_id"]; + this.job = dbAssoc["job_loc_job"]; + this.position = toVector3(dbAssoc["job_loc_pos_x"], dbAssoc["job_loc_pos_y"], dbAssoc["job_loc_pos_z"]); + this.blip = false; + this.pickup = false; + this.enabled = dbAssoc["job_loc_enabled"]; + this.interior = dbAssoc["job_loc_int"]; + this.dimension = dbAssoc["job_loc_vw"]; + } + } +}; + +class JobWhiteListData { + constructor(dbAssoc = false) { + this.databaseId = 0; + this.job = 0; + this.subAccount = 0 + this.enabled = false; + this.index = -1; + this.jobIndex = -1; + this.needsSaved = false; + + if(dbAssoc) { + this.databaseId = dbAssoc["job_wl_id"]; + this.job = dbAssoc["job_wl_job"]; + this.subAccount = dbAssoc["job_wl_sacct"] + this.enabled = dbAssoc["job_wl_enabled"]; + } + } +}; + +class JobBlackListData { + constructor(dbAssoc = false) { + this.databaseId = 0; + this.job = 0; + this.subAccount = 0 + this.enabled = false; + this.index = -1; + this.jobIndex = -1; + this.needsSaved = false; + + if(dbAssoc) { + this.databaseId = dbAssoc["job_bl_id"]; + this.job = dbAssoc["job_bl_job"]; + this.subAccount = dbAssoc["job_bl_sacct"] + this.enabled = dbAssoc["job_bl_enabled"]; + } + } +}; + +class KeyBindData { + constructor(dbAssoc = false, key = 0, commandString = "", keyState = VRR_KEYSTATE_UP) { + this.databaseId = 0; + this.key = key; + this.account = 0; + this.commandString = commandString; + this.whenAdded = 0; + this.enabled = true; + this.keyState = false; + this.index = -1; + this.needsSaved = false; + + if(dbAssoc) { + this.databaseId = dbAssoc["acct_hotkey_id"]; + this.key = toInteger(dbAssoc["acct_hotkey_key"]); + this.account = toInteger(dbAssoc["acct_hotkey_acct"]); + this.commandString = dbAssoc["acct_hotkey_cmdstr"]; + this.whenAdded = dbAssoc["acct_hotkey_when_added"]; + this.enabled = intToBool(dbAssoc["acct_hotkey_enabled"]); + this.keyState = intToBool(dbAssoc["acct_hotkey_down"]); + } + } +}; + +class BlackListedGameScriptData { + constructor(dbAssoc = false) { + this.databaseId = 0; + this.enabled = false + this.server = 0; + this.scriptName = ""; + this.index = -1; + this.needsSaved = false; + + if(dbAssoc) { + this.databaseId = dbAssoc["ac_script_bl_id"]; + this.enabled = intToBool(dbAssoc["ac_script_bl_enabled"]); + this.server = dbAssoc["ac_script_bl_server"]; + this.scriptName = dbAssoc["ac_script_bl_name"]; + } + } +}; + +class WhiteListedGameScriptData { + constructor(dbAssoc = false) { + this.databaseId = 0; + this.enabled = false + this.server = 0; + this.scriptName = ""; + this.index = -1; + this.needsSaved = false; + + if(dbAssoc) { + this.databaseId = dbAssoc["ac_script_wl_id"]; + this.enabled = intToBool(dbAssoc["ac_script_wl_enabled"]); + this.server = dbAssoc["ac_script_wl_server"]; + this.scriptName = dbAssoc["ac_script_wl_name"]; + } + } +}; + +class RemovedWorldObjectData { + constructor(model, position, range) { + this.model = model; + this.position = position; + this.range = range; + } +}; + +class ExcludedGroundSnowModel { + constructor(model) { + this.model = model; + } +}; + +class InteriorTemplateData { + constructor(exitPosition, exitInterior) { + this.exitPosition = exitPosition; + this.exitInterior = exitInterior; + } +}; + +class RadioStationData { + constructor(dbAssoc) { + this.databaseId = 0; + this.name = ""; + this.url = ""; + this.genre = ""; + this.codec = ""; + this.index = -1; + + if(dbAssoc) { + this.databaseId = dbAssoc["radio_id"]; + this.name = dbAssoc["radio_name"]; + this.url = dbAssoc["radio_url"]; + this.genre = dbAssoc["radio_genre"]; + this.codec = dbAssoc["radio_codec"]; + } + } +}; + +class ItemData { + constructor(dbAssoc = false) { + this.databaseId = 0; + this.index = 0; + this.itemTypeIndex = 0; + this.itemType = 0; + this.ownerType = VRR_ITEM_OWNER_NONE; + this.ownerId = 0; + this.ownerIndex = -1; + this.position = toVector3(0.0, 0.0, 0.0); + this.interior = 0; + this.dimension = 0; + this.object = null; + this.buyPrice = 0; + this.needsSaved = false; + this.amount = 0; + this.value = 0; + this.enabled = false; + this.extra = false; + + if(dbAssoc) { + this.databaseId = toInteger(dbAssoc["item_id"]); + this.index = 0; + this.itemTypeIndex = 0; + this.itemType = toInteger(dbAssoc["item_type"]); + this.ownerType = toInteger(dbAssoc["item_owner_type"]);; + this.ownerId = toInteger(dbAssoc["item_owner_id"]); + this.position = toVector3(toFloat(dbAssoc["item_pos_x"]), toFloat(dbAssoc["item_pos_y"]), toFloat(dbAssoc["item_pos_z"])); + this.interior = toInteger(dbAssoc["item_int"]); + this.dimension = toInteger(dbAssoc["item_vw"]); + this.buyPrice = toInteger(dbAssoc["item_buy_price"]); + this.amount = toInteger(dbAssoc["item_amount"]); + this.value = toInteger(dbAssoc["item_value"]); + this.enabled = intToBool(toInteger(dbAssoc["item_enabled"])); + } + } +}; + +class ItemTypeData { + constructor(dbAssoc = false) { + this.databaseId = 0; + this.index = 0; + this.name = "Unknown"; + this.enabled = false; + this.useType = VRR_ITEM_USETYPE_NONE; + this.useId = 0; + this.useValue = 0; + this.maxValue = 0; + this.dropType = VRR_ITEM_DROPTYPE_NONE; + this.useId = 0; + this.dropPosition = toVector3(0.0, 0.0, 0.0); + this.dropRotation = toVector3(0.0, 0.0, 0.0); + this.dropScale = toVector3(0.0, 0.0, 0.0); + this.dropModel = 0; + this.orderPrice = 0; + this.orderValue = 0; + this.demandMultiplier = 1; + this.supplyMultiplier = 1; + this.riskMultiplier = 1; + this.needsSaved = false; + this.useDelay = 0; + this.switchDelay = 0; + this.pickupDelay = 0; + this.putDelay = 0; + this.takeDelay = 0; + this.giveDelay = 0; + this.dropDelay = 0; + + if(dbAssoc) { + this.databaseId = toInteger(dbAssoc["item_type_id"]); + this.name = dbAssoc["item_type_name"]; + this.enabled = intToBool(toInteger(dbAssoc["item_type_enabled"])); + this.useType = toInteger(dbAssoc["item_type_use_type"]); + this.dropType = toInteger(dbAssoc["item_type_drop_type"]); + this.useId = toInteger(dbAssoc["item_type_use_id"]); + this.dropPosition = toVector3(toFloat(dbAssoc["item_type_drop_pos_x"]), toFloat(dbAssoc["item_type_drop_pos_y"]), toFloat(dbAssoc["item_type_drop_pos_z"])); + this.dropRotation = toVector3(toFloat(dbAssoc["item_type_drop_rot_x"]), toFloat(dbAssoc["item_type_drop_rot_y"]), toFloat(dbAssoc["item_type_drop_rot_z"])); + this.dropScale = toVector3(toFloat(dbAssoc["item_type_drop_scale_x"]), toFloat(dbAssoc["item_type_drop_scale_y"]), toFloat(dbAssoc["item_type_drop_scale_z"])); + this.dropModel = toInteger(dbAssoc["item_type_drop_model"]); + this.useId = toInteger(dbAssoc["item_type_use_id"]); + this.useValue = toInteger(dbAssoc["item_type_use_value"]); + this.maxValue = toInteger(dbAssoc["item_type_max_value"]); + this.orderPrice = toInteger(dbAssoc["item_type_order_price"]); + this.orderValue = toInteger(dbAssoc["item_type_order_value"]); + this.demandMultiplier = toFloat(dbAssoc["item_type_demand_multiplier"]); + this.supplyMultiplier = toFloat(dbAssoc["item_type_supply_multiplier"]); + this.riskMultiplier = toFloat(dbAssoc["item_type_risk_multiplier"]); + this.size = toInteger(dbAssoc["item_type_size"]); + this.capacity = toInteger(dbAssoc["item_type_capacity"]); + this.useDelay = toInteger(dbAssoc["item_type_delay_use"]); + this.switchDelay = toInteger(dbAssoc["item_type_delay_switch"]); + this.pickupDelay = toInteger(dbAssoc["item_type_delay_pickup"]); + this.putDelay = toInteger(dbAssoc["item_type_delay_put"]); + this.takeDelay = toInteger(dbAssoc["item_type_delay_take"]); + this.giveDelay = toInteger(dbAssoc["item_type_delay_give"]); + this.dropDelay = toInteger(dbAssoc["item_type_delay_drop"]); + } + } +}; +class NPCData { + constructor(dbAssoc) { + this.databaseId = 0; + this.server = 0; + this.firstName = "John"; + this.lastName = "Doe"; + this.middleName = "Q"; + this.skin = 0; + this.cash = 0; + this.spawnPosition = toVector3(0.0, 0.0, 0.0); + this.spawnHeading = 0.0; + this.clan = 0; + this.isWorking = false; + this.jobUniform = this.skin; + this.lastJobVehicle = null; + this.job = 0; + this.weapons = []; + this.interior = 0; + this.dimension = 0; + this.pedScale = toVector3(1.0, 1.0, 1.0); + this.walkStyle = 0; + this.fightStyle = 0; + this.health = 100; + this.armour = 100; + this.currentAction = VRR_NPCACTION_NONE; + this.triggers = []; + + this.bodyParts = { + hair: [0,0], + head: [0,0], + upper: [0,0], + lower: [0,0], + }; + + this.bodyProps = { + hair: [0,0], + eyes: [0,0], + head: [0,0], + leftHand: [0,0], + rightHand: [0,0], + leftWrist: [0,0], + rightWrist: [0,0], + hip: [0,0], + leftFoot: [0,0], + rightFoot: [0,0], + }; + + if(dbAssoc) { + this.databaseId = toInteger(dbAssoc["npc_id"]); + this.server = toInteger(dbAssoc["npc_server"]); + this.firstName = dbAssoc["npc_name_first"]; + this.lastName = dbAssoc["npc_name_last"]; + this.middleName = dbAssoc["npc_name_middle"] || ""; + this.skin = toInteger(dbAssoc["npc_skin"]); + this.cash = toInteger(dbAssoc["npc_cash"]); + this.spawnPosition = toVector3(toFloat(dbAssoc["npc_pos_x"]), toFloat(dbAssoc["npc_pos_y"]), toFloat(dbAssoc["npc_pos_z"])); + this.spawnHeading = toFloat(dbAssoc["npc_angle"]); + this.lastLogin = toInteger(dbAssoc["npc_when_lastlogin"]); + this.clan = toInteger(dbAssoc["npc_clan"]); + this.clanFlags = toInteger(dbAssoc["npc_clan_flags"]); + this.clanRank = toInteger(dbAssoc["npc_clan_rank"]); + this.clanTitle = toInteger(dbAssoc["npc_clan_title"]); + this.job = toInteger(dbAssoc["npc_job"]); + this.interior = toInteger(dbAssoc["npc_int"]); + this.dimension = toInteger(dbAssoc["npc_vw"]); + this.pedScale = toVector3(toFloat(dbAssoc["npc_scale_x"]), toFloat(dbAssoc["npc_scale_y"]), toFloat(dbAssoc["npc_scale_z"])); + this.walkStyle = toInteger(dbAssoc["npc_walkstyle"]); + this.fightStyle = toInteger(dbAssoc["npc_fightstyle"]); + this.health = toInteger(dbAssoc["npc_health"]); + this.armour = toInteger(dbAssoc["npc_armour"]); + + this.bodyParts = { + hair: [toInteger(dbAssoc["npc_hd_part_hair_model"]) || 0, toInteger(dbAssoc["npc_hd_part_hair_texture"]) || 0], + head: [toInteger(dbAssoc["npc_hd_part_head_model"]) || 0, toInteger(dbAssoc["npc_hd_part_head_texture"]) || 0], + upper: [toInteger(dbAssoc["npc_hd_part_upper_model"]) || 0, toInteger(dbAssoc["npc_hd_part_upper_texture"]) || 0], + lower: [toInteger(dbAssoc["npc_hd_part_lower_model"]) || 0, toInteger(dbAssoc["npc_hd_part_lower_texture"]) || 0], + }; + + this.bodyProps = { + hair: [toInteger(dbAssoc["npc_hd_prop_hair_model"]) || 0, toInteger(dbAssoc["npc_hd_prop_hair_texture"]) || 0], + eyes: [toInteger(dbAssoc["npc_hd_prop_eyes_model"]) || 0, toInteger(dbAssoc["npc_hd_prop_eyes_texture"]) || 0], + head: [toInteger(dbAssoc["npc_hd_prop_head_model"]) || 0, toInteger(dbAssoc["npc_hd_prop_head_texture"]) || 0], + leftHand: [toInteger(dbAssoc["npc_hd_prop_lefthand_model"]) || 0, toInteger(dbAssoc["npc_hd_prop_lefthand_texture"]) || 0], + rightHand: [toInteger(dbAssoc["npc_hd_prop_righthand_model"]) || 0, toInteger(dbAssoc["npc_hd_prop_righthand_texture"]) || 0], + leftWrist: [toInteger(dbAssoc["npc_hd_prop_leftwrist_model"]) || 0, toInteger(dbAssoc["npc_hd_prop_leftwrist_texture"]) || 0], + rightWrist: [toInteger(dbAssoc["npc_hd_prop_rightwrist_model"]) || 0, toInteger(dbAssoc["npc_hd_prop_rightwrist_texture"]) || 0], + hip: [toInteger(dbAssoc["npc_hd_prop_hip_model"]) || 0, toInteger(dbAssoc["npc_hd_prop_hip_texture"]) || 0], + leftFoot: [toInteger(dbAssoc["npc_hd_prop_leftfoot_model"]) || 0, toInteger(dbAssoc["npc_hd_prop_leftfoot_texture"]) || 0], + rightFoot: [toInteger(dbAssoc["npc_hd_prop_rightfoot_model"]) || 0, toInteger(dbAssoc["npc_hd_prop_rightfoot_texture"]) || 0], + }; + } + } +}; + +class NPCTriggerData { + constructor(dbAssoc) { + this.databaseId = 0; + this.npcId = 0; + this.index = 0; + this.npc = 0; + this.triggerType = 0; + this.conditions = []; + this.responses = []; + + if(dbAssoc) { + this.databaseId = toInteger(dbAssoc["npc_trig_id"]); + this.npc = toInteger(dbAssoc["npc_trig_npc"]); + this.triggerType = toInteger(dbAssoc["npc_trig_type"]); + } + } +}; + +class NPCTriggerConditionData { + constructor(dbAssoc) { + this.databaseId = 0; + this.triggerId = 0; + this.index = 0; + this.conditionType = 0; + this.conditionValue = false; + this.matchType = false; + + if(dbAssoc) { + this.databaseId = toInteger(dbAssoc["npc_trig_cond_id"]); + this.npc = toInteger(dbAssoc["npc_trig_cond_trig"]); + this.conditionType = toInteger(dbAssoc["npc_trig_cond_type"]); + this.conditionValue = toInteger(dbAssoc["npc_trig_cond_val"]); + this.matchType = toInteger(dbAssoc["npc_trig_cond_val"]); + } + } +}; + +class NPCTriggerResponseData { + constructor(dbAssoc) { + this.databaseId = 0; + this.triggerId = 0; + this.index = 0; + this.responseType = 0; + this.responseValue = false; + + if(dbAssoc) { + this.databaseId = toInteger(dbAssoc["npc_trig_resp_id"]); + this.npc = toInteger(dbAssoc["npc_trig_resp_trig"]); + this.responseType = toInteger(dbAssoc["npc_trig_resp_type"]); + this.responseValue = toInteger(dbAssoc["npc_trig_resp_val"]); + } + } +}; \ No newline at end of file diff --git a/scripts/server/client.js b/scripts/server/client.js index afc5d7d9..843f43a4 100644 --- a/scripts/server/client.js +++ b/scripts/server/client.js @@ -434,6 +434,13 @@ function sendPlayerMouseCameraToggle(client) { // =========================================================================== +function setPlayerMouseCameraState(client, state) { + logToConsole(LOG_DEBUG, `[VRR.Client] Sending signal to toggle mouse camera ${getPlayerDisplayForConsole(client)}`); + triggerNetworkEvent("vrr.mouseCameraForce", client, state); +} + +// =========================================================================== + function sendPlayerMouseCursorToggle(client) { logToConsole(LOG_DEBUG, `[VRR.Client] Sending signal to toggle mouse cursor ${getPlayerDisplayForConsole(client)}`); triggerNetworkEvent("vrr.mouseCursor", client); @@ -1005,4 +1012,10 @@ function forcePlayerToSyncElementProperties(client, element) { triggerNetworkEvent("vrr.syncElement", client, element.id); } +// =========================================================================== + +function sendPlayerPedPartsAndProps(client) { + triggerNetworkEvent("vrr.ped") +} + // =========================================================================== \ No newline at end of file diff --git a/scripts/server/command.js b/scripts/server/command.js index 61cb4526..ae88f676 100644 --- a/scripts/server/command.js +++ b/scripts/server/command.js @@ -247,10 +247,12 @@ function loadCommands() { commandData("r", walkieTalkieChatCommand, "", getStaffFlagValue("none"), true, false), commandData("additemtype", createItemTypeCommand, "", getStaffFlagValue("manageItems"), true, false), - commandData("itemusetype", setItemTypeUseTypeCommand, " ", getStaffFlagValue("manageItems"), true, false), - commandData("itemuseval", setItemTypeUseValueCommand, " ", getStaffFlagValue("manageItems"), true, false), - commandData("itemorderprice", setItemTypeOrderPriceCommand, " ", getStaffFlagValue("manageItems"), true, false), - commandData("itemriskmult", setItemTypeRiskMultiplierCommand, " ", getStaffFlagValue("manageItems"), true, false), + commandData("itemtypeusetype", setItemTypeUseTypeCommand, " ", getStaffFlagValue("manageItems"), true, false), + commandData("itemtypeuseval", setItemTypeUseValueCommand, " ", getStaffFlagValue("manageItems"), true, false), + commandData("itemtypeorderprice", setItemTypeOrderPriceCommand, " ", getStaffFlagValue("manageItems"), true, false), + commandData("itemtyperiskmult", setItemTypeRiskMultiplierCommand, " ", getStaffFlagValue("manageItems"), true, false), + + commandData("delplritem", deleteItemInPlayerInventoryCommand, " ", getStaffFlagValue("manageItems"), true, false), ], job: [ commandData("takejob", takeJobCommand, "", getStaffFlagValue("none"), true, false), @@ -462,7 +464,7 @@ function getCommands() { // =========================================================================== function commandData(command, handlerFunction, syntaxString = "", requiredStaffFlags = getStaffFlagValue("none"), requireLogin = true, allowOnDiscord = true, usageHelpMessage) { - return new serverClasses.commandData(command, handlerFunction, syntaxString, requiredStaffFlags, requireLogin, allowOnDiscord, usageHelpMessage); + return new CommandData(command, handlerFunction, syntaxString, requiredStaffFlags, requireLogin, allowOnDiscord, usageHelpMessage); } // =========================================================================== diff --git a/scripts/server/config.js b/scripts/server/config.js index 11ceed45..156a53e2 100644 --- a/scripts/server/config.js +++ b/scripts/server/config.js @@ -88,7 +88,7 @@ function loadServerConfigFromGameAndPort(gameId, port, mpMod) { if(dbQuery) { if(dbQuery.numRows > 0) { let dbAssoc = fetchQueryAssoc(dbQuery); - let tempServerConfigData = new serverClasses.serverConfigData(dbAssoc); + let tempServerConfigData = new ServerConfigData(dbAssoc); freeDatabaseQuery(dbQuery); return tempServerConfigData; } @@ -108,7 +108,7 @@ function loadServerConfigFromId(tempServerId) { if(dbQuery) { if(dbQuery.numRows > 0) { let dbAssoc = fetchQueryAssoc(dbQuery); - let tempServerConfigData = serverClasses.serverConfigData(dbAssoc); + let tempServerConfigData = new ServerConfigData(dbAssoc); freeDatabaseQuery(dbQuery); return tempServerConfigData; } @@ -134,62 +134,62 @@ function applyConfigToServer(tempServerConfig) { // =========================================================================== -function saveServerConfigToDatabase(serverConfigData) { +function saveServerConfigToDatabase() { logToConsole(LOG_DEBUG, `[VRR.Config]: Saving server ${serverConfigData.databaseId} configuration to database ...`); if(getServerConfig().needsSaved) { let dbConnection = connectToDatabase(); if(dbConnection) { let data = [ - ["svr_logo", boolToInt(serverConfigData.showLogo)], - ["svr_gui", boolToInt(serverConfigData.useGUI)], - ["svr_start_time_hour", serverConfigData.hour], - ["svr_start_time_min", serverConfigData.minute], - ["svr_start_weather", serverConfigData.weather], - ["svr_start_snow_falling", boolToInt(serverConfigData.fallingSnow)], - ["svr_start_snow_ground", boolToInt(serverConfigData.groundSnow)], - ["svr_newchar_pos_x", serverConfigData.newCharacter.spawnPosition.x], - ["svr_newchar_pos_y", serverConfigData.newCharacter.spawnPosition.y], - ["svr_newchar_pos_z", serverConfigData.newCharacter.spawnPosition.z], - ["svr_newchar_rot_z", serverConfigData.newCharacter.spawnHeading], - ["svr_newchar_skin", serverConfigData.newCharacter.skin], - ["svr_newchar_money", serverConfigData.newCharacter.money], - ["svr_gui_col1_r", serverConfigData.guiColour[0]], - ["svr_gui_col1_g", serverConfigData.guiColour[1]], - ["svr_gui_col1_b", serverConfigData.guiColour[2]], - ["svr_connectcam_pos_x", serverConfigData.connectCameraPosition.x], - ["svr_connectcam_pos_y", serverConfigData.connectCameraPosition.y], - ["svr_connectcam_pos_z", serverConfigData.connectCameraPosition.z], - ["svr_connectcam_lookat_x", serverConfigData.connectCameraLookAt.x], - ["svr_connectcam_lookat_y", serverConfigData.connectCameraLookAt.y], - ["svr_connectcam_lookat_z", serverConfigData.connectCameraLookAt.z], - ["svr_charselect_cam_pos_x", serverConfigData.characterSelectCameraPosition.x], - ["svr_charselect_cam_pos_y", serverConfigData.characterSelectCameraPosition.y], - ["svr_charselect_cam_pos_z", serverConfigData.characterSelectCameraPosition.z], - ["svr_charselect_cam_lookat_x", serverConfigData.characterSelectCameraLookAt.x], - ["svr_charselect_cam_lookat_y", serverConfigData.characterSelectCameraLookAt.y], - ["svr_charselect_cam_lookat_z", serverConfigData.characterSelectCameraLookAt.z], - ["svr_charselect_ped_pos_x", serverConfigData.characterSelectPedPosition.x], - ["svr_charselect_ped_pos_y", serverConfigData.characterSelectPedPosition.y], - ["svr_charselect_ped_pos_z", serverConfigData.characterSelectPedPosition.z], - ["svr_charselect_ped_rot_z", serverConfigData.characterSelectPedHeading], - ["svr_charselect_int", serverConfigData.characterSelectInterior], - ["svr_charselect_vw", serverConfigData.characterSelectDimension], - ["svr_inflation_multiplier", serverConfigData.inflationMultiplier], - ["svr_ac_enabled", serverConfigData.antiCheat.enabled], - ["svr_ac_check_scripts", serverConfigData.antiCheat.checkGameScripts], - ["svr_ac_script_wl", serverConfigData.antiCheat.gameScriptWhiteListEnabled], - ["svr_ac_script_bl", serverConfigData.antiCheat.gameScriptBlackListEnabled], - ["svr_job_pickups", boolToInt(serverConfigData.createJobPickups)], - ["svr_job_blips", boolToInt(serverConfigData.createJobBlips)], - ["svr_biz_pickups", boolToInt(serverConfigData.createBusinessPickups)], - ["svr_biz_blips", boolToInt(serverConfigData.createBusinessBlips)], - ["svr_house_pickups", boolToInt(serverConfigData.createHousePickups)], - ["svr_house_blips", boolToInt(serverConfigData.createHouseBlips)], - ["svr_intro_music", serverConfigData.intromUsic], + ["svr_logo", boolToInt(getServerConfig().showLogo)], + ["svr_gui", boolToInt(getServerConfig().useGUI)], + ["svr_start_time_hour", getServerConfig().hour], + ["svr_start_time_min", getServerConfig().minute], + ["svr_start_weather", getServerConfig().weather], + ["svr_start_snow_falling", boolToInt(getServerConfig().fallingSnow)], + ["svr_start_snow_ground", boolToInt(getServerConfig().groundSnow)], + ["svr_newchar_pos_x", getServerConfig().newCharacter.spawnPosition.x], + ["svr_newchar_pos_y", getServerConfig().newCharacter.spawnPosition.y], + ["svr_newchar_pos_z", getServerConfig().newCharacter.spawnPosition.z], + ["svr_newchar_rot_z", getServerConfig().newCharacter.spawnHeading], + ["svr_newchar_skin", getServerConfig().newCharacter.skin], + ["svr_newchar_money", getServerConfig().newCharacter.money], + ["svr_gui_col1_r", getServerConfig().guiColour[0]], + ["svr_gui_col1_g", getServerConfig().guiColour[1]], + ["svr_gui_col1_b", getServerConfig().guiColour[2]], + ["svr_connectcam_pos_x", getServerConfig().connectCameraPosition.x], + ["svr_connectcam_pos_y", getServerConfig().connectCameraPosition.y], + ["svr_connectcam_pos_z", getServerConfig().connectCameraPosition.z], + ["svr_connectcam_lookat_x", getServerConfig().connectCameraLookAt.x], + ["svr_connectcam_lookat_y", getServerConfig().connectCameraLookAt.y], + ["svr_connectcam_lookat_z", getServerConfig().connectCameraLookAt.z], + ["svr_charselect_cam_pos_x", getServerConfig().characterSelectCameraPosition.x], + ["svr_charselect_cam_pos_y", getServerConfig().characterSelectCameraPosition.y], + ["svr_charselect_cam_pos_z", getServerConfig().characterSelectCameraPosition.z], + ["svr_charselect_cam_lookat_x", getServerConfig().characterSelectCameraLookAt.x], + ["svr_charselect_cam_lookat_y", getServerConfig().characterSelectCameraLookAt.y], + ["svr_charselect_cam_lookat_z", getServerConfig().characterSelectCameraLookAt.z], + ["svr_charselect_ped_pos_x", getServerConfig().characterSelectPedPosition.x], + ["svr_charselect_ped_pos_y", getServerConfig().characterSelectPedPosition.y], + ["svr_charselect_ped_pos_z", getServerConfig().characterSelectPedPosition.z], + ["svr_charselect_ped_rot_z", getServerConfig().characterSelectPedHeading], + ["svr_charselect_int", getServerConfig().characterSelectInterior], + ["svr_charselect_vw", getServerConfig().characterSelectDimension], + ["svr_inflation_multiplier", getServerConfig().inflationMultiplier], + ["svr_ac_enabled", getServerConfig().antiCheat.enabled], + ["svr_ac_check_scripts", getServerConfig().antiCheat.checkGameScripts], + ["svr_ac_script_wl", getServerConfig().antiCheat.gameScriptWhiteListEnabled], + ["svr_ac_script_bl", getServerConfig().antiCheat.gameScriptBlackListEnabled], + ["svr_job_pickups", boolToInt(getServerConfig().createJobPickups)], + ["svr_job_blips", boolToInt(getServerConfig().createJobBlips)], + ["svr_biz_pickups", boolToInt(getServerConfig().createBusinessPickups)], + ["svr_biz_blips", boolToInt(getServerConfig().createBusinessBlips)], + ["svr_house_pickups", boolToInt(getServerConfig().createHousePickups)], + ["svr_house_blips", boolToInt(getServerConfig().createHouseBlips)], + ["svr_intro_music", getServerConfig().introMusic], ]; let dbQuery = null; - let queryString = createDatabaseUpdateQuery("svr_main", data, `svr_id=${serverConfigData.databaseId}`); + let queryString = createDatabaseUpdateQuery("svr_main", data, `svr_id=${serverConfig.databaseId}`); dbQuery = queryDatabase(dbConnection, queryString); getServerConfig().needsSaved = false; @@ -203,6 +203,12 @@ function saveServerConfigToDatabase(serverConfigData) { // =========================================================================== +/** + * This is a command handler function. + * + * @return {ServerConfigData} - Server configuration data + * + */ function getServerConfig() { return serverConfig; } @@ -256,7 +262,7 @@ function setTimeCommand(command, params, client) { return false; } - getServerConfig().hour = minute; + getServerConfig().hour = hour; getServerConfig().minute = minute; gta.time.hour = getServerConfig().hour; diff --git a/scripts/server/const.js b/scripts/server/const.js index a9709694..b65da51b 100644 --- a/scripts/server/const.js +++ b/scripts/server/const.js @@ -307,4 +307,8 @@ const VRR_NPC_COND_MATCH_EXACT_CASE = 9; // Must match string exactly (c const VRR_BIZ_TYPE_NONE = 0; // None (invalid) const VRR_BIZ_TYPE_NORMAL = 1; // Normal business (sells items) const VRR_BIZ_TYPE_BANK = 2; // Bank -const VRR_BIZ_TYPE_PUBLIC = 3; // Public business (Government, public service, etc) \ No newline at end of file +const VRR_BIZ_TYPE_PUBLIC = 3; // Public business (Government, public service, etc) + +const VRR_RETURNTO_TYPE_NONE = 0; // "Return to" data is invalid +const VRR_RETURNTO_TYPE_ADMINGET = 1; // "Return to" data is from admin teleporting +const VRR_RETURNTO_TYPE_SKINSELECT = 2; // "Return to" data is from skin select \ No newline at end of file diff --git a/scripts/server/event.js b/scripts/server/event.js index 21d4f38a..1c637334 100644 --- a/scripts/server/event.js +++ b/scripts/server/event.js @@ -243,16 +243,16 @@ async function onPlayerEnteredVehicle(client, clientVehicle, seat) { vehicle.engine = getVehicleData(vehicle).engine; if(getVehicleData(vehicle).buyPrice > 0) { - messagePlayerAlert(client, `This ${getVehicleName(vehicle)} is for sale! Cost: ${getInlineChatColourByName("lightGrey")}$${getVehicleData(vehicle).buyPrice}`); + messagePlayerAlert(client, `This ${getVehicleName(vehicle)} is for sale! Cost: ${getInlineChatColourByName("lightGrey")}$${makeLargeNumberReadable(getVehicleData(vehicle).buyPrice)}`); messagePlayerTip(client, `Use /vehbuy if you want to buy it.`); resetVehiclePosition(vehicle); } else if(getVehicleData(vehicle).rentPrice > 0) { if(getVehicleData(vehicle).rentedBy != client) { - messagePlayerAlert(client, `This ${getVehicleName(vehicle)} is for rent! Cost: ${getInlineChatColourByName("lightGrey")}$${getVehicleData(vehicle).rentPrice} per minute`); + messagePlayerAlert(client, `This ${getVehicleName(vehicle)} is for rent! Cost: ${getInlineChatColourByName("lightGrey")}$${makeLargeNumberReadable(getVehicleData(vehicle).rentPrice)} per minute`); messagePlayerTip(client, `Use /vehrent if you want to rent it.`); resetVehiclePosition(vehicle); } else { - messagePlayerAlert(client, `You are renting this ${getVehicleName(vehicle)} for ${getInlineChatColourByName("lightGrey")}$${getVehicleData(vehicle).rentPrice} per minute. ${getInlineChatColourByName("white")}Use ${getInlineChatColourByName("lightGrey")}/stoprent ${getInlineChatColourByName("white")}if you want to stop renting it.`); + messagePlayerAlert(client, `You are renting this ${getVehicleName(vehicle)} for ${getInlineChatColourByName("lightGrey")}$${makeLargeNumberReadable(getVehicleData(vehicle).rentPrice)} per minute. ${getInlineChatColourByName("white")}Use ${getInlineChatColourByName("lightGrey")}/stoprent ${getInlineChatColourByName("white")}if you want to stop renting it.`); } } else { let ownerName = "Nobody"; @@ -365,7 +365,7 @@ function onPlayerDeath(client, position) { setTimeout(function() { if(getPlayerCurrentSubAccount(client).inJail) { let closestJail = getClosestJail(getPlayerPosition(client)); - client.despawnPlayer(); + //client.despawnPlayer(); getPlayerCurrentSubAccount(client).interior = closestJail.interior; getPlayerCurrentSubAccount(client).dimension = closestJail.dimension; if(getServerGame() == GAME_GTA_IV) { @@ -380,7 +380,7 @@ function onPlayerDeath(client, position) { updatePlayerSpawnedState(client, true); } else { let closestHospital = getClosestHospital(getPlayerPosition(client)); - client.despawnPlayer(); + //client.despawnPlayer(); getPlayerCurrentSubAccount(client).interior = closestHospital.interior; getPlayerCurrentSubAccount(client).dimension = closestHospital.dimension; if(getServerGame() == GAME_GTA_IV) { @@ -421,21 +421,21 @@ function onPlayerSpawn(client) { logToConsole(LOG_DEBUG, `[VRR.Event] Checking ${getPlayerDisplayForConsole(client)}'s player data`); if(!getPlayerData(client)) { logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)}'s player data is invalid. Kicking them from server.`); - client.despawnPlayer(); + client.disconnect(); return false; } logToConsole(LOG_DEBUG, `[VRR.Event] Checking ${getPlayerDisplayForConsole(client)}'s login status`); if(!getPlayerData(client).loggedIn) { logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)} is NOT logged in. Despawning their player.`); - client.despawnPlayer(); + client.disconnect(); return false; } logToConsole(LOG_DEBUG, `[VRR.Event] Checking ${getPlayerDisplayForConsole(client)}'s selected character status`); if(getPlayerData(client).currentSubAccount == -1) { logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)} has NOT selected a character. Despawning their player.`); - client.despawnPlayer(); + client.disconnect(); return false; } @@ -534,22 +534,25 @@ function onPlayerSpawn(client) { sendPlayerEnterPropertyKey(client, keyId.key); } - if(isGTAIV()) { - setEntityData(client.player, "vrr.bodyPartHair", getPlayerCurrentSubAccount(client).bodyParts.hair, true); - setEntityData(client.player, "vrr.bodyPartHead", getPlayerCurrentSubAccount(client).bodyParts.head, true); - setEntityData(client.player, "vrr.bodyPartUpper", getPlayerCurrentSubAccount(client).bodyParts.upper, true); - setEntityData(client.player, "vrr.bodyPartLower", getPlayerCurrentSubAccount(client).bodyParts.lower, true); + //if(isGTAIV()) { + // setEntityData(client.player, "vrr.bodyPartHair", getPlayerCurrentSubAccount(client).bodyParts.hair, true); + // setEntityData(client.player, "vrr.bodyPartHead", getPlayerCurrentSubAccount(client).bodyParts.head, true); + // setEntityData(client.player, "vrr.bodyPartUpper", getPlayerCurrentSubAccount(client).bodyParts.upper, true); + // setEntityData(client.player, "vrr.bodyPartLower", getPlayerCurrentSubAccount(client).bodyParts.lower, true); + // setEntityData(client.player, "vrr.bodyPropHair", getPlayerCurrentSubAccount(client).bodyProps.hair, true); + // setEntityData(client.player, "vrr.bodyPropEyes", getPlayerCurrentSubAccount(client).bodyProps.eyes, true); + // setEntityData(client.player, "vrr.bodyPartHead", getPlayerCurrentSubAccount(client).bodyProps.head, true); + // setEntityData(client.player, "vrr.bodyPartLeftHand", getPlayerCurrentSubAccount(client).bodyProps.leftHand, true); + // setEntityData(client.player, "vrr.bodyPartRightHand", getPlayerCurrentSubAccount(client).bodyProps.rightHand, true); + // setEntityData(client.player, "vrr.bodyPartLeftWrist", getPlayerCurrentSubAccount(client).bodyProps.leftWrist, true); + // setEntityData(client.player, "vrr.bodyPartRightWrist", getPlayerCurrentSubAccount(client).bodyProps.rightWrist, true); + // setEntityData(client.player, "vrr.bodyPartHip", getPlayerCurrentSubAccount(client).bodyProps.hip, true); + // setEntityData(client.player, "vrr.bodyPartLeftFoot", getPlayerCurrentSubAccount(client).bodyProps.leftFoot, true); + // setEntityData(client.player, "vrr.bodyPartRightFoot", getPlayerCurrentSubAccount(client).bodyProps.rightFoot, true); + //} - setEntityData(client.player, "vrr.bodyPropHair", getPlayerCurrentSubAccount(client).bodyProps.hair, true); - setEntityData(client.player, "vrr.bodyPropEyes", getPlayerCurrentSubAccount(client).bodyProps.eyes, true); - setEntityData(client.player, "vrr.bodyPartHead", getPlayerCurrentSubAccount(client).bodyProps.head, true); - setEntityData(client.player, "vrr.bodyPartLeftHand", getPlayerCurrentSubAccount(client).bodyProps.leftHand, true); - setEntityData(client.player, "vrr.bodyPartRightHand", getPlayerCurrentSubAccount(client).bodyProps.rightHand, true); - setEntityData(client.player, "vrr.bodyPartLeftWrist", getPlayerCurrentSubAccount(client).bodyProps.leftWrist, true); - setEntityData(client.player, "vrr.bodyPartRightWrist", getPlayerCurrentSubAccount(client).bodyProps.rightWrist, true); - setEntityData(client.player, "vrr.bodyPartHip", getPlayerCurrentSubAccount(client).bodyProps.hip, true); - setEntityData(client.player, "vrr.bodyPartLeftFoot", getPlayerCurrentSubAccount(client).bodyProps.leftFoot, true); - setEntityData(client.player, "vrr.bodyPartRightFoot", getPlayerCurrentSubAccount(client).bodyProps.rightFoot, true); + if(isGTAIV()) { + sendPlayerPedPartsAndProps(client); } logToConsole(LOG_DEBUG, `[VRR.Event] Setting ${getPlayerDisplayForConsole(client)}'s ped state to ready`); diff --git a/scripts/server/house.js b/scripts/server/house.js index ed36b5c5..1acb1fc0 100644 --- a/scripts/server/house.js +++ b/scripts/server/house.js @@ -37,7 +37,7 @@ function loadHousesFromDatabase() { if(dbQuery) { if(dbQuery.numRows > 0) { while(dbAssoc = fetchQueryAssoc(dbQuery)) { - let tempHouseData = new serverClasses.houseData(dbAssoc); + let tempHouseData = new HouseData(dbAssoc); tempHouses.push(tempHouseData); logToConsole(LOG_VERBOSE, `[VRR.House]: House '${tempHouseData.description}' (ID ${tempHouseData.databaseId}) loaded!`); } @@ -62,7 +62,7 @@ function loadHousesFromDatabase() { * */ function createHouseCommand(command, params, client) { - let entranceLocation = new serverClasses.houseLocationData(false); + let entranceLocation = new HouseLocationData(false); entranceLocation.entrancePosition = getPlayerPosition(client); entranceLocation.entranceRotation = 0.0; entranceLocation.entrancePickupModel = getGameConfig().pickupModels[getServerGame()].house; @@ -82,10 +82,10 @@ function createHouseCommand(command, params, client) { saveHouseToDatabase(houseId-1); - createHouseEntrancePickup(houseId); - createHouseExitPickup(houseId); - createHouseEntranceBlip(houseId); - createHouseExitBlip(houseId); + createHouseEntrancePickup(houseId-1); + createHouseExitPickup(houseId-1); + createHouseEntranceBlip(houseId-1); + createHouseExitBlip(houseId-1); //getHouseData(houseId).needsSaved = true; @@ -382,7 +382,7 @@ function setHouseInteriorTypeCommand(command, params, client) { } if(isNaN(typeParam)) { - let tempHouseLocation = new serverClasses.houseLocationData(false); + let tempHouseLocation = new HouseLocationData(false); if(toLowerCase(typeParam) == "none") { tempHouseLocation.exitPosition = toVector3(0.0, 0.0, 0.0); @@ -591,7 +591,7 @@ function deleteHouse(houseId, whoDeleted = 0) { removePlayersFromHouse(houseId); - getServerData().houses.splice(houseId, 1); + getServerData().houses[houseId] = false; } // =========================================================================== @@ -620,7 +620,7 @@ function removePlayerFromHouses(client) { * */ function createHouse(description, entranceLocation) { - let tempHouseData = new serverClasses.houseData(false); + let tempHouseData = new HouseData(false); tempHouseData.description = description; tempHouseData.entrancePosition = entranceLocation.entrancePosition; diff --git a/scripts/server/item.js b/scripts/server/item.js index 66df7293..8c53b6d8 100644 --- a/scripts/server/item.js +++ b/scripts/server/item.js @@ -31,7 +31,7 @@ function loadItemsFromDatabase() { if(dbQuery) { if(dbQuery.numRows > 0) { while(dbFetchAssoc = fetchQueryAssoc(dbQuery)) { - let tempItemData = new serverClasses.itemData(dbFetchAssoc); + let tempItemData = new ItemData(dbFetchAssoc); tempItems.push(tempItemData); } } @@ -53,7 +53,7 @@ function loadItemTypesFromDatabase() { if(dbQuery) { if(getQueryNumRows(dbQuery) > 0) { while(dbFetchAssoc = fetchQueryAssoc(dbQuery)) { - let tempItemTypeData = new serverClasses.itemTypeData(dbFetchAssoc); + let tempItemTypeData = new ItemTypeData(dbFetchAssoc); tempItemTypes.push(tempItemTypeData); } } @@ -68,7 +68,7 @@ function loadItemTypesFromDatabase() { // =========================================================================== function createItem(itemTypeId, value, ownerType, ownerId, amount=1) { - let tempItemData = new serverClasses.itemData(false); + let tempItemData = new ItemData(false); tempItemData.itemType = getItemTypeData(itemTypeId).databaseId; tempItemData.ownerType = ownerType; tempItemData.ownerId = ownerId; @@ -991,18 +991,20 @@ function getPlayerFirstEmptyHotBarSlot(client) { // =========================================================================== function cachePlayerHotBarItems(client) { - if(!isPlayerWorking(client)) { - for(let i = 0 ; i <= 9 ; i++) { - getPlayerData(client).hotBarItems[i] = -1; - } + if(isPlayerWorking(client)) { + return false; + } - for(let i in getServerData().items) { - if(getItemData(i).ownerType == VRR_ITEM_OWNER_PLAYER) { - if(getItemData(i).ownerId == getPlayerCurrentSubAccount(client).databaseId) { - let firstSlot = getPlayerFirstEmptyHotBarSlot(client); - if(firstSlot != -1) { - getPlayerData(client).hotBarItems[firstSlot] = i; - } + for(let i = 0 ; i <= 9 ; i++) { + getPlayerData(client).hotBarItems[i] = -1; + } + + for(let i in getServerData().items) { + if(getItemData(i).ownerType == VRR_ITEM_OWNER_PLAYER) { + if(getItemData(i).ownerId == getPlayerCurrentSubAccount(client).databaseId) { + let firstSlot = getPlayerFirstEmptyHotBarSlot(client); + if(firstSlot != -1) { + getPlayerData(client).hotBarItems[firstSlot] = i; } } } @@ -1067,7 +1069,8 @@ function deleteItem(itemId) { if(getItemData(itemId).databaseId > 0) { quickDatabaseQuery(`DELETE FROM item_main WHERE item_id = ${getItemData(itemId).databaseId}`); } - getServerData().items.splice(itemId, 1); + getServerData().items[itemId] = false; + setItemDataIndexes(); } // =========================================================================== @@ -1285,14 +1288,12 @@ function saveItemToDatabase(itemId) { // =========================================================================== function storePlayerItemsInJobLocker(client) { - for(let i in getPlayerData(client).hotBarItems) { - //if(getPlayerData(client).hotBarItems[i] != -1) { - getPlayerData(client).jobLockerCache[i] = getPlayerData(client).hotBarItems[i]; - getPlayerData(client).hotBarItems[i] = -1; - //} + for(let i = 0 ; i <= 8 ; i++) { + getPlayerData(client).jobLockerCache[i] = getPlayerData(client).hotBarItems[i]; + getPlayerData(client).hotBarItems[i] = -1; } - cachePlayerHotBarItems(client); + //cachePlayerHotBarItems(client); updatePlayerHotBar(client); } @@ -1305,15 +1306,12 @@ function restorePlayerJobLockerItems(client) { } } - for(let i in getPlayerData(client).jobLockerCache) { - //if(getPlayerData(client).jobLockerCache[i] != -1) { - getPlayerData(client).hotBarItems[i] = getPlayerData(client).jobLockerCache[i]; - getPlayerData(client).jobLockerCache[i] = -1; - //} + for(let i = 0 ; i <= 8 ; i++) { + getPlayerData(client).hotBarItems[i] = getPlayerData(client).jobLockerCache[i]; + getPlayerData(client).jobLockerCache[i] = -1; } cachePlayerHotBarItems(client); - updatePlayerHotBar(client); } @@ -1431,7 +1429,44 @@ function toggleItemEnabledCommand(command, params, client) { } getItemData(getPlayerActiveItem(client)).enabled = !getItemData(getPlayerActiveItem(client)).enabled; - messagePlayerNormal(client, `You turned ${getBoolRedGreenInlineColour(getItemData(itemIndex).enabled)}${toUpperCase(getOnOffFromBool(getItemData(itemIndex).enabled))} ${getInlineChatColourByName("white")}your ${getItemName(getPlayerActiveItem(client))} in slot ${getPlayerActiveItemSlot(client)} ${getInlineChatColourByName("lightGrey")}${getItemValueDisplayForItem(getPlayerActiveItem(client))}`) + messagePlayerNormal(client, `You turned ${getBoolRedGreenInlineColour(getItemData(itemIndex).enabled)}${toUpperCase(getOnOffFromBool(getItemData(itemIndex).enabled))} ${getInlineChatColourByName("white")}your ${getItemName(getPlayerActiveItem(client))} in slot ${getPlayerActiveItemSlot(client)} ${getInlineChatColourByName("lightGrey")}${getItemValueDisplayForItem(getPlayerActiveItem(client))}`); +} + +// =========================================================================== + +function deleteItemInPlayerInventoryCommand(command, params, client) { + if(areParamsEmpty(params)) { + messagePlayerSyntax(client, getCommandSyntaxText(command)); + return false; + } + + let splitParams = params.split(" "); + let targetClient = getPlayerFromParams(splitParams[0]); + let hotBarSlot = splitParams[1]; + + if(isNaN(hotBarSlot)) { + messagePlayerError(client, `The item slot must be a number!`); + return false; + } + + if(toInteger(hotBarSlot) <= 0 || toInteger(hotBarSlot) > 9) { + messagePlayerError(client, `The item slot must be between 1 and 9!`); + return false; + } + + if(getPlayerData(client).hotBarItems[hotBarSlot-1] == -1) { + messagePlayerError(client, `${getCharacterFullName(client)} doesn't have anything in that slot!`); + return false; + } + + if(getItemData(getPlayerData(client).hotBarItems[hotBarSlot-1])) { + messagePlayerError(client, `${getCharacterFullName(client)} doesn't have anything in that slot!`); + return false; + } + + let tempName = getItemTypeData(getItemData(getPlayerData(client).hotBarItems[hotBarSlot-1]).itemTypeIndex).name + deleteItem(getPlayerData(client).hotBarItems[hotBarSlot-1]); + messagePlayerSuccess(client, `You deleted the ${getInlineChatColourByName("lightGrey")}${tempName} ${getInlineChatColourByName("white")}item in ${getInlineChatColourByName("lightGrey")}${getCharacterFullName(client)}'s ${getInlineChatColourByName("white")}inventory`); } // =========================================================================== diff --git a/scripts/server/job.js b/scripts/server/job.js index 2ea2bc0d..e39bdbea 100644 --- a/scripts/server/job.js +++ b/scripts/server/job.js @@ -39,7 +39,7 @@ function loadJobsFromDatabase() { if(dbQuery) { if(dbQuery.numRows > 0) { while(dbAssoc = fetchQueryAssoc(dbQuery)) { - let tempJobData = new serverClasses.jobData(dbAssoc); + let tempJobData = new JobData(dbAssoc); tempJobData.locations = loadJobLocationsFromDatabase(tempJobData.databaseId); tempJobData.equipment = loadJobEquipmentsFromDatabase(tempJobData.databaseId); tempJobData.uniforms = loadJobUniformsFromDatabase(tempJobData.databaseId); @@ -95,7 +95,7 @@ function loadJobEquipmentsFromDatabase(jobDatabaseId) { if(dbQuery) { if(dbQuery.numRows > 0) { while(dbAssoc = fetchQueryAssoc(dbQuery)) { - let tempJobEquipmentData = new serverClasses.jobEquipmentData(dbAssoc); + let tempJobEquipmentData = new JobEquipmentData(dbAssoc); tempJobEquipmentData.items = loadJobEquipmentItemsFromDatabase(tempJobEquipmentData.databaseId); tempJobEquipments.push(tempJobEquipmentData); logToConsole(LOG_DEBUG, `[VRR.Job]: Job equipment '${tempJobEquipmentData.name}' loaded from database successfully!`); @@ -125,7 +125,7 @@ function loadJobLocationsFromDatabase(jobDatabaseId) { if(dbQuery) { if(dbQuery.numRows > 0) { while(dbAssoc = fetchQueryAssoc(dbQuery)) { - let tempJobLocationData = new serverClasses.jobLocationData(dbAssoc); + let tempJobLocationData = new JobLocationData(dbAssoc); tempJobLocations.push(tempJobLocationData); logToConsole(LOG_DEBUG, `[VRR.Job]: Job location '${tempJobLocationData.databaseId}' loaded from database successfully!`); } @@ -154,7 +154,7 @@ function loadJobUniformsFromDatabase(jobDatabaseId) { if(dbQuery) { if(dbQuery.numRows > 0) { while(dbAssoc = fetchQueryAssoc(dbQuery)) { - let tempJobUniformData = new serverClasses.jobUniformData(dbAssoc); + let tempJobUniformData = new JobUniformData(dbAssoc); tempJobUniforms.push(tempJobUniformData); logToConsole(LOG_DEBUG, `[VRR.Job]: Job uniform '${tempJobUniformData.databaseId}' loaded from database successfully!`); } @@ -183,7 +183,7 @@ function loadJobEquipmentItemsFromDatabase(jobEquipmentDatabaseId) { if(dbQuery) { if(dbQuery.numRows > 0) { while(dbAssoc = fetchQueryAssoc(dbQuery)) { - let tempJobEquipmentItemData = new serverClasses.jobEquipmentItemData(dbAssoc); + let tempJobEquipmentItemData = new JobEquipmentItemData(dbAssoc); tempJobEquipmentItems.push(tempJobEquipmentItemData); logToConsole(LOG_DEBUG, `[VRR.Job]: Job equipment item '${tempJobEquipmentItemData.databaseId}' loaded from database successfully!`); } @@ -1363,7 +1363,7 @@ function setAllJobDataIndexes() { // =========================================================================== function createJobLocation(jobId, position, interior, dimension) { - let jobLocationData = new serverClasses.jobLocationData(false); + let jobLocationData = new JobLocationData(false); jobLocationData.position = position; jobLocationData.job = getJobData(jobId).databaseId; jobLocationData.interior = interior; diff --git a/scripts/server/keybind.js b/scripts/server/keybind.js index 281644f8..3e180e3e 100644 --- a/scripts/server/keybind.js +++ b/scripts/server/keybind.js @@ -70,7 +70,7 @@ function removeKeyBindCommand(command, params, client) { // =========================================================================== function addPlayerKeyBind(client, keyId, tempCommand, tempParams) { - let keyBindData = new serverClasses.keyBindData(false, keyId, `${tempCommand} ${tempParams}`); + let keyBindData = new KeyBindData(false, keyId, `${tempCommand} ${tempParams}`); getPlayerData(client).accountData.keyBinds.push(keyBindData); sendAddAccountKeyBindToClient(client, keyId, KEYSTATE_UP); diff --git a/scripts/server/moderation.js b/scripts/server/moderation.js index 7dad8fd0..689aa708 100644 --- a/scripts/server/moderation.js +++ b/scripts/server/moderation.js @@ -543,10 +543,10 @@ function getPlayerCommand(command, params, client) { removePlayerFromVehicle(targetClient); - getPlayerData(targetClient).returnToPosition = getPlayerPosition(targetClient); - getPlayerData(targetClient).returnToHeading = getPlayerPosition(targetClient); - getPlayerData(targetClient).returnToDimension = getPlayerDimension(targetClient); - getPlayerData(targetClient).returnToInterior = getPlayerInterior(targetClient); + //getPlayerData(targetClient).returnToPosition = getPlayerPosition(targetClient); + //getPlayerData(targetClient).returnToHeading = getPlayerPosition(targetClient); + //getPlayerData(targetClient).returnToDimension = getPlayerDimension(targetClient); + //getPlayerData(targetClient).returnToInterior = getPlayerInterior(targetClient); if(isPlayerInAnyHouse(targetClient)) { getPlayerData(targetClient).returnToHouse = getEntityData(client, "vrr.inHouse"); diff --git a/scripts/server/native/gtac.js b/scripts/server/native/gtac.js index c34b781b..4761ad56 100644 --- a/scripts/server/native/gtac.js +++ b/scripts/server/native/gtac.js @@ -3047,6 +3047,51 @@ let gameData = { ["sitback", 0, 169, VRR_ANIMTYPE_ADD, 0.0, null, null, null, null, VRR_ANIMMOVE_BACK], ], [ // GTA SA + ["walk", 0, 0, VRR_ANIMTYPE_ADD, 0.0, null, null, null, null, VRR_ANIMMOVE_NONE], + ["jog", 0, 1, VRR_ANIMTYPE_ADD, 0.0, null, null, null, null, VRR_ANIMMOVE_NONE], + ["look1", 0, 4, VRR_ANIMTYPE_ADD, 0.0, null, null, null, null, VRR_ANIMMOVE_NONE], + ["holdrifle", 0, 11, VRR_ANIMTYPE_ADD, 0.0, null, null, null, null, VRR_ANIMMOVE_NONE], + ["talk1", 0, 12, VRR_ANIMTYPE_ADD, 0.0, null, null, null, null, VRR_ANIMMOVE_NONE], + ["wave1", 0, 13, VRR_ANIMTYPE_ADD, 0.0, null, null, null, null, VRR_ANIMMOVE_NONE], + ["swim1", 0, 14, VRR_ANIMTYPE_ADD, 0.0, null, null, null, null, VRR_ANIMMOVE_NONE], + ["die1", 0, 15, VRR_ANIMTYPE_ADD, 0.0, null, null, null, null, VRR_ANIMMOVE_NONE], + ["die2", 0, 16, VRR_ANIMTYPE_ADD, 0.0, null, null, null, null, VRR_ANIMMOVE_NONE], + ["diehead", 0, 19, VRR_ANIMTYPE_ADD, 0.0, null, null, null, null, VRR_ANIMMOVE_NONE], + ["diestomach", 0, 20, VRR_ANIMTYPE_ADD, 0.0, null, null, null, null, VRR_ANIMMOVE_NONE], + ["choke", 0, 21, VRR_ANIMTYPE_ADD, 0.0, null, null, null, null, VRR_ANIMMOVE_NONE], + ["remotepress", 0, 48, VRR_ANIMTYPE_ADD, 0.0, null, null, null, null, VRR_ANIMMOVE_NONE], + ["pickup1", 0, 99, VRR_ANIMTYPE_ADD, 0.0, null, null, null, null, VRR_ANIMMOVE_NONE], + ["pickup2", 0, 100, VRR_ANIMTYPE_ADD, 0.0, null, null, null, null, VRR_ANIMMOVE_NONE], + ["backhandright", 0, 103, VRR_ANIMTYPE_ADD, 0.0, null, null, null, null, VRR_ANIMMOVE_NONE], + ["backhandleft", 0, 104, VRR_ANIMTYPE_ADD, 0.0, null, null, null, null, VRR_ANIMMOVE_NONE], + ["knockback", 0, 105, VRR_ANIMTYPE_ADD, 0.0, null, null, null, null, VRR_ANIMMOVE_NONE], + ["idle1", 0, 135, VRR_ANIMTYPE_ADD, 0.0, null, null, null, null, VRR_ANIMMOVE_NONE], + ["knockback", 0, 105, VRR_ANIMTYPE_ADD, 0.0, null, null, null, null, VRR_ANIMMOVE_NONE], + ["cower", 0, 141, VRR_ANIMTYPE_ADD, 0.0, null, null, null, null, VRR_ANIMMOVE_NONE], + ["handsup", 0, 142, VRR_ANIMTYPE_ADD, 0.0, null, null, null, null, VRR_ANIMMOVE_NONE], + ["fucku", 0, 144, VRR_ANIMTYPE_ADD, 0.0, null, null, null, null, VRR_ANIMMOVE_NONE], + ["phoneout", 0, 145, VRR_ANIMTYPE_ADD, 0.0, null, null, null, null, VRR_ANIMMOVE_NONE], + ["phonein", 0, 146, VRR_ANIMTYPE_ADD, 0.0, null, null, null, null, VRR_ANIMMOVE_NONE], + ["phonetalk", 0, 146, VRR_ANIMTYPE_ADD, 0.0, null, null, null, null, VRR_ANIMMOVE_NONE], + ["sit1", 0, 150, VRR_ANIMTYPE_ADD, 0.0, null, null, null, null, VRR_ANIMMOVE_NONE], + ["atm", 0, 151, VRR_ANIMTYPE_ADD, 0.0, null, null, null, null, VRR_ANIMMOVE_NONE], + ["mindtrick", 0, 153, VRR_ANIMTYPE_ADD, 0.0, null, null, null, null, VRR_ANIMMOVE_NONE], + ["faceshocked", 0, 150, VRR_ANIMTYPE_ADD, 0.0, null, null, null, null, VRR_ANIMMOVE_NONE], + ["facesurprised", 0, 150, VRR_ANIMTYPE_ADD, 0.0, null, null, null, null, VRR_ANIMMOVE_NONE], + ["faceconfused", 0, 150, VRR_ANIMTYPE_ADD, 0.0, null, null, null, null, VRR_ANIMMOVE_NONE], + ["faceangry", 0, 159, VRR_ANIMTYPE_ADD, 0.0, null, null, null, null, VRR_ANIMMOVE_NONE], + ["facetalk1", 0, 160, VRR_ANIMTYPE_ADD, 0.0, null, null, null, null, VRR_ANIMMOVE_NONE], + ["look2", 0, 165, VRR_ANIMTYPE_ADD, 0.0, null, null, null, null, VRR_ANIMMOVE_NONE], + ["gestureno", 0, 166, VRR_ANIMTYPE_ADD, 0.0, null, null, null, null, VRR_ANIMMOVE_NONE], + ["gestureyes", 0, 167, VRR_ANIMTYPE_ADD, 0.0, null, null, null, null, VRR_ANIMMOVE_NONE], + ["wave2", 0, 168, VRR_ANIMTYPE_ADD, 0.0, null, null, null, null, VRR_ANIMMOVE_NONE], + ["snort", 0, 169, VRR_ANIMTYPE_ADD, 0.0, null, null, null, null, VRR_ANIMMOVE_NONE], + ["sitright", 0, 150, VRR_ANIMTYPE_ADD, 0.0, null, null, null, null, VRR_ANIMMOVE_RIGHT], + ["sitleft", 0, 150, VRR_ANIMTYPE_ADD, 0.0, null, null, null, null, VRR_ANIMMOVE_LEFT], + ["sitforward", 0, 150, VRR_ANIMTYPE_ADD, 0.0, null, null, null, null, VRR_ANIMMOVE_FORWARD], + ["sitback", 0, 150, VRR_ANIMTYPE_ADD, 0.0, null, null, null, null, VRR_ANIMMOVE_BACK], + + /* ["talk", "PED", "IDLE_CHAT", VRR_ANIMTYPE_ADD, 0.0, null, null, null, null], ["fucku", "PED", "FUCKU", VRR_ANIMTYPE_ADD, 0.0, null, null, null, null], ["taichi", "PARK", "Tai_Chi_Loop", VRR_ANIMTYPE_ADD, 0.0, null, null, null, null], @@ -3063,10 +3108,9 @@ let gameData = { ["sit2", "BEACH", "ParkSit_M_loop", VRR_ANIMTYPE_ADD, 0.0, null, null, null, null], ["sit3", "BEACH", "ParkSit_W_loop", VRR_ANIMTYPE_ADD, 0.0, null, null, null, null], ["sit4", "BEACH", "SitnWait_loop_W", VRR_ANIMTYPE_ADD, 0.0, null, null, null, null], - ["sitleft", "FOOD", "FF_Sit_In_L", VRR_ANIMTYPE_ADD, 0.0, null, null, null, null], - ["sitright", "FOOD", "FF_Sit_In_R", VRR_ANIMTYPE_ADD, 0.0, null, null, null, null], ["scratch", "MISC","Scratchballs_01", VRR_ANIMTYPE_ADD, 0.0, null, null, null, null], ["standup", "ped", "SEAT_up", VRR_ANIMTYPE_ADD, 0.0, null, null, null, null], + */ ], null, [ // GTA IV @@ -4841,6 +4885,13 @@ function getElementHeading(element) { // =========================================================================== +function setElementInterior(element, interior) { + setEntityData(element, "vrr.interior", interior, true); + forcePlayerToSyncElementProperties(null, element); +} + +// =========================================================================== + function setElementCollisionsEnabled(element, state) { triggerNetworkEvent("vrr.elementCollisions", getClientFromSyncerId(element.syncer), element.id, state); } diff --git a/scripts/server/native/mafiac.js b/scripts/server/native/mafiac.js index c213a212..38db8603 100644 --- a/scripts/server/native/mafiac.js +++ b/scripts/server/native/mafiac.js @@ -889,7 +889,7 @@ let gameData = { false, [ // Mafia 1 - //new serverClasses.removedWorldObjectData("fraightback04", toVector3(1229.88, -84.8012, 13.4004), 50.0), // Truck trailer in Easy Credit Autos dealership parking lot + //new RemovedWorldObjectData("fraightback04", toVector3(1229.88, -84.8012, 13.4004), 50.0), // Truck trailer in Easy Credit Autos dealership parking lot ], [ // Mafia 2 diff --git a/scripts/server/radio.js b/scripts/server/radio.js index 4af0a57c..b077d1eb 100644 --- a/scripts/server/radio.js +++ b/scripts/server/radio.js @@ -27,7 +27,7 @@ function loadRadioStationsFromDatabase() { let dbQuery = queryDatabase(dbConnection, dbQueryString); if(dbQuery) { while(dbAssoc = fetchQueryAssoc(dbQuery)) { - let tempRadioStationData = new serverClasses.radioStationData(dbAssoc); + let tempRadioStationData = new RadioStationData(dbAssoc); tempRadioStations.push(tempRadioStationData); } freeDatabaseQuery(dbQuery); diff --git a/scripts/server/subaccount.js b/scripts/server/subaccount.js index 5ffb4460..5b4ccc6a 100644 --- a/scripts/server/subaccount.js +++ b/scripts/server/subaccount.js @@ -24,7 +24,7 @@ function loadSubAccountFromName(firstName, lastName) { if(dbQuery) { let dbAssoc = fetchQueryAssoc(dbQuery); freeDatabaseQuery(dbQuery); - return new serverClasses.subAccountData(dbAssoc); + return new SubAccountData(dbAssoc); } disconnectFromDatabase(dbConnection); } @@ -42,7 +42,7 @@ function loadSubAccountFromId(subAccountId) { if(dbQuery) { let dbAssoc = fetchQueryAssoc(dbQuery); freeDatabaseQuery(dbQuery); - return new serverClasses.subAccountData(dbAssoc); + return new SubAccountData(dbAssoc); } disconnectFromDatabase(dbConnection); } @@ -62,7 +62,7 @@ function loadSubAccountsFromAccount(accountId) { let dbQuery = queryDatabase(dbConnection, dbQueryString); if(dbQuery) { while(dbAssoc = fetchQueryAssoc(dbQuery)) { - let tempSubAccount = new serverClasses.subAccountData(dbAssoc); + let tempSubAccount = new SubAccountData(dbAssoc); // Make sure skin is valid if(tempSubAccount.skin == -1) { @@ -425,7 +425,7 @@ function switchCharacterCommand(command, params, client) { resetClientStuff(client); - client.despawnPlayer(); + //client.despawnPlayer(); getPlayerData(client).switchingCharacter = true; //spawnPlayer(client, getServerConfig().characterSelectPedPosition, getServerConfig().characterSelectPedHeading, getPlayerCurrentSubAccount(client).skin, getServerConfig().characterSelectInterior, getServerConfig().characterSelectDimension); //showCharacterSelectCameraToPlayer(client); diff --git a/scripts/server/timers.js b/scripts/server/timers.js index 63fcd926..2f6f4228 100644 --- a/scripts/server/timers.js +++ b/scripts/server/timers.js @@ -25,13 +25,55 @@ function saveAllServerDataToDatabase() { } logToConsole(LOG_DEBUG, "[VRR.Utilities]: Saving all server data to database ..."); - saveAllClientsToDatabase(); - saveAllClansToDatabase(); - saveAllHousesToDatabase(); - saveAllBusinessesToDatabase(); - saveServerConfigToDatabase(getServerConfig()); - saveAllVehiclesToDatabase(); - saveAllItemsToDatabase(); + + try { + saveAllClientsToDatabase(); + } catch(error) { + logToConsole(LOG_ERROR, `Could not save clients to database: ${error}`); + } + + try { + saveAllClansToDatabase(); + } catch(error) { + logToConsole(LOG_ERROR, `Could not save clans to database: ${error}`); + } + + try { + saveAllHousesToDatabase(); + } catch(error) { + logToConsole(LOG_ERROR, `Could not save houses to database: ${error}`); + } + + try { + saveAllBusinessesToDatabase(); + } catch(error) { + logToConsole(LOG_ERROR, `Could not save businesses to database: ${error}`); + } + + try { + saveServerConfigToDatabase(getServerConfig()); + } catch(error) { + logToConsole(LOG_ERROR, `Could not save server config to database: ${error}`); + } + + try { + saveAllVehiclesToDatabase(); + } catch(error) { + logToConsole(LOG_ERROR, `Could not save vehicles to database: ${error}`); + } + + try { + saveAllItemsToDatabase(); + } catch(error) { + logToConsole(LOG_ERROR, `Could not save items to database: ${error}`); + } + + try { + saveServerConfigToDatabase(); + } catch(error) { + logToConsole(LOG_ERROR, `Could not save server config to database: ${error}`); + } + logToConsole(LOG_DEBUG, "[VRR.Utilities]: Saved all server data to database!"); } diff --git a/scripts/server/utilities.js b/scripts/server/utilities.js index 6d294176..41ab5975 100644 --- a/scripts/server/utilities.js +++ b/scripts/server/utilities.js @@ -118,7 +118,7 @@ function makeReadableTime(hour, minute) { meridianStr = "AM"; } - if(hour > 12) { + if(hour > 11) { let actualHour = hour-12; if(actualHour < 10) { hourStr = "0" + toString(hour-12); diff --git a/scripts/server/vehicle.js b/scripts/server/vehicle.js index 93c7fbc1..034f5665 100644 --- a/scripts/server/vehicle.js +++ b/scripts/server/vehicle.js @@ -28,7 +28,7 @@ function loadVehiclesFromDatabase() { let dbQuery = queryDatabase(dbConnection, dbQueryString); if(dbQuery) { while(dbAssoc = fetchQueryAssoc(dbQuery)) { - let tempVehicleData = new serverClasses.vehicleData(dbAssoc); + let tempVehicleData = new VehicleData(dbAssoc); tempVehicles.push(tempVehicleData); } freeDatabaseQuery(dbQuery); @@ -213,7 +213,7 @@ function createVehicleCommand(command, params, client) { } let frontPos = getPosInFrontOfPos(getPlayerPosition(client), getPlayerHeading(client), getGlobalConfig().spawnCarDistance); - let vehicle = createPermanentVehicle(modelId, frontPos, getPlayerHeading(client)); + let vehicle = createPermanentVehicle(modelId, frontPos, getPlayerHeading(client), getPlayerInterior(client), getPlayerDimension(client)); messageAdmins(`${getInlineChatColourByName("lightGrey")}${getPlayerName(client)} ${getInlineChatColourByName("white")}created a ${getInlineChatColourByType("vehiclePurple")}${getVehicleName(vehicle)}!`); } @@ -234,7 +234,7 @@ function createTemporaryVehicleCommand(command, params, client) { } let frontPos = getPosInFrontOfPos(getPlayerPosition(client), getPlayerHeading(client), getGlobalConfig().spawnCarDistance); - let vehicle = createTemporaryVehicle(modelId, frontPos, getPlayerHeading(client)); + let vehicle = createTemporaryVehicle(modelId, frontPos, getPlayerHeading(client), getPlayerInterior(client), getPlayerDimension(client)); messageAdmins(`${getInlineChatColourByName("lightGrey")}${getPlayerName(client)} ${getInlineChatColourByName("white")}created a temporary ${getInlineChatColourByType("vehiclePurple")}${getVehicleName(vehicle)}`); } @@ -877,6 +877,24 @@ function setVehicleOwnerCommand(command, params, client) { // =========================================================================== +function setVehiclePublicCommand(command, params, client) { + if(!isPlayerInAnyVehicle(client)) { + messagePlayerError(client, "You need to be in a vehicle!"); + return false; + } + + let vehicle = getPlayerVehicle(client); + + getVehicleData(vehicle).ownerType = VRR_VEHOWNER_PUBLIC; + getVehicleData(vehicle).ownerId = 0; + + messageAdmins(`${getInlineChatColourByName("lightGrey")}${getPlayerName(client)} ${getInlineChatColourByName("white")}set their ${getInlineChatColourByType("vehiclePurple")}${getVehicleName(vehicle)} ${getInlineChatColourByName("white")}a public vehicle!`); + + getVehicleData(vehicle).needsSaved = true; +} + +// =========================================================================== + function setVehicleRentPriceCommand(command, params, client) { if(!isPlayerInAnyVehicle(client)) { messagePlayerError(client, "You need to be in a vehicle!"); @@ -1089,7 +1107,7 @@ function reloadAllVehiclesCommand(command, params, client) { function respawnAllVehiclesCommand(command, params, client) { for(let i in getServerData().vehicles) { - respawnVehicle(vehicle); + respawnVehicle(getServerData().vehicles[i]); } //spawnAllVehicles(); @@ -1127,7 +1145,7 @@ function respawnVehicle(vehicle) { // =========================================================================== function spawnVehicle(vehicleData) { - let vehicle = gta.createVehicle(vehicleData.model, vehicleData.spawnPosition, vehicleData.spawnRotation); + let vehicle = createGameVehicle(vehicleData.model, vehicleData.spawnPosition, vehicleData.spawnRotation); addToWorld(vehicle); if(doesGameHaveServerElements()) { @@ -1140,20 +1158,26 @@ function spawnVehicle(vehicleData) { vehicle.colour4 = vehicleData.colour4; } - vehicle.engine = intToBool(vehicleData.engine); + if(vehicleData.spawnLocked) { + vehicle.engine = false; + } else { + vehicle.engine = intToBool(vehicleData.engine); + } + + vehicle.locked = intToBool(vehicleData.locked); + //vehicle.lights = intToBool(vehicleData.lights); //vehicle.health = vehicleData.health; //vehicle.position = vehicleData.spawnPosition; vehicle.heading = vehicleData.spawnRotation; - - vehicle.locked = intToBool(vehicleData.locked); } vehicleData.vehicle = vehicle; setEntityData(vehicle, "vrr.livery", vehicleData.livery); setEntityData(vehicle, "vrr.upgrades", vehicleData.extras); + setEntityData(vehicle, "vrr.interior", vehicleData.interior); return vehicle; } @@ -1212,15 +1236,17 @@ async function getPlayerNewVehicle(client) { // =========================================================================== -function createNewDealershipVehicle(model, spawnPosition, spawnRotation, price, dealershipId) { +function createNewDealershipVehicle(model, spawnPosition, spawnRotation, price, dealershipId, interior = 0, dimension = 0) { let vehicle = createGameVehicle(model, spawnPosition, spawnRotation); if(!vehicle) { return false; } setVehicleHeading(vehicle, spawnRotation); + setElementInterior(vehicle, interior); + setElementDimension(vehicle, dimension); addToWorld(vehicle); - let tempVehicleData = new serverClasses.vehicleData(false, vehicle); + let tempVehicleData = new VehicleData(false, vehicle); tempVehicleData.buyPrice = price; tempVehicleData.spawnLocked = true; tempVehicleData.spawnPosition = spawnPosition; @@ -1235,12 +1261,14 @@ function createNewDealershipVehicle(model, spawnPosition, spawnRotation, price, // =========================================================================== -function createTemporaryVehicle(modelId, position, heading) { +function createTemporaryVehicle(modelId, position, heading, interior = 0, dimension = 0) { let vehicle = createGameVehicle(modelId, position, heading); setVehicleHeading(vehicle, heading); + setElementInterior(vehicle, interior); + setElementDimension(vehicle, dimension); addToWorld(vehicle); - let tempVehicleData = new serverClasses.vehicleData(false, vehicle); + let tempVehicleData = new VehicleData(false, vehicle); tempVehicleData.databaseId = -1; let slot = getServerData().vehicles.push(tempVehicleData); setEntityData(vehicle, "vrr.dataSlot", slot-1, false); @@ -1250,12 +1278,14 @@ function createTemporaryVehicle(modelId, position, heading) { // =========================================================================== -function createPermanentVehicle(modelId, position, heading) { +function createPermanentVehicle(modelId, position, heading, interior = 0, dimension = 0) { let vehicle = createGameVehicle(modelId, position, heading); setVehicleHeading(vehicle, heading); + setElementInterior(vehicle, interior); + setElementDimension(vehicle, dimension); addToWorld(vehicle); - let tempVehicleData = new serverClasses.vehicleData(false, vehicle); + let tempVehicleData = new VehicleData(false, vehicle); let slot = getServerData().vehicles.push(tempVehicleData); setEntityData(vehicle, "vrr.dataSlot", slot-1, false);