diff --git a/scripts/client/gui.js b/scripts/client/gui.js index 853dcb58..7930102f 100644 --- a/scripts/client/gui.js +++ b/scripts/client/gui.js @@ -108,55 +108,55 @@ function closeAllWindows() { // =========================================================================== function isAnyGUIActive() { - if(!guiReady) { + if (!guiReady) { return false; } - if(infoDialog.window.shown == true) { + if (infoDialog.window.shown == true) { return true; } - if(yesNoDialog.window.shown == true) { + if (yesNoDialog.window.shown == true) { return true; } - if(errorDialog.window.shown == true) { + if (errorDialog.window.shown == true) { return true; } - if(register.window.shown == true) { + if (register.window.shown == true) { return true; } - if(login.window.shown == true) { + if (login.window.shown == true) { return true; } - if(newCharacter.window.shown == true) { + if (newCharacter.window.shown == true) { return true; } - if(characterSelect.window.shown == true) { + if (characterSelect.window.shown == true) { return true; } - if(twoFactorAuth.window.shown == true) { + if (twoFactorAuth.window.shown == true) { return true; } - if(listDialog.window.shown == true) { + if (listDialog.window.shown == true) { return true; } - if(passwordReset.window.shown == true) { + if (passwordReset.window.shown == true) { return true; } - if(passwordChange.window.shown == true) { + if (passwordChange.window.shown == true) { return true; } - if(localeChooser.window.shown == true) { + if (localeChooser.window.shown == true) { return true; } @@ -170,7 +170,7 @@ function setGUIColours(red1, green1, blue1, red2, green2, blue2, red3, green3, b primaryColour = [red1, green1, blue1]; secondaryColour = [red2, green2, blue2]; primaryTextColour = [red3, green3, blue3]; - focusedColour = [red1+focusedColourOffset, green1+focusedColourOffset, blue1+focusedColourOffset]; + focusedColour = [red1 + focusedColourOffset, green1 + focusedColourOffset, blue1 + focusedColourOffset]; initGUI(); } @@ -188,38 +188,38 @@ function hideAllGUI() { function processGUIKeyPress(keyCode) { logToConsole(LOG_DEBUG, `[VRR.GUI] Processing key press: ${keyCode}`); - if(!isAnyGUIActive()) { + if (!isAnyGUIActive()) { logToConsole(LOG_DEBUG, `[VRR.GUI] GUI is not active. Cancelling keypress processing.`); return false; } - if(keyCode == SDLK_RETURN || keyCode == SDLK_RETURN2) { + if (keyCode == SDLK_RETURN || keyCode == SDLK_RETURN2) { logToConsole(LOG_DEBUG, `[VRR.GUI] Key press is submit (${guiSubmitKey})`); - if(guiSubmitKey != false) { + if (guiSubmitKey != false) { logToConsole(LOG_DEBUG, `[VRR.GUI] Calling submit key function`); guiSubmitKey.call(); } - } else if(keyCode == getKeyIdFromParams("left") || keyCode == getKeyIdFromParams("a")) { + } else if (keyCode == getKeyIdFromParams("left") || keyCode == getKeyIdFromParams("a")) { logToConsole(LOG_DEBUG, `[VRR.GUI] Key press is left (${guiLeftKey})`); - if(guiLeftKey != false) { + if (guiLeftKey != false) { logToConsole(LOG_DEBUG, `[VRR.GUI] Calling left key function`); guiLeftKey.call(); } - } else if(keyCode == getKeyIdFromParams("right") || keyCode == getKeyIdFromParams("d")) { + } else if (keyCode == getKeyIdFromParams("right") || keyCode == getKeyIdFromParams("d")) { logToConsole(LOG_DEBUG, `[VRR.GUI] Key press is right (${guiRightKey})`); - if(guiRightKey != false) { + if (guiRightKey != false) { logToConsole(LOG_DEBUG, `[VRR.GUI] Calling right key function`); guiRightKey.call(); } - } else if(keyCode == getKeyIdFromParams("down") || keyCode == getKeyIdFromParams("s")) { + } else if (keyCode == getKeyIdFromParams("down") || keyCode == getKeyIdFromParams("s")) { logToConsole(LOG_DEBUG, `[VRR.GUI] Key press is down (${guiDownKey})`); - if(guiDownKey != false) { + if (guiDownKey != false) { logToConsole(LOG_DEBUG, `[VRR.GUI] Calling down key function`); guiDownKey.call(); } - } else if(keyCode == getKeyIdFromParams("up") || keyCode == getKeyIdFromParams("w")) { + } else if (keyCode == getKeyIdFromParams("up") || keyCode == getKeyIdFromParams("w")) { logToConsole(LOG_DEBUG, `[VRR.GUI] Key press is up (${guiUpKey})`); - if(guiUpKey != false) { + if (guiUpKey != false) { logToConsole(LOG_DEBUG, `[VRR.GUI] Calling up key function`); guiUpKey.call(); } @@ -229,7 +229,7 @@ function processGUIKeyPress(keyCode) { // =========================================================================== function processToggleGUIKeyPress(keyCode) { - if(keyCode == disableGUIKey) { + if (keyCode == disableGUIKey) { sendNetworkEventToServer("vrr.toggleGUI"); } } diff --git a/scripts/client/gui/changepass.js b/scripts/client/gui/changepass.js index 39476dfd..c600245e 100644 --- a/scripts/client/gui/changepass.js +++ b/scripts/client/gui/changepass.js @@ -19,8 +19,8 @@ let passwordChange = { // =========================================================================== function initChangePasswordGUI() { - logToConsole(LOG_DEBUG, `[VRR.GUI] Creating password change GUI ...`); - passwordChange.window = mexui.window(game.width/2-130, game.height/2-125, 300, 250, 'Change Password', { + logToConsole(LOG_DEBUG, `[VRR.GUI] Creating password change GUI ...`); + passwordChange.window = mexui.window(game.width / 2 - 130, game.height / 2 - 125, 300, 250, 'Change Password', { main: { backgroundColour: toColour(secondaryColour[0], secondaryColour[1], secondaryColour[2], windowAlpha), transitionTime: 500, @@ -36,17 +36,17 @@ function initChangePasswordGUI() { backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], windowTitleAlpha), } }); - passwordChange.window.titleBarIconSize = toVector2(0,0); + passwordChange.window.titleBarIconSize = toVector2(0, 0); passwordChange.window.titleBarHeight = 0; passwordChange.window.titleBarShown = false; - passwordChange.window.image(85, -10, 140, 140, mainLogoPath, { + passwordChange.window.image(100, 20, 75, 75, mainLogoPath, { focused: { borderColour: toColour(0, 0, 0, 0), }, }); - passwordChange.messageLabel = passwordChange.window.text(20, 75, 260, 20, 'Enter a new password', { + passwordChange.messageLabel = passwordChange.window.text(20, 95, 260, 20, 'Enter a new password', { main: { textSize: 10.0, textAlign: 0.5, @@ -143,7 +143,7 @@ function showChangePasswordGUI(errorMessage) { mexui.focusedControl = passwordChange.passwordInput; guiSubmitKey = checkChangePassword; - showLocaleChooserGUI(new Vec2(getScreenWidth()/2-(localeChooser.window.size.x/2), passwordChange.window.position.y+passwordChange.window.size.y+20)); + showLocaleChooserGUI(new Vec2(getScreenWidth() / 2 - (localeChooser.window.size.x / 2), passwordChange.window.position.y + passwordChange.window.size.y + 20)); } // =========================================================================== diff --git a/scripts/client/gui/resetpass.js b/scripts/client/gui/resetpass.js index f81eafc4..c04ebf17 100644 --- a/scripts/client/gui/resetpass.js +++ b/scripts/client/gui/resetpass.js @@ -20,8 +20,8 @@ let passwordReset = { // =========================================================================== function initResetPasswordGUI() { - logToConsole(LOG_DEBUG, `[VRR.GUI] Creating password reset GUI ...`); - passwordReset.window = mexui.window(getScreenWidth()/2-150, getScreenHeight()/2-135, 300, 275, 'RESET PASSWORD', { + logToConsole(LOG_DEBUG, `[VRR.GUI] Creating password reset GUI ...`); + passwordReset.window = mexui.window(getScreenWidth() / 2 - 150, getScreenHeight() / 2 - 135, 300, 275, 'RESET PASSWORD', { main: { backgroundColour: toColour(secondaryColour[0], secondaryColour[1], secondaryColour[2], windowAlpha), transitionTime: 500, @@ -38,7 +38,7 @@ function initResetPasswordGUI() { borderColour: toColour(0, 0, 0, 0), }, }); - passwordReset.window.titleBarIconSize = toVector2(0,0); + passwordReset.window.titleBarIconSize = toVector2(0, 0); passwordReset.window.titleBarHeight = 0; passwordReset.window.titleBarShown = false; @@ -82,7 +82,7 @@ function initResetPasswordGUI() { }); passwordReset.emailInput.placeholder = "Email"; - passwordReset.resetPasswordButton = passwordReset.window.button(180, 240, 100, 15, 'RESET PASSWORD', { + passwordReset.resetPasswordButton = passwordReset.window.button(20, 205, 260, 30, 'RESET PASSWORD', { main: { backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha), textColour: toColour(primaryTextColour[0], primaryTextColour[1], primaryTextColour[2], 255), @@ -134,14 +134,14 @@ function showResetPasswordGUI() { mexui.focusedControl = passwordReset.emailInput; guiSubmitKey = checkResetPassword; - showLocaleChooserGUI(new Vec2(getScreenWidth()/2-(localeChooser.window.size.x/2), passwordReset.window.position.y+passwordReset.window.size.y+20)); + showLocaleChooserGUI(new Vec2(getScreenWidth() / 2 - (localeChooser.window.size.x / 2), passwordReset.window.position.y + passwordReset.window.size.y + 20)); //showSmallGameMessage(`If you don't have a mouse cursor, press ${toUpperCase(getKeyNameFromId(disableGUIKey))} to disable GUI`, COLOUR_WHITE, 7500); } // =========================================================================== function checkResetPassword() { - logToConsole(LOG_DEBUG, `[VRR.GUI] Checking password reset with server ...`); + logToConsole(LOG_DEBUG, `[VRR.GUI] Checking password reset with server (${passwordReset.emailInput.lines[0]}) ...`); sendNetworkEventToServer("vrr.checkResetPassword", passwordReset.emailInput.lines[0]); } @@ -157,12 +157,12 @@ function resetPasswordFailed(errorMessage) { // =========================================================================== function resetPasswordCodeInputGUI() { - logToConsole(LOG_DEBUG|LOG_WARN, `[VRR.GUI] Server reports password reset email confirmation was successful. Asking for code ...`); + logToConsole(LOG_DEBUG | LOG_WARN, `[VRR.GUI] Server reports password reset email confirmation was successful. Asking for code ...`); closeAllWindows(); passwordReset.messageLabel.text = getLocaleString("GUIResetPasswordCodeInputLabel"); //passwordReset.messageLabel.styles.main.textColour = toColour(180, 32, 32, 255); - passwordReset.emailInput.text = ""; + passwordReset.emailInput.lines[0] = ""; passwordReset.emailInput.placeholder = getLocaleString("GUIResetPasswordCodePlaceholder"); guiSubmitKey = checkResetPassword; @@ -172,7 +172,7 @@ function resetPasswordCodeInputGUI() { // =========================================================================== function resetPasswordEmailInputGUI() { - logToConsole(LOG_DEBUG|LOG_WARN, `[VRR.GUI] Server reports password reset request was approved. Asking for email ...`); + logToConsole(LOG_DEBUG | LOG_WARN, `[VRR.GUI] Server reports password reset request was approved. Asking for email ...`); closeAllWindows(); passwordReset.messageLabel.text = getLocaleString("GUIResetPasswordConfirmEmailLabel"); @@ -188,8 +188,8 @@ function resetPasswordEmailInputGUI() { function switchToLoginGUI() { guiSubmitKey = false; - closeAllWindows(); - showLoginGUI(); + closeAllWindows(); + showLoginGUI(); } // =========================================================================== \ No newline at end of file diff --git a/scripts/client/index.js b/scripts/client/index.js deleted file mode 100644 index 4dd994ea..00000000 --- a/scripts/client/index.js +++ /dev/null @@ -1,34 +0,0 @@ -// For RAGEMP only - -// Shared Scripts -require("../scripts/shared/const.js"); -require("../scripts/shared/utilities.js"); -require("../scripts/shared/gamedata.js"); - -// Multiplayer Mod (Wrapped Natives) -require("scripts/client/native/ragemp.js"); - -// Client Scripts -require("scripts/client/gui.js"); -require("scripts/client/main.js"); -require("scripts/client/nametag.js"); -require("scripts/client/sync.js"); -require("scripts/client/scoreboard.js"); -require("scripts/client/keybind.js"); -require("scripts/client/chatbox.js"); -require("scripts/client/label.js"); -require("scripts/client/skin-select.js"); -require("scripts/client/server.js"); -require("scripts/client/job.js"); -require("scripts/client/event.js"); -require("scripts/client/item.js"); -require("scripts/client/utilities.js"); -require("scripts/client/messaging.js"); -require("scripts/client/logo.js"); -require("scripts/client/afk.js"); -require("scripts/client/mousecam.js"); -require("scripts/client/radio.js"); -require("scripts/client/animation.js"); - -// Startup -require("scripts/client/startup.js"); \ No newline at end of file diff --git a/scripts/client/utilities.js b/scripts/client/utilities.js index eb8185c8..ae09a778 100644 --- a/scripts/client/utilities.js +++ b/scripts/client/utilities.js @@ -17,9 +17,9 @@ function setLocalPlayerFrozenState(state) { function setLocalPlayerControlState(controlState, cursorState = false) { logToConsole(LOG_DEBUG, `[VRR.Utilities] Setting control state to ${controlState} (Cursor: ${cursorState})`); controlsEnabled = controlState; - if(getGame() == VRR_GAME_GTA_III || getGame() == VRR_GAME_GTA_VC) { + if (getGame() == VRR_GAME_GTA_III || getGame() == VRR_GAME_GTA_VC) { game.SET_PLAYER_CONTROL(game.GET_PLAYER_ID(), boolToInt(controlState)); - } else if(getGame() != VRR_GAME_GTA_IV) { + } else if (getGame() != VRR_GAME_GTA_IV) { setElementCollisionsEnabled(localPlayer, controlState); setPedInvincible(localPlayer, true); } @@ -28,10 +28,10 @@ function setLocalPlayerControlState(controlState, cursorState = false) { // =========================================================================== function fadeLocalCamera(state, time) { - if(isFadeCameraSupported()) { - logToConsole(LOG_DEBUG, `[VRR.Utilities] Fading camera ${(state)?"in":"out"} for ${time} seconds`); + if (isFadeCameraSupported()) { + logToConsole(LOG_DEBUG, `[VRR.Utilities] Fading camera ${(state) ? "in" : "out"} for ${time} seconds`); - if(isFadeCameraSupported()) { + if (isFadeCameraSupported()) { game.fadeCamera(state, time); } } @@ -47,7 +47,7 @@ function removeLocalPlayerFromVehicle() { function restoreLocalCamera() { logToConsole(LOG_DEBUG, `[VRR.Utilities] Camera restored`); - if(isCustomCameraSupported()) { + if (isCustomCameraSupported()) { game.restoreCamera(true); } }; @@ -64,7 +64,7 @@ function clearLocalPlayerOwnedPeds() { function setLocalCameraLookAt(cameraPosition, cameraLookAt) { logToConsole(LOG_DEBUG, `[VRR.Utilities] Set camera to look at [${cameraLookAt.x}, ${cameraLookAt.y}, ${cameraLookAt.z}] from [${cameraPosition.x}, ${cameraPosition.y}, ${cameraPosition.z}]`); - if(isCustomCameraSupported()) { + if (isCustomCameraSupported()) { game.setCameraLookAt(cameraPosition, cameraLookAt, true); } } @@ -75,13 +75,13 @@ function setCityAmbienceState(state, clearElements = false) { logToConsole(LOG_DEBUG, `[VRR.Utilities] Ambient civilians and traffic ${(state) ? "enabled" : "disabled"}`); game.setTrafficEnabled(state); - if(getMultiplayerMod() == VRR_MPMOD_GTAC) { + if (getMultiplayerMod() == VRR_MPMOD_GTAC) { game.setGenerateCarsAroundCamera(state); - if(getGame() != VRR_GAME_GTA_SA) { + if (getGame() != VRR_GAME_GTA_SA) { game.setCiviliansEnabled(state); } - if(clearElements) { + if (clearElements) { clearSelfOwnedPeds(); clearSelfOwnedVehicles(); } @@ -94,12 +94,12 @@ function runClientCode(code, returnTo) { let returnValue = "Nothing"; try { returnValue = eval("(" + code + ")"); - } catch(error) { + } catch (error) { sendNetworkEventToServer("vrr.runCodeFail", returnTo, error.toString()); return false; } let returnValueString = returnValue; - if(returnValue != null && returnValue != undefined) { + if (returnValue != null && returnValue != undefined) { returnValueString = `${returnValue.toString()} (${typeof returnValue})`; } else { returnValueString = "null/undefined"; @@ -110,10 +110,10 @@ function runClientCode(code, returnTo) { // =========================================================================== function enterVehicleAsPassenger() { - if(localPlayer.vehicle == null) { + if (localPlayer.vehicle == null) { let tempVehicle = getClosestVehicle(localPlayer.position); - if(getGame() != VRR_GAME_GTA_IV) { - if(tempVehicle != null) { + if (getGame() != VRR_GAME_GTA_IV) { + if (tempVehicle != null) { localPlayer.enterVehicle(tempVehicle, false); } } else { @@ -133,13 +133,13 @@ function enterVehicleAsPassenger() { function giveLocalPlayerWeapon(weaponId, ammo, active) { logToConsole(LOG_DEBUG, `[VRR.Utilities] Giving weapon ${weaponId} with ${ammo} ammo`); forceWeapon = weaponId; - if(getGame() == VRR_GAME_MAFIA_ONE) { + if (getGame() == VRR_GAME_MAFIA_ONE) { localPlayer.giveWeapon(weaponId, 0, ammo); forceWeaponAmmo = 0; forceWeaponClipAmmo = ammo; } else { localPlayer.giveWeapon(weaponId, ammo, active); - if(getGame() < VRR_GAME_GTA_IV) { + if (getGame() < VRR_GAME_GTA_IV) { forceWeaponAmmo = localPlayer.getWeaponAmmunition(getWeaponSlot(weaponId)); forceWeaponClipAmmo = localPlayer.getWeaponClipAmmunition(getWeaponSlot(weaponId)); } else { @@ -154,7 +154,7 @@ function giveLocalPlayerWeapon(weaponId, ammo, active) { function clearLocalPlayerWeapons(clearData) { logToConsole(LOG_DEBUG, `[VRR.Utilities] Clearing weapons`); localPlayer.clearWeapons(); - if(clearData == true) { + if (clearData == true) { forceWeapon = 0; forceWeaponAmmo = 0; forceWeaponClipAmmo = 0; @@ -165,11 +165,11 @@ function clearLocalPlayerWeapons(clearData) { function setLocalPlayerPosition(position) { logToConsole(LOG_DEBUG, `[VRR.Utilities] Setting position to ${position.x}, ${position.y}, ${position.z}`); - if(typeof localPlayer.velocity != "undefined") { + if (typeof localPlayer.velocity != "undefined") { localPlayer.velocity = toVector3(0.0, 0.0, 0.0); } - if(typeof localPlayer.position != "undefined") { + if (typeof localPlayer.position != "undefined") { localPlayer.position = position; } } @@ -178,7 +178,7 @@ function setLocalPlayerPosition(position) { function setLocalPlayerHeading(heading) { logToConsole(LOG_DEBUG, `[VRR.Utilities] Setting heading to ${heading}`); - if(typeof localPlayer.heading != "undefined") { + if (typeof localPlayer.heading != "undefined") { localPlayer.heading = heading; } } @@ -187,26 +187,28 @@ function setLocalPlayerHeading(heading) { function setLocalPlayerInterior(interior) { logToConsole(LOG_DEBUG, `[VRR.Utilities] Setting interior to ${interior}`); - if(getMultiplayerMod() == VRR_MPMOD_GTAC) { - if(!isGTAIV()) { + if (getMultiplayerMod() == VRR_MPMOD_GTAC) { + if (!isGTAIV()) { localPlayer.interior = interior; game.cameraInterior = interior; } //else { - //if(getGameConfig().mainWorldInterior != interior) { - // let interiorId = natives.getInteriorAtCoords(localPlayer.position); - // natives.activateInterior(interiorId, true); - // natives.loadAllObjectsNow(); - //} - //let interiorId = natives.getInteriorAtCoords(localPlayer.position); - //natives.activateInterior(interiorId, true); + //if(getGameConfig().mainWorldInterior != interior) { + // let interiorId = natives.getInteriorAtCoords(localPlayer.position); + // natives.activateInterior(interiorId, true); + // natives.loadAllObjectsNow(); + //} + //let interiorId = natives.getInteriorAtCoords(localPlayer.position); + //natives.activateInterior(interiorId, true); //} } - let vehicles = getElementsByType(ELEMENT_VEHICLE); - for(let i in vehicles) { - if(getEntityData(vehicles[i], "vrr.interior")) { - vehicles[i].interior = getEntityData(vehicles[i], "vrr.interior"); - } + if (areServerElementsSupported() && isGameFeatureSupported("interior")) { + let vehicles = getElementsByType(ELEMENT_VEHICLE); + for (let i in vehicles) { + if (getEntityData(vehicles[i], "vrr.interior")) { + vehicles[i].interior = getEntityData(vehicles[i], "vrr.interior"); + } + } } } @@ -215,7 +217,7 @@ function setLocalPlayerInterior(interior) { function setSnowState(falling, ground) { logToConsole(LOG_DEBUG, `[VRR.Utilities] Setting falling snow to ${falling} and ground snow to ${ground}`); snowing = falling; - if(ground) { + if (ground) { forceSnowing(false); forceSnowing(ground); } @@ -231,7 +233,7 @@ function setLocalPlayerHealth(health) { function playPedSpeech(pedName, speechId) { logToConsole(LOG_DEBUG, `[VRR.Utilities] Making ${pedName}'s ped talk (${speechId})`); - if(getMultiplayerMod() == VRR_MPMOD_GTAC) { + if (getMultiplayerMod() == VRR_MPMOD_GTAC) { game.SET_CHAR_SAY(int, int); } } @@ -252,12 +254,12 @@ function getWeaponSlot(weaponId) { // =========================================================================== function setLocalPlayerDrunkEffect(amount, duration) { - if(getMultiplayerMod() == VRR_MPMOD_GTAC) { + if (getMultiplayerMod() == VRR_MPMOD_GTAC) { logToConsole(LOG_DEBUG, `[VRR.Utilities] Drunk effect set to ${amount} for ${duration} ms`); drunkEffectAmount = 0; - drunkEffectDurationTimer = setInterval(function() { + drunkEffectDurationTimer = setInterval(function () { drunkEffectAmount = drunkEffectAmount; - if(drunkEffectAmount > 0) { + if (drunkEffectAmount > 0) { //game.SET_MOTION_BLUR(drunkEffectAmount); game.SET_PLAYER_DRUNKENNESS(drunkEffectAmount, duration); } else { @@ -271,8 +273,8 @@ function setLocalPlayerDrunkEffect(amount, duration) { // =========================================================================== function getLocalPlayerVehicleSeat() { - for(let i = 0 ; i <= 4 ; i++) { - if(localPlayer.vehicle.getOccupant(i) == localPlayer) { + for (let i = 0; i <= 4; i++) { + if (localPlayer.vehicle.getOccupant(i) == localPlayer) { return i; } } @@ -282,9 +284,9 @@ function getLocalPlayerVehicleSeat() { function clearSelfOwnedPeds() { logToConsole(LOG_DEBUG, `Clearing self-owned peds`); - getElementsByType(ELEMENT_PED).forEach(function(ped) { + getElementsByType(ELEMENT_PED).forEach(function (ped) { //if(ped.isOwner) { - destroyElement(ped); + destroyElement(ped); //} }); } @@ -293,9 +295,9 @@ function clearSelfOwnedPeds() { function clearSelfOwnedVehicles() { logToConsole(LOG_DEBUG, `Clearing self-owned vehicles`); - getElementsByType(ELEMENT_VEHICLE).forEach(function(vehicle) { + getElementsByType(ELEMENT_VEHICLE).forEach(function (vehicle) { //if(vehicle.isOwner) { - destroyElement(vehicle); + destroyElement(vehicle); //} }); } @@ -303,7 +305,7 @@ function clearSelfOwnedVehicles() { // =========================================================================== function setMouseCameraState(state) { - logToConsole(LOG_DEBUG, `[VRR.Utilities] ${(state)?"Enabled":"Disabled"} mouse camera`); + logToConsole(LOG_DEBUG, `[VRR.Utilities] ${(state) ? "Enabled" : "Disabled"} mouse camera`); mouseCameraEnabled = state; SetStandardControlsEnabled(!mouseCameraEnabled); } @@ -311,14 +313,14 @@ function setMouseCameraState(state) { // =========================================================================== function toggleMouseCursor() { - logToConsole(LOG_DEBUG, `[VRR.Utilities] ${(!gui.cursorEnabled)?"Enabled":"Disabled"} mouse cursor`); + logToConsole(LOG_DEBUG, `[VRR.Utilities] ${(!gui.cursorEnabled) ? "Enabled" : "Disabled"} mouse cursor`); gui.showCursor(!gui.cursorEnabled, gui.cursorEnabled); } // =========================================================================== function toggleMouseCursor() { - logToConsole(LOG_DEBUG, `[VRR.Utilities] ${(!gui.cursorEnabled)?"Enabled":"Disabled"} mouse cursor`); + logToConsole(LOG_DEBUG, `[VRR.Utilities] ${(!gui.cursorEnabled) ? "Enabled" : "Disabled"} mouse cursor`); setMouseCameraState(!mouseCameraEnabled); } @@ -332,7 +334,7 @@ function setPlayerWeaponDamageEvent(clientName, eventType) { // =========================================================================== function setPlayerWeaponDamageEnabled(clientName, state) { - logToConsole(LOG_DEBUG, `[VRR.Utilities] ${(state)?"Enabled":"Disabled"} damage from ${clientName}`); + logToConsole(LOG_DEBUG, `[VRR.Utilities] ${(state) ? "Enabled" : "Disabled"} damage from ${clientName}`); weaponDamageEnabled[clientName] = state; } @@ -340,11 +342,11 @@ function setPlayerWeaponDamageEnabled(clientName, state) { function setLocalPlayerCash(amount) { logToConsole(LOG_DEBUG, `[VRR.Utilities] Setting local player money`); - if(typeof localPlayer.money != "undefined") { + if (typeof localPlayer.money != "undefined") { localPlayer.money = toInteger(amount); } - if(getGame() == VRR_GAME_GTA_IV) { + if (getGame() == VRR_GAME_GTA_IV) { natives.setMultiplayerHudCash(amount); } } @@ -352,9 +354,9 @@ function setLocalPlayerCash(amount) { // =========================================================================== function destroyAutoCreatedPickups() { - if(typeof ELEMENT_PICKUP != "undefined") { - getElementsByType(ELEMENT_PICKUP).forEach(function(pickup) { - if(pickup.isOwner) { + if (typeof ELEMENT_PICKUP != "undefined") { + getElementsByType(ELEMENT_PICKUP).forEach(function (pickup) { + if (pickup.isOwner) { destroyElement(pickup); } }); @@ -364,15 +366,15 @@ function destroyAutoCreatedPickups() { // =========================================================================== function processLocalPlayerControlState() { - if(localPlayer == null) { + if (localPlayer == null) { return false; } - if(isSpawned) { + if (isSpawned) { return false; } - if(!controlsEnabled) { + if (!controlsEnabled) { clearLocalPedState(); } } @@ -380,15 +382,15 @@ function processLocalPlayerControlState() { // =========================================================================== function processWantedLevelReset() { - if(localPlayer == null) { + if (localPlayer == null) { return false; } - if(!isSpawned) { + if (!isSpawned) { return false; } - if(typeof localPlayer.wantedLevel != "undefined") { + if (typeof localPlayer.wantedLevel != "undefined") { localPlayer.wantedLevel = forceWantedLevel; } } @@ -396,13 +398,13 @@ function processWantedLevelReset() { // =========================================================================== function processLocalPlayerVehicleControlState() { - if(areServerElementsSupported()) { - if(inVehicle && localPlayer.vehicle != null) { - if(doesEntityDataExist(localPlayer.vehicle, "vrr.engine")) { - if(getEntityData(localPlayer.vehicle, "vrr.engine") == false) { + if (areServerElementsSupported()) { + if (inVehicle && localPlayer.vehicle != null) { + if (doesEntityDataExist(localPlayer.vehicle, "vrr.engine")) { + if (getEntityData(localPlayer.vehicle, "vrr.engine") == false) { localPlayer.vehicle.engine = false; - if(!localPlayer.vehicle.engine) { - if(typeof localPlayer.vehicle.velocity != "undefined") { + if (!localPlayer.vehicle.engine) { + if (typeof localPlayer.vehicle.velocity != "undefined") { localPlayer.vehicle.velocity = toVector3(0.0, 0.0, 0.0); localPlayer.vehicle.turnVelocity = toVector3(0.0, 0.0, 0.0); } @@ -423,15 +425,15 @@ function processLocalPlayerVehicleControlState() { function processLocalPlayerSphereEntryExitHandling() { let position = getLocalPlayerPosition(); - if(areMarkersSupported()) { - getElementsByType(ELEMENT_MARKER).forEach(function(sphere) { - if(getDistance(position, sphere.position) <= sphere.radius) { - if(!inSphere) { + if (areMarkersSupported()) { + getElementsByType(ELEMENT_MARKER).forEach(function (sphere) { + if (getDistance(position, sphere.position) <= sphere.radius) { + if (!inSphere) { inSphere = sphere; triggerEvent("OnLocalPlayerEnterSphere", null, sphere); } } else { - if(inSphere) { + if (inSphere) { inSphere = false; triggerEvent("OnLocalPlayerExitSphere", null, sphere); } @@ -443,10 +445,10 @@ function processLocalPlayerSphereEntryExitHandling() { // =========================================================================== function processJobRouteSphere() { - if(getGame() == VRR_GAME_GTA_SA) { + if (getGame() == VRR_GAME_GTA_SA) { let position = getLocalPlayerPosition(); - if(jobRouteLocationSphere != null) { - if(getDistance(position, jobRouteLocationSphere.position) <= 2.0) { + if (jobRouteLocationSphere != null) { + if (getDistance(position, jobRouteLocationSphere.position) <= 2.0) { enteredJobRouteSphere(); } } @@ -456,11 +458,11 @@ function processJobRouteSphere() { // =========================================================================== function forceLocalPlayerEquippedWeaponItem() { - if(typeof localPlayer.weapon != "undefined") { - if(forceWeapon != 0) { - if(localPlayer.weapon != forceWeapon) { + if (typeof localPlayer.weapon != "undefined") { + if (forceWeapon != 0) { + if (localPlayer.weapon != forceWeapon) { localPlayer.weapon = forceWeapon; - if(getGame() < VRR_GAME_GTA_IV) { + if (getGame() < VRR_GAME_GTA_IV) { localPlayer.setWeaponClipAmmunition(getWeaponSlot(forceWeapon), forceWeaponClipAmmo); localPlayer.setWeaponAmmunition(getWeaponSlot(forceWeapon), forceWeaponAmmo); } @@ -471,7 +473,7 @@ function forceLocalPlayerEquippedWeaponItem() { //} } } else { - if(localPlayer.weapon > 0) { + if (localPlayer.weapon > 0) { localPlayer.clearWeapons(); } } @@ -482,7 +484,7 @@ function forceLocalPlayerEquippedWeaponItem() { function getLocalPlayerPosition() { let position = localPlayer.position; - if(localPlayer.vehicle) { + if (localPlayer.vehicle) { position = localPlayer.vehicle.position; } @@ -492,14 +494,14 @@ function getLocalPlayerPosition() { // =========================================================================== function processLocalPlayerVehicleEntryExitHandling() { - if(localPlayer.vehicle) { - if(!inVehicle) { + if (localPlayer.vehicle) { + if (!inVehicle) { inVehicle = localPlayer.vehicle; inVehicleSeat = getLocalPlayerVehicleSeat(); triggerEvent("OnLocalPlayerEnteredVehicle", inVehicle, inVehicleSeat); } } else { - if(inVehicle) { + if (inVehicle) { triggerEvent("OnLocalPlayerExitedVehicle", inVehicle, inVehicleSeat); inVehicle = false; inVehicleSeat = false; @@ -510,7 +512,7 @@ function processLocalPlayerVehicleEntryExitHandling() { // =========================================================================== function getVehicleForNetworkEvent(vehicle) { - if(getGame() == VRR_GAME_GTA_IV) { + if (getGame() == VRR_GAME_GTA_IV) { return natives.getNetworkIdFromVehicle(vehicle); } return vehicle.id; @@ -521,7 +523,7 @@ function getVehicleForNetworkEvent(vehicle) { function setMinuteDuration(minuteDuration) { logToConsole(LOG_DEBUG, `[VRR.Utilities] Setting minute duration to ${minuteDuration}ms`); - if(isTimeSupported()) { + if (isTimeSupported()) { game.time.minuteDuration = minuteDuration; } } @@ -535,17 +537,17 @@ function getStreamingRadioVolumeForPosition(position) { // =========================================================================== function getLocalPlayerLookAtPosition() { - if(localPlayer != null) { - let centerCameraPos = getWorldFromScreenPosition(toVector3(game.width/2, game.height/2, 0)); - return getWorldFromScreenPosition(toVector3(game.width/2, game.height/2, getDistance(centerCameraPos, localPlayer.position)+20)); + if (localPlayer != null) { + let centerCameraPos = getWorldFromScreenPosition(toVector3(game.width / 2, game.height / 2, 0)); + return getWorldFromScreenPosition(toVector3(game.width / 2, game.height / 2, getDistance(centerCameraPos, localPlayer.position) + 20)); } } // =========================================================================== function processInteriorLightsRendering() { - if(renderInteriorLights) { - if(!interiorLightsEnabled) { + if (renderInteriorLights) { + if (!interiorLightsEnabled) { graphics.drawRectangle(null, toVector2(0.0, 0.0), toVector2(game.width, game.height), interiorLightsColour, interiorLightsColour, interiorLightsColour, interiorLightsColour); } } @@ -555,16 +557,16 @@ 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) { + 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") { + if (typeof clients[toInteger(params)] != "undefined") { return clients[toInteger(params)]; } } @@ -575,15 +577,15 @@ function getPlayerFromParams(params) { // =========================================================================== function processNearbyPickups() { - if(typeof ELEMENT_PICKUP != "undefined") { + if (typeof ELEMENT_PICKUP != "undefined") { let pickups = getElementsByType(ELEMENT_PICKUP); - for(let i in pickups) { - if(getDistance(pickups[i].position, localPlayer.position) < 5) { + for (let i in pickups) { + if (getDistance(pickups[i].position, localPlayer.position) < 5) { //if(pickups[i].interior == localPlayer.interior && pickups[i].dimension == localPlayer.dimension) { - if(currentPickup != pickups[i]) { - currentPickup = pickups[i]; - sendNetworkEventToServer("vrr.pickup", pickups[i].id); - } + if (currentPickup != pickups[i]) { + currentPickup = pickups[i]; + sendNetworkEventToServer("vrr.pickup", pickups[i].id); + } //} } } @@ -593,7 +595,7 @@ function processNearbyPickups() { // =========================================================================== function processGameSpecifics() { - if(getGame() < VRR_GAME_GTA_IV) { + if (getGame() < VRR_GAME_GTA_IV) { game.clearMessages(); } diff --git a/scripts/server/account.js b/scripts/server/account.js index c3b9f551..c2e4f7a0 100644 --- a/scripts/server/account.js +++ b/scripts/server/account.js @@ -15,12 +15,12 @@ function initAccountScript() { // =========================================================================== function loginCommand(command, params, client) { - if(!isPlayerRegistered(client)) { + if (!isPlayerRegistered(client)) { messagePlayerError(client, getLocaleString(client, "NameNotRegistered")); return false; } - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -34,7 +34,7 @@ function loginCommand(command, params, client) { function toggleAutoLoginByIPCommand(command, params, client) { let flagValue = getAccountSettingsFlagValue("AutoLoginIP"); - if(hasBitFlag(getPlayerData(client).accountData.settings, flagValue)) { + if (hasBitFlag(getPlayerData(client).accountData.settings, flagValue)) { getPlayerData(client).accountData.settings = removeBitFlag(getPlayerData(client).accountData.settings, flagValue); messagePlayerSuccess(client, getLocaleString(client, "AutomaticLoginIPToggle", `{softRed}${toUpperCase(getLocaleString(client, "Off"))}`)); } else { @@ -49,7 +49,7 @@ function toggleAutoLoginByIPCommand(command, params, client) { function toggleNoRandomTipsCommand(command, params, client) { let flagValue = getAccountSettingsFlagValue("NoRandomTips"); - if(hasBitFlag(getPlayerData(client).accountData.settings, flagValue)) { + if (hasBitFlag(getPlayerData(client).accountData.settings, flagValue)) { getPlayerData(client).accountData.settings = removeBitFlag(getPlayerData(client).accountData.settings, flagValue); messagePlayerSuccess(client, getLocaleString(client, "RandomTipsToggle", `{softRed}${toUpperCase(getLocaleString(client, "Off"))}`)); } else { @@ -64,7 +64,7 @@ function toggleNoRandomTipsCommand(command, params, client) { function toggleNoActionTipsCommand(command, params, client) { let flagValue = getAccountSettingsFlagValue("NoActionTips"); - if(hasBitFlag(getPlayerData(client).accountData.settings, flagValue)) { + if (hasBitFlag(getPlayerData(client).accountData.settings, flagValue)) { getPlayerData(client).accountData.settings = removeBitFlag(getPlayerData(client).accountData.settings, flagValue); messagePlayerSuccess(client, getLocaleString(client, "ActionTipsToggle", `{softRed}${toUpperCase(getLocaleString(client, "Off"))}`)); } else { @@ -79,7 +79,7 @@ function toggleNoActionTipsCommand(command, params, client) { function toggleAutoSelectLastCharacterCommand(command, params, client) { let flagValue = getAccountSettingsFlagValue("AutoSelectLastCharacter"); - if(hasBitFlag(getPlayerData(client).accountData.settings, flagValue)) { + if (hasBitFlag(getPlayerData(client).accountData.settings, flagValue)) { getPlayerData(client).accountData.settings = removeBitFlag(getPlayerData(client).accountData.settings, flagValue); messagePlayerSuccess(client, getLocaleString(client, "AutoSpawnLastCharToggle", `{softRed}${toUpperCase(getLocaleString(client, "Off"))}`)); } else { @@ -95,7 +95,7 @@ function toggleAccountGUICommand(command, params, client) { // Remember, the flag is BACKWARD. Enabled = NO GUI! let flagValue = getAccountSettingsFlagValue("NoGUI"); - if(doesPlayerHaveGUIEnabled(client)) { + if (doesPlayerHaveGUIEnabled(client)) { getPlayerData(client).accountData.settings = addBitFlag(getPlayerData(client).accountData.settings, flagValue); messagePlayerNormal(client, getLocaleString(client, "GUIAccountSettingToggle", `{softRed}${toUpperCase(getLocaleString(client, "Off"))}{MAINCOLOUR}`)); logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} has toggled GUI for their account OFF.`); @@ -105,9 +105,9 @@ function toggleAccountGUICommand(command, params, client) { logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} has toggled GUI for their account ON.`); } - if(!isPlayerLoggedIn(client)) { - if(getPlayerData().accountData.databaseId != 0) { - if(doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) { + if (!isPlayerLoggedIn(client)) { + if (getPlayerData().accountData.databaseId != 0) { + if (doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) { showPlayerLoginGUI(client); logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the login GUI`); } else { @@ -116,7 +116,7 @@ function toggleAccountGUICommand(command, params, client) { logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the login message (GUI disabled)`); } } else { - if(doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) { + if (doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) { showPlayerRegistrationGUI(client); logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the register GUI`); } else { @@ -134,7 +134,7 @@ function toggleAccountGUICommand(command, params, client) { function toggleAccountLoginAttemptNotificationsCommand(command, params, client) { let flagValue = getAccountSettingsFlagValue("AuthAttemptAlert"); - if(doesPlayerHaveLoginAlertsEnabled(client)) { + if (doesPlayerHaveLoginAlertsEnabled(client)) { getPlayerData(client).accountData.settings = removeBitFlag(getPlayerData(client).accountData.settings, flagValue); messagePlayerNormal(client, `⚙️ You turned ${getBoolRedGreenInlineColour(false)}OFF{MAINCOLOUR} notification by email when somebody tries to login to your account`); logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} has toggled the login attempt email notifications OFF for their account`); @@ -152,11 +152,11 @@ function toggleAccountLoginAttemptNotificationsCommand(command, params, client) function toggleAccountServerLogoCommand(command, params, client) { let flagValue = getAccountSettingsFlagValue("NoServerLogo"); - if(!doesPlayerHaveLogoEnabled(client)) { + if (!doesPlayerHaveLogoEnabled(client)) { getPlayerData(client).accountData.settings = removeBitFlag(getPlayerData(client).accountData.settings, flagValue); messagePlayerSuccess(client, getLocaleString(client, "AccountServerLogoSet", `${getBoolRedGreenInlineColour(true)}${getLocaleString(client, "On")}{MAINCOLOUR}`)); logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} has toggled the server logo ON for their account`); - if(getServerConfig().showLogo) { + if (getServerConfig().showLogo) { updatePlayerShowLogoState(client, true); } } else { @@ -174,21 +174,21 @@ function toggleAccountServerLogoCommand(command, params, client) { function toggleAccountTwoFactorAuthCommand(command, params, client) { let flagValue = getAccountSettingsFlagValue("TwoStepAuth"); - if(getEmailConfig().enabled) { - if(getPlayerData(client).accountData.emailAddress == "") { + if (getEmailConfig().enabled) { + if (getPlayerData(client).accountData.emailAddress == "") { messagePlayerError(client, getLocaleString(client, "NeedEmailFor2FA")); messagePlayerTip(client, getLocaleString(client, "SetEmailHelpTip", `{ALTCOLOUR}/setemail{MAINCOLOUR}`)); return false; } - if(!isAccountEmailVerified(getPlayerData(client).accountData)) { + if (!isAccountEmailVerified(getPlayerData(client).accountData)) { messagePlayerError(client, getLocaleString(client, "NeedEmailVerifiedFor2FA")); messagePlayerTip(client, getLocaleString(client, "VerifyEmailHelpTip", `{ALTCOLOUR}/verifyemail{MAINCOLOUR}`)); return false; } } - if(!doesPlayerHaveTwoFactorAuthEnabled(client)) { + if (!doesPlayerHaveTwoFactorAuthEnabled(client)) { getPlayerData(client).accountData.settings = addBitFlag(getPlayerData(client).accountData.settings, flagValue); messagePlayerSuccess(client, getLocaleString(client, "TwoFactorAuthSet", `${getBoolRedGreenInlineColour(true)}${getLocaleString(client, "On")}{MAINCOLOUR}`)); logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} has toggled two-factor authentication ON for their account`); @@ -203,12 +203,12 @@ function toggleAccountTwoFactorAuthCommand(command, params, client) { // =========================================================================== function registerCommand(command, params, client) { - if(isPlayerRegistered(client)) { + if (isPlayerRegistered(client)) { messagePlayerError(client, getLocaleString(client, "AccountNameAlreadyRegistered")); return false; } - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -222,7 +222,7 @@ function registerCommand(command, params, client) { // =========================================================================== function changeAccountPasswordCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -230,12 +230,12 @@ function changeAccountPasswordCommand(command, params, client) { let oldPassword = getParam(params, " ", 1); let newPassword = getParam(params, " ", 2); - if(isAccountPasswordCorrect(getPlayerData(client).accountData, hashAccountPassword(getPlayerData(client).accountData.name, oldPassword))) { + if (isAccountPasswordCorrect(getPlayerData(client).accountData, hashAccountPassword(getPlayerData(client).accountData.name, oldPassword))) { messagePlayerError(client, `The old password is invalid!`); return false; } - if(!doesPasswordMeetRequirements(newPassword)) { + if (!doesPasswordMeetRequirements(newPassword)) { messagePlayerError(client, getLocaleString(client, "PasswordNotGoodEnough")); messagePlayerInfo(client, getLocaleString(client, "PasswordNeedsBase", `${getLocaleString(client, "PasswordNeedsCapitals", getGlobalConfig().passwordRequiredCapitals)}, ${getLocaleString(client, "PasswordNeedsSymbols", getGlobalConfig().passwordRequiredSymbols)}`)); return false; @@ -248,17 +248,17 @@ function changeAccountPasswordCommand(command, params, client) { // =========================================================================== function setAccountChatScrollLinesCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } - if(isNaN(params)) { + if (isNaN(params)) { messagePlayerError(client, getLocaleString(client, "ChatScrollLinesNotNumber")); return false; } - if(toInteger(params) < 1 || toInteger(params) > 6) { + if (toInteger(params) < 1 || toInteger(params) > 6) { messagePlayerError(client, getLocaleString(client, "ChatScrollLinesMustBeBetween", getGlobalConfig().minChatLines, getGlobalConfig().maxChatLines)); return false; } @@ -273,12 +273,12 @@ function setAccountChatScrollLinesCommand(command, params, client) { // =========================================================================== function setAccountChatAutoHideDelayCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } - if(isNaN(params)) { + if (isNaN(params)) { messagePlayerError(client, `The delay time must be a number!`); return false; } @@ -293,14 +293,14 @@ function setAccountChatAutoHideDelayCommand(command, params, client) { // =========================================================================== function setAccountEmailCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } let emailAddress = getParam(params, " ", 1); - if(!isValidEmailAddress(emailAddress)) { + if (!isValidEmailAddress(emailAddress)) { messagePlayerError(client, getLocaleString(client, "RegistrationFailedInvalidEmail")); return false; } @@ -310,7 +310,7 @@ function setAccountEmailCommand(command, params, client) { // return false; //} - if(getPlayerData(client).accountData.emailAddress != "" && isAccountEmailVerified(getPlayerData(client).accountData)) { + if (getPlayerData(client).accountData.emailAddress != "" && isAccountEmailVerified(getPlayerData(client).accountData)) { messagePlayerError(client, getLocaleString(client, "AccountEmailAlreadySetAndVerified")); return false; } @@ -330,19 +330,19 @@ function setAccountEmailCommand(command, params, client) { // =========================================================================== function verifyAccountEmailCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } let verificationCode = getParam(params, " ", 1); - if(isAccountEmailVerified(getPlayerData(client).accountData)) { + if (isAccountEmailVerified(getPlayerData(client).accountData)) { messagePlayerError(client, `You already verified your email!`); return false; } - if(module.hashing.sha512(verificationCode) != getPlayerData(client).accountData.emailVerificationCode) { + if (module.hashing.sha512(verificationCode) != getPlayerData(client).accountData.emailVerificationCode) { messagePlayerError(client, getLocaleString(client, "InvalidEmailVerificationCode")); let emailVerificationCode = generateEmailVerificationCode(); setAccountEmailVerificationCode(getPlayerData(client).accountData, emailVerificationCode); @@ -394,14 +394,14 @@ function setAccountDiscordCommand(command, params, client) { messagePlayerError(client, `This command is not yet finished and will be available soon!`); return false; - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } let discordName = getParam(params, " ", 1); - if(!isValidEmailAddress(emailAddress)) { + if (!isValidEmailAddress(emailAddress)) { messagePlayerError(client, `The discord '${discordName} is not valid!`); return false; } @@ -414,11 +414,11 @@ function setAccountDiscordCommand(command, params, client) { // =========================================================================== function isPlayerLoggedIn(client) { - if(isConsole(client)) { + if (isConsole(client)) { return true; } - if(getPlayerData(client) != null) { + if (getPlayerData(client) != null) { return getPlayerData(client).loggedIn; } @@ -428,12 +428,12 @@ function isPlayerLoggedIn(client) { // =========================================================================== function isPlayerRegistered(client) { - if(isConsole(client)) { + if (isConsole(client)) { return true; } - if(getPlayerData(client).accountData != false) { - if(getPlayerData(client).accountData.databaseId != 0) { + if (getPlayerData(client).accountData != false) { + if (getPlayerData(client).accountData.databaseId != 0) { return true; } } @@ -451,7 +451,7 @@ function doesPasswordMeetRequirements(password) { // =========================================================================== function isAccountPasswordCorrect(accountData, password) { - if(accountData.password == password) { + if (accountData.password == password) { return true; } @@ -462,15 +462,15 @@ function isAccountPasswordCorrect(accountData, password) { function loadAccountFromName(accountName, fullLoad = false) { let dbConnection = connectToDatabase(); - if(dbConnection) { + if (dbConnection) { accountName = escapeDatabaseString(dbConnection, accountName); let dbQueryString = `SELECT acct_main.*, acct_svr.* FROM acct_main INNER JOIN acct_svr ON acct_svr.acct_svr_acct = acct_main.acct_id AND acct_svr.acct_svr_svr = ${getServerId()} WHERE acct_name = '${accountName}' LIMIT 1;`; let dbQuery = queryDatabase(dbConnection, dbQueryString); - if(dbQuery) { - if(dbQuery.numRows > 0) { + if (dbQuery) { + if (dbQuery.numRows > 0) { let dbAssoc = fetchQueryAssoc(dbQuery); let tempAccountData = new AccountData(dbAssoc); - if(fullLoad) { + if (fullLoad) { tempAccountData.messages = loadAccountMessagesFromDatabase(tempAccountData.databaseId); tempAccountData.notes = loadAccountStaffNotesFromDatabase(tempAccountData.databaseId); tempAccountData.contacts = loadAccountContactsFromDatabase(tempAccountData.databaseId); @@ -489,14 +489,14 @@ function loadAccountFromName(accountName, fullLoad = false) { function loadAccountFromId(accountId, fullLoad = false) { let dbConnection = connectToDatabase(); - if(dbConnection) { + if (dbConnection) { let dbQueryString = `SELECT *, acct_ip AS ipstring FROM acct_main WHERE acct_id = ${accountId} LIMIT 1;`; let dbQuery = queryDatabase(dbConnection, dbQueryString); - if(dbQuery) { + if (dbQuery) { let dbAssoc = fetchQueryAssoc(dbQuery); let tempAccountData = new AccountData(dbAssoc); freeDatabaseQuery(dbQuery); - if(fullLoad) { + if (fullLoad) { tempAccountData.messages = loadAccountMessagesFromDatabase(tempAccountData.databaseId); tempAccountData.notes = loadAccountStaffNotesFromDatabase(tempAccountData.databaseId); tempAccountData.contacts = loadAccountContactsFromDatabase(tempAccountData.databaseId); @@ -513,7 +513,7 @@ function loadAccountFromId(accountId, fullLoad = false) { // =========================================================================== function getAccountHashingFunction() { - switch(toLowerCase(getGlobalConfig().accountPasswordHash)) { + switch (toLowerCase(getGlobalConfig().accountPasswordHash)) { case "md5": return module.hashing.md5; @@ -553,7 +553,7 @@ function getAccountHashingFunction() { function isNameRegistered(name) { let accountData = loadAccountFromName(name, true); - if(accountData.databaseId > 0) { + if (accountData.databaseId > 0) { return true; } @@ -582,19 +582,19 @@ function loginSuccess(client) { updateConnectionLogOnAuth(client, getPlayerData(client).accountData.databaseId); - if(doesPlayerHaveStaffPermission(client, "Developer") || doesPlayerHaveStaffPermission(client, "ManageServer")) { + if (doesPlayerHaveStaffPermission(client, "Developer") || doesPlayerHaveStaffPermission(client, "ManageServer")) { logToConsole(LOG_WARN, `[VRR.Account] ${getPlayerDisplayForConsole(client)} has needed permissions and is being given administrator access`); setPlayerNativeAdminState(client, true); } - if(doesServerHaveTesterOnlyEnabled()) { - if(!hasBitFlag(getPlayerData(client).accountData.flags.moderation, getModerationFlagValue("IsTester"))) { - setTimeout(function() { + if (doesServerHaveTesterOnlyEnabled()) { + if (!hasBitFlag(getPlayerData(client).accountData.flags.moderation, getModerationFlagValue("IsTester"))) { + setTimeout(function () { getPlayerData(client).customDisconnectReason = "Kicked - Not a tester"; disconnectPlayer(client); }, 3500); - if(doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) { + if (doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) { logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the error GUI (not a tester).`); showPlayerErrorGUI(client, getLocaleString(client, "NotATester"), getLocaleString(client, "AccessDenied")); return false; @@ -606,8 +606,8 @@ function loginSuccess(client) { } } - if(getPlayerData(client).subAccounts.length == 0) { - if(doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) { + if (getPlayerData(client).subAccounts.length == 0) { + if (doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) { showPlayerPrompt(client, getLocaleString(client, "NoCharactersGUIMessage"), getLocaleString(client, "NoCharactersGUIWindowTitle"), getLocaleString(client, "Yes"), getLocaleString(client, "No")); getPlayerData(client).promptType = VRR_PROMPT_CREATEFIRSTCHAR; logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the no characters prompt GUI`); @@ -639,7 +639,7 @@ function loginSuccess(client) { function saveAccountToDatabase(accountData) { let dbConnection = connectToDatabase(); - if(dbConnection) { + if (dbConnection) { logToConsole(LOG_VERBOSE, `Escaping account data for ${accountData.name}`); let safeAccountName = escapeDatabaseString(dbConnection, accountData.name); logToConsole(LOG_VERBOSE, `${accountData.name}'s name escaped successfully`); @@ -686,13 +686,13 @@ function saveAccountToDatabase(accountData) { // =========================================================================== function saveAccountKeyBindToDatabase(keyBindData) { - if(keyBindData.databaseId == -1) { + if (keyBindData.databaseId == -1) { // Keybind is a default or temporary keybind, don't save return false; } let dbConnection = connectToDatabase(); - if(dbConnection) { + if (dbConnection) { let safeCommandString = escapeDatabaseString(dbConnection, keyBindData.commandString); let data = [ @@ -705,7 +705,7 @@ function saveAccountKeyBindToDatabase(keyBindData) { ]; let dbQuery = null; - if(keyBindData.databaseId == 0) { + if (keyBindData.databaseId == 0) { let queryString = createDatabaseInsertQuery("acct_hotkey", data); dbQuery = queryDatabase(dbConnection, queryString); keyBindData.databaseId = getDatabaseInsertId(dbConnection); @@ -724,7 +724,7 @@ function saveAccountKeyBindToDatabase(keyBindData) { function saveAccountStaffNotesDatabase(staffNoteData) { let dbConnection = connectToDatabase(); - if(dbConnection) { + if (dbConnection) { let safeNoteContent = escapeDatabaseString(dbConnection, staffNoteData.note); let data = [ @@ -736,7 +736,7 @@ function saveAccountStaffNotesDatabase(staffNoteData) { ]; let dbQuery = null; - if(staffNoteData.databaseId == 0) { + if (staffNoteData.databaseId == 0) { let queryString = createDatabaseInsertQuery("acct_note", data); dbQuery = queryDatabase(dbConnection, queryString); staffNoteData.databaseId = getDatabaseInsertId(dbConnection); @@ -779,13 +779,13 @@ function saveAccountContactsToDatabase(accountContactData) { function createAccount(name, password, email = "") { let dbConnection = connectToDatabase(); - if(dbConnection) { + if (dbConnection) { let hashedPassword = hashAccountPassword(name, password); let safeName = escapeDatabaseString(dbConnection, name); let safeEmail = escapeDatabaseString(dbConnection, email); let dbQuery = queryDatabase(dbConnection, `INSERT INTO acct_main (acct_name, acct_pass, acct_email, acct_when_registered) VALUES ('${safeName}', '${hashedPassword}', '${safeEmail}', CURRENT_TIMESTAMP())`); - if(getDatabaseInsertId(dbConnection) > 0) { + if (getDatabaseInsertId(dbConnection) > 0) { let tempAccountData = loadAccountFromId(getDatabaseInsertId(dbConnection), false); createDefaultAccountServerData(tempAccountData.databaseId); tempAccountData.messages = loadAccountMessagesFromDatabase(tempAccountData.databaseId); @@ -801,15 +801,16 @@ function createAccount(name, password, email = "") { // =========================================================================== -function checkLogin(client, password) { - getPlayerData(client).loginAttemptsRemaining = getPlayerData(client).loginAttemptsRemaining-1; - if(getPlayerData(client).loginAttemptsRemaining <= 0) { +async function checkLogin(client, password) { + getPlayerData(client).loginAttemptsRemaining = getPlayerData(client).loginAttemptsRemaining - 1; + if (getPlayerData(client).loginAttemptsRemaining <= 0) { + getPlayerData(client).customDisconnectReason = "Kicked - Failed to login"; disconnectPlayer(client); } - if(isPlayerLoggedIn(client)) { + if (isPlayerLoggedIn(client)) { logToConsole(LOG_WARN, `[VRR.Account] ${getPlayerDisplayForConsole(client)} attempted to login but is already logged in`); - if(doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) { + if (doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) { showPlayerLoginSuccessGUI(client); } else { messagePlayerError(client, "You are already logged in!"); @@ -818,9 +819,9 @@ function checkLogin(client, password) { return false; } - if(!isPlayerRegistered(client)) { + if (!isPlayerRegistered(client)) { logToConsole(LOG_WARN, `[VRR.Account] ${getPlayerDisplayForConsole(client)} attempted to login but is not registered`); - if(doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) { + if (doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) { showPlayerRegistrationGUI(client); logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the register GUI`); } else { @@ -830,9 +831,9 @@ function checkLogin(client, password) { return false; } - if(areParamsEmpty(password)) { + if (areParamsEmpty(password)) { logToConsole(LOG_WARN, `[VRR.Account] ${getPlayerDisplayForConsole(client)} attempted to login but failed (empty password). ${getPlayerData(client).loginAttemptsRemaining} login attempts remaining`); - if(doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) { + if (doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) { showPlayerLoginFailedGUI(client, `Invalid password! ${getPlayerData(client).loginAttemptsRemaining} tries remaining.`); logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the login GUI with ${getPlayerData(client).loginAttemptsRemaining} login attempts remaining alert.`); } else { @@ -840,15 +841,16 @@ function checkLogin(client, password) { logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the login message (GUI disabled) with ${getPlayerData(client).loginAttemptsRemaining} login attempts remaining alert.`); } - if(isAccountEmailVerified(getPlayerData(client).accountData) && !isAccountSettingFlagEnabled(getPlayerData(client).accountData, getAccountSettingsFlagValue("AuthAttemptAlert"))) { - sendAccountLoginFailedNotification(getPlayerData(client).accountData.emailAddress, getPlayerName(client), getPlayerIP(client), getGame()); - } + // Disabling email login alerts for now. It hangs the server for a couple seconds. Need a way to thread it. + //if (isAccountEmailVerified(getPlayerData(client).accountData) && !isAccountSettingFlagEnabled(getPlayerData(client).accountData, getAccountSettingsFlagValue("AuthAttemptAlert"))) { + // await sendAccountLoginFailedNotification(getPlayerData(client).accountData.emailAddress, getPlayerName(client), getPlayerIP(client), getGame()); + //} return false; } - if(!isAccountPasswordCorrect(getPlayerData(client).accountData, hashAccountPassword(getPlayerName(client), password))) { + if (!isAccountPasswordCorrect(getPlayerData(client).accountData, hashAccountPassword(getPlayerName(client), password))) { logToConsole(LOG_WARN, `[VRR.Account] ${getPlayerDisplayForConsole(client)} attempted to login but failed (wrong password). ${getPlayerData(client).loginAttemptsRemaining} login attempts remaining`); - if(doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) { + if (doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) { showPlayerLoginFailedGUI(client, `Invalid password! ${getPlayerData(client).loginAttemptsRemaining} tries remaining.`); logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the login GUI with ${getPlayerData(client).loginAttemptsRemaining} login attempts remaining alert.`); } else { @@ -856,28 +858,30 @@ function checkLogin(client, password) { logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the login message (GUI disabled) with ${getPlayerData(client).loginAttemptsRemaining} login attempts remaining alert.`); } - if(isAccountEmailVerified(getPlayerData(client).accountData) && !isAccountSettingFlagEnabled(getPlayerData(client).accountData, getAccountSettingsFlagValue("AuthAttemptAlert"))) { - sendAccountLoginFailedNotification(getPlayerData(client).accountData.emailAddress, getPlayerName(client), getPlayerIP(client), getGame()); - } + // Disabling email login alerts for now. It hangs the server for a couple seconds. Need a way to thread it. + //if (isAccountEmailVerified(getPlayerData(client).accountData) && !isAccountSettingFlagEnabled(getPlayerData(client).accountData, getAccountSettingsFlagValue("AuthAttemptAlert"))) { + // await sendAccountLoginFailedNotification(getPlayerData(client).accountData.emailAddress, getPlayerName(client), getPlayerIP(client), getGame()); + //} return false; } - if(doesPlayerHaveTwoFactorAuthEnabled(client) && checkForSMTPModule() && getEmailConfig().enabled) { + if (doesPlayerHaveTwoFactorAuthEnabled(client) && checkForSMTPModule() && getEmailConfig().enabled) { getPlayerData(client).twoFactorAuthCode = toUpperCase(generateRandomString(6)); showPlayerTwoFactorAuthenticationGUI(client); sendAccountTwoFactorAuthCode(getPlayerData(client).accountData.emailAddress, getPlayerName(client), getPlayerData(client).twoFactorAuthCode); return true; } - if(doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) { + if (doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) { showPlayerLoginSuccessGUI(client); } loginSuccess(client); - if(isAccountEmailVerified(getPlayerData(client).accountData) && !isAccountSettingFlagEnabled(getPlayerData(client).accountData, getAccountSettingsFlagValue("AuthAttemptAlert"))) { - sendAccountLoginSuccessNotification(getPlayerData(client).accountData.emailAddress, getPlayerName(client), getPlayerIP(client), getGame()); - } + // Disabling email login alerts for now. It hangs the server for a couple seconds. Need a way to thread it. + //if (isAccountEmailVerified(getPlayerData(client).accountData) && !isAccountSettingFlagEnabled(getPlayerData(client).accountData, getAccountSettingsFlagValue("AuthAttemptAlert"))) { + // await sendAccountLoginSuccessNotification(getPlayerData(client).accountData.emailAddress, getPlayerName(client), getPlayerIP(client), getGame()); + //} } // =========================================================================== @@ -885,8 +889,8 @@ function checkLogin(client, password) { function checkRegistration(client, password, confirmPassword = "", emailAddress = "") { logToConsole(LOG_DEBUG, `[VRR.Account]: Checking registration for ${getPlayerName(client)}`); - if(isPlayerRegistered(client)) { - if(doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) { + if (isPlayerRegistered(client)) { + if (doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) { showPlayerLoginGUI(client); } else { messagePlayerError(client, getLocaleString(client, "AlreadyRegistered")); @@ -895,8 +899,8 @@ function checkRegistration(client, password, confirmPassword = "", emailAddress return false; } - if(isPlayerLoggedIn(client)) { - if(doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) { + if (isPlayerLoggedIn(client)) { + if (doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) { showPlayerLoginSuccessGUI(client); } else { messagePlayerError(client, getLocaleString(client, "AlreadyLoggedIn")); @@ -905,8 +909,8 @@ function checkRegistration(client, password, confirmPassword = "", emailAddress return false; } - if(areParamsEmpty(password)) { - if(doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) { + if (areParamsEmpty(password)) { + if (doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) { showPlayerRegistrationFailedGUI(client, getLocaleString(client, "RegistrationFailedNoPassword")); logToConsole(LOG_WARN, `${getPlayerDisplayForConsole(client)} failed to create an account (password is blank)`); } else { @@ -916,32 +920,32 @@ function checkRegistration(client, password, confirmPassword = "", emailAddress return false; } - if(doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) { - if(areParamsEmpty(confirmPassword)) { + if (doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) { + if (areParamsEmpty(confirmPassword)) { showPlayerRegistrationFailedGUI(client, getLocaleString(client, "RegistrationFailedNoPasswordConfirm")); logToConsole(LOG_WARN, `${getPlayerDisplayForConsole(client)} failed to create an account (password confirm is blank)`); return false; } } - if(doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) { - if(areParamsEmpty(emailAddress)) { + if (doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) { + if (areParamsEmpty(emailAddress)) { showPlayerRegistrationFailedGUI(client, getLocaleString(client, "RegistrationFailedNoEmail")); logToConsole(LOG_WARN, `${getPlayerDisplayForConsole(client)} failed to create an account (email address is blank)`); return false; } } - if(doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) { - if(password != confirmPassword) { + if (doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) { + if (password != confirmPassword) { showPlayerRegistrationFailedGUI(client, getLocaleString(client, "RegistrationFailedPasswordMismatch")); logToConsole(LOG_WARN, `${getPlayerDisplayForConsole(client)} failed to create an account (password and confirm don't match)`); return false; } } - if(!doesPasswordMeetRequirements(password)) { - if(doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) { + if (!doesPasswordMeetRequirements(password)) { + if (doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) { // Work on this later. Function should return true by default anyway for now. showPlayerRegistrationFailedGUI(client, getLocaleString(client, "RegistrationFailedNoPasswordWeak")); logToConsole(LOG_WARN, `${getPlayerDisplayForConsole(client)} failed to create an account (password doesn't meet requirements)`); @@ -951,16 +955,16 @@ function checkRegistration(client, password, confirmPassword = "", emailAddress return false; } - if(doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) { - if(!isValidEmailAddress(emailAddress)) { + if (doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) { + if (!isValidEmailAddress(emailAddress)) { showPlayerRegistrationFailedGUI(client, getLocaleString(client, "RegistrationFailedInvalidEmail")); return false; } } let accountData = createAccount(getPlayerName(client), password, emailAddress); - if(!accountData) { - if(doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) { + if (!accountData) { + if (doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) { showPlayerRegistrationFailedGUI(client, getLocaleString(client, "RegistrationFailedCreateError")); } else { messagePlayerAlert(client, getLocaleString(client, "RegistrationFailedCreateError")); @@ -974,7 +978,7 @@ function checkRegistration(client, password, confirmPassword = "", emailAddress getPlayerData(client).loggedIn = true; messagePlayerSuccess(client, getLocaleString(client, "RegistrationSuccess")); - if(checkForSMTPModule() && getEmailConfig().enabled) { + if (checkForSMTPModule() && getEmailConfig().enabled) { messagePlayerAlert(client, getLocaleString(client, "RegistrationEmailVerifyReminder")); let emailVerificationCode = generateEmailVerificationCode(); setAccountEmailVerificationCode(getPlayerData(client).accountData, emailVerificationCode); @@ -982,12 +986,13 @@ function checkRegistration(client, password, confirmPassword = "", emailAddress logToConsole(LOG_WARN, `${getPlayerDisplayForConsole(client)} was sent a registration email verification code`); } - if(doesServerHaveTesterOnlyEnabled() && !isPlayerATester(client)) { - setTimeout(function() { + if (doesServerHaveTesterOnlyEnabled() && !isPlayerATester(client)) { + setTimeout(function () { + getPlayerData(client).customDisconnectReason = "Kicked - Not a tester"; disconnectPlayer(client); }, 5000); - if(doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) { + if (doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) { logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the error GUI (not a tester).`); showPlayerErrorGUI(client, getLocaleString(client, "NotATester"), getLocaleString(client, "AccessDenied")); return false; @@ -999,7 +1004,7 @@ function checkRegistration(client, password, confirmPassword = "", emailAddress } else { messagePlayerAlert(client, getLocaleString(client, "RegistrationCreateCharReminder")); - if(doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) { + if (doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) { showPlayerRegistrationSuccessGUI(client); showPlayerPrompt(client, getLocaleString(client, "NoCharactersMessage"), getLocaleString(client, "NoCharactersWindowTitle"), getLocaleString(client, "Yes"), getLocaleString(client, "No")); getPlayerData(client).promptType = VRR_PROMPT_CREATEFIRSTCHAR; @@ -1012,14 +1017,14 @@ function checkRegistration(client, password, confirmPassword = "", emailAddress // =========================================================================== function checkAccountResetPasswordRequest(client, inputText) { - if(!checkForSMTPModule() || !getEmailConfig().enabled) { + if (!checkForSMTPModule() || !getEmailConfig().enabled) { return false; } - switch(getPlayerData(client).passwordResetState) { + switch (getPlayerData(client).passwordResetState) { case VRR_RESETPASS_STATE_EMAILCONFIRM: { - if(toLowerCase(getPlayerData(client).accountData.emailAddress) != toLowerCase(inputText)) { - logToConsole(LOG_INFO|LOG_WARN, `${getPlayerDisplayForConsole(client)} failed to reset their password (email not correct)`); + if (toLowerCase(getPlayerData(client).accountData.emailAddress) != toLowerCase(inputText)) { + logToConsole(LOG_INFO | LOG_WARN, `${getPlayerDisplayForConsole(client)} failed to reset their password (email not correct)`); showPlayerErrorGUI(client, getLocaleString(client, "GUIErrorResetPasswordFailedInvalidEmail"), getLocaleString(client, "GUIErrorTitle"), getLocaleString(client, "GUIOkButton")); return false; } @@ -1029,22 +1034,23 @@ function checkAccountResetPasswordRequest(client, inputText) { getPlayerData(client).passwordResetCode = passwordResetCode; showPlayerResetPasswordCodeInputGUI(client); sendPasswordResetEmail(client, passwordResetCode); - logToConsole(LOG_INFO, `${getPlayerDisplayForConsole(client)} submitted successful email for password reset. Sending email and awaiting verification code input ...`); + logToConsole(LOG_INFO, `${getPlayerDisplayForConsole(client)} submitted successful email for password reset. Sending email and awaiting verification code input (${passwordResetCode}) ...`); break; } case VRR_RESETPASS_STATE_CODEINPUT: { - if(inputText != "") { - if(getPlayerData(client).passwordResetCode == toUpperCase(inputText)) { + logToConsole(LOG_INFO, `${getPlayerDisplayForConsole(client)} submitted code for password reset (${inputText}) ...`); + if (inputText != "") { + if (getPlayerData(client).passwordResetCode == toUpperCase(inputText)) { getPlayerData(client).passwordResetState = VRR_RESETPASS_STATE_SETPASS; - showPlayerChangePasswordGUI(client, getLocaleString(client)); + showPlayerChangePasswordGUI(client); logToConsole(LOG_INFO, `${getPlayerDisplayForConsole(client)} entered the correct reset password verification code. Awaiting new password input ...`); } else { - getPlayerData(client).passwordResetState = VRR_RESETPASS_STATE_NONE; getPlayerData(client).passwordResetAttemptsRemaining = getPlayerData(client).passwordResetAttemptsRemaining - 1; - logToConsole(LOG_INFO|LOG_WARN, `${getPlayerDisplayForConsole(client)} failed to reset their password (verification code not correct, ${getPlayerData(client).passwordResetAttemptsRemaining} attempts remaining)`); - if(getPlayerData(client).passwordResetAttemptsRemaining <= 0) { - logToConsole(LOG_INFO|LOG_WARN, `${getPlayerDisplayForConsole(client)} failed to reset their password (verification code not correct, no more attempts remaining, kicking ...)`); + logToConsole(LOG_INFO | LOG_WARN, `${getPlayerDisplayForConsole(client)} failed to reset their password (verification code not correct, ${getPlayerData(client).passwordResetAttemptsRemaining} attempts remaining)`); + if (getPlayerData(client).passwordResetAttemptsRemaining <= 0) { + logToConsole(LOG_INFO | LOG_WARN, `${getPlayerDisplayForConsole(client)} failed to reset their password (verification code not correct, no more attempts remaining, kicking ...)`); + getPlayerData(client).customDisconnectReason = "Kicked - Failed to login"; disconnectPlayer(client); return false; } @@ -1067,11 +1073,11 @@ function checkAccountResetPasswordRequest(client, inputText) { // =========================================================================== function checkAccountChangePassword(client, newPassword, confirmNewPassword) { - if(!isPlayerLoggedIn(client)) { - if(getPlayerData(client).passwordResetState != VRR_RESETPASS_STATE_SETPASS) { + if (!isPlayerLoggedIn(client)) { + if (getPlayerData(client).passwordResetState != VRR_RESETPASS_STATE_SETPASS) { //getPlayerData(client).passwordResetState = VRR_RESETPASS_STATE_NONE; //disconnectPlayer(client); - logToConsole(LOG_DEBUG|LOG_WARN, `${getPlayerDisplayForConsole(client)} failed to change their password (not logged in or not using reset password)`); + logToConsole(LOG_DEBUG | LOG_WARN, `${getPlayerDisplayForConsole(client)} failed to change their password (not logged in or not using reset password)`); return false; } } @@ -1081,7 +1087,7 @@ function checkAccountChangePassword(client, newPassword, confirmNewPassword) { // return false; //} - if(!doesPasswordMeetRequirements(newPassword)) { + if (!doesPasswordMeetRequirements(newPassword)) { let passwordRequirementsString = `${needsCapitals}, ${needsNumbers}, ${needsSymbols}`; let needsCapitals = getLocaleString(client, "PasswordNeedsCapitals", "1"); let needsNumbers = getLocaleString(client, "PasswordNeedsNumbers", "1"); @@ -1089,13 +1095,13 @@ function checkAccountChangePassword(client, newPassword, confirmNewPassword) { messagePlayerError(client, getLocaleString(client, "AccountPasswordNeedsImproved")); messagePlayerInfo(client, getLocaleString(client, "PasswordNeedsBase", passwordRequirementsString)); - logToConsole(LOG_DEBUG|LOG_WARN, `${getPlayerDisplayForConsole(client)} failed to change their password (password doesn't mean requirements)`); + logToConsole(LOG_DEBUG | LOG_WARN, `${getPlayerDisplayForConsole(client)} failed to change their password (password doesn't mean requirements)`); return false; } - if(newPassword != confirmNewPassword) { + if (newPassword != confirmNewPassword) { messagePlayerError(client, getLocaleString(client, "PasswordsDontMatch")); - logToConsole(LOG_DEBUG|LOG_WARN, `${getPlayerDisplayForConsole(client)} failed to change their password (password and confirm don't match)`); + logToConsole(LOG_DEBUG | LOG_WARN, `${getPlayerDisplayForConsole(client)} failed to change their password (password and confirm don't match)`); return false; } @@ -1105,7 +1111,7 @@ function checkAccountChangePassword(client, newPassword, confirmNewPassword) { saveAccountToDatabase(getPlayerData(client).accountData); - if(getPlayerData(client).passwordResetState == VRR_RESETPASS_STATE_SETPASS) { + if (getPlayerData(client).passwordResetState == VRR_RESETPASS_STATE_SETPASS) { getPlayerData(client).passwordResetState = VRR_RESETPASS_STATE_NONE; } @@ -1123,7 +1129,7 @@ function isValidEmailAddress(emailAddress) { function saveAllPlayersToDatabase() { logToConsole(LOG_DEBUG, "[VRR.Account]: Saving all clients to database ..."); - getClients().forEach(function(client) { + getClients().forEach(function (client) { savePlayerToDatabase(client); }); logToConsole(LOG_DEBUG, "[VRR.Account]: All clients saved to database successfully!"); @@ -1132,22 +1138,22 @@ function saveAllPlayersToDatabase() { // =========================================================================== function savePlayerToDatabase(client) { - if(getPlayerData(client) == null) { + if (getPlayerData(client) == null) { return false; } - if(!isPlayerLoggedIn(client)) { + if (!isPlayerLoggedIn(client)) { return false; } logToConsole(LOG_DEBUG, `[VRR.Account]: Saving client ${getPlayerName(client)} to database ...`); saveAccountToDatabase(getPlayerData(client).accountData); - if(getPlayerData(client).currentSubAccount != -1) { + if (getPlayerData(client).currentSubAccount != -1) { //let subAccountData = getPlayerCurrentSubAccount(client); - if(getPlayerPed(client) != null) { - if(getPlayerData(client).returnToPosition != null && getPlayerData(client).returnToType != VRR_RETURNTO_TYPE_ADMINGET) { + if (getPlayerPed(client) != null) { + if (getPlayerData(client).returnToPosition != null && getPlayerData(client).returnToType != VRR_RETURNTO_TYPE_ADMINGET) { getPlayerCurrentSubAccount(client).spawnPosition = getPlayerData(client).returnToPosition; getPlayerCurrentSubAccount(client).spawnHeading = getPlayerData(client).returnToHeading.z; getPlayerCurrentSubAccount(client).interior = getPlayerData(client).returnToInterior; @@ -1171,15 +1177,15 @@ function savePlayerToDatabase(client) { function initClient(client) { logToConsole(LOG_DEBUG, `[VRR.Account] Initializing client ${getPlayerDisplayForConsole(client)} ...`); - if(isConsole(client)) { - logToConsole(LOG_DEBUG|LOG_ERROR, `[VRR.Account] Client initialization failed for ${getPlayerDisplayForConsole(client)}! (is console client)`); + if (isConsole(client)) { + logToConsole(LOG_DEBUG | LOG_ERROR, `[VRR.Account] Client initialization failed for ${getPlayerDisplayForConsole(client)}! (is console client)`); return false; } logToConsole(LOG_DEBUG, `[VRR.Account] Initializing client ${getPlayerDisplayForConsole(client)} ...`); - if(playerInitialized[client.index] == true) { - logToConsole(LOG_DEBUG|LOG_ERROR, `[VRR.Account] Client initialization failed for ${getPlayerDisplayForConsole(client)}! (already initialized)`); + if (playerInitialized[client.index] == true) { + logToConsole(LOG_DEBUG | LOG_ERROR, `[VRR.Account] Client initialization failed for ${getPlayerDisplayForConsole(client)}! (already initialized)`); return false; } @@ -1191,14 +1197,14 @@ function initClient(client) { sendPlayerGUIInit(client); updatePlayerSnowState(client); - logToConsole(LOG_DEBUG, `[VRR.Account] Showing connect camera to ${getPlayerDisplayForConsole(client)} ...`); - showConnectCameraToPlayer(client); + //logToConsole(LOG_DEBUG, `[VRR.Account] Showing connect camera to ${getPlayerDisplayForConsole(client)} ...`); + //showConnectCameraToPlayer(client); messageClient(`Please wait ...`, client, getColourByName("softGreen")); logToConsole(LOG_DEBUG, `[VRR.Account] Waiting for 2.5 seconds to prevent race attack ...`); - setTimeout(function() { - if(client != null) { + setTimeout(function () { + if (client != null) { clearChatBox(client); logToConsole(LOG_DEBUG, `[VRR.Account] Loading account for ${getPlayerDisplayForConsole(client)}`); let tempAccountData = loadAccountFromName(getPlayerName(client), true); @@ -1212,19 +1218,19 @@ function initClient(client) { getServerData().clients[getPlayerId(client)].connectTime = getCurrentUnixTimestamp(); requestClientInfo(client); - if(tempAccountData != false) { + if (tempAccountData != false) { sendPlayerLocaleId(client, getPlayerData(client).accountData.locale); - if(isAccountAutoIPLoginEnabled(tempAccountData) && getPlayerData(client).accountData.ipAddress == getPlayerIP(client)) { + if (isAccountAutoIPLoginEnabled(tempAccountData) && getPlayerData(client).accountData.ipAddress == getPlayerIP(client)) { messagePlayerAlert(client, getLocaleString(client, "AutoLoggedInIP")); loginSuccess(client); playRadioStreamForPlayer(client, getServerIntroMusicURL(), true, getPlayerStreamingRadioVolume(client)); } else { - if(doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) { + if (doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) { logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the login GUI.`); showPlayerLoginGUI(client); } else { logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the login message (GUI disabled).`); - messagePlayerNormal(client, getLocaleString(client, "WelcomeBack", getServerName(), getPlayerName(client), "/login"),getColourByName("softGreen")); + messagePlayerNormal(client, getLocaleString(client, "WelcomeBack", getServerName(), getPlayerName(client), "/login"), getColourByName("softGreen")); //if(checkForGeoIPModule()) { // let iso = module.geoip.getCountryISO(getPlayerIP(client)); @@ -1236,7 +1242,7 @@ function initClient(client) { } } else { sendPlayerLocaleId(client, 0); - if(doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) { + if (doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) { logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the register GUI.`); showPlayerRegistrationGUI(client); } else { @@ -1248,8 +1254,6 @@ function initClient(client) { getServerData().clients[getPlayerId(client)].keyBinds = loadAccountKeybindsFromDatabase(getServerData().clients[getPlayerId(client)].accountData.databaseId); sendAccountKeyBindsToClient(client); - - } }, 2500); @@ -1259,7 +1263,7 @@ function initClient(client) { function saveConnectionToDatabase(client) { let dbConnection = connectToDatabase(); - if(dbConnection) { + if (dbConnection) { let safeName = escapeDatabaseString(dbConnection, getPlayerName(client)); let dbQueryString = `INSERT INTO conn_main (conn_when_connect, conn_server, conn_script_version, conn_game_version, conn_client_version, conn_name, conn_ip) VALUES (NOW(), ${getServerConfig().databaseId}, '${scriptVersion}', '${getPlayerGameVersion(client)}', '0.0.0', '${safeName}', '${getPlayerIP(client)}')`; queryDatabase(dbConnection, dbQueryString); @@ -1271,7 +1275,7 @@ function saveConnectionToDatabase(client) { // =========================================================================== function createDefaultAccountServerData(accountDatabaseId) { - for(let i = 1 ; i <= 5 ; i++) { + for (let i = 1; i <= 5; i++) { let dbQueryString = `INSERT INTO acct_svr (acct_svr_acct, acct_svr_svr) VALUES (${accountDatabaseId}, ${i})`; quickDatabaseQuery(dbQueryString); } @@ -1287,7 +1291,7 @@ function loadAccountKeybindsFromDatabase(accountDatabaseID) { let dbQuery = null; let dbAssoc; - for(let i in getGlobalConfig().keyBind.defaultKeyBinds) { + for (let i in getGlobalConfig().keyBind.defaultKeyBinds) { let tempKeyBindData = new KeyBindData(false); tempKeyBindData.databaseId = -1; tempKeyBindData.key = getKeyIdFromParams(getGlobalConfig().keyBind.defaultKeyBinds[i].keyName); @@ -1296,12 +1300,12 @@ function loadAccountKeybindsFromDatabase(accountDatabaseID) { tempAccountKeybinds.push(tempKeyBindData); } - if(accountDatabaseID != 0 && typeof accountDatabaseId != "undefined") { - if(dbConnection) { + if (accountDatabaseID != 0 && typeof accountDatabaseId != "undefined") { + 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)) { + if (dbQuery) { + if (dbQuery.numRows > 0) { + while (dbAssoc = fetchQueryAssoc(dbQuery)) { 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!`); @@ -1327,11 +1331,11 @@ function loadAccountStaffNotesFromDatabase(accountDatabaseID) { let dbQuery = null; let dbAssoc; - if(dbConnection) { + if (dbConnection) { dbQuery = queryDatabase(dbConnection, "SELECT * FROM `acct_note` WHERE `acct_note_deleted` = 0 AND `acct_note_acct` = " + toString(accountDatabaseID)); - if(dbQuery) { - if(dbQuery.numRows > 0) { - while(dbAssoc = fetchQueryAssoc(dbQuery)) { + if (dbQuery) { + if (dbQuery.numRows > 0) { + while (dbAssoc = fetchQueryAssoc(dbQuery)) { let tempAccountStaffNoteData = new AccountStaffNoteData(dbAssoc); tempAccountStaffNotes.push(tempAccountStaffNoteData); logToConsole(LOG_DEBUG, `[VRR.Account]: Account staff note '${tempAccountStaffNoteData.databaseId}' loaded from database successfully!`); @@ -1356,11 +1360,11 @@ function loadAccountContactsFromDatabase(accountDatabaseID) { let dbQuery = null; let dbAssoc; - if(dbConnection) { + if (dbConnection) { dbQuery = queryDatabase(dbConnection, "SELECT * FROM `acct_contact` WHERE `acct_contact_deleted` = 0 AND `acct_contact_acct` = " + toString(accountDatabaseID)); - if(dbQuery) { - if(dbQuery.numRows > 0) { - while(dbAssoc = fetchQueryAssoc(dbQuery)) { + if (dbQuery) { + if (dbQuery.numRows > 0) { + while (dbAssoc = fetchQueryAssoc(dbQuery)) { let tempAccountContactData = new AccountContactData(dbAssoc); tempAccountContacts.push(tempAccountContactData); logToConsole(LOG_DEBUG, `[VRR.Account]: Account contact '${tempAccountContactData.databaseId}' loaded from database successfully!`); @@ -1385,11 +1389,11 @@ function loadAccountMessagesFromDatabase(accountDatabaseID) { let dbQuery = null; let dbAssoc; - if(dbConnection) { + if (dbConnection) { dbQuery = queryDatabase(dbConnection, "SELECT * FROM `acct_msg` WHERE `acct_msg_deleted` = 0 AND `acct_msg_acct` = " + toString(accountDatabaseID)); - if(dbQuery) { - if(dbQuery.numRows > 0) { - while(dbAssoc = fetchQueryAssoc(dbQuery)) { + if (dbQuery) { + if (dbQuery.numRows > 0) { + while (dbAssoc = fetchQueryAssoc(dbQuery)) { let tempAccountMessageData = new AccountContactData(dbAssoc); tempAccountMessages.push(tempAccountMessageData); logToConsole(LOG_DEBUG, `[VRR.Account]: Account contact '${tempAccountMessageData.databaseId}' loaded from database successfully!`); @@ -1523,7 +1527,7 @@ function sendAccountLoginFailedNotification(emailAddress, name, ip, game = getGa emailBodyText = emailBodyText.replace("{IPADDRESS}", ip); emailBodyText = emailBodyText.replace("{LOCATION}", `${cityName}, ${subDivisionName}, ${countryName}`); emailBodyText = emailBodyText.replace("{SERVERNAME}", getServerName()); - emailBodyText = emailBodyText.replace("{TIMESTAMP}", date.toLocaleString('en-US')); + emailBodyText = emailBodyText.replace("{TIMESTAMP}", new Date().toLocaleString('en-US')); sendEmail(emailAddress, name, `Login failed on ${getServerName()}`, emailBodyText); return true; @@ -1541,9 +1545,9 @@ function sendAccountLoginSuccessNotification(emailAddress, name, ip, game = getG emailBodyText = emailBodyText.replace("{IPADDRESS}", ip); emailBodyText = emailBodyText.replace("{LOCATION}", `${cityName}, ${subDivisionName}, ${countryName}`); emailBodyText = emailBodyText.replace("{SERVERNAME}", getServerName()); - emailBodyText = emailBodyText.replace("{TIMESTAMP}", date.toLocaleString('en-US')); + emailBodyText = emailBodyText.replace("{TIMESTAMP}", new Date().toLocaleString('en-US')); - sendEmail(emailAddress, name, `Login failed on ${getServerName()}`, emailBodyText); + sendEmail(emailAddress, name, `Login successful on ${getServerName()}`, emailBodyText); return true; } @@ -1562,13 +1566,14 @@ function doesPlayerHaveRandomTipsDisabled(client) { // =========================================================================== function checkPlayerTwoFactorAuthentication(client, authCode) { - if(getPlayerData(client).twoFactorAuthCode != "") { - if(toUpperCase(getPlayerData(client).twoFactorAuthCode) == toUpperCase(authCode)) { + if (getPlayerData(client).twoFactorAuthCode != "") { + if (toUpperCase(getPlayerData(client).twoFactorAuthCode) == toUpperCase(authCode)) { loginSuccess(client); return true; } } + getPlayerData(client).customDisconnectReason = "Kicked - Failed to login"; disconnectPlayer(client); return false; } diff --git a/scripts/server/ban.js b/scripts/server/ban.js index 6f42cd31..2eacd1ff 100644 --- a/scripts/server/ban.js +++ b/scripts/server/ban.js @@ -15,7 +15,7 @@ function initBanScript() { // =========================================================================== function accountBanCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -24,28 +24,30 @@ function accountBanCommand(command, params, client) { let targetClient = getPlayerFromParams(getParam(params, " ", 1)); let reason = splitParams.slice(1).join(" "); - if(!targetClient) { + if (!targetClient) { messagePlayerError(client, "That player is not connected!") return false; } // Prevent banning admins with really high permissions - if(doesPlayerHaveStaffPermission(targetClient, "ManageServer") || doesPlayerHaveStaffPermission(targetClient, "Developer")) { + if (doesPlayerHaveStaffPermission(targetClient, "ManageServer") || doesPlayerHaveStaffPermission(targetClient, "Developer")) { messagePlayerError(client, getLocaleString(client, "CantBanPlayer")); return false; } logToConsole(LOG_WARN, `[VRR.Ban]: ${getPlayerDisplayForConsole(targetClient)} (${getPlayerData(targetClient).accountData.name}) account was banned by ${getPlayerDisplayForConsole(client)}. Reason: ${reason}`); - announceAdminAction(`PlayerAccountBanned`, `{ALTCOLOUR}${getPlayerName(client)}{MAINCOLOUR}`); + announceAdminAction(`PlayerAccountBanned`, `{ALTCOLOUR}${getPlayerName(targetClient)}{MAINCOLOUR}`); banAccount(getPlayerData(targetClient).accountData.databaseId, getPlayerData(client).accountData.databaseId, reason); - disconnectPlayer(client); + + getPlayerData(targetClient).customDisconnectReason = `Banned - ${reason}`; + disconnectPlayer(targetClient); } // =========================================================================== function subAccountBanCommand(command, params, client, fromDiscord) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -54,29 +56,30 @@ function subAccountBanCommand(command, params, client, fromDiscord) { let targetClient = getPlayerFromParams(getParam(params, " ", 1)); let reason = splitParams.slice(1).join(" "); - if(!targetClient) { + if (!targetClient) { messagePlayerError(client, "That player is not connected!") return false; } // Prevent banning admins with really high permissions - if(doesPlayerHaveStaffPermission(targetClient, "ManageServer") || doesPlayerHaveStaffPermission(targetClient, "Developer")) { + if (doesPlayerHaveStaffPermission(targetClient, "ManageServer") || doesPlayerHaveStaffPermission(targetClient, "Developer")) { messagePlayerError(client, getLocaleString(client, "CantBanPlayer")); return false; } logToConsole(LOG_WARN, `[VRR.Ban]: ${getPlayerDisplayForConsole(targetClient)} (${getPlayerData(targetClient).accountData.name})'s subaccount was banned by ${getPlayerDisplayForConsole(client)}. Reason: ${reason}`); - announceAdminAction(`PlayerCharacterBanned`, `{ALTCOLOUR}${getPlayerName(client)}{MAINCOLOUR}`); + announceAdminAction(`PlayerCharacterBanned`, `{ALTCOLOUR}${getPlayerName(targetClient)}{MAINCOLOUR}`); banSubAccount(getPlayerData(targetClient).currentSubAccountData.databaseId, getPlayerData(client).accountData.databaseId, reason); - disconnectPlayer(client); + getPlayerData(targetClient).customDisconnectReason = `Banned - ${reason}`; + disconnectPlayer(targetClient); } // =========================================================================== function ipBanCommand(command, params, client, fromDiscord) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -85,13 +88,13 @@ function ipBanCommand(command, params, client, fromDiscord) { let targetClient = getPlayerFromParams(getParam(params, " ", 1)); let reason = splitParams.slice(1).join(" "); - if(!targetClient) { + if (!targetClient) { messagePlayerError(client, "That player is not connected!") return false; } // Prevent banning admins with really high permissions - if(doesPlayerHaveStaffPermission(targetClient, "ManageServer") || doesPlayerHaveStaffPermission(targetClient, "Developer")) { + if (doesPlayerHaveStaffPermission(targetClient, "ManageServer") || doesPlayerHaveStaffPermission(targetClient, "Developer")) { messagePlayerError(client, getLocaleString(client, "CantBanPlayer")); return false; } @@ -99,6 +102,7 @@ function ipBanCommand(command, params, client, fromDiscord) { announceAdminAction(`PlayerIPBanned`, `{ALTCOLOUR}${getPlayerName(targetClient)}{MAINCOLOUR}`); banIPAddress(getPlayerIP(targetClient), getPlayerData(client).accountData.databaseId, reason); + getPlayerData(targetClient).customDisconnectReason = `IP Banned - ${reason}`; serverBanIP(getPlayerIP(targetClient)); disconnectPlayer(targetClient); } @@ -106,7 +110,7 @@ function ipBanCommand(command, params, client, fromDiscord) { // =========================================================================== function subNetBanCommand(command, params, client, fromDiscord) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -116,13 +120,13 @@ function subNetBanCommand(command, params, client, fromDiscord) { let octetAmount = Number(getParam(params, " ", 2)); let reason = splitParams.slice(2).join(" "); - if(!targetClient) { + if (!targetClient) { messagePlayerError(client, "That player is not connected!") return false; } // Prevent banning admins with really high permissions - if(doesPlayerHaveStaffPermission(targetClient, "ManageServer") || doesPlayerHaveStaffPermission(targetClient, "Developer")) { + if (doesPlayerHaveStaffPermission(targetClient, "ManageServer") || doesPlayerHaveStaffPermission(targetClient, "Developer")) { messagePlayerError(client, getLocaleString(client, "CantBanPlayer")); return false; } @@ -130,6 +134,7 @@ function subNetBanCommand(command, params, client, fromDiscord) { announceAdminAction(`PlayerSubNetBanned`, `{ALTCOLOUR}${getPlayerName(client)}{MAINCOLOUR}`); banSubNet(getPlayerIP(targetClient), getSubNet(getPlayerIP(targetClient), octetAmount), getPlayerData(client).accountData.databaseId, reason); + getPlayerData(client).customDisconnectReason = `IP Subnet Banned - ${reason}`; serverBanIP(getPlayerIP(targetClient)); } @@ -137,7 +142,7 @@ function subNetBanCommand(command, params, client, fromDiscord) { function banAccount(accountId, adminAccountId, reason) { let dbConnection = connectToDatabase(); - if(dbConnection) { + if (dbConnection) { let safeReason = dbConnection.escapetoString(reason); let dbQuery = queryDatabase(dbConnection, `INSERT INTO ban_main (ban_type, ban_detail, ban_who_banned, ban_reason) VALUES (${VRR_BANTYPE_ACCOUNT}, ${accountId}, ${adminAccountId}, '${safeReason}');`); freeDatabaseQuery(dbQuery); @@ -152,7 +157,7 @@ function banAccount(accountId, adminAccountId, reason) { function banSubAccount(subAccountId, adminAccountId, reason) { let dbConnection = connectToDatabase(); - if(dbConnection) { + if (dbConnection) { let safeReason = dbConnection.escapetoString(reason); let dbQuery = queryDatabase(dbConnection, `INSERT INTO ban_main (ban_type, ban_detail, ban_who_banned, ban_reason) VALUES (${VRR_BANTYPE_SUBACCOUNT}, ${subAccountId}, ${adminAccountId}, '${safeReason}');`); freeDatabaseQuery(dbQuery); @@ -167,7 +172,7 @@ function banSubAccount(subAccountId, adminAccountId, reason) { function banIPAddress(ipAddress, adminAccountId, reason) { let dbConnection = connectToDatabase(); - if(dbConnection) { + if (dbConnection) { let safeReason = dbConnection.escapetoString(reason); let dbQuery = queryDatabase(dbConnection, `INSERT INTO ban_main (ban_type, ban_detail, ban_who_banned, ban_reason) VALUES (${VRR_BANTYPE_IPADDRESS}, INET_ATON(${ipAddress}), ${adminAccountId}, '${safeReason}');`); freeDatabaseQuery(dbQuery); @@ -182,7 +187,7 @@ function banIPAddress(ipAddress, adminAccountId, reason) { function banSubNet(ipAddressStart, ipAddressEnd, adminAccountId, reason) { let dbConnection = connectToDatabase(); - if(dbConnection) { + if (dbConnection) { let safeReason = dbConnection.escapetoString(reason); let dbQuery = queryDatabase(dbConnection, `INSERT INTO ban_main (ban_type, ban_ip_start, ban_ip_end, ban_who_banned, ban_reason) VALUES (${VRR_BANTYPE_SUBNET}, INET_ATON(${ipAddressStart}), INET_ATON(${ipAddressEnd}), ${adminAccountId}, '${safeReason}');`); freeDatabaseQuery(dbQuery); @@ -197,7 +202,7 @@ function banSubNet(ipAddressStart, ipAddressEnd, adminAccountId, reason) { function unbanAccount(accountId, adminAccountId) { let dbConnection = connectToDatabase(); - if(dbConnection) { + if (dbConnection) { let dbQuery = queryDatabase(dbConnection, `UPDATE ban_main SET ban_who_removed=${adminAccountId}, ban_removed=1 WHERE ban_type=${VRR_BANTYPE_ACCOUNT} AND ban_detail=${accountId}`); freeDatabaseQuery(dbQuery); dbConnection.close(); @@ -211,7 +216,7 @@ function unbanAccount(accountId, adminAccountId) { function unbanSubAccount(subAccountId, adminAccountId) { let dbConnection = connectToDatabase(); - if(dbConnection) { + if (dbConnection) { let dbQuery = queryDatabase(dbConnection, `UPDATE ban_main SET ban_who_removed=${adminAccountId}, ban_removed=1 WHERE ban_type=${VRR_BANTYPE_SUBACCOUNT} AND ban_detail=${subAccountId}`); freeDatabaseQuery(dbQuery); dbConnection.close(); @@ -225,7 +230,7 @@ function unbanSubAccount(subAccountId, adminAccountId) { function unbanIPAddress(ipAddress, adminAccountId) { let dbConnection = connectToDatabase(); - if(dbConnection) { + if (dbConnection) { let dbQuery = queryDatabase(dbConnection, `UPDATE ban_main SET ban_who_removed=${adminAccountId}, ban_removed=1 WHERE ban_type=${VRR_BANTYPE_IPADDRESS} AND ban_detail=INET_ATON(${ipAddress})`); freeDatabaseQuery(dbQuery); dbConnection.close(); @@ -239,7 +244,7 @@ function unbanIPAddress(ipAddress, adminAccountId) { function unbanSubNet(ipAddressStart, ipAddressEnd, adminAccountId) { let dbConnection = connectToDatabase(); - if(dbConnection) { + if (dbConnection) { let dbQuery = queryDatabase(dbConnection, `UPDATE ban_main SET ban_who_removed=${adminAccountId}, ban_removed=1 WHERE ban_type=${VRR_BANTYPE_SUBNET} AND ban_ip_start=INET_ATON(${ipAddressStart}) AND ban_ip_end=INET_ATON(${ipAddressEnd})`); freeDatabaseQuery(dbQuery); dbConnection.close(); @@ -253,7 +258,7 @@ function unbanSubNet(ipAddressStart, ipAddressEnd, adminAccountId) { function isAccountBanned(accountId) { let bans = getServerData().bans.filter(ban => ban.type === VRR_BANTYPE_ACCOUNT && ban.detail === accountId); - if(bans.length > 0) { + if (bans.length > 0) { return true; } @@ -264,7 +269,7 @@ function isAccountBanned(accountId) { function isSubAccountBanned(subAccountId) { let bans = getServerData().bans.filter(ban => ban.type === VRR_BANTYPE_SUBACCOUNT && ban.detail === subAccountId); - if(bans.length > 0) { + if (bans.length > 0) { return true; } @@ -275,7 +280,7 @@ function isSubAccountBanned(subAccountId) { function isIpAddressBanned(ipAddress) { let bans = getServerData().bans.filter(ban => ban.type === VRR_BANTYPE_IPADDRESS && ban.detail === ipAddress); - if(bans.length > 0) { + if (bans.length > 0) { return true; } diff --git a/scripts/server/business.js b/scripts/server/business.js index 29944f8a..bdb1cf14 100644 --- a/scripts/server/business.js +++ b/scripts/server/business.js @@ -19,10 +19,10 @@ function initBusinessScript() { function loadBusinessFromId(businessId) { let dbConnection = connectToDatabase(); - if(dbConnection) { + if (dbConnection) { let dbQueryString = `SELECT * FROM biz_main WHERE biz_id = ${businessId} LIMIT 1;`; let dbQuery = queryDatabase(dbConnection, dbQueryString); - if(dbQuery) { + if (dbQuery) { let dbAssoc = fetchQueryAssoc(dbQuery); freeDatabaseQuery(dbQuery); return new BusinessData(dbAssoc); @@ -43,11 +43,11 @@ function loadBusinessesFromDatabase() { let dbQuery = null; let dbAssoc; - if(dbConnection) { - dbQuery = queryDatabase(dbConnection, `SELECT * FROM biz_main WHERE biz_server = ${getServerId()}`); - if(dbQuery) { - if(dbQuery.numRows > 0) { - while(dbAssoc = fetchQueryAssoc(dbQuery)) { + if (dbConnection) { + dbQuery = queryDatabase(dbConnection, `SELECT * FROM biz_main WHERE biz_deleted = 0 AND biz_server = ${getServerId()}`); + if (dbQuery) { + if (dbQuery.numRows > 0) { + while (dbAssoc = fetchQueryAssoc(dbQuery)) { let tempBusinessData = new BusinessData(dbAssoc); //tempBusinessData.locations = loadBusinessLocationsFromDatabase(tempBusinessData.databaseId); //tempBusinessData.gameScripts = loadBusinessGameScriptsFromDatabase(tempBusinessData.databaseId); @@ -75,12 +75,12 @@ function loadBusinessLocationsFromDatabase(businessId) { let dbAssoc; let dbQueryString = ""; - if(dbConnection) { + if (dbConnection) { dbQueryString = `SELECT * FROM biz_loc WHERE biz_loc_biz = ${businessId}`; dbQuery = queryDatabase(dbConnection, dbQueryString); - if(dbQuery) { - if(dbQuery.numRows > 0) { - while(dbAssoc = fetchQueryAssoc(dbQuery)) { + if (dbQuery) { + if (dbQuery.numRows > 0) { + while (dbAssoc = fetchQueryAssoc(dbQuery)) { let tempBusinessLocationData = new BusinessLocationData(dbAssoc); tempBusinessLocations.push(tempBusinessLocationData); logToConsole(LOG_VERBOSE, `[VRR.Business]: Location '${tempBusinessLocationData.name}' loaded from database successfully!`); @@ -157,7 +157,7 @@ function createBusinessCommand(command, params, client) { * */ function createBusinessLocationCommand(command, params, client) { - if(!isPlayerSpawned(client)) { + if (!isPlayerSpawned(client)) { messagePlayerError(client, "You must be spawned to use this command!"); return false; } @@ -165,11 +165,11 @@ function createBusinessLocationCommand(command, params, client) { let locationType = toString(getParam(params, " ", 1)); let businessId = getPlayerBusiness(client); - if(!areParamsEmpty(params)) { + if (!areParamsEmpty(params)) { businessId = getBusinessFromParams(params); } - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } @@ -207,8 +207,8 @@ function createBusiness(name, entrancePosition, exitPosition, entrancePickupMode setBusinessDataIndexes(); saveAllBusinessesToDatabase(); - createBusinessPickups(businessId-1); - createBusinessBlips(businessId-1); + createBusinessPickups(businessId - 1); + createBusinessBlips(businessId - 1); return tempBusinessData; } @@ -227,11 +227,11 @@ function createBusiness(name, entrancePosition, exitPosition, entrancePickupMode function deleteBusinessCommand(command, params, client) { let businessId = getPlayerBusiness(client); - if(!areParamsEmpty(params)) { + if (!areParamsEmpty(params)) { businessId = getBusinessFromParams(params); } - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } @@ -273,12 +273,12 @@ function setBusinessNameCommand(command, params, client) { let businessId = getPlayerBusiness(client); - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } - if(!canPlayerManageBusiness(client, businessId)) { + if (!canPlayerManageBusiness(client, businessId)) { messagePlayerError(client, getLocaleString(client, "CantModifyBusiness")); return false; } @@ -302,7 +302,7 @@ function setBusinessNameCommand(command, params, client) { * */ function setBusinessOwnerCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -310,17 +310,17 @@ function setBusinessOwnerCommand(command, params, client) { let newBusinessOwner = getPlayerFromParams(params); let businessId = getPlayerBusiness(client); - if(!newBusinessOwner) { + if (!newBusinessOwner) { messagePlayerError(client, getLocaleString(client, "InvalidPlayer")); return false; } - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } - if(!canPlayerManageBusiness(client, businessId)) { + if (!canPlayerManageBusiness(client, businessId)) { messagePlayerError(client, getLocaleString(client, "CantModifyBusiness")); return false; } @@ -344,7 +344,7 @@ function setBusinessOwnerCommand(command, params, client) { * */ function setBusinessJobCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -352,17 +352,17 @@ function setBusinessJobCommand(command, params, client) { let jobId = getJobFromParams(params); let businessId = getPlayerBusiness(client); - if(!getJobData(jobId)) { + if (!getJobData(jobId)) { messagePlayerError(client, getLocaleString(client, "InvalidJob")); return false; } - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } - if(!canPlayerManageBusiness(client, businessId)) { + if (!canPlayerManageBusiness(client, businessId)) { messagePlayerError(client, getLocaleString(client, "CantModifyBusiness")); return false; } @@ -388,24 +388,24 @@ function setBusinessJobCommand(command, params, client) { function setBusinessClanCommand(command, params, client) { let businessId = getPlayerBusiness(client); - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(getLocaleString(client, "InvalidBusiness")); return false; } let clanId = getPlayerClan(client); - if(!getClanData(clanId)) { + if (!getClanData(clanId)) { messagePlayerError(client, getLocaleString(client, "InvalidClan")); return false; } - if(getBusinessData(business).ownerType != VRR_VEHOWNER_PLAYER) { + if (getBusinessData(business).ownerType != VRR_VEHOWNER_PLAYER) { messagePlayerError(client, getLocaleString(client, "MustOwnBusiness")); return false; } - if(getBusinessData(business).ownerId != getPlayerCurrentSubAccount(client).databaseId) { + if (getBusinessData(business).ownerId != getPlayerCurrentSubAccount(client).databaseId) { messagePlayerError(client, getLocaleString(client, "MustOwnBusiness")); return false; } @@ -432,28 +432,28 @@ function setBusinessClanCommand(command, params, client) { function setBusinessRankCommand(command, params, client) { let businessId = getPlayerBusiness(client); - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(getLocaleString(client, "InvalidBusiness")); return false; } let rankId = params; - if(!canPlayerManageBusiness(client, businessId)) { + if (!canPlayerManageBusiness(client, businessId)) { messagePlayerError(client, getLocaleString(client, "CantModifyBusiness")); return false; } - if(getVehicleData(vehicle).ownerType == VRR_VEHOWNER_CLAN) { + if (getVehicleData(vehicle).ownerType == VRR_VEHOWNER_CLAN) { let clanId = getClanIdFromDatabaseId(getBusinessData(businessId).ownerId); rankId = getClanRankFromParams(clanId, params); - if(!getClanRankData(clanId, rankId)) { + if (!getClanRankData(clanId, rankId)) { messagePlayerError(client, getLocaleString(client, "ClanRankInvalid")); return false; } getBusinessData(businessId).rank = getClanRankData(clanId, rankId).databaseId; messagePlayerSuccess(client, `{MAINCOLOUR}You set business {businessBlue}${getBusinessData(businessId).name} {MAINCOLOUR}rank to {ALTCOLOUR}${getClanRankData(clanId, rankId).name} {MAINCOLOUR}of the {clanOrange}${getClanData(clanId).name} {MAINCOLOUR}clan!`); - } else if(getBusinessData(businessId).ownerType == VRR_VEHOWNER_JOB) { + } else if (getBusinessData(businessId).ownerType == VRR_VEHOWNER_JOB) { getBusinessData(businessId).rank = rankId; messagePlayerSuccess(client, `{MAINCOLOUR}You set business {businessBlue}${getBusinessData(businessId).name} {MAINCOLOUR}rank to {ALTCOLOUR}${rankId} {MAINCOLOUR}of the {jobYellow}${getJobData(getJobIdFromDatabaseId(getBusinessData(businessId).ownerId)).name} {MAINCOLOUR}job!`); } @@ -472,39 +472,39 @@ function setBusinessRankCommand(command, params, client) { * @return {bool} Whether or not the command was successful * */ - function setBusinessRankCommand(command, params, client) { - if(areParamsEmpty(params)) { +function setBusinessRankCommand(command, params, client) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } let businessId = getPlayerBusiness(client); - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(getLocaleString(client, "InvalidBusiness")); return false; } let clanId = getPlayerClan(client); - if(!getClanData(clanId)) { + if (!getClanData(clanId)) { messagePlayerError(client, getLocaleString(client, "InvalidClan")); return false; } let clanRankId = getClanRankFromParams(clanId, params); - if(!getClanRankData(clanId, clanRankId)) { + if (!getClanRankData(clanId, clanRankId)) { messagePlayerError(client, getLocaleString(client, "ClanRankInvalid")); return false; } - if(!canPlayerManageBusiness(client, businessId)) { + if (!canPlayerManageBusiness(client, businessId)) { messagePlayerError(client, getLocaleString(client, "CantModifyBusiness")); return false; } - if(getClanRankData(clanId, clanRankId).level > getPlayerCurrentSubAccount(client).clanRank) { + if (getClanRankData(clanId, clanRankId).level > getPlayerCurrentSubAccount(client).clanRank) { messagePlayerError(client, "That rank is above your level!"); return false; } @@ -529,23 +529,23 @@ function setBusinessRankCommand(command, params, client) { function setBusinessJobCommand(command, params, client) { let businessId = getPlayerBusiness(client); - if(!areParamsEmpty(params)) { + if (!areParamsEmpty(params)) { businessId = getBusinessFromParams(params); } let closestJobLocation = getClosestJobLocation(getVehiclePosition(vehicle)); let jobId = closestJobLocation.job; - if(!areParamsEmpty(params)) { + if (!areParamsEmpty(params)) { jobId = getJobIdFromParams(params); } - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } - if(!getJobData(jobId)) { + if (!getJobData(jobId)) { messagePlayerError(client, getLocaleString(client, "InvalidJob")); return false; } @@ -571,11 +571,11 @@ function setBusinessJobCommand(command, params, client) { function setBusinessPublicCommand(command, params, client) { let businessId = getPlayerBusiness(client); - if(!areParamsEmpty(params)) { + if (!areParamsEmpty(params)) { businessId = getBusinessFromParams(params); } - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } @@ -601,11 +601,11 @@ function setBusinessPublicCommand(command, params, client) { function removeBusinessOwnerCommand(command, params, client) { let businessId = getPlayerBusiness(client); - if(!areParamsEmpty(params)) { + if (!areParamsEmpty(params)) { businessId = getBusinessFromParams(params); } - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } @@ -628,15 +628,15 @@ function removeBusinessOwnerCommand(command, params, client) { * @return {bool} Whether or not the command was successful * */ - function toggleBusinessInteriorLightsCommand(command, params, client) { +function toggleBusinessInteriorLightsCommand(command, params, client) { let businessId = getPlayerBusiness(client); - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } - if(!canPlayerManageBusiness(client, businessId)) { + if (!canPlayerManageBusiness(client, businessId)) { messagePlayerError(client, "You can't change the interior lights for this business!"); return false; } @@ -663,12 +663,12 @@ function setBusinessEntranceFeeCommand(command, params, client) { let entranceFee = toInteger(getParam(params, " ", 1)) || 0; let businessId = getPlayerBusiness(client); - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } - if(!canPlayerManageBusiness(client, businessId)) { + if (!canPlayerManageBusiness(client, businessId)) { messagePlayerError(client, getLocaleString(client, "CantModifyBusiness")); return false; } @@ -692,11 +692,11 @@ function setBusinessEntranceFeeCommand(command, params, client) { function getBusinessInfoCommand(command, params, client) { let businessId = getPlayerBusiness(client); - if(!areParamsEmpty(params)) { + if (!areParamsEmpty(params)) { businessId = getBusinessFromParams(params); } - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } @@ -704,7 +704,7 @@ function getBusinessInfoCommand(command, params, client) { let businessData = getBusinessData(businessId); let ownerName = "Unknown"; - switch(businessData.ownerType) { + switch (businessData.ownerType) { case VRR_BIZOWNER_CLAN: ownerName = getClanData(businessData.ownerId).name; break; @@ -755,7 +755,7 @@ function getBusinessInfoCommand(command, params, client) { messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderBusinessInfo", businessData.name))); let chunkedList = splitArrayIntoChunks(stats, 6); - for(let i in chunkedList) { + for (let i in chunkedList) { messagePlayerInfo(client, chunkedList[i].join(", ")); } @@ -776,11 +776,11 @@ function getBusinessInfoCommand(command, params, client) { function getBusinessFloorItemsCommand(command, params, client) { let businessId = getPlayerBusiness(client); - if(!areParamsEmpty(params)) { + if (!areParamsEmpty(params)) { businessId = getBusinessFromParams(params); } - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } @@ -802,11 +802,11 @@ function getBusinessFloorItemsCommand(command, params, client) { function getBusinessStorageItemsCommand(command, params, client) { let businessId = getPlayerBusiness(client); - if(!areParamsEmpty(params)) { + if (!areParamsEmpty(params)) { businessId = getBusinessFromParams(params); } - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } @@ -829,19 +829,19 @@ function setBusinessPickupCommand(command, params, client) { let typeParam = getParam(params, " ", 1) || "business"; let businessId = getPlayerBusiness(client); - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } - if(isNaN(typeParam)) { - if(isNull(getGameConfig().pickupModels[getGame()][typeParam])) { + if (isNaN(typeParam)) { + if (isNull(getGameConfig().pickupModels[getGame()][typeParam])) { messagePlayerError(client, "Invalid pickup type! Use a pickup type name or a model ID"); let pickupTypes = Object.keys(getGameConfig().pickupModels[getGame()]); let chunkedList = splitArrayIntoChunks(pickupTypes, 10); messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderPickupTypes"))); - for(let i in chunkedList) { + for (let i in chunkedList) { messagePlayerInfo(client, chunkedList[i].join(", ")); } return false; @@ -874,18 +874,18 @@ function setBusinessInteriorTypeCommand(command, params, client) { let typeParam = getParam(params, " ", 1) || "business"; let businessId = getPlayerBusiness(client); - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } - if(typeof getGameConfig().interiors[getGame()] == "undefined") { + if (typeof getGameConfig().interiors[getGame()] == "undefined") { messagePlayerError(client, `There are no interiors available for this game!`); return false; } - if(isNaN(typeParam)) { - if(toLowerCase(typeParam) == "None") { + if (isNaN(typeParam)) { + if (toLowerCase(typeParam) == "None") { getBusinessData(businessId).exitPosition = toVector3(0.0, 0.0, 0.0); getBusinessData(businessId).exitDimension = 0; getBusinessData(businessId).exitInterior = -1; @@ -897,13 +897,13 @@ function setBusinessInteriorTypeCommand(command, params, client) { return false; } - if(isNull(getGameConfig().interiors[getGame()][typeParam])) { + if (isNull(getGameConfig().interiors[getGame()][typeParam])) { messagePlayerError(client, "Invalid interior type! Use an interior type name"); let interiorTypesList = Object.keys(getGameConfig().interiors[getGame()]); let chunkedList = splitArrayIntoChunks(interiorTypesList, 10); messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderInteriorTypes"))); - for(let i in chunkedList) { + for (let i in chunkedList) { messagePlayerInfo(client, chunkedList[i].join(", ")); } return false; @@ -911,7 +911,7 @@ function setBusinessInteriorTypeCommand(command, params, client) { getBusinessData(businessId).exitPosition = getGameConfig().interiors[getGame()][typeParam][0]; getBusinessData(businessId).exitInterior = getGameConfig().interiors[getGame()][typeParam][1]; - getBusinessData(businessId).exitDimension = getBusinessData(businessId).databaseId+getGlobalConfig().businessDimensionStart; + getBusinessData(businessId).exitDimension = getBusinessData(businessId).databaseId + getGlobalConfig().businessDimensionStart; getBusinessData(businessId).exitPickupModel = getGameConfig().pickupModels[getGame()].Exit; getBusinessData(businessId).hasInterior = true; getBusinessData(businessId).customInterior = getGameConfig().interiors[getGame()][typeParam][2]; @@ -941,28 +941,28 @@ function setBusinessInteriorTypeCommand(command, params, client) { * @return {bool} Whether or not the command was successful * */ - function addBusinessPropertyTemplateEntities(command, params, client) { +function addBusinessPropertyTemplateEntities(command, params, client) { let propertyTemplateParam = getParam(params, " ", 1) || "business"; let businessId = getPlayerBusiness(client); - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } - if(typeof getGameConfig().interiors[getGame()] == "undefined") { + if (typeof getGameConfig().interiors[getGame()] == "undefined") { messagePlayerError(client, `There are no property templates available for this game!`); return false; } - if(isNaN(propertyTemplateParam)) { - if(isNull(getGameConfig().interiors[getGame()][typeParam])) { + if (isNaN(propertyTemplateParam)) { + if (isNull(getGameConfig().interiors[getGame()][typeParam])) { messagePlayerError(client, "Invalid interior type! Use an interior type name"); let interiorTypesList = Object.keys(getGameConfig().properties[getGame()]); let chunkedList = splitArrayIntoChunks(interiorTypesList, 10); messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderPropertyTemplateTypes"))); - for(let i in chunkedList) { + for (let i in chunkedList) { messagePlayerInfo(client, chunkedList[i].join(", ")); } return false; @@ -970,7 +970,7 @@ function setBusinessInteriorTypeCommand(command, params, client) { getBusinessData(businessId).exitPosition = getGameConfig().interiors[getGame()][typeParam][0]; getBusinessData(businessId).exitInterior = getGameConfig().interiors[getGame()][typeParam][1]; - getBusinessData(businessId).exitDimension = getBusinessData(businessId).databaseId+getGlobalConfig().businessDimensionStart; + getBusinessData(businessId).exitDimension = getBusinessData(businessId).databaseId + getGlobalConfig().businessDimensionStart; getBusinessData(businessId).exitPickupModel = getGameConfig().pickupModels[getGame()].Exit; getBusinessData(businessId).hasInterior = true; getBusinessData(businessId).customInterior = getGameConfig().interiors[getGame()][typeParam][2]; @@ -1004,20 +1004,20 @@ function setBusinessBlipCommand(command, params, client) { let typeParam = getParam(params, " ", 1) || "business"; let businessId = getPlayerBusiness(client); - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } - if(isNaN(typeParam)) { - if(isNull(getGameConfig().blipSprites[getGame()][typeParam])) { + if (isNaN(typeParam)) { + if (isNull(getGameConfig().blipSprites[getGame()][typeParam])) { messagePlayerError(client, "Invalid business type! Use a business type name or a blip image ID"); let blipTypes = Object.keys(getGameConfig().blipSprites[getGame()]); let chunkedList = splitArrayIntoChunks(blipTypes, 10); messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderBlipTypes"))); - for(let i in chunkedList) { + for (let i in chunkedList) { messagePlayerInfo(client, chunkedList[i].join(", ")); } return false; @@ -1049,34 +1049,34 @@ function giveDefaultItemsToBusinessCommand(command, params, client) { let typeParam = getParam(params, " ", 1) || "business"; let businessId = getPlayerBusiness(client); - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } - if(!isNaN(typeParam)) { + if (!isNaN(typeParam)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } - if(isNull(getGameConfig().defaultBusinessItems[getGame()][typeParam])) { + if (isNull(getGameConfig().defaultBusinessItems[getGame()][typeParam])) { messagePlayerError(client, "Invalid business items type! Use a business items type name"); let businessItemTypes = Object.keys(getGameConfig().defaultBusinessItems[getGame()]); let chunkedList = splitArrayIntoChunks(businessItemTypes, 10); messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderDefaultBusinessItemTypes"))); - for(let i in chunkedList) { + for (let i in chunkedList) { messagePlayerInfo(client, chunkedList[i].join(", ")); } return false; } - for(let i in getGameConfig().defaultBusinessItems[getGame()][typeParam]) { + for (let i in getGameConfig().defaultBusinessItems[getGame()][typeParam]) { let itemTypeId = getItemTypeFromParams(getGameConfig().defaultBusinessItems[getGame()][typeParam][i][0]); let itemTypeData = getItemTypeData(itemTypeId); - if(itemTypeData) { + if (itemTypeData) { let newItemIndex = createItem(itemTypeId, itemTypeData.orderValue, VRR_ITEM_OWNER_BIZFLOOR, getBusinessData(businessId).databaseId, getGameConfig().defaultBusinessItems[getGame()][typeParam][i][1]); - getItemData(newItemIndex).buyPrice = applyServerInflationMultiplier(itemTypeData.orderPrice)*getGameConfig().defaultBusinessItems[getGame()][typeParam][i][2]; + getItemData(newItemIndex).buyPrice = applyServerInflationMultiplier(itemTypeData.orderPrice) * getGameConfig().defaultBusinessItems[getGame()][typeParam][i][2]; } } @@ -1099,7 +1099,7 @@ function giveDefaultItemsToBusinessCommand(command, params, client) { function setBusinessEntranceLabelToDealershipCommand(command, params, client) { let businessId = getPlayerBusiness(client); - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } @@ -1123,13 +1123,13 @@ function setBusinessEntranceLabelToDealershipCommand(command, params, client) { function deleteBusinessFloorItemsCommand(command, params, client) { let businessId = getPlayerBusiness(client); - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } let tempCache = getBusinessData(businessId).floorItemCache; - for(let i in tempCache) { + for (let i in tempCache) { deleteItem(tempCache[i]); } @@ -1152,13 +1152,13 @@ function deleteBusinessFloorItemsCommand(command, params, client) { function deleteBusinessStorageItemsCommand(command, params, client) { let businessId = getPlayerBusiness(client); - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } let tempCache = getBusinessData(businessId).storageItemCache; - for(let i in tempCache) { + for (let i in tempCache) { deleteItem(tempCache[i]); } @@ -1179,7 +1179,7 @@ function deleteBusinessStorageItemsCommand(command, params, client) { * */ function withdrawFromBusinessCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -1187,17 +1187,17 @@ function withdrawFromBusinessCommand(command, params, client) { let amount = toInteger(getParam(params, " ", 1)) || 0; let businessId = getPlayerBusiness(client); - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } - if(!canPlayerManageBusiness(client, businessId)) { + if (!canPlayerManageBusiness(client, businessId)) { messagePlayerError(client, getLocaleString(client, "CantModifyBusiness")); return false; } - if(getBusinessData(businessId).till < amount) { + if (getBusinessData(businessId).till < amount) { messagePlayerError(client, `Business {businessBlue}${tempBusinessData.name} doesn't have that much money! Use /bizbalance.`); return false; } @@ -1222,7 +1222,7 @@ function withdrawFromBusinessCommand(command, params, client) { * */ function setBusinessBuyPriceCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -1230,17 +1230,17 @@ function setBusinessBuyPriceCommand(command, params, client) { let amount = toInteger(getParam(params, " ", 1)) || 0; let businessId = getPlayerBusiness(client); - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } - if(!canPlayerManageBusiness(client, businessId)) { + if (!canPlayerManageBusiness(client, businessId)) { messagePlayerError(client, getLocaleString(client, "CantModifyBusiness")); return false; } - if(amount < 0) { + if (amount < 0) { messagePlayerError(client, `The amount can't be less than 0!`); return false; } @@ -1264,7 +1264,7 @@ function setBusinessBuyPriceCommand(command, params, client) { * */ function depositIntoBusinessCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -1272,7 +1272,7 @@ function depositIntoBusinessCommand(command, params, client) { let amount = toInteger(getParam(params, " ", 1)) || 0; let businessId = getPlayerBusiness(client); - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } @@ -1283,7 +1283,7 @@ function depositIntoBusinessCommand(command, params, client) { // return false; //} - if(getPlayerCurrentSubAccount(client).cash < amount) { + if (getPlayerCurrentSubAccount(client).cash < amount) { messagePlayerError(client, `You don't have that much money! You only have $${getPlayerCurrentSubAccount(client).cash}`); return false; } @@ -1308,20 +1308,20 @@ function depositIntoBusinessCommand(command, params, client) { * */ function orderItemForBusinessCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } - if(!areThereEnoughParams(params, 3, " ")) { + if (!areThereEnoughParams(params, 3, " ")) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } let splitParams = params.split(" "); - let itemType = getItemTypeFromParams(splitParams.slice(0,-2).join(" ")); + let itemType = getItemTypeFromParams(splitParams.slice(0, -2).join(" ")); - if(!getItemTypeData(itemType)) { + if (!getItemTypeData(itemType)) { messagePlayerError(client, `Invalid item type name or ID!`); messagePlayerInfo(client, `Use {ALTCOLOUR}/itemtypes {MAINCOLOUR}for a list of items`); return false; @@ -1332,19 +1332,19 @@ function orderItemForBusinessCommand(command, params, client) { let value = toInteger(splitParams.slice(-1)) || getItemTypeData(itemType).capacity; let businessId = getPlayerBusiness(client); - logToConsole(LOG_DEBUG, `[VRR.Business] ${getPlayerDisplayForConsole(client)} is ordering ${amount} ${splitParams.slice(0,-2).join(" ")} (${value})`); + logToConsole(LOG_DEBUG, `[VRR.Business] ${getPlayerDisplayForConsole(client)} is ordering ${amount} ${splitParams.slice(0, -2).join(" ")} (${value})`); - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } - if(!canPlayerManageBusiness(client, businessId)) { + if (!canPlayerManageBusiness(client, businessId)) { messagePlayerError(client, getLocaleString(client, "CantModifyBusiness")); return false; } - let orderTotalCost = pricePerItem*amount; + let orderTotalCost = pricePerItem * amount; //getPlayerData(client).promptType = VRR_PROMPT_BIZORDER; getPlayerData(client).businessOrderAmount = amount; @@ -1370,8 +1370,8 @@ function orderItemForBusinessCommand(command, params, client) { * */ function orderItemForBusiness(businessId, itemType, amount) { - if(getBusinessData(businessId).till < orderTotalCost) { - let neededAmount = orderTotalCost-getBusinessData(businessId).till; + if (getBusinessData(businessId).till < orderTotalCost) { + let neededAmount = orderTotalCost - getBusinessData(businessId).till; //messagePlayerError(client, `The business doesn't have enough money (needs {ALTCOLOUR}$${neededAmount} {MAINCOLOUR}more)! Use {ALTCOLOUR}/bizdeposit {MAINCOLOUR}to add money to the business.`); return false; } @@ -1395,16 +1395,16 @@ function orderItemForBusiness(businessId, itemType, amount) { function viewBusinessTillAmountCommand(command, params, client) { let businessId = getPlayerBusiness(client); - if(!areParamsEmpty(params)) { + if (!areParamsEmpty(params)) { businessId = getBusinessFromParams(params); } - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } - if(!canPlayerManageBusiness(client, businessId)) { + if (!canPlayerManageBusiness(client, businessId)) { messagePlayerError(client, getLocaleString(client, "CantModifyBusiness")); return false; } @@ -1426,17 +1426,17 @@ function viewBusinessTillAmountCommand(command, params, client) { function buyBusinessCommand(command, params, client) { let businessId = getPlayerBusiness(client); - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } - if(getBusinessData(businessId).buyPrice <= 0) { + if (getBusinessData(businessId).buyPrice <= 0) { messagePlayerError(client, getLocaleString(client, "BusinessNotForSale")); return false; } - if(getPlayerCurrentSubAccount(client).cash < getBusinessData(businessId).buyPrice) { + if (getPlayerCurrentSubAccount(client).cash < getBusinessData(businessId).buyPrice) { messagePlayerError(client, getLocaleString(client, "BusinessPurchaseNotEnoughMoney")); return false; } @@ -1459,11 +1459,11 @@ function buyBusinessCommand(command, params, client) { function moveBusinessEntranceCommand(command, params, client) { let businessId = getPlayerBusiness(client); - if(!areParamsEmpty(params)) { + if (!areParamsEmpty(params)) { businessId = getBusinessFromParams(params); } - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } @@ -1499,11 +1499,11 @@ function moveBusinessEntranceCommand(command, params, client) { function moveBusinessExitCommand(command, params, client) { let businessId = getPlayerBusiness(client); - if(!areParamsEmpty(params)) { + if (!areParamsEmpty(params)) { businessId = getBusinessFromParams(params); } - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } @@ -1527,7 +1527,7 @@ function moveBusinessExitCommand(command, params, client) { function getBusinessDataFromDatabaseId(databaseId) { let matchingBusinesses = getServerData().businesses.filter(b => b.databaseId == businessId) - if(matchingBusinesses.length == 1) { + if (matchingBusinesses.length == 1) { return matchingBusinesses[0]; } return false; @@ -1545,9 +1545,9 @@ function getBusinessDataFromDatabaseId(databaseId) { */ function getClosestBusinessEntrance(position, dimension) { let closest = 0; - for(let i in getServerData().businesses) { - if(getServerData().businesses[i].entranceDimension == dimension) { - if(getDistance(position, getServerData().businesses[i].entrancePosition) <= getDistance(position, getServerData().businesses[closest].entrancePosition)) { + for (let i in getServerData().businesses) { + if (getServerData().businesses[i].entranceDimension == dimension) { + if (getDistance(position, getServerData().businesses[i].entrancePosition) <= getDistance(position, getServerData().businesses[closest].entrancePosition)) { closest = i; } } @@ -1567,9 +1567,9 @@ function getClosestBusinessEntrance(position, dimension) { */ function getClosestBusinessExit(position, dimension) { let closest = 0; - for(let i in getServerData().businesses) { - if(getServerData().businesses[i].hasInterior && getServerData().businesses[i].exitDimension == dimension) { - if(getDistance(position, getServerData().businesses[i].exitPosition) <= getDistance(position, getServerData().businesses[closest].exitPosition)) { + for (let i in getServerData().businesses) { + if (getServerData().businesses[i].hasInterior && getServerData().businesses[i].exitDimension == dimension) { + if (getDistance(position, getServerData().businesses[i].exitPosition) <= getDistance(position, getServerData().businesses[closest].exitPosition)) { closest = i; } } @@ -1587,8 +1587,8 @@ function getClosestBusinessExit(position, dimension) { * */ function isPlayerInAnyBusiness(client) { - for(let i in getServerData().businesses) { - if(getServerData().businesses[i].hasInterior && getServerData().businesses[i].exitDimension == getPlayerDimension(client)) { + for (let i in getServerData().businesses) { + if (getServerData().businesses[i].hasInterior && getServerData().businesses[i].exitDimension == getPlayerDimension(client)) { return i; } } @@ -1606,19 +1606,23 @@ function isPlayerInAnyBusiness(client) { * */ function getPlayerBusiness(client) { - if(getPlayerDimension(client) == getGameConfig().mainWorldDimension[getGame()]) { + if (getServerData().businesses.length == 0) { + return -1; + } + + if (getPlayerDimension(client) == getGameConfig().mainWorldDimension[getGame()]) { let closestEntrance = getClosestBusinessEntrance(getPlayerPosition(client), getPlayerDimension(client)); - if(getDistance(getPlayerPosition(client), getBusinessData(closestEntrance).entrancePosition) <= getGlobalConfig().enterPropertyDistance) { + if (getDistance(getPlayerPosition(client), getBusinessData(closestEntrance).entrancePosition) <= getGlobalConfig().enterPropertyDistance) { return getBusinessData(closestEntrance).index; } } else { let closestEntrance = getClosestBusinessEntrance(getPlayerPosition(client), getPlayerDimension(client)); - if(getDistance(getPlayerPosition(client), getBusinessData(closestEntrance).entrancePosition) <= getGlobalConfig().enterPropertyDistance) { + if (getDistance(getPlayerPosition(client), getBusinessData(closestEntrance).entrancePosition) <= getGlobalConfig().enterPropertyDistance) { return getBusinessData(closestEntrance).index; } - for(let i in getServerData().businesses) { - if(getServerData().businesses[i].hasInterior && getServerData().businesses[i].exitDimension == getPlayerDimension(client)) { + for (let i in getServerData().businesses) { + if (getServerData().businesses[i].hasInterior && getServerData().businesses[i].exitDimension == getPlayerDimension(client)) { return i; } } @@ -1635,12 +1639,12 @@ function getPlayerBusiness(client) { * */ function saveAllBusinessesToDatabase() { - if(getServerConfig().devServer) { + if (getServerConfig().devServer) { return false; } - for(let i in getServerData().businesses) { - if(getServerData().businesses[i].needsSaved) { + for (let i in getServerData().businesses) { + if (getServerData().businesses[i].needsSaved) { saveBusinessToDatabase(i); } } @@ -1660,13 +1664,13 @@ function saveAllBusinessesToDatabase() { function saveBusinessToDatabase(businessId) { let tempBusinessData = getServerData().businesses[businessId]; - if(!tempBusinessData.needsSaved) { + if (!tempBusinessData.needsSaved) { return false; } logToConsole(LOG_DEBUG, `[VRR.Business]: Saving business '${tempBusinessData.name}' to database ...`); let dbConnection = connectToDatabase(); - if(dbConnection) { + if (dbConnection) { let safeBusinessName = escapeDatabaseString(dbConnection, tempBusinessData.name); let data = [ @@ -1705,7 +1709,7 @@ function saveBusinessToDatabase(businessId) { ]; let dbQuery = null; - if(tempBusinessData.databaseId == 0) { + if (tempBusinessData.databaseId == 0) { let queryString = createDatabaseInsertQuery("biz_main", data); dbQuery = queryDatabase(dbConnection, queryString); getServerData().businesses[businessId].databaseId = getDatabaseInsertId(dbConnection); @@ -1734,11 +1738,15 @@ function saveBusinessToDatabase(businessId) { * */ function createAllBusinessPickups() { - if(!getServerConfig().createBusinessPickups) { + if (!getServerConfig().createBusinessPickups) { return false; } - for(let i in getServerData().businesses) { + if (!isGameFeatureSupported("pickups")) { + return false; + } + + for (let i in getServerData().businesses) { createBusinessEntrancePickup(i); createBusinessExitPickup(i); updateBusinessPickupLabelData(i); @@ -1756,11 +1764,15 @@ function createAllBusinessPickups() { * */ function createAllBusinessBlips() { - if(!getServerConfig().createBusinessBlips) { + if (!getServerConfig().createBusinessBlips) { return false; } - for(let i in getServerData().businesses) { + if (!isGameFeatureSupported("blips")) { + return false; + } + + for (let i in getServerData().businesses) { createBusinessEntranceBlip(i); createBusinessExitBlip(i); } @@ -1776,11 +1788,15 @@ function createAllBusinessBlips() { * */ function createBusinessEntrancePickup(businessId) { - if(!areServerElementsSupported()) { + if (!areServerElementsSupported()) { return false; } - if(!getServerConfig().createBusinessPickups) { + if (!getServerConfig().createBusinessPickups) { + return false; + } + + if (!isGameFeatureSupported("pickups")) { return false; } @@ -1790,29 +1806,29 @@ function createBusinessEntrancePickup(businessId) { // return false; //} - if(businessData.entrancePickupModel == -1) { + if (businessData.entrancePickupModel == -1) { return false; } let pickupModelId = getGameConfig().pickupModels[getGame()].Business; - if(businessData.entrancePickupModel != 0) { + if (businessData.entrancePickupModel != 0) { pickupModelId = businessData.entrancePickupModel; } logToConsole(LOG_VERBOSE, `[VRR.Job]: Creating entrance pickup for business ${businessData.name} (model ${pickupModelId})`); - if(areServerElementsSupported()) { + if (areServerElementsSupported()) { let entrancePickup = createGamePickup(pickupModelId, businessData.entrancePosition, getGameConfig().pickupTypes[getGame()].business); - if(entrancePickup != null) { - if(businessData.entranceDimension != -1) { + if (entrancePickup != null) { + if (businessData.entranceDimension != -1) { setElementDimension(entrancePickup, businessData.entranceDimension); setElementOnAllDimensions(entrancePickup, false); } else { setElementOnAllDimensions(entrancePickup, true); } - if(getGlobalConfig().businessPickupStreamInDistance == -1 || getGlobalConfig().businessPickupStreamOutDistance == -1) { + if (getGlobalConfig().businessPickupStreamInDistance == -1 || getGlobalConfig().businessPickupStreamOutDistance == -1) { entrancePickup.netFlags.distanceStreaming = false; } else { setElementStreamInDistance(entrancePickup, getGlobalConfig().businessPickupStreamInDistance); @@ -1825,7 +1841,7 @@ function createBusinessEntrancePickup(businessId) { } else { let pickupModelId = getGameConfig().pickupModels[getGame()].Business; - if(businessData.entrancePickupModel != 0) { + if (businessData.entrancePickupModel != 0) { pickupModelId = businessData.entrancePickupModel; } sendBusinessToPlayer(null, businessId, businessData.name, businessData.entrancePosition, blipModelId, pickupModelId, businessData.hasInterior, doesBusinessHaveAnyItemsToBuy(businessId)); @@ -1844,7 +1860,15 @@ function createBusinessEntrancePickup(businessId) { * */ function createBusinessEntranceBlip(businessId) { - if(!getServerConfig().createBusinessBlips) { + if (!areServerElementsSupported()) { + return false; + } + + if (!getServerConfig().createBusinessBlips) { + return false; + } + + if (!isGameFeatureSupported("blips")) { return false; } @@ -1854,29 +1878,29 @@ function createBusinessEntranceBlip(businessId) { // return false; //} - if(businessData.entranceBlipModel == -1) { + if (businessData.entranceBlipModel == -1) { return false; } let blipModelId = getGameConfig().blipSprites[getGame()].Business; - if(businessData.entranceBlipModel != 0) { + if (businessData.entranceBlipModel != 0) { blipModelId = businessData.entranceBlipModel; } logToConsole(LOG_VERBOSE, `[VRR.Job]: Creating entrance blip for business ${businessData.name} (model ${blipModelId})`); - if(areServerElementsSupported()) { + if (areServerElementsSupported()) { let entranceBlip = createGameBlip(businessData.entrancePosition, blipModelId, 1, getColourByType("businessBlue")); - if(entranceBlip != null) { - if(businessData.entranceDimension != -1) { + if (entranceBlip != null) { + if (businessData.entranceDimension != -1) { setElementDimension(entranceBlip, businessData.entranceDimension); setElementOnAllDimensions(entranceBlip, false); } else { setElementOnAllDimensions(entranceBlip, true); } - if(getGlobalConfig().businessBlipStreamInDistance == -1 || getGlobalConfig().businessBlipStreamOutDistance == -1) { + if (getGlobalConfig().businessBlipStreamInDistance == -1 || getGlobalConfig().businessBlipStreamOutDistance == -1) { entranceBlip.netFlags.distanceStreaming = false; } else { setElementStreamInDistance(entranceBlip, getGlobalConfig().businessBlipStreamInDistance); @@ -1898,11 +1922,15 @@ function createBusinessEntranceBlip(businessId) { * */ function createBusinessExitPickup(businessId) { - if(!areServerElementsSupported()) { + if (!areServerElementsSupported()) { return false; } - if(!getServerConfig().createBusinessPickups) { + if (!getServerConfig().createBusinessPickups) { + return false; + } + + if (!isGameFeatureSupported("pickups")) { return false; } @@ -1912,28 +1940,28 @@ function createBusinessExitPickup(businessId) { // return false; //} - if(businessData.exitPickupModel == -1) { + if (businessData.exitPickupModel == -1) { return false; } let pickupModelId = getGameConfig().pickupModels[getGame()].Exit; - if(businessData.exitPickupModel != 0) { + if (businessData.exitPickupModel != 0) { pickupModelId = businessData.exitPickupModel; } logToConsole(LOG_VERBOSE, `[VRR.Job]: Creating exit pickup for business ${businessData.name} (model ${pickupModelId})`); let exitPickup = createGamePickup(pickupModelId, businessData.exitPosition, getGameConfig().pickupTypes[getGame()].business); - if(exitPickup != null) { - if(businessData.exitDimension != -1) { + if (exitPickup != null) { + if (businessData.exitDimension != -1) { setElementDimension(exitPickup, businessData.exitDimension); setElementOnAllDimensions(exitPickup, false); } else { setElementOnAllDimensions(exitPickup, true); } - if(getGlobalConfig().businessPickupStreamInDistance == -1 || getGlobalConfig().businessPickupStreamOutDistance == -1) { + if (getGlobalConfig().businessPickupStreamInDistance == -1 || getGlobalConfig().businessPickupStreamOutDistance == -1) { exitPickup.netFlags.distanceStreaming = false; } else { setElementStreamInDistance(exitPickup, getGlobalConfig().businessPickupStreamInDistance); @@ -1955,11 +1983,15 @@ function createBusinessExitPickup(businessId) { * */ function createBusinessExitBlip(businessId) { - if(!areServerElementsSupported()) { + if (!areServerElementsSupported()) { return false; } - if(!getServerConfig().createBusinessBlips) { + if (!getServerConfig().createBusinessBlips) { + return false; + } + + if (!isGameFeatureSupported("blips")) { return false; } @@ -1969,28 +2001,28 @@ function createBusinessExitBlip(businessId) { // return false; //} - if(businessData.exitBlipModel == -1) { + if (businessData.exitBlipModel == -1) { return false; } let blipModelId = getGameConfig().blipSprites[getGame()].Business; - if(businessData.exitBlipModel != 0) { + if (businessData.exitBlipModel != 0) { blipModelId = businessData.exitBlipModel; } logToConsole(LOG_VERBOSE, `[VRR.Job]: Creating exit blip for business ${businessData.name} (model ${blipModelId})`); let exitBlip = createGameBlip(businessData.exitPosition, blipModelId, 1, getColourByName("businessBlue")); - if(exitBlip != null) { - if(businessData.exitDimension != -1) { + if (exitBlip != null) { + if (businessData.exitDimension != -1) { setElementDimension(exitBlip, businessData.exitDimension); setElementOnAllDimensions(exitBlip, false); } else { setElementOnAllDimensions(exitBlip, true); } - if(getGlobalConfig().businessBlipStreamInDistance == -1 || getGlobalConfig().businessBlipStreamOutDistance == -1) { + if (getGlobalConfig().businessBlipStreamInDistance == -1 || getGlobalConfig().businessBlipStreamOutDistance == -1) { exitBlip.netFlags.distanceStreaming = false; } else { setElementStreamInDistance(exitBlip, getGlobalConfig().businessBlipStreamInDistance); @@ -2010,7 +2042,7 @@ function createBusinessExitBlip(businessId) { * @return {Boolean} Whether or not the business was deleted * */ -function deleteBusiness(businessId, deletedBy = 0) { +function deleteBusiness(businessId, whoDeleted = 0) { let tempBusinessData = getServerData().businesses[businessId]; let dbConnection = connectToDatabase(); @@ -2019,9 +2051,9 @@ function deleteBusiness(businessId, deletedBy = 0) { deleteBusinessBlips(businessId); deleteBusinessPickups(businessId); - if(dbConnection) { - dbQuery = queryDatabase(dbConnection, `DELETE FROM biz_main WHERE biz_id = ${tempBusinessData.databaseId}`); - if(dbQuery) { + if (dbConnection) { + dbQuery = queryDatabase(dbConnection, `UPDATE biz_main WHERE biz_deleted = 1, biz_when_deleted = UNIX_TIMESTAMP(), biz_who_deleted = ${whoDeleted} WHERE biz_id ${tempBusinessData.databaseId}`); + if (dbQuery) { freeDatabaseQuery(dbQuery); } disconnectFromDatabase(dbConnection); @@ -2044,9 +2076,9 @@ function deleteBusiness(businessId, deletedBy = 0) { * */ function removePlayersFromBusiness(businessId) { - getClients().forEach(function(client) { - if(doesBusinessHaveInterior(businessId)) { - if(getPlayerBusiness(client) == businessId) { + getClients().forEach(function (client) { + if (doesBusinessHaveInterior(businessId)) { + if (getPlayerBusiness(client) == businessId) { exitBusiness(client); } } @@ -2081,11 +2113,11 @@ function removePlayerFromBusiness(client) { function exitBusiness(client) { let businessId = getPlayerBusiness(client); - if(businessId == false) { + if (businessId == false) { return false; } - if(isPlayerSpawned(client)) { + if (isPlayerSpawned(client)) { setPlayerInterior(client, getServerData().businesses[businessId].entranceInterior); setPlayerDimension(client, getServerData().businesses[businessId].entranceDimension); setPlayerPosition(client, getServerData().businesses[businessId].entrancePosition); @@ -2105,7 +2137,7 @@ function exitBusiness(client) { * */ function getBusinessOwnerTypeText(ownerType) { - switch(ownerType) { + switch (ownerType) { case VRR_BIZOWNER_CLAN: return "clan"; @@ -2131,7 +2163,7 @@ function getBusinessOwnerTypeText(ownerType) { * @return {BusinessData} The business's data (class instance) */ function getBusinessData(businessId) { - if(typeof getServerData().businesses[businessId] != null) { + if (typeof getServerData().businesses[businessId] != null) { return getServerData().businesses[businessId]; } return false; @@ -2156,11 +2188,15 @@ function doesBusinessHaveInterior(businessId) { * @returns {Boolean} Whether or not the entrance pickup of the business was deleted */ function deleteBusinessEntrancePickup(businessId) { - if(!areServerElementsSupported()) { + if (!areServerElementsSupported()) { return false; } - if(getBusinessData(businessId).entrancePickup != null) { + if (!isGameFeatureSupported("pickups")) { + return false; + } + + if (getBusinessData(businessId).entrancePickup != null) { //removeFromWorld(getBusinessData(businessId).entrancePickup); deleteGameElement(getBusinessData(businessId).entrancePickup); getBusinessData(businessId).entrancePickup = null; @@ -2179,11 +2215,15 @@ function deleteBusinessEntrancePickup(businessId) { * @returns {Boolean} Whether or not the exit pickup of the business was deleted */ function deleteBusinessExitPickup(businessId) { - if(!areServerElementsSupported()) { + if (!areServerElementsSupported()) { return false; } - if(getBusinessData(businessId).exitPickup != null) { + if (!isGameFeatureSupported("pickups")) { + return false; + } + + if (getBusinessData(businessId).exitPickup != null) { //removeFromWorld(getBusinessData(businessId).exitPickup); deleteGameElement(getBusinessData(businessId).exitPickup); getBusinessData(businessId).exitPickup = null; @@ -2198,11 +2238,15 @@ function deleteBusinessExitPickup(businessId) { * @returns {Boolean} Whether or not the entrance blip of the business was deleted */ function deleteBusinessEntranceBlip(businessId) { - if(!areServerElementsSupported()) { + if (!areServerElementsSupported()) { return false; } - if(getBusinessData(businessId).entranceBlip != null) { + if (!isGameFeatureSupported("blips")) { + return false; + } + + if (getBusinessData(businessId).entranceBlip != null) { //removeFromWorld(getBusinessData(businessId).entranceBlip); deleteGameElement(getBusinessData(businessId).entranceBlip); getBusinessData(businessId).entranceBlip = null; @@ -2217,11 +2261,15 @@ function deleteBusinessEntranceBlip(businessId) { * @returns {Boolean} Whether or not the exit blip of the business was deleted */ function deleteBusinessExitBlip(businessId) { - if(!areServerElementsSupported()) { + if (!areServerElementsSupported()) { return false; } - if(getBusinessData(businessId).exitBlip != null) { + if (!isGameFeatureSupported("blip")) { + return false; + } + + if (getBusinessData(businessId).exitBlip != null) { //removeFromWorld(getBusinessData(businessId).exitBlip); deleteGameElement(getBusinessData(businessId).exitBlip); getBusinessData(businessId).exitBlip = null; @@ -2241,11 +2289,11 @@ function deleteBusinessExitBlip(businessId) { */ function reloadAllBusinessesCommand(command, params, client) { let clients = getClients(); - for(let i in clients) { + for (let i in clients) { removePlayerFromBusiness(clients[i]); } - for(let i in getServerData().businesses) { + for (let i in getServerData().businesses) { deleteBusinessExitBlip(i); deleteBusinessEntranceBlip(i); deleteBusinessExitPickup(i); @@ -2271,7 +2319,7 @@ function reloadAllBusinessesCommand(command, params, client) { * @returns {Boolean} Whether or not the exit blip of the business was deleted */ function setBusinessDataIndexes() { - for(let i in getServerData().businesses) { + for (let i in getServerData().businesses) { getServerData().businesses[i].index = i; } } @@ -2291,7 +2339,7 @@ function addToBusinessInventory(businessId, itemType, amount, buyPrice) { saveItemToDatabase(tempItemData); getServerData().items.push(tempItemData); - let index = getServerData().items.length-1; + let index = getServerData().items.length - 1; getServerData().items[index].index = index; } @@ -2309,25 +2357,25 @@ function addToBusinessInventory(businessId, itemType, amount, buyPrice) { function buyFromBusinessCommand(command, params, client) { let businessId = getPlayerBusiness(client); - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { showBusinessFloorInventoryToPlayer(client, businessId); messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } - if(getBusinessData(businessId).locked) { + if (getBusinessData(businessId).locked) { messagePlayerError(client, `This business is closed!`); return false; } - if(getBusinessData(businessId).hasInterior) { - if(!getPlayerBusiness(client)) { - if(!doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForCommand(client, "enter")) { + if (getBusinessData(businessId).hasInterior) { + if (!getPlayerBusiness(client)) { + if (!doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForCommand(client, "enter")) { messagePlayerTip(client, getLocaleString(client, "NeedToEnterPropertyKeyPress", "business", `{ALTCOLOUR}${toUpperCase(getKeyNameFromId(getPlayerKeyBindForCommand(client, "enter")).key)}{MAINCOLOUR}`)); } else { messagePlayerNormal(client, getLocaleString(client, "NeedToEnterBusinessCommand", "business", "{ALTCOLOUR}/enter{MAINCOLOUR}")); @@ -2338,57 +2386,57 @@ function buyFromBusinessCommand(command, params, client) { let itemSlot = toInteger(getParam(params, " ", 1)) || 1; - if(typeof getBusinessData(businessId).floorItemCache[itemSlot-1] == "undefined") { + if (typeof getBusinessData(businessId).floorItemCache[itemSlot - 1] == "undefined") { messagePlayerError(client, `Item slot ${itemSlot} doesn't exist!`); return false; } - if(getBusinessData(businessId).floorItemCache[itemSlot-1] == -1) { + if (getBusinessData(businessId).floorItemCache[itemSlot - 1] == -1) { messagePlayerError(client, `Item slot ${itemSlot} slot is empty!`); return false; } let amount = 1; - if(areThereEnoughParams(params, 2, " ")) { + if (areThereEnoughParams(params, 2, " ")) { amount = toInteger(getParam(params, " ", 2)) || 1; - if(amount <= 0) { + if (amount <= 0) { messagePlayerError(client, getLocaleString(client, "AmountMustBeMoreThan", "0")); return false; } } - if(getItemData(getBusinessData(businessId).floorItemCache[itemSlot-1]).amount < amount) { - messagePlayerError(client, `There are only ${getItemData(getBusinessData(businessId).floorItemCache[itemSlot-1]).amount} ${getItemTypeData(getItemData(getBusinessData(businessId).floorItemCache[itemSlot-1]).itemTypeIndex).name} in slot ${itemSlot-1}`); + if (getItemData(getBusinessData(businessId).floorItemCache[itemSlot - 1]).amount < amount) { + messagePlayerError(client, `There are only ${getItemData(getBusinessData(businessId).floorItemCache[itemSlot - 1]).amount} ${getItemTypeData(getItemData(getBusinessData(businessId).floorItemCache[itemSlot - 1]).itemTypeIndex).name} in slot ${itemSlot - 1}`); return false; } let firstSlot = getPlayerFirstEmptyHotBarSlot(client); - if(firstSlot == -1) { + if (firstSlot == -1) { messagePlayerError(client, messagePlayerError(client, getLocaleString(client, "InventoryFullCantCarry"))); return false; } - let totalCost = getItemData(getBusinessData(businessId).floorItemCache[itemSlot-1]).buyPrice*amount; - let itemName = getItemTypeData(getItemData(getBusinessData(businessId).floorItemCache[itemSlot-1]).itemTypeIndex).name; + let totalCost = getItemData(getBusinessData(businessId).floorItemCache[itemSlot - 1]).buyPrice * amount; + let itemName = getItemTypeData(getItemData(getBusinessData(businessId).floorItemCache[itemSlot - 1]).itemTypeIndex).name; - if(getPlayerCurrentSubAccount(client).cash < totalCost) { - messagePlayerError(client, getLocaleString(client, "NotEnoughCashNeedAmountMore", `{ALTCOLOUR}${getBusinessData(businessId).floorItemCache[itemSlot-1].buyPrice*amount-getPlayerCurrentSubAccount(client).cash}{MAINCOLOUR}`)); + if (getPlayerCurrentSubAccount(client).cash < totalCost) { + messagePlayerError(client, getLocaleString(client, "NotEnoughCashNeedAmountMore", `{ALTCOLOUR}${getBusinessData(businessId).floorItemCache[itemSlot - 1].buyPrice * amount - getPlayerCurrentSubAccount(client).cash}{MAINCOLOUR}`)); return false; } takePlayerCash(client, totalCost); - createItem(getItemData(getBusinessData(businessId).floorItemCache[itemSlot-1]).itemTypeIndex, getItemData(getBusinessData(businessId).floorItemCache[itemSlot-1]).value, VRR_ITEM_OWNER_PLAYER, getPlayerCurrentSubAccount(client).databaseId, amount); + createItem(getItemData(getBusinessData(businessId).floorItemCache[itemSlot - 1]).itemTypeIndex, getItemData(getBusinessData(businessId).floorItemCache[itemSlot - 1]).value, VRR_ITEM_OWNER_PLAYER, getPlayerCurrentSubAccount(client).databaseId, amount); cachePlayerHotBarItems(client); getBusinessData(businessId).till = getBusinessData(businessId).till + totalCost; - getItemData(getBusinessData(businessId).floorItemCache[itemSlot-1]).amount = getItemData(getBusinessData(businessId).floorItemCache[itemSlot-1]).amount - amount; - if(getItemData(getBusinessData(businessId).floorItemCache[itemSlot-1]).amount == 0) { - destroyItem(getBusinessData(businessId).floorItemCache[itemSlot-1]); + getItemData(getBusinessData(businessId).floorItemCache[itemSlot - 1]).amount = getItemData(getBusinessData(businessId).floorItemCache[itemSlot - 1]).amount - amount; + if (getItemData(getBusinessData(businessId).floorItemCache[itemSlot - 1]).amount == 0) { + destroyItem(getBusinessData(businessId).floorItemCache[itemSlot - 1]); } - let useType = getItemTypeData(getItemData(getBusinessData(businessId).floorItemCache[itemSlot-1]).itemTypeIndex).useType; - if(useType == VRR_ITEM_USETYPE_WEAPON || VRR_ITEM_USETYPE_TAZER || useType == VRR_ITEM_USETYPE_AMMO_CLIP) { - if(isPlayerWeaponBanned(client) && !isPlayerExemptFromAntiCheat(client)) { + let useType = getItemTypeData(getItemData(getBusinessData(businessId).floorItemCache[itemSlot - 1]).itemTypeIndex).useType; + if (useType == VRR_ITEM_USETYPE_WEAPON || VRR_ITEM_USETYPE_TAZER || useType == VRR_ITEM_USETYPE_AMMO_CLIP) { + if (isPlayerWeaponBanned(client) && !isPlayerExemptFromAntiCheat(client)) { messagePlayerError(client, getLocaleString(client, "WeaponBanned")); return false; } @@ -2397,7 +2445,7 @@ function buyFromBusinessCommand(command, params, client) { //messagePlayerSuccess(client, `You bought ${amount} {ALTCOLOUR}${itemName} {MAINCOLOUR}for ${totalCost} ${priceEach}`); meActionToNearbyPlayers(client, `buys a ${itemName}`); - if(doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForCommand("inv")) { + if (doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForCommand("inv")) { let keyData = getPlayerKeyBindForCommand("inv"); messagePlayerNewbieTip(client, getLocaleString(client, "ViewInventoryKeyPressTip", `{ALTCOLOUR}${getKeyNameFromId(keyData.key)}{MAINCOLOUR}`)); } else { @@ -2419,33 +2467,33 @@ function buyFromBusinessCommand(command, params, client) { function setBusinessItemSellPriceCommand(command, params, client) { let businessId = getBusinessFromParams(getParam(params, " ", 3)) || getPlayerBusiness(client); - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } let itemSlot = toInteger(getParam(params, " ", 1)) || 0; - if(typeof getBusinessData(businessId).floorItemCache[itemSlot-1] == "undefined") { - messagePlayerError(client, `Item slot ${itemSlot-1} doesn't exist!`); + if (typeof getBusinessData(businessId).floorItemCache[itemSlot - 1] == "undefined") { + messagePlayerError(client, `Item slot ${itemSlot - 1} doesn't exist!`); return false; } - if(getBusinessData(businessId).floorItemCache[itemSlot-1] == -1) { - messagePlayerError(client, `Item slot ${itemSlot-1} slot is empty!`); + if (getBusinessData(businessId).floorItemCache[itemSlot - 1] == -1) { + messagePlayerError(client, `Item slot ${itemSlot - 1} slot is empty!`); return false; } - let oldPrice = getBusinessData(businessId).floorItemCache[itemSlot-1].buyPrice; + let oldPrice = getBusinessData(businessId).floorItemCache[itemSlot - 1].buyPrice; let newPrice = toInteger(getParam(params, " ", 2)) || oldPrice; - if(newPrice < 0) { + if (newPrice < 0) { messagePlayerError(client, "The price can't be negative!"); return false; } - getItemData(getBusinessData(businessId).floorItemCache[itemSlot-1]).buyPrice = newPrice; + getItemData(getBusinessData(businessId).floorItemCache[itemSlot - 1]).buyPrice = newPrice; - messagePlayerSuccess(client, `You changed the price of the {ALTCOLOUR}${getItemTypeData(getItemData(getBusinessData(businessId).floorItemCache[itemSlot-1]).itemTypeIndex).name}'s {MAINCOLOUR}in slot {ALTCOLOUR}${itemSlot} {MAINCOLOUR}from $${makeLargeNumberReadable(oldPrice)} to $${makeLargeNumberReadable(newprice)}`); + messagePlayerSuccess(client, `You changed the price of the {ALTCOLOUR}${getItemTypeData(getItemData(getBusinessData(businessId).floorItemCache[itemSlot - 1]).itemTypeIndex).name}'s {MAINCOLOUR}in slot {ALTCOLOUR}${itemSlot} {MAINCOLOUR}from $${makeLargeNumberReadable(oldPrice)} to $${makeLargeNumberReadable(newprice)}`); } // =========================================================================== @@ -2462,33 +2510,33 @@ function setBusinessItemSellPriceCommand(command, params, client) { function storeItemInBusinessStorageCommand(command, params, client) { let businessId = getBusinessFromParams(getParam(params, " ", 3)) || getPlayerBusiness(client); - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } let itemSlot = toInteger(getParam(params, " ", 1)) || 0; - if(typeof getBusinessData(businessId).floorItemCache[itemSlot-1] == "undefined") { + if (typeof getBusinessData(businessId).floorItemCache[itemSlot - 1] == "undefined") { messagePlayerError(client, `Item slot ${itemSlot} doesn't exist!`); return false; } - if(getBusinessData(businessId).floorItemCache[itemSlot-1] == -1) { + if (getBusinessData(businessId).floorItemCache[itemSlot - 1] == -1) { messagePlayerError(client, `Item slot ${itemSlot} slot is empty!`); return false; } let firstSlot = getBusinessStorageFirstFreeItemSlot(businessId); - if(firstSlot == -1) { + if (firstSlot == -1) { messagePlayerError(client, `There isn't any room in this business storage`); return false; } - getItemData(getBusinessData(businessId).floorItemCache[itemSlot-1]).ownerType = VRR_ITEM_OWNER_BIZSTORAGE; - getBusinessData(businessId).storageItemCache[firstSlot] = getBusinessData(businessId).floorItemCache[itemSlot-1]; - getBusinessData(businessId).storageItemCache[itemSlot-1] = -1; + getItemData(getBusinessData(businessId).floorItemCache[itemSlot - 1]).ownerType = VRR_ITEM_OWNER_BIZSTORAGE; + getBusinessData(businessId).storageItemCache[firstSlot] = getBusinessData(businessId).floorItemCache[itemSlot - 1]; + getBusinessData(businessId).storageItemCache[itemSlot - 1] = -1; messagePlayerSuccess(client, `You moved the ${getItemTypeData(getItemData(getBusinessData(businessId).storageItemCache[firstSlot]).itemTypeIndex).name}s in slot ${itemSlot} to the business storage in slot ${firstSlot}`); } @@ -2506,33 +2554,33 @@ function storeItemInBusinessStorageCommand(command, params, client) { function stockItemOnBusinessFloorCommand(command, params, client) { let businessId = getPlayerBusiness(client); - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } let itemSlot = toInteger(getParam(params, " ", 1)) || 0; - if(typeof getBusinessData(businessId).storageItemCache[itemSlot-1] == "undefined") { + if (typeof getBusinessData(businessId).storageItemCache[itemSlot - 1] == "undefined") { messagePlayerError(client, `Item slot ${itemSlot} doesn't exist!`); return false; } - if(getBusinessData(businessId).storageItemCache[itemSlot-1] == -1) { + if (getBusinessData(businessId).storageItemCache[itemSlot - 1] == -1) { messagePlayerError(client, `Item slot ${itemSlot} slot is empty!`); return false; } let firstSlot = getBusinessFloorFirstFreeItemSlot(businessId); - if(firstSlot == -1) { + if (firstSlot == -1) { messagePlayerError(client, `There isn't any room in this business storage`); return false; } - getItemData(getBusinessData(businessId).storageItemCache[itemSlot-1]).ownerType = VRR_ITEM_OWNER_BIZFLOOR; - getBusinessData(businessId).floorItemCache[firstSlot] = getBusinessData(businessId).storageItemCache[itemSlot-1]; - getBusinessData(businessId).storageItemCache[itemSlot-1] = -1; + getItemData(getBusinessData(businessId).storageItemCache[itemSlot - 1]).ownerType = VRR_ITEM_OWNER_BIZFLOOR; + getBusinessData(businessId).floorItemCache[firstSlot] = getBusinessData(businessId).storageItemCache[itemSlot - 1]; + getBusinessData(businessId).storageItemCache[itemSlot - 1] = -1; messagePlayerSuccess(client, `You moved the ${getItemTypeData(getItemData(getBusinessData(businessId).storageItemCache[firstSlot]).itemTypeIndex).name}s in slot ${itemSlot} of the business storage to the business floor slot ${firstSlot}`); } @@ -2555,7 +2603,7 @@ function getBusinessFloorFirstFreeItemSlot(businessId) { // Caches all items for all businesses function cacheAllBusinessItems() { logToConsole(LOG_DEBUG, "[VRR.Business] Caching all business items ..."); - for(let i in getServerData().businesses) { + for (let i in getServerData().businesses) { cacheBusinessItems(i); } logToConsole(LOG_DEBUG, "[VRR.Business] Cached all business items successfully!"); @@ -2574,10 +2622,10 @@ function cacheBusinessItems(businessId) { //getBusinessData(businessId).storageItemCache = getServerData().items.filter(item => item.ownerType == VRR_ITEM_OWNER_BIZSTORAGE && item.ownerId == businessData.databaseId); logToConsole(LOG_VERBOSE, `[VRR.Business] Caching business items for business ${businessId} (${getBusinessData(businessId).name}) ...`); - for(let i in getServerData().items) { - if(getItemData(i).ownerType == VRR_ITEM_OWNER_BIZFLOOR && getItemData(i).ownerId == getBusinessData(businessId).databaseId) { + for (let i in getServerData().items) { + if (getItemData(i).ownerType == VRR_ITEM_OWNER_BIZFLOOR && getItemData(i).ownerId == getBusinessData(businessId).databaseId) { getBusinessData(businessId).floorItemCache.push(i); - } else if(getItemData(i).ownerType == VRR_ITEM_OWNER_BIZSTORAGE && getItemData(i).ownerId == getBusinessData(businessId).databaseId) { + } else if (getItemData(i).ownerType == VRR_ITEM_OWNER_BIZSTORAGE && getItemData(i).ownerId == getBusinessData(businessId).databaseId) { getBusinessData(businessId).storageItemCache.push(i); } } @@ -2596,17 +2644,17 @@ function getBusinessIdFromDatabaseId(databaseId) { // Updates all pickup data for a business by businessId function updateBusinessPickupLabelData(businessId) { - if(!areServerElementsSupported()) { + if (!areServerElementsSupported()) { return false; } - if(getBusinessData(businessId).exitPickup != null) { + if (getBusinessData(businessId).exitPickup != null) { setEntityData(getBusinessData(businessId).exitPickup, "vrr.owner.type", VRR_PICKUP_BUSINESS_EXIT, false); setEntityData(getBusinessData(businessId).exitPickup, "vrr.owner.id", businessId, false); setEntityData(getBusinessData(businessId).exitPickup, "vrr.label.type", VRR_LABEL_EXIT, true); } - if(getBusinessData(businessId).entrancePickup != null) { + if (getBusinessData(businessId).entrancePickup != null) { setEntityData(getBusinessData(businessId).entrancePickup, "vrr.owner.type", VRR_PICKUP_BUSINESS_ENTRANCE, false); setEntityData(getBusinessData(businessId).entrancePickup, "vrr.owner.id", businessId, false); setEntityData(getBusinessData(businessId).entrancePickup, "vrr.label.type", VRR_LABEL_BUSINESS, true); @@ -2614,7 +2662,7 @@ function updateBusinessPickupLabelData(businessId) { setEntityData(getBusinessData(businessId).entrancePickup, "vrr.label.locked", getBusinessData(businessId).locked, true); setEntityData(getBusinessData(businessId).entrancePickup, "vrr.label.help", VRR_PROPLABEL_INFO_NONE, true); - switch(getBusinessData(businessId).labelHelpType) { + switch (getBusinessData(businessId).labelHelpType) { case VRR_PROPLABEL_INFO_ENTERVEHICLE: { setEntityData(getBusinessData(businessId).entrancePickup, "vrr.label.help", VRR_PROPLABEL_INFO_ENTERVEHICLE, true); break; @@ -2631,10 +2679,10 @@ function updateBusinessPickupLabelData(businessId) { } default: { - if(getBusinessData(businessId).hasInterior) { + if (getBusinessData(businessId).hasInterior) { setEntityData(getBusinessData(businessId).entrancePickup, "vrr.label.help", VRR_PROPLABEL_INFO_ENTER, true); } else { - if(doesBusinessHaveAnyItemsToBuy(businessId)) { + if (doesBusinessHaveAnyItemsToBuy(businessId)) { setEntityData(getBusinessData(businessId).entrancePickup, "vrr.label.help", VRR_PROPLABEL_INFO_BUY, true); } else { removeEntityData(getBusinessData(businessId).entrancePickup, "vrr.label.help"); @@ -2675,7 +2723,7 @@ function resetAllBusinessPickups(businessId) { // =========================================================================== function resetAllBusinessBlips() { - for(let i in getServerData().businesses) { + for (let i in getServerData().businesses) { deleteBusinessBlips(i); createBusinessBlips(i); } @@ -2691,7 +2739,7 @@ function createBusinessBlips(businessId) { // =========================================================================== function resetAllBusinessPickups() { - for(let i in getServerData().businesses) { + for (let i in getServerData().businesses) { deleteBusinessPickups(i); createBusinessPickups(i); } @@ -2730,8 +2778,8 @@ function doesBusinessHaveAnyItemsToBuy(businessId) { function updateBusinessInteriorLightsForOccupants(businessId) { let clients = getClients() - for(let i in clients) { - if(getPlayerBusiness(clients[i]) == businessId) { + for (let i in clients) { + if (getPlayerBusiness(clients[i]) == businessId) { updateInteriorLightsForPlayer(clients[i], getBusinessData(businessId).interiorLights); } } @@ -2740,16 +2788,16 @@ function updateBusinessInteriorLightsForOccupants(businessId) { // =========================================================================== function canPlayerWithdrawFromBusinessTill(client, businessId) { - if(doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageBusinesses"))) { + if (doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageBusinesses"))) { return true; } - if(getBusinessData(businessId).ownerType == VRR_BIZOWNER_PLAYER && getBusinessData(businessId).ownerId == getPlayerCurrentSubAccount(client).databaseId) { + if (getBusinessData(businessId).ownerType == VRR_BIZOWNER_PLAYER && getBusinessData(businessId).ownerId == getPlayerCurrentSubAccount(client).databaseId) { return true; } - if(getBusinessData(businessId).ownerType == VRR_BIZOWNER_CLAN && getBusinessData(businessId).ownerId == getClanData(getPlayerClan(client)).databaseId) { - if(doesPlayerHaveClanPermission(client, getClanFlagValue("ManageBusinesses"))) { + if (getBusinessData(businessId).ownerType == VRR_BIZOWNER_CLAN && getBusinessData(businessId).ownerId == getClanData(getPlayerClan(client)).databaseId) { + if (doesPlayerHaveClanPermission(client, getClanFlagValue("ManageBusinesses"))) { return true; } } @@ -2760,16 +2808,16 @@ function canPlayerWithdrawFromBusinessTill(client, businessId) { // =========================================================================== function canPlayerSetBusinessInteriorLights(client, businessId) { - if(doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageBusinesses"))) { + if (doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageBusinesses"))) { return true; } - if(getBusinessData(businessId).ownerType == VRR_BIZOWNER_PLAYER && getBusinessData(businessId).ownerId == getPlayerCurrentSubAccount(client).databaseId) { + if (getBusinessData(businessId).ownerType == VRR_BIZOWNER_PLAYER && getBusinessData(businessId).ownerId == getPlayerCurrentSubAccount(client).databaseId) { return true; } - if(getBusinessData(businessId).ownerType == VRR_BIZOWNER_CLAN && getBusinessData(businessId).ownerId == getClanData(getPlayerClan(client)).databaseId) { - if(doesPlayerHaveClanPermission(client, getClanFlagValue("ManageBusinesses"))) { + if (getBusinessData(businessId).ownerType == VRR_BIZOWNER_CLAN && getBusinessData(businessId).ownerId == getClanData(getPlayerClan(client)).databaseId) { + if (doesPlayerHaveClanPermission(client, getClanFlagValue("ManageBusinesses"))) { return true; } } @@ -2780,16 +2828,16 @@ function canPlayerSetBusinessInteriorLights(client, businessId) { // =========================================================================== function canPlayerLockUnlockBusiness(client, businessId) { - if(doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageBusinesses"))) { + if (doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageBusinesses"))) { return true; } - if(getBusinessData(businessId).ownerType == VRR_BIZOWNER_PLAYER && getBusinessData(businessId).ownerId == getPlayerCurrentSubAccount(client).databaseId) { + if (getBusinessData(businessId).ownerType == VRR_BIZOWNER_PLAYER && getBusinessData(businessId).ownerId == getPlayerCurrentSubAccount(client).databaseId) { return true; } - if(getBusinessData(businessId).ownerType == VRR_BIZOWNER_CLAN && getBusinessData(businessId).ownerId == getClanData(getPlayerClan(client)).databaseId) { - if(doesPlayerHaveClanPermission(client, getClanFlagValue("ManageBusinesses"))) { + if (getBusinessData(businessId).ownerType == VRR_BIZOWNER_CLAN && getBusinessData(businessId).ownerId == getClanData(getPlayerClan(client)).databaseId) { + if (doesPlayerHaveClanPermission(client, getClanFlagValue("ManageBusinesses"))) { return true; } } @@ -2800,19 +2848,19 @@ function canPlayerLockUnlockBusiness(client, businessId) { // =========================================================================== function canPlayerManageBusiness(client, businessId) { - if(doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageBusinesses"))) { + if (doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageBusinesses"))) { return true; } - if(getBusinessData(businessId).ownerType == VRR_BIZOWNER_PLAYER) { - if(getBusinessData(businessId).ownerId == getPlayerCurrentSubAccount(client).databaseId) { + if (getBusinessData(businessId).ownerType == VRR_BIZOWNER_PLAYER) { + if (getBusinessData(businessId).ownerId == getPlayerCurrentSubAccount(client).databaseId) { return true; } } - if(getBusinessData(businessId).ownerType == VRR_BIZOWNER_CLAN) { - if(getBusinessData(businessId).ownerId == getPlayerClan(client)) { - if(doesPlayerHaveClanPermission(client, getClanFlagValue("ManageBusinesses"))) { + if (getBusinessData(businessId).ownerType == VRR_BIZOWNER_CLAN) { + if (getBusinessData(businessId).ownerId == getPlayerClan(client)) { + if (doesPlayerHaveClanPermission(client, getClanFlagValue("ManageBusinesses"))) { return true; } @@ -2842,14 +2890,14 @@ function deleteBusinessPickups(business) { // =========================================================================== function getBusinessFromParams(params) { - if(isNaN(params)) { - for(let i in getServerData().businesses) { - if(toLowerCase(getServerData().businesses[i].name).indexOf(toLowerCase(params)) != -1) { + if (isNaN(params)) { + for (let i in getServerData().businesses) { + if (toLowerCase(getServerData().businesses[i].name).indexOf(toLowerCase(params)) != -1) { return i; } } } else { - if(typeof getServerData().businesses[params] != "undefined") { + if (typeof getServerData().businesses[params] != "undefined") { return toInteger(params); } } @@ -2859,7 +2907,7 @@ function getBusinessFromParams(params) { // =========================================================================== function deleteAllBusinessBlips() { - for(let i in getServerData().businesses) { + for (let i in getServerData().businesses) { deleteBusinessBlips(i); } } @@ -2867,7 +2915,7 @@ function deleteAllBusinessBlips() { // =========================================================================== function deleteAllBusinessPickups() { - for(let i in getServerData().businesses) { + for (let i in getServerData().businesses) { deleteBusinessPickups(i); } } @@ -2876,8 +2924,8 @@ function deleteAllBusinessPickups() { function getBusinessFromInteriorAndDimension(dimension, interior) { let businesses = getServerData().businesses; - for(let i in businesses) { - if(businesses[i].exitInterior == interior && businesses[i].exitDimension == dimension) { + for (let i in businesses) { + if (businesses[i].exitInterior == interior && businesses[i].exitDimension == dimension) { return i; } } @@ -2891,8 +2939,8 @@ function getClosestBusinessWithBuyableItemOfUseType(position, useType) { let availableBusinesses = getBusinessesWithBuyableItemOfUseType(useType); let closestBusiness = 0; - for(let i in availableBusinesses) { - if(getDistance(position, getBusinessData(availableBusinesses[i]).entrancePosition) < getDistance(position, getBusinessData(availableBusinesses[closestBusiness]).entrancePosition)) { + for (let i in availableBusinesses) { + if (getDistance(position, getBusinessData(availableBusinesses[i]).entrancePosition) < getDistance(position, getBusinessData(availableBusinesses[closestBusiness]).entrancePosition)) { closestBusiness = i; } } @@ -2903,8 +2951,8 @@ function getClosestBusinessWithBuyableItemOfUseType(position, useType) { function getBusinessesWithBuyableItemOfUseType(useType) { let businesses = getServerData().businesses; - for(let i in businesses) { - if(doesBusinessHaveBuyableItemOfUseType(i, useType)) { + for (let i in businesses) { + if (doesBusinessHaveBuyableItemOfUseType(i, useType)) { availableBusinesses.push(i); } } @@ -2916,10 +2964,10 @@ function getBusinessesWithBuyableItemOfUseType(useType) { function doesBusinessHaveBuyableItemOfUseType(businessId, useType) { let floorItems = getBusinessData(businessId).floorItemCache; - for(let i in floorItems) { - if(floorItems[i] != -1) { - if(getItemData(floorItems[i]) != false) { - if(getItemTypeData(getItemData(floorItems[i])).useType == useType) { + for (let i in floorItems) { + if (floorItems[i] != -1) { + if (getItemData(floorItems[i]) != false) { + if (getItemTypeData(getItemData(floorItems[i])).useType == useType) { return true; } } diff --git a/scripts/server/clan.js b/scripts/server/clan.js index 5fa85af6..e409f65b 100644 --- a/scripts/server/clan.js +++ b/scripts/server/clan.js @@ -124,7 +124,7 @@ function removeClanRank(clanId, rankId) { return false; } - quickDatabaseQuery(`DELETE FROM clan_rank WHERE clan_rank_id = ${tempClanRankData.database}`); + quickDatabaseQuery(`UPDATE clan_rank SET clan_rank_deleted = 1, clan_rank_when_deleted = UNIX_TIMESTAMP(), clan_rank_who_deleted = ${getPlayerData(client).accountData.databaseId} WHERE biz_id ${tempClanRankData.database}`); getClanData(clanId).ranks.splice(tempClanRankData.index, 1); } @@ -210,7 +210,7 @@ function deleteClanCommand(command, params, client) { } messageAdmins(`{adminOrange}${getPlayerName(client)} {MAINCOLOUR}deleted clan {clanOrange}${getClanData(clanId).name}`); - deleteClan(clanId); + deleteClan(clanId, getPlayerData(client).accountData.databaseId); } // =========================================================================== @@ -879,12 +879,12 @@ function createClan(name) { // =========================================================================== -function deleteClan(clanId) { +function deleteClan(clanId, whoDeleted = 0) { //saveAllClansToDatabase(); let dbConnection = connectToDatabase(); if(dbConnection) { - let dbQuery = queryDatabase(dbConnection, `UPDATE clan_main SET clan_deleted = 1 WHERE clan_id = ${clanId}`); + let dbQuery = queryDatabase(dbConnection, `UPDATE clan_main SET clan_deleted = 1, clan_when_deleted = UNIX_TIMESTAMP, clan_who_deleted = ${whoDeleted} WHERE clan_id = ${clanId}`); freeDatabaseQuery(dbQuery); disconnectFromDatabase(dbConnection); diff --git a/scripts/server/class.js b/scripts/server/class.js index aa8f7ea4..9bb7fe04 100644 --- a/scripts/server/class.js +++ b/scripts/server/class.js @@ -91,7 +91,7 @@ class ServerConfigData { sendAdmin: true, }; - if(dbAssoc) { + if (dbAssoc) { this.databaseId = dbAssoc["svr_id"]; this.newCharacter = { spawnPosition: toVector3(dbAssoc["svr_newchar_pos_x"], dbAssoc["svr_newchar_pos_y"], dbAssoc["svr_newchar_pos_z"]), @@ -99,7 +99,7 @@ class ServerConfigData { 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"]); @@ -118,6 +118,7 @@ class ServerConfigData { this.createJobBlips = intToBool(toInteger(dbAssoc["svr_job_blips"])); this.createBusinessBlips = intToBool(toInteger(dbAssoc["svr_biz_blips"])); this.createHouseBlips = intToBool(toInteger(dbAssoc["svr_house_blips"])); + this.createPlayerBlips = intToBool(toInteger(dbAssoc["svr_player_blips"])); this.guiColourPrimary = [toInteger(dbAssoc["svr_gui_col1_r"]), toInteger(dbAssoc["svr_gui_col1_g"]), toInteger(dbAssoc["svr_gui_col1_b"])]; this.guiColourSecondary = [toInteger(dbAssoc["svr_gui_col2_r"]), toInteger(dbAssoc["svr_gui_col2_g"]), toInteger(dbAssoc["svr_gui_col2_b"])]; this.guiTextColourPrimary = [toInteger(dbAssoc["svr_gui_textcol1_r"]), toInteger(dbAssoc["svr_gui_textcol1_g"]), toInteger(dbAssoc["svr_gui_textcol1_b"])]; @@ -153,8 +154,12 @@ class ServerConfigData { */ class ClientData { constructor(client, accountData, subAccounts) { + /** @member {AccountData} accountData */ this.accountData = accountData; + + /** @member {Array.} subAccounts */ this.subAccounts = subAccounts; // Characters + this.client = client; this.currentSubAccount = -1; this.loggedIn = false; @@ -239,6 +244,7 @@ class ClientData { this.incomingDamageMultiplier = 1; this.weaponDamageEvent = VRR_WEAPON_DAMAGE_EVENT_NORMAL; + // Animation this.currentAnimation = -1; this.currentAnimationPositionOffset = false; this.currentAnimationPositionReturnTo = false; @@ -247,16 +253,13 @@ class ClientData { this.passwordResetState = VRR_RESETPASS_STATE_NONE; this.passwordResetCode = ""; - this.lastJobVehicle = null; this.health = 100; this.locale = 0; - this.enteringVehicle = null; - this.customDisconnectReason = ""; - this.interiorCutscene = -1; + this.playerBlip = null; } }; @@ -275,15 +278,14 @@ class AccountData { }; this.staffTitle = ""; this.ircAccount = ""; - this.discordAccount = 0, - this.settings = 0, + this.discordAccount = 0; + this.settings = 0; this.emailAddress = ""; - this.ipAddress = 0, + this.ipAddress = 0; this.notes = []; this.messages = []; this.contacts = []; - this.subAccounts = []; this.emailVerificationCode = ""; this.twoFactorAuthVerificationCode = ""; @@ -294,7 +296,7 @@ class AccountData { this.streamingRadioVolume = 20; this.locale = 0; - if(dbAssoc) { + if (dbAssoc) { this.databaseId = dbAssoc["acct_id"]; this.name = dbAssoc["acct_name"]; this.password = dbAssoc["acct_pass"]; @@ -338,7 +340,7 @@ class AccountContactData { this.whenAdded = 0; this.needsSaved = false; - if(dbAssoc) { + if (dbAssoc) { this.databaseId = dbAssoc["acct_contact_id"]; this.accountId = dbAssoc["acct_contact_acct"]; this.contactAccountId = dbAssoc["acct_contact_contact"]; @@ -364,7 +366,7 @@ class AccountMessageData { this.message = ""; this.needsSaved = false; - if(dbAssoc) { + if (dbAssoc) { this.databaseId = dbAssoc["acct_msg_id"]; this.account = dbAssoc["acct_msg_acct"]; this.whoSent = dbAssoc["acct_msg_who_sent"]; @@ -393,7 +395,7 @@ class AccountStaffNoteData { this.note = ""; this.needsSaved = false; - if(dbAssoc) { + if (dbAssoc) { this.databaseId = dbAssoc["acct_note_id"]; this.account = dbAssoc["acct_note_acct"]; this.whoAdded = dbAssoc["acct_note_who_added"]; @@ -444,26 +446,26 @@ class SubAccountData { this.accent = ""; this.bodyParts = { - hair: [0,0], - head: [0,0], - upper: [0,0], - lower: [0,0], + 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], + 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) { + if (dbAssoc) { this.databaseId = dbAssoc["sacct_id"]; this.serverId = toInteger(dbAssoc["sacct_server"]); this.firstName = dbAssoc["sacct_name_first"]; @@ -567,7 +569,7 @@ class BusinessData { this.customInterior = false; - if(dbAssoc) { + if (dbAssoc) { this.databaseId = toInteger(dbAssoc["biz_id"]); this.name = toString(dbAssoc["biz_name"]); this.ownerType = toInteger(dbAssoc["biz_owner_type"]); @@ -621,7 +623,7 @@ class BusinessLocationData { this.interior = 0; this.dimension = 0; - if(dbAssoc) { + if (dbAssoc) { this.databaseId = toInteger(dbAssoc["biz_loc_id"]); this.name = toString(dbAssoc["biz_loc_name"]); this.type = toInteger(dbAssoc["biz_loc_type"]); @@ -648,7 +650,7 @@ class BusinessGameScriptData { this.businessIndex = -1; this.needsSaved = false; - if(dbAssoc) { + if (dbAssoc) { this.databaseId = toInteger(dbAssoc["biz_script_id"]); this.name = toString(dbAssoc["biz_script_name"]); this.state = toInteger(dbAssoc["biz_script_state"]); @@ -703,7 +705,7 @@ class HouseData { this.customInterior = false; - if(dbAssoc) { + if (dbAssoc) { this.databaseId = toInteger(dbAssoc["house_id"]); this.description = toString(dbAssoc["house_description"]); this.ownerType = toInteger(dbAssoc["house_owner_type"]); @@ -754,7 +756,7 @@ class HouseLocationData { this.interior = 0; this.dimension = 0; - if(dbAssoc) { + if (dbAssoc) { this.databaseId = toInteger(dbAssoc["house_loc_id"]); this.name = toString(dbAssoc["house_loc_name"]); this.type = toInteger(dbAssoc["house_loc_type"]); @@ -786,7 +788,7 @@ class HouseGameScriptData { this.houseIndex = -1; this.needsSaved = false; - if(dbAssoc) { + if (dbAssoc) { this.databaseId = toInteger(dbAssoc["house_script_id"]); this.name = toString(dbAssoc["house_script_name"]); this.state = toInteger(dbAssoc["house_script_state"]); @@ -814,7 +816,7 @@ class ClanData { this.needsSaved = false; this.motd = false; - if(dbAssoc) { + if (dbAssoc) { this.databaseId = toInteger(dbAssoc["clan_id"]); this.name = dbAssoc["clan_name"]; this.owner = toInteger(dbAssoc["clan_owner"]); @@ -843,7 +845,7 @@ class ClanRankData { this.clanIndex = -1; this.needsSaved = false; - if(dbAssoc) { + if (dbAssoc) { this.databaseId = toInteger(dbAssoc["clan_rank_id"]); this.clan = toInteger(dbAssoc["clan_rank_clan"]); this.name = dbAssoc["clan_rank_name"]; @@ -873,7 +875,7 @@ class ClanMemberData { this.rankIndex = -1; this.needsSaved = false; - if(dbAssoc) { + if (dbAssoc) { this.databaseId = toInteger(dbAssoc["clan_member_id"]); this.subAccount = toInteger(dbAssoc["clan_member_sacct"]); this.clan = toInteger(dbAssoc["clan_member_clan"]); @@ -960,7 +962,7 @@ class VehicleData { this.triggers = []; - if(dbAssoc) { + if (dbAssoc) { // General Info this.databaseId = toInteger(dbAssoc["veh_id"]); this.serverId = toInteger(dbAssoc["veh_server"]); @@ -1081,7 +1083,7 @@ class JobData { this.blackList = []; this.routes = []; - if(dbAssoc) { + if (dbAssoc) { this.databaseId = dbAssoc["job_id"]; this.serverId = dbAssoc["job_server"]; this.type = dbAssoc["job_type"]; @@ -1119,7 +1121,7 @@ class JobEquipmentData { this.needsSaved = false; this.items = []; - if(dbAssoc) { + if (dbAssoc) { this.databaseId = dbAssoc["job_equip_id"]; this.job = dbAssoc["job_equip_job"]; this.name = dbAssoc["job_equip_name"]; @@ -1143,7 +1145,7 @@ class JobEquipmentItemData { this.jobIndex = -1; this.needsSaved = false; - if(dbAssoc) { + if (dbAssoc) { this.databaseId = dbAssoc["job_equip_item_id"]; this.equipmentId = dbAssoc["job_equip_item_equip"]; this.itemType = dbAssoc["job_equip_item_type"]; @@ -1169,26 +1171,26 @@ class JobUniformData { this.needsSaved = false; this.bodyParts = { - hair: [0,0], - head: [0,0], - upper: [0,0], - lower: [0,0], + 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], + 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) { + if (dbAssoc) { this.databaseId = dbAssoc["job_uniform_id"]; this.job = dbAssoc["job_uniform_job"]; this.name = dbAssoc["job_uniform_name"]; @@ -1237,7 +1239,7 @@ class JobLocationData { this.needsSaved = false; this.routeCache = []; - if(dbAssoc) { + if (dbAssoc) { this.databaseId = toInteger(dbAssoc["job_loc_id"]); this.jobId = toInteger(dbAssoc["job_loc_job"]); this.position = toVector3(toFloat(dbAssoc["job_loc_pos_x"]), toFloat(dbAssoc["job_loc_pos_y"]), toFloat(dbAssoc["job_loc_pos_z"])); @@ -1258,7 +1260,7 @@ class JobWhiteListData { this.jobIndex = -1; this.needsSaved = false; - if(dbAssoc) { + if (dbAssoc) { this.databaseId = dbAssoc["job_wl_id"]; this.job = dbAssoc["job_wl_job"]; this.subAccount = dbAssoc["job_wl_sacct"] @@ -1277,7 +1279,7 @@ class JobBlackListData { this.jobIndex = -1; this.needsSaved = false; - if(dbAssoc) { + if (dbAssoc) { this.databaseId = dbAssoc["job_bl_id"]; this.job = dbAssoc["job_bl_job"]; this.subAccount = dbAssoc["job_bl_sacct"] @@ -1298,7 +1300,7 @@ class KeyBindData { this.index = -1; this.needsSaved = false; - if(dbAssoc) { + if (dbAssoc) { this.databaseId = dbAssoc["acct_hotkey_id"]; this.key = toInteger(dbAssoc["acct_hotkey_key"]); this.account = toInteger(dbAssoc["acct_hotkey_acct"]); @@ -1319,7 +1321,7 @@ class RadioStationData { this.codec = ""; this.index = -1; - if(dbAssoc) { + if (dbAssoc) { this.databaseId = dbAssoc["radio_id"]; this.name = dbAssoc["radio_name"]; this.url = dbAssoc["radio_url"]; @@ -1349,7 +1351,7 @@ class ItemData { this.enabled = false; this.extra = false; - if(dbAssoc) { + if (dbAssoc) { this.databaseId = toInteger(dbAssoc["item_id"]); this.index = 0; this.itemTypeIndex = 0; @@ -1412,7 +1414,7 @@ class ItemTypeData { this.takeAnimationIndex = false; this.switchAnimationIndex = false; - if(dbAssoc) { + if (dbAssoc) { this.databaseId = toInteger(dbAssoc["item_type_id"]); this.serverId = toInteger(dbAssoc["item_type_server"]); this.name = dbAssoc["item_type_name"]; @@ -1486,28 +1488,28 @@ class NPCData { this.ownerId = 0; this.bodyParts = { - hair: [0,0], - head: [0,0], - upper: [0,0], - lower: [0,0], + 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], + 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], }; this.triggers = []; - if(dbAssoc) { + if (dbAssoc) { this.databaseId = toInteger(dbAssoc["npc_id"]); this.serverId = toInteger(dbAssoc["npc_server"]); this.name = dbAssoc["npc_name"]; @@ -1567,7 +1569,7 @@ class NPCTriggerData { this.conditions = []; this.responses = []; - if(dbAssoc) { + if (dbAssoc) { this.databaseId = toInteger(dbAssoc["npc_trig_id"]); this.npc = toInteger(dbAssoc["npc_trig_npc"]); this.triggerType = toInteger(dbAssoc["npc_trig_type"]); @@ -1585,7 +1587,7 @@ class NPCTriggerConditionData { this.conditionValue = false; this.matchType = false; - if(dbAssoc) { + 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"]); @@ -1604,7 +1606,7 @@ class NPCTriggerResponseData { this.responseType = 0; this.responseValue = false; - if(dbAssoc) { + 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"]); @@ -1622,7 +1624,7 @@ class BanData { this.name = ""; this.reason = ""; - if(dbAssoc) { + if (dbAssoc) { this.databaseId = toInteger(dbAssoc["ban_id"]); this.type = dbAssoc["ban_type"]; this.detail = toInteger(dbAssoc["ban_detail"]); @@ -1653,7 +1655,7 @@ class JobRouteData { this.locationNextMessage = ""; this.locations = []; - if(dbAssoc) { + if (dbAssoc) { this.databaseId = toInteger(dbAssoc["job_route_id"]); this.name = toString(dbAssoc["job_route_name"]); this.jobId = toInteger(dbAssoc["job_route_job"]); @@ -1685,7 +1687,7 @@ class JobRouteLocationData { this.stopDelay = 0; this.pay = 0; - if(dbAssoc) { + if (dbAssoc) { this.databaseId = toInteger(dbAssoc["job_route_loc_id"]); this.name = toString(dbAssoc["job_route_loc_name"]); this.routeId = toInteger(dbAssoc["job_route_loc_route"]); @@ -1708,7 +1710,7 @@ class GateData { this.ownerType = VRR_GATEOWNER_NONE; this.ownerId = 0; - if(dbAssoc) { + if (dbAssoc) { this.databaseId = toInteger(dbAssoc["gate_id"]); this.name = toString(dbAssoc["gate_name"]); this.scriptName = toString(dbAssoc["gate_script_name"]); diff --git a/scripts/server/client.js b/scripts/server/client.js index d776ea15..3c424815 100644 --- a/scripts/server/client.js +++ b/scripts/server/client.js @@ -92,7 +92,7 @@ function updatePlayerNameTag(client) { function updateAllPlayerNameTags() { logToConsole(LOG_DEBUG, `[VRR.Client] Sending updated nametags to all players`); let clients = getClients(); - for(let i in clients) { + for (let i in clients) { updatePlayerNameTag(clients[i]); } } @@ -109,7 +109,7 @@ function updatePlayerPing(client) { function playerClientReady(client) { playerResourceReady[client.index] = true; logToConsole(LOG_DEBUG, `[VRR.Client] ${getPlayerDisplayForConsole(client)}'s client resources are downloaded and ready! Started: ${getYesNoFromBool(playerResourceStarted[client.index])}`); - if(playerResourceStarted[client.index] == true) { + if (playerResourceStarted[client.index] == true) { initClient(client); } } @@ -126,7 +126,7 @@ function playerGUIReady(client) { function playerClientStarted(client) { playerResourceStarted[client.index] = true; logToConsole(LOG_DEBUG, `[VRR.Client] ${getPlayerDisplayForConsole(client)}'s client resources are started and running! Ready: ${getYesNoFromBool(playerResourceReady[client.index])}`); - if(playerResourceReady[client.index] == true) { + if (playerResourceReady[client.index] == true) { initClient(client); } } @@ -135,6 +135,7 @@ function playerClientStarted(client) { function playerClientStopped(client) { logToConsole(LOG_DEBUG, `[VRR.Client] ${getPlayerDisplayForConsole(client)}'s client resources have stopped (possibly error?). Kicking them from the server ...`); + getPlayerData(targetClient).customDisconnectReason = `Kicked - Client script verification failed. Possible hacks.`; disconnectPlayer(client); } @@ -219,7 +220,7 @@ function syncPlayerProperties(client) { // =========================================================================== function updatePlayerSnowState(client) { - if(isSnowSupported(getGame())) { + if (isSnowSupported(getGame())) { logToConsole(LOG_DEBUG, `[VRR.Client] Setting ${getPlayerDisplayForConsole(client)}'s snow state (Falling: ${toUpperCase(getOnOffFromBool(getServerConfig().fallingSnow))}, Ground: ${toUpperCase(getOnOffFromBool(getServerConfig().groundSnow))})`); sendNetworkEventToPlayer("vrr.snow", client, getServerConfig().fallingSnow, getServerConfig().groundSnow); } @@ -230,12 +231,12 @@ function updatePlayerSnowState(client) { function updatePlayerHotBar(client) { logToConsole(LOG_DEBUG, `[VRR.Client] Sending updated hotbar data to ${getPlayerDisplayForConsole(client)}`); let tempHotBarItems = []; - for(let i in getPlayerData(client).hotBarItems) { + for (let i in getPlayerData(client).hotBarItems) { let itemImage = ""; let itemValue = 0; let itemExists = false; - if(getPlayerData(client).hotBarItems[i] != -1) { - if(getItemData(getPlayerData(client).hotBarItems[i])) { + if (getPlayerData(client).hotBarItems[i] != -1) { + if (getItemData(getPlayerData(client).hotBarItems[i])) { let itemData = getItemData(getPlayerData(client).hotBarItems[i]); let itemTypeData = getItemTypeData(itemData.itemTypeIndex); itemExists = true; @@ -532,9 +533,9 @@ function sendChatBoxMessageToPlayer(client, messageText, colour) { // =========================================================================== function showPlayerItemTakeDelay(client, itemId) { - if(getItemData(itemId)) { + if (getItemData(itemId)) { let delay = getItemTypeData(getItemData(itemId).itemTypeIndex).pickupDelay; - if(delay > 0) { + if (delay > 0) { logToConsole(LOG_DEBUG, `[VRR.Client] Showing item TAKE delay to ${getPlayerDisplayForConsole(client)} (${delay} milliseconds)`); sendNetworkEventToPlayer("vrr.showItemActionDelay", client, delay); } else { @@ -547,9 +548,9 @@ function showPlayerItemTakeDelay(client, itemId) { // =========================================================================== function showPlayerItemUseDelay(client, itemSlot) { - if(getItemData(getPlayerData(client).hotBarItems[itemSlot])) { + if (getItemData(getPlayerData(client).hotBarItems[itemSlot])) { let delay = getItemTypeData(getItemData(getPlayerData(client).hotBarItems[itemSlot]).itemTypeIndex).useDelay; - if(delay > 0) { + if (delay > 0) { logToConsole(LOG_DEBUG, `[VRR.Client] Showing item USE delay to ${getPlayerDisplayForConsole(client)} (${delay} milliseconds)`); sendNetworkEventToPlayer("vrr.showItemActionDelay", client, delay); } else { @@ -562,9 +563,9 @@ function showPlayerItemUseDelay(client, itemSlot) { // =========================================================================== function showPlayerItemDropDelay(client, itemSlot) { - if(getItemData(getPlayerData(client).hotBarItems[itemSlot])) { + if (getItemData(getPlayerData(client).hotBarItems[itemSlot])) { let delay = getItemTypeData(getItemData(getPlayerData(client).hotBarItems[itemSlot]).itemTypeIndex).dropDelay; - if(delay > 0) { + if (delay > 0) { logToConsole(LOG_DEBUG, `[VRR.Client] Showing item DROP delay to ${getPlayerDisplayForConsole(client)} (${delay} milliseconds)`); sendNetworkEventToPlayer("vrr.showItemActionDelay", client, delay); } else { @@ -577,9 +578,9 @@ function showPlayerItemDropDelay(client, itemSlot) { // =========================================================================== function showPlayerItemPickupDelay(client, itemId) { - if(getItemData(itemId)) { + if (getItemData(itemId)) { let delay = getItemTypeData(getItemData(itemId).itemTypeIndex).pickupDelay; - if(delay > 0) { + if (delay > 0) { logToConsole(LOG_DEBUG, `[VRR.Client] Showing item PICKUP delay to ${getPlayerDisplayForConsole(client)} (${delay} milliseconds)`); sendNetworkEventToPlayer("vrr.showItemActionDelay", client, delay); } else { @@ -592,9 +593,9 @@ function showPlayerItemPickupDelay(client, itemId) { // =========================================================================== function showPlayerItemPutDelay(client, itemSlot) { - if(getItemData(getPlayerData(client).hotBarItems[itemSlot])) { + if (getItemData(getPlayerData(client).hotBarItems[itemSlot])) { let delay = getItemTypeData(getItemData(getPlayerData(client).hotBarItems[itemSlot]).itemTypeIndex).putDelay; - if(delay > 0) { + if (delay > 0) { logToConsole(LOG_DEBUG, `[VRR.Client] Showing item PUT delay to ${getPlayerDisplayForConsole(client)} (${delay} milliseconds)`); sendNetworkEventToPlayer("vrr.showItemActionDelay", client, delay); } else { @@ -607,13 +608,13 @@ function showPlayerItemPutDelay(client, itemSlot) { // =========================================================================== function showPlayerItemSwitchDelay(client, itemSlot) { - if(itemSlot != -1) { - if(getPlayerData(client).hotBarItems[itemSlot] != -1) { + if (itemSlot != -1) { + if (getPlayerData(client).hotBarItems[itemSlot] != -1) { let delay = getItemTypeData(getItemData(getPlayerData(client).hotBarItems[itemSlot]).itemTypeIndex).switchDelay; - if(delay > 0) { + if (delay > 0) { logToConsole(LOG_DEBUG, `[VRR.Client] Showing item switch delay to ${getPlayerDisplayForConsole(client)} (${delay} milliseconds)`); sendNetworkEventToPlayer("vrr.showItemActionDelay", client, delay); - } else{ + } else { logToConsole(LOG_DEBUG, `[VRR.Client] Showing item switch delay to ${getPlayerDisplayForConsole(client)} (instant)`); playerItemActionDelayComplete(client); } @@ -646,29 +647,29 @@ function sendPlayerClearPedState(client) { function playerDamagedByPlayer(client, damagerEntityName, weaponId, pedPiece, healthLoss) { let damagerEntity = getPlayerFromParams(damagerEntityName); - if(isNull(damagerEntity)) { + if (isNull(damagerEntity)) { logToConsole(LOG_DEBUG, `[VRR.Client] ${getPlayerDisplayForConsole(client)}'s damager entity from ID is null`); return false; } logToConsole(LOG_DEBUG, `[VRR.Client] ${getPlayerDisplayForConsole(client)} was damaged by ${damagerEntity}`); - if(isNull(damagerEntity)) { + if (isNull(damagerEntity)) { logToConsole(LOG_DEBUG, `[VRR.Client] ${getPlayerDisplayForConsole(client)}'s damager client is INVALID`); return false; } - if(!getPlayerData(damagerEntity) || !getPlayerData(client)) { + if (!getPlayerData(damagerEntity) || !getPlayerData(client)) { logToConsole(LOG_DEBUG, `[VRR.Client] ${getPlayerDisplayForConsole(client)}'s damager's client data is INVALID`); return false; } logToConsole(LOG_DEBUG, `[VRR.Client] ${getPlayerDisplayForConsole(client)}'s damager is ${getPlayerDisplayForConsole(damagerEntity)}`); - switch(getPlayerData(damagerEntity).weaponDamageEvent) { + switch (getPlayerData(damagerEntity).weaponDamageEvent) { case VRR_WEAPON_DAMAGE_EVENT_TAZER: logToConsole(LOG_DEBUG, `[VRR.Client] ${getPlayerDisplayForConsole(client)}'s damager ${getPlayerDisplayForConsole(damagerEntity)} is using a tazer`); - if(!isPlayerTazed(client) && !isPlayerHandCuffed(client) && !isPlayerInAnyVehicle(client)) { + if (!isPlayerTazed(client) && !isPlayerHandCuffed(client) && !isPlayerInAnyVehicle(client)) { logToConsole(LOG_DEBUG, `[VRR.Client] ${getPlayerDisplayForConsole(client)} was not previously tazed, binded, or in a vehicle. Taze successful`); meActionToNearbyPlayers(damagerEntity, `electrifies ${getCharacterFullName(client)} with their tazer`); tazePlayer(client); @@ -682,13 +683,13 @@ function playerDamagedByPlayer(client, damagerEntityName, weaponId, pedPiece, he break; case VRR_WEAPON_DAMAGE_EVENT_NORMAL: - logToConsole(LOG_DEBUG, `[VRR.Client] ${getPlayerDisplayForConsole(client)}'s damager ${getPlayerDisplayForConsole(damagerEntity)} caused ${healthLoss} damage (damage reduction makes it ${(healthLoss*getPlayerData(client).incomingDamageMultiplier)})`); - setPlayerHealth(client, getPlayerHealth(client)-(healthLoss*getPlayerData(client).incomingDamageMultiplier)); + logToConsole(LOG_DEBUG, `[VRR.Client] ${getPlayerDisplayForConsole(client)}'s damager ${getPlayerDisplayForConsole(damagerEntity)} caused ${healthLoss} damage (damage reduction makes it ${(healthLoss * getPlayerData(client).incomingDamageMultiplier)})`); + setPlayerHealth(client, getPlayerHealth(client) - (healthLoss * getPlayerData(client).incomingDamageMultiplier)); break; default: - logToConsole(LOG_DEBUG, `[VRR.Client] ${getPlayerDisplayForConsole(client)}'s damager ${getPlayerDisplayForConsole(damagerEntity)} caused ${healthLoss} damage (damage reduction makes it ${(healthLoss*getPlayerData(client).incomingDamageMultiplier)})`); - setPlayerHealth(client, getPlayerHealth(client)-(healthLoss*getPlayerData(client).incomingDamageMultiplier)); + logToConsole(LOG_DEBUG, `[VRR.Client] ${getPlayerDisplayForConsole(client)}'s damager ${getPlayerDisplayForConsole(damagerEntity)} caused ${healthLoss} damage (damage reduction makes it ${(healthLoss * getPlayerData(client).incomingDamageMultiplier)})`); + setPlayerHealth(client, getPlayerHealth(client) - (healthLoss * getPlayerData(client).incomingDamageMultiplier)); break; } } @@ -732,7 +733,7 @@ function updateHeadingInVehicleData(client, vehicle, heading) { // =========================================================================== function forcePlayerIntoSkinSelect(client) { - if(typeof getGameConfig().skinChangePosition[getGame()] != "undefined") { + if (typeof getGameConfig().skinChangePosition[getGame()] != "undefined") { getPlayerData(client).returnToPosition = getPlayerPosition(client); getPlayerData(client).returnToHeading = getPlayerHeading(client); getPlayerData(client).returnToInterior = getPlayerInterior(client); @@ -742,7 +743,7 @@ function forcePlayerIntoSkinSelect(client) { setPlayerPosition(client, getGameConfig().skinChangePosition[getGame()][0]); setPlayerHeading(client, getGameConfig().skinChangePosition[getGame()][1]); setPlayerInterior(client, getGameConfig().skinChangePosition[getGame()][2]); - setPlayerDimension(client, getPlayerId(client)+500); + setPlayerDimension(client, getPlayerId(client) + 500); } sendNetworkEventToPlayer("vrr.skinSelect", client, true); @@ -757,9 +758,9 @@ function updatePlayerCash(client) { // =========================================================================== function sendAllPoliceStationBlips(client) { - if(getGameConfig().blipSprites[getGame()].policeStation != -1) { + if (getGameConfig().blipSprites[getGame()].policeStation != -1) { let tempBlips = []; - for(let i in getServerData().policeStations[getGame()]) { + for (let i in getServerData().policeStations[getGame()]) { tempBlips.push([ getGameConfig().blipSprites[getGame()].policeStation, getServerData().policeStations[getGame()][i].position.x, @@ -776,9 +777,9 @@ function sendAllPoliceStationBlips(client) { // =========================================================================== function sendAllFireStationBlips(client) { - if(getGameConfig().blipSprites[getGame()].fireStation != -1) { + if (getGameConfig().blipSprites[getGame()].fireStation != -1) { let tempBlips = []; - for(let i in getServerData().fireStations[getGame()]) { + for (let i in getServerData().fireStations[getGame()]) { tempBlips.push([ getGameConfig().blipSprites[getGame()].fireStation, getServerData().fireStations[getGame()][i].position.x, @@ -795,9 +796,9 @@ function sendAllFireStationBlips(client) { // =========================================================================== function sendAllHospitalBlips(client) { - if(getGameConfig().blipSprites[getGame()].hospital != -1) { + if (getGameConfig().blipSprites[getGame()].hospital != -1) { let tempBlips = []; - for(let i in getServerData().hospitals[getGame()]) { + for (let i in getServerData().hospitals[getGame()]) { tempBlips.push([ getGameConfig().blipSprites[getGame()].hospital, getServerData().hospitals[getGame()][i].position.x, @@ -814,9 +815,9 @@ function sendAllHospitalBlips(client) { // =========================================================================== function sendAllAmmunationBlips(client) { - if(getGameConfig().blipSprites[getGame()].ammunation != -1) { + if (getGameConfig().blipSprites[getGame()].ammunation != -1) { let tempBlips = []; - for(let i in getServerData().ammunations[getGame()]) { + for (let i in getServerData().ammunations[getGame()]) { tempBlips.push([ getGameConfig().blipSprites[getGame()].ammunation, getServerData().ammunations[getGame()][i].position.x, @@ -833,9 +834,9 @@ function sendAllAmmunationBlips(client) { // =========================================================================== function sendAllPayAndSprayBlips(client) { - if(getGameConfig().blipSprites[getGame()].payAndSpray != -1) { + if (getGameConfig().blipSprites[getGame()].payAndSpray != -1) { let tempBlips = []; - for(let i in getServerData().payAndSprays[getGame()]) { + for (let i in getServerData().payAndSprays[getGame()]) { tempBlips.push([ getGameConfig().blipSprites[getGame()].payAndSpray, getServerData().payAndSprays[getGame()][i].position.x, @@ -852,9 +853,9 @@ function sendAllPayAndSprayBlips(client) { // =========================================================================== function sendAllFuelStationBlips(client) { - if(getGameConfig().blipSprites[getGame()].fuelStation != -1) { + if (getGameConfig().blipSprites[getGame()].fuelStation != -1) { let tempBlips = []; - for(let i in getServerData().fuelStations[getGame()]) { + for (let i in getServerData().fuelStations[getGame()]) { tempBlips.push([ getGameConfig().blipSprites[getGame()].fuelStation, getServerData().fuelStations[getGame()][i].position.x, @@ -884,11 +885,11 @@ function sendPlayerSetArmour(client, armour) { function playerFinishedSkinSelection(client, allowedSkinIndex) { sendNetworkEventToPlayer("vrr.skinSelect", client, false); - if(allowedSkinIndex == -1) { + if (allowedSkinIndex == -1) { messagePlayerAlert(client, "You canceled the skin change."); restorePlayerCamera(client); - if(getPlayerData(client).returnToPosition != null && getPlayerData(client).returnToType == VRR_RETURNTO_TYPE_SKINSELECT) { + if (getPlayerData(client).returnToPosition != null && getPlayerData(client).returnToType == VRR_RETURNTO_TYPE_SKINSELECT) { setPlayerPosition(client, getPlayerData(client).returnToPosition); setPlayerHeading(client, getPlayerData(client).returnToHeading); setPlayerInterior(client, getPlayerData(client).returnToInterior); @@ -902,14 +903,14 @@ function playerFinishedSkinSelection(client, allowedSkinIndex) { return false; } else { getPlayerCurrentSubAccount(client).skin = getSkinIndexFromModel(getServerData().allowedSkins[allowedSkinIndex][0]); - if(isPlayerWorking(client)) { + if (isPlayerWorking(client)) { messagePlayerAlert(client, "Your new skin has been saved but won't be shown until you stop working."); setPlayerSkin(client, getJobData(getPlayerCurrentSubAccount(client).job).uniforms[getPlayerData(client).jobUniform].skinId); } else { setPlayerSkin(client, getPlayerCurrentSubAccount(client).skin); } - if(getPlayerData(client).returnToPosition != null && getPlayerData(client).returnToType == VRR_RETURNTO_TYPE_SKINSELECT) { + if (getPlayerData(client).returnToPosition != null && getPlayerData(client).returnToType == VRR_RETURNTO_TYPE_SKINSELECT) { setPlayerPosition(client, getPlayerData(client).returnToPosition); setPlayerHeading(client, getPlayerData(client).returnToHeading); setPlayerInterior(client, getPlayerData(client).returnToInterior); @@ -1049,9 +1050,9 @@ function onPlayerNearPickup(client, pickupId) { // =========================================================================== function updateAllInteriorVehiclesForPlayer(client, interior, dimension) { - for(let i in getServerData().vehicles) { - if(getServerData().vehicles[i].vehicle != false) { - if(getServerData().vehicles[i].interior == interior && getServerData().vehicles[i].dimension == dimension) { + for (let i in getServerData().vehicles) { + if (getServerData().vehicles[i].vehicle != false) { + if (getServerData().vehicles[i].interior == interior && getServerData().vehicles[i].dimension == dimension) { forcePlayerToSyncElementProperties(client, getServerData().vehicles[i].vehicle); } } @@ -1061,7 +1062,7 @@ function updateAllInteriorVehiclesForPlayer(client, interior, dimension) { // =========================================================================== function setPlayerBuyingVehicleState(client, state, vehicleId, position) { - if(getGlobalConfig().useServerSideVehiclePurchaseCheck == false) { + if (getGlobalConfig().useServerSideVehiclePurchaseCheck == false) { sendNetworkEventToPlayer("vrr.vehBuyState", client, state, vehicleId, position); } } @@ -1069,7 +1070,7 @@ function setPlayerBuyingVehicleState(client, state, vehicleId, position) { // ========================================================================== function receiveVehiclePurchaseStateUpdateFromClient(client, state) { - if(getGlobalConfig().useServerSideVehiclePurchaseCheck == false) { + if (getGlobalConfig().useServerSideVehiclePurchaseCheck == false) { checkVehiclePurchasing(client); } } @@ -1114,7 +1115,7 @@ function sendVehicleToPlayer(client, vehicleId, model, position, heading, colour function sendAllBusinessesToPlayer(client) { let businesses = getServerData().businesses; - for(let i in businesses) { + for (let i in businesses) { sendBusinessToPlayer(client, businesses[i].index, businesses[i].name, businesses[i].entrancePosition, businesses[i].entranceBlipModel, businesses[i].entrancePickupModel, businesses[i].hasInterior, false); } } @@ -1123,7 +1124,7 @@ function sendAllBusinessesToPlayer(client) { function sendAllHousesToPlayer(client) { let houses = getServerData().houses; - for(let i in houses) { + for (let i in houses) { sendHouseToPlayer(client, houses[i].index, houses[i].entrancePosition, houses[i].entranceBlipModel, houses[i].entrancePickupModel, houses[i].hasInterior); } } @@ -1132,10 +1133,10 @@ function sendAllHousesToPlayer(client) { function sendAllJobsToPlayer(client) { let jobs = getServerData().jobs; - for(let i in jobs) { - for(let j in jobs[i].locations) { - sendJobToPlayer(client, jobs[i].index, jobs[i].locations[j].index, jobs[i].name, jobs[i].locations[j].position, jobs[i].blipModel); - } + for (let i in jobs) { + for (let j in jobs[i].locations) { + sendJobToPlayer(client, jobs[i].index, jobs[i].locations[j].index, jobs[i].name, jobs[i].locations[j].position, jobs[i].blipModel); + } } } @@ -1143,7 +1144,7 @@ function sendAllJobsToPlayer(client) { function sendAllVehiclesToPlayer(client) { let vehicles = getServerData().vehicles; - for(let i in vehicles) { + for (let i in vehicles) { sendVehicleToPlayer(client, vehicles[i].index, vehicles[i].model, vehicles[i].syncPosition, vehicles[i].syncHeading, vehicles[i].colour1, vehicles[i].colour2, vehicles[i].colour3, vehicles[i].colour4); } } @@ -1222,4 +1223,13 @@ function showLocaleChooserForPlayer(client) { sendNetworkEventToPlayer("vrr.localeChooser", client); } +// ========================================================================== + +function sendPlayerLocaleStrings(client) { + let strings = getGlobalConfig().locale.sendStringsToClient; + for (let i in strings) { + sendNetworkEventToPlayer("vrr.localeString", client, strings[i], getLocaleString(client, strings[i])); + } +} + // ========================================================================== \ No newline at end of file diff --git a/scripts/server/config.js b/scripts/server/config.js index 34e0c931..be9c961d 100644 --- a/scripts/server/config.js +++ b/scripts/server/config.js @@ -85,8 +85,11 @@ let globalConfig = { houseBlipStreamOutDistance: 120, jobBlipStreamInDistance: -1, jobBlipStreamOutDistance: -1, + playerBlipStreamInDistance: -1, + playerBlipStreamOutDistance: -1, handcuffPlayerDistance: 3, firstAidKitPlayerDistance: 3, + droppedItemPickupRange: 2, passwordRequiredCapitals: 0, passwordRequiredNumbers: 0, passwordRequiredSymbols: 0, @@ -107,49 +110,49 @@ function loadGlobalConfig() { logToConsole(LOG_DEBUG, "[VRR.Config] Loading global configuration ..."); try { getGlobalConfig().database = loadDatabaseConfig(); - } catch(error) { + } catch (error) { logToConsole(LOG_ERROR, `[VRR.Config] Failed to load global configuration. Error: ${error}`); thisResource.stop(); } try { getGlobalConfig().economy = loadEconomyConfig(); - } catch(error) { + } catch (error) { logToConsole(LOG_ERROR, `[VRR.Config] Failed to load economy configuration. Error: ${error}`); thisResource.stop(); } try { getGlobalConfig().locale = loadLocaleConfig(); - } catch(error) { + } catch (error) { logToConsole(LOG_ERROR, `[VRR.Config] Failed to load locale configuration. Error: ${error}`); thisResource.stop(); } try { getGlobalConfig().accents = loadAccentConfig(); - } catch(error) { + } catch (error) { logToConsole(LOG_ERROR, `[VRR.Config] Failed to load accent configuration. Error: ${error}`); thisResource.stop(); } try { getGlobalConfig().discord = loadDiscordConfig(); - } catch(error) { + } catch (error) { logToConsole(LOG_ERROR, `[VRR.Config] Failed to load discord configuration. Error: ${error}`); thisResource.stop(); } try { getGlobalConfig().keyBind = loadKeyBindConfig(); - } catch(error) { + } catch (error) { logToConsole(LOG_ERROR, `[VRR.Config] Failed to load keybind configuration. Error: ${error}`); thisResource.stop(); } try { getGlobalConfig().email = loadEmailConfig(); - } catch(error) { + } catch (error) { logToConsole(LOG_ERROR, `[VRR.Config] Failed to load email configuration. Error: ${error}`); thisResource.stop(); } @@ -161,11 +164,11 @@ function loadGlobalConfig() { function loadServerConfigFromGameAndPort(gameId, port) { let dbConnection = connectToDatabase(); - if(dbConnection) { + if (dbConnection) { let dbQueryString = `SELECT * FROM svr_main WHERE svr_game = ${gameId} AND svr_port = ${port} LIMIT 1;`; let dbQuery = queryDatabase(dbConnection, dbQueryString); - if(dbQuery) { - if(dbQuery.numRows > 0) { + if (dbQuery) { + if (dbQuery.numRows > 0) { let dbAssoc = fetchQueryAssoc(dbQuery); let tempServerConfigData = new ServerConfigData(dbAssoc); freeDatabaseQuery(dbQuery); @@ -181,11 +184,11 @@ function loadServerConfigFromGameAndPort(gameId, port) { function loadServerConfigFromId(tempServerId) { let dbConnection = connectToDatabase(); - if(dbConnection) { + if (dbConnection) { let dbQueryString = `SELECT * FROM svr_main WHERE svr_id = ${tempServerId} LIMIT 1;`; let dbQuery = queryDatabase(dbConnection, dbQueryString); - if(dbQuery) { - if(dbQuery.numRows > 0) { + if (dbQuery) { + if (dbQuery.numRows > 0) { let dbAssoc = fetchQueryAssoc(dbQuery); let tempServerConfigData = new ServerConfigData(dbAssoc); freeDatabaseQuery(dbQuery); @@ -203,12 +206,12 @@ function applyConfigToServer(tempServerConfig) { logToConsole(LOG_INFO, "[VRR.Config]: Applying server config ..."); logToConsole(LOG_DEBUG, "[VRR.Config]: Server config applied successfully!"); - if(isTimeSupported()) { + if (isTimeSupported()) { logToConsole(LOG_DEBUG, `[VRR.Config]: Setting time to to ${tempServerConfig.hour}:${tempServerConfig.minute} with minute duration of ${tempServerConfig.minuteDuration}`); setGameTime(tempServerConfig.hour, tempServerConfig.minute, tempServerConfig.minuteDuration); } - if(isWeatherSupported()) { + if (isWeatherSupported()) { logToConsole(LOG_DEBUG, `[VRR.Config]: Setting weather to ${tempServerConfig.weather}`); game.forceWeather(tempServerConfig.weather); } @@ -220,9 +223,9 @@ function applyConfigToServer(tempServerConfig) { function saveServerConfigToDatabase() { logToConsole(LOG_DEBUG, `[VRR.Config]: Saving server ${getServerConfig().databaseId} configuration to database ...`); - if(getServerConfig().needsSaved) { + if (getServerConfig().needsSaved) { let dbConnection = connectToDatabase(); - if(dbConnection) { + if (dbConnection) { let data = [ //["svr_settings", toInteger(getServerConfig().settings)], ["svr_start_time_hour", getServerConfig().hour], @@ -261,7 +264,7 @@ function saveServerConfigToDatabase() { ["svr_inflation_multiplier", getServerConfig().inflationMultiplier], ["svr_intro_music", getServerConfig().introMusicURL], ["svr_gui", getServerConfig().useGUI], - ["svr_logo", getServerConfig().useLogo], + ["svr_logo", getServerConfig().showLogo], ["svr_snow_falling", getServerConfig().fallingSnow], ["svr_snow_ground", getServerConfig().groundSnow], ["svr_biz_blips", getServerConfig().createBusinessBlips], @@ -329,7 +332,7 @@ function getServerId() { * */ function setTimeCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -337,12 +340,12 @@ function setTimeCommand(command, params, client) { let hour = toInteger(getParam(params, " ", 1)); let minute = toInteger(getParam(params, " ", 2)) || 0; - if(hour > 23 || hour < 0) { + if (hour > 23 || hour < 0) { messagePlayerError(client, "The hour must be between 0 and 23!"); return false; } - if(minute > 59 || minute < 0) { + if (minute > 59 || minute < 0) { messagePlayerError(client, "The minute must be between 0 and 59!"); return false; } @@ -374,7 +377,7 @@ function setTimeCommand(command, params, client) { * */ function setMinuteDurationCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -401,14 +404,14 @@ function setMinuteDurationCommand(command, params, client) { * */ function setWeatherCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } let weatherId = getWeatherFromParams(getParam(params, " ", 1)); - if(!weatherId) { + if (!weatherId) { messagePlayerError(client, `That weather ID or name is invalid!`); return false; } @@ -435,7 +438,7 @@ function setWeatherCommand(command, params, client) { * */ function setSnowingCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -468,7 +471,7 @@ function setSnowingCommand(command, params, client) { * */ function setServerGUIColoursCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -481,7 +484,7 @@ function setServerGUIColoursCommand(command, params, client) { getServerConfig().guiColour = [colourRed, colourGreen, colourBlue]; let clients = getClients(); - for(let i in clients) { + for (let i in clients) { sendPlayerGUIColours(clients[i]); } @@ -525,7 +528,7 @@ function toggleServerLogoCommand(command, params, client) { * @return {bool} Whether or not the command was successful * */ - function toggleServerJobBlipsCommand(command, params, client) { +function toggleServerJobBlipsCommand(command, params, client) { getServerConfig().createJobBlips = !getServerConfig().createJobBlips; getServerConfig().needsSaved = true; @@ -545,7 +548,7 @@ function toggleServerLogoCommand(command, params, client) { * @return {bool} Whether or not the command was successful * */ - function toggleServerJobPickupsCommand(command, params, client) { +function toggleServerJobPickupsCommand(command, params, client) { getServerConfig().createJobPickups = !getServerConfig().createJobPickups; getServerConfig().needsSaved = true; @@ -565,7 +568,7 @@ function toggleServerLogoCommand(command, params, client) { * @return {bool} Whether or not the command was successful * */ - function toggleServerBusinessBlipsCommand(command, params, client) { +function toggleServerBusinessBlipsCommand(command, params, client) { getServerConfig().createBusinessBlips = !getServerConfig().createBusinessBlips; getServerConfig().needsSaved = true; @@ -585,7 +588,7 @@ function toggleServerLogoCommand(command, params, client) { * @return {bool} Whether or not the command was successful * */ - function toggleServerBusinessPickupsCommand(command, params, client) { +function toggleServerBusinessPickupsCommand(command, params, client) { getServerConfig().createBusinessPickups = !getServerConfig().createBusinessPickups; getServerConfig().needsSaved = true; @@ -605,7 +608,7 @@ function toggleServerLogoCommand(command, params, client) { * @return {bool} Whether or not the command was successful * */ - function toggleServerHouseBlipsCommand(command, params, client) { +function toggleServerHouseBlipsCommand(command, params, client) { getServerConfig().createHouseBlips = !getServerConfig().createHouseBlips; getServerConfig().needsSaved = true; @@ -625,7 +628,7 @@ function toggleServerLogoCommand(command, params, client) { * @return {bool} Whether or not the command was successful * */ - function toggleServerHousePickupsCommand(command, params, client) { +function toggleServerHousePickupsCommand(command, params, client) { getServerConfig().createHousePickups = !getServerConfig().createHousePickups; getServerConfig().needsSaved = true; @@ -650,7 +653,7 @@ function toggleServerGUICommand(command, params, client) { getServerConfig().needsSaved = true; - announceAdminAction(`ServerGUISet`, `${getPlayerName(client)}{MAINCOLOUR}`, `{adminOrange}${getPlayerName(client)}{MAINCOLOUR}`, `${getBoolRedGreenInlineColour(getServerConfig().useGUI)}${toUpperCase(getOnOffFromBool(getServerConfig().useGUI))}{MAINCOLOUR}`); + announceAdminAction(`ServerGUISet`, `${getPlayerName(client)}{MAINCOLOUR}`, `${getBoolRedGreenInlineColour(getServerConfig().useGUI)}${toUpperCase(getOnOffFromBool(getServerConfig().useGUI))}{MAINCOLOUR}`); updateServerRules(); return true; } @@ -690,7 +693,7 @@ function toggleServerUseRealWorldTimeCommand(command, params, client) { * */ function setServerRealWorldTimeZoneCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -756,7 +759,7 @@ function reloadEmailConfigurationCommand(command, params, client) { * */ function reloadDatabaseConfigurationCommand(command, params, client) { - if(getDatabaseConfig().usePersistentConnection && isDatabaseConnected(persistentDatabaseConnection)) { + if (getDatabaseConfig().usePersistentConnection && isDatabaseConnected(persistentDatabaseConnection)) { logToConsole(LOG_WARN, `[VRR.Database] Closing persistent database connection`); persistentDatabaseConnection.close(); persistentDatabaseConnection = null; @@ -765,7 +768,7 @@ function reloadDatabaseConfigurationCommand(command, params, client) { getGlobalConfig().database = loadDatabaseConfig(); messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} reloaded the database config`); databaseEnabled = true; - if(getDatabaseConfig().usePersistentConnection) { + if (getDatabaseConfig().usePersistentConnection) { connectToDatabase(); } return true; @@ -782,8 +785,8 @@ function reloadDatabaseConfigurationCommand(command, params, client) { * @return {bool} Whether or not the command was successful * */ - function setServerNameTagDistanceCommand(command, params, client) { - if(areParamsEmpty(params)) { +function setServerNameTagDistanceCommand(command, params, client) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -807,7 +810,7 @@ function getServerIntroMusicURL() { function loadLocaleConfig() { logToConsole(LOG_DEBUG, "[VRR.Config] Loading locale configuration"); let localeConfig = JSON.parse(loadTextFile(`config/locale.json`)); - if(localeConfig != null) { + if (localeConfig != null) { return localeConfig; } } @@ -817,7 +820,7 @@ function loadLocaleConfig() { function loadEconomyConfig() { logToConsole(LOG_DEBUG, "[VRR.Config] Loading economy configuration"); let economyConfig = JSON.parse(loadTextFile(`config/economy.json`)); - if(economyConfig != null) { + if (economyConfig != null) { return economyConfig; } } @@ -827,7 +830,7 @@ function loadEconomyConfig() { function loadAccentConfig() { logToConsole(LOG_DEBUG, "[VRR.Config] Loading accents configuration"); let accentConfig = JSON.parse(loadTextFile(`config/accents.json`)); - if(accentConfig != null) { + if (accentConfig != null) { return accentConfig; } } @@ -837,7 +840,7 @@ function loadAccentConfig() { function loadDiscordConfig() { logToConsole(LOG_DEBUG, "[VRR.Config] Loading discord configuration"); let discordConfig = JSON.parse(loadTextFile(`config/discord.json`)); - if(discordConfig != null) { + if (discordConfig != null) { return discordConfig; } return false; @@ -848,7 +851,7 @@ function loadDiscordConfig() { function loadDatabaseConfig() { logToConsole(LOG_DEBUG, "[VRR.Config] Loading database configuration"); let databaseConfig = JSON.parse(loadTextFile("config/database.json")); - if(databaseConfig != null) { + if (databaseConfig != null) { return databaseConfig; } return false; @@ -859,7 +862,7 @@ function loadDatabaseConfig() { function loadKeyBindConfig() { logToConsole(LOG_DEBUG, "[VRR.Config] Loading keybind configuration"); let keyBindConfig = JSON.parse(loadTextFile("config/keybind.json")); - if(keyBindConfig != null) { + if (keyBindConfig != null) { return keyBindConfig; } return false; @@ -870,7 +873,7 @@ function loadKeyBindConfig() { function loadEmailConfig() { logToConsole(LOG_DEBUG, "[VRR.Config] Loading email configuration"); let emailConfig = JSON.parse(loadTextFile("config/email.json")); - if(emailConfig != null) { + if (emailConfig != null) { return emailConfig; } return false; @@ -954,7 +957,7 @@ function loadServerConfig() { logToConsole(LOG_DEBUG, "[VRR.Config] Loading server configuration"); try { serverConfig = loadServerConfigFromGameAndPort(getGame(), getServerPort()); - } catch(error) { + } catch (error) { logToConsole(LOG_ERROR, `[VRR.Config] Could not load server configuration for game ${getGame()} and port ${getServerPort}`); thisResource.stop(); } diff --git a/scripts/server/discord.js b/scripts/server/discord.js index 39f1877c..66c17e76 100644 --- a/scripts/server/discord.js +++ b/scripts/server/discord.js @@ -53,7 +53,7 @@ function messageDiscordUser(discordUser, messageText) { // =========================================================================== function sendDiscordSocketData(socketData) { - if(!getDiscordSocket()) { + if (!getDiscordSocket()) { return false; } @@ -63,11 +63,11 @@ function sendDiscordSocketData(socketData) { // =========================================================================== function isClientFromDiscord(client) { - if(client == null) { + if (client == null) { return false; } - if(client instanceof Client) { + if (client instanceof Client) { return false; } else { return true; @@ -89,58 +89,82 @@ function getDiscordUserData(discordUserId) { // =========================================================================== function messageDiscordChatChannel(messageString) { - if(getServerConfig().devServer == true) { + if (getServerConfig().devServer == true) { return false; } - if(!getGlobalConfig().discord.sendChat) { + if (!getGlobalConfig().discord.sendChat) { return false; } - if(!getServerConfig().discord.sendChat) { + if (!getServerConfig().discord.sendChat) { return false; } messageString = removeColoursInMessage(messageString); - triggerWebHook(messageString, getServerId(), VRR_DISCORD_WEBHOOK_LOG); + triggerDiscordWebHook(messageString, getServerId(), VRR_DISCORD_WEBHOOK_LOG); } // =========================================================================== function messageDiscordEventChannel(messageString) { - if(getServerConfig().devServer == true) { + if (getServerConfig().devServer == true) { return false; } - if(!getGlobalConfig().discord.sendEvents) { + if (!getGlobalConfig().discord.sendEvents) { return false; } - if(!getServerConfig().discord.sendEvents) { + if (!getServerConfig().discord.sendEvents) { return false; } messageString = removeColoursInMessage(messageString); - triggerWebHook(messageString, getServerId(), VRR_DISCORD_WEBHOOK_LOG); + triggerDiscordWebHook(messageString, getServerId(), VRR_DISCORD_WEBHOOK_LOG); } // =========================================================================== function messageDiscordAdminChannel(messageString) { - if(getServerConfig().devServer == true) { + if (getServerConfig().devServer == true) { return false; } - if(!getGlobalConfig().discord.sendAdmin) { + if (!getGlobalConfig().discord.sendAdmin) { return false; } - if(!getServerConfig().discord.sendAdmin) { + if (!getServerConfig().discord.sendAdmin) { return false; } messageString = removeColoursInMessage(messageString); - triggerWebHook(messageString, getServerId(), VRR_DISCORD_WEBHOOK_ADMIN); + triggerDiscordWebHook(messageString, getServerId(), VRR_DISCORD_WEBHOOK_ADMIN); +} + +// =========================================================================== + +function triggerDiscordWebHook(messageString, serverId = getServerId(), type = VRR_DISCORD_WEBHOOK_LOG) { + if (!getGlobalConfig().discord.webhook.enabled) { + return false; + } + + let tempURL = getGlobalConfig().discord.webhook.webhookBaseURL; + tempURL = tempURL.replace("{0}", encodeURI(messageString)); + tempURL = tempURL.replace("{1}", serverId); + tempURL = tempURL.replace("{2}", type); + tempURL = tempURL.replace("{3}", getGlobalConfig().discord.webhook.pass); + + httpGet( + tempURL, + "", + function (data) { + + }, + function (data) { + } + ); } // =========================================================================== \ No newline at end of file diff --git a/scripts/server/economy.js b/scripts/server/economy.js index e42479cb..c320b850 100644 --- a/scripts/server/economy.js +++ b/scripts/server/economy.js @@ -15,13 +15,13 @@ function initEconomyScript() { // =========================================================================== function getTimeDisplayUntilPlayerPayDay(client) { - return getTimeDifferenceDisplay(sdl.ticks-getPlayerData(client).payDayTickStart); + return getTimeDifferenceDisplay(sdl.ticks - getPlayerData(client).payDayTickStart); } // =========================================================================== function applyServerInflationMultiplier(value) { - return toInteger(Math.round(value*getServerConfig().inflationMultiplier)) + return toInteger(Math.round(value * getServerConfig().inflationMultiplier)) } // =========================================================================== @@ -31,28 +31,28 @@ function playerPayDay(client) { let grossIncome = getPlayerData(client).payDayAmount; // Passive income - grossIncome = grossIncome + getGlobalConfig().economy.passiveIncomePerPayDay; + grossIncome = Math.round(grossIncome + getGlobalConfig().economy.passiveIncomePerPayDay); // Payday bonus - grossIncome = grossIncome*getGlobalConfig().economy.grossIncomeMultiplier; + grossIncome = Math.round(grossIncome * getGlobalConfig().economy.grossIncomeMultiplier); // Double bonus - if(isDoubleBonusActive()) { - grossIncome = grossIncome*2; + if (isDoubleBonusActive()) { + grossIncome = Math.round(grossIncome * 2); } let incomeTaxAmount = Math.round(calculateIncomeTax(wealth)); - let netIncome = grossIncome-incomeTaxAmount; + let netIncome = Math.round(grossIncome - incomeTaxAmount); messagePlayerAlert(client, "== Payday! ============================="); messagePlayerInfo(client, `Paycheck: {ALTCOLOUR}$${grossIncome}`); messagePlayerInfo(client, `Taxes: {ALTCOLOUR}$${incomeTaxAmount}`); messagePlayerInfo(client, `You receive: {ALTCOLOUR}$${netIncome}`); - if(netIncome < incomeTaxAmount) { + if (netIncome < incomeTaxAmount) { let totalCash = getPlayerCash(client); - let canPayNow = totalCash+netIncome; - if(incomeTaxAmount <= canPayNow) { + let canPayNow = totalCash + netIncome; + if (incomeTaxAmount <= canPayNow) { takePlayerCash(client, canPayNow); messagePlayerInfo(client, `{orange}${getLocaleString(client, "RemainingTaxPaidInCash", `{ALTCOLOUR}${canPayNow}{MAINCOLOUR}`)}`); messagePlayerAlert(client, `{orange}${getLocaleString(client, "LostMoneyFromTaxes")}`); @@ -65,12 +65,12 @@ function playerPayDay(client) { let houseCount = getAllHousesOwnedByPlayer(client).length; let businessCount = getAllBusinessesOwnedByPlayer(client).length; - attemptRepossession(client, incomeTaxAmount-canPayNow); + attemptRepossession(client, incomeTaxAmount - canPayNow); let newVehicleCount = getAllVehiclesOwnedByPlayer(client).length; let newHouseCount = getAllHousesOwnedByPlayer(client).length; let newBusinessCount = getAllBusinessesOwnedByPlayer(client).length; - messagePlayerInfo(client, `{orange}${getLocaleString(client, "AssetsRepossessedForTaxes", newVehicleCount-vehicleCount, newHouseCount-houseCount, newBusinessCount-businessCount)}`); + messagePlayerInfo(client, `{orange}${getLocaleString(client, "AssetsRepossessedForTaxes", newVehicleCount - vehicleCount, newHouseCount - houseCount, newBusinessCount - businessCount)}`); } } @@ -84,29 +84,29 @@ function calculateWealth(client) { let houses = getAllHousesOwnedByPlayer(client); let businesses = getAllBusinessesOwnedByPlayer(client); - let vehicleUpKeep = applyServerInflationMultiplier(vehicles.length*getGlobalConfig().economy.upKeepCosts.upKeepPerVehicle); - let houseUpKeep = applyServerInflationMultiplier(houses.length*getGlobalConfig().economy.upKeepCosts.upKeepPerHouse); - let businessUpKeep = applyServerInflationMultiplier(businesses.length*getGlobalConfig().economy.upKeepCosts.upKeepPerBusiness); + let vehicleUpKeep = applyServerInflationMultiplier(vehicles.length * getGlobalConfig().economy.upKeepCosts.upKeepPerVehicle); + let houseUpKeep = applyServerInflationMultiplier(houses.length * getGlobalConfig().economy.upKeepCosts.upKeepPerHouse); + let businessUpKeep = applyServerInflationMultiplier(businesses.length * getGlobalConfig().economy.upKeepCosts.upKeepPerBusiness); - return vehicleUpKeep+houseUpKeep+businessUpKeep; + return vehicleUpKeep + houseUpKeep + businessUpKeep; } // =========================================================================== function calculateIncomeTax(amount) { - return amount*getGlobalConfig().economy.incomeTaxRate; + return amount * getGlobalConfig().economy.incomeTaxRate; } // =========================================================================== function forcePlayerPayDayCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } let targetClient = getPlayerFromParams(params); - if(!targetClient) { + if (!targetClient) { messagePlayerError(client, "That player is not connected!"); return false; } @@ -118,21 +118,21 @@ function forcePlayerPayDayCommand(command, params, client) { // =========================================================================== function setPayDayBonusMultiplier(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } let newMultiplier = params; - if(isNaN(newMultiplier)) { + if (isNaN(newMultiplier)) { messagePlayerError(client, getLocaleString(client, "AmountNotNumber")); return false; } getGlobalConfig().economy.grossIncomeMultiplier = newMultiplier; - announceAdminAction(`PaydayBonusSet`, `{adminOrange}${getPlayerName(client)}{MAINCOLOUR}`, `{ALTCOLOUR}${newMultiplier*100}%{MAINCOLOUR}`); + announceAdminAction(`PaydayBonusSet`, `{adminOrange}${getPlayerName(client)}{MAINCOLOUR}`, `{ALTCOLOUR}${newMultiplier * 100}%{MAINCOLOUR}`); } // =========================================================================== @@ -155,7 +155,7 @@ function wealthInfoCommand(command, params, client) { function attemptRepossession(client, totalToPay) { let leftToPay = totalToPay; - while(leftToPay > 0) { + while (leftToPay > 0) { let repossessionValue = repossessFirstAsset(client); leftToPay = leftToPay - repossessionValue; } @@ -166,19 +166,19 @@ function attemptRepossession(client, totalToPay) { function repossessFirstAsset(client) { let vehicles = getAllVehiclesOwnedByPlayer(client); - if(vehicles.length > 0) { - deleteVehicle(vehicles[0]) + if (vehicles.length > 0) { + deleteVehicle(vehicles[0]); return getGlobalConfig().economy.upKeepCosts.upKeepPerVehicle; } let houses = getAllHousesOwnedByPlayer(client); - if(houses.length > 0) { + if (houses.length > 0) { deleteHouse(houses[0].index); return getGlobalConfig().economy.upKeepCosts.upKeepPerHouse; } let businesses = getAllBusinessesOwnedByPlayer(client); - if(businesses.length > 0) { + if (businesses.length > 0) { deleteBusiness(businesses[0].index); return getGlobalConfig().economy.upKeepCosts.upKeepPerBusiness; } @@ -205,7 +205,7 @@ function getAllHousesOwnedByPlayer(client) { // =========================================================================== function isDoubleBonusActive() { - if(isWeekend()) { + if (isWeekend()) { return true; } diff --git a/scripts/server/email.js b/scripts/server/email.js index d9593512..689c546e 100644 --- a/scripts/server/email.js +++ b/scripts/server/email.js @@ -14,23 +14,26 @@ function initEmailScript() { // =========================================================================== -function sendEmail(toEmail, toName, subject, body) { - if(!checkForSMTPModule()) { +async function sendEmail(toEmail, toName, subject, body) { + if (!checkForSMTPModule()) { return false; } - module.smtp.send( - getEmailConfig().smtp.host, - getEmailConfig().smtp.port, - intToBool(getEmailConfig().smtp.useTLS), - getEmailConfig().smtp.username, - getEmailConfig().smtp.password, - toEmail, - toName, - subject, - body, - getEmailConfig().smtp.from, - getEmailConfig().smtp.fromName); + Promise.resolve().then(() => { + module.smtp.send( + getEmailConfig().smtp.host, + getEmailConfig().smtp.port, + intToBool(getEmailConfig().smtp.useTLS), + getEmailConfig().smtp.username, + getEmailConfig().smtp.password, + toEmail, + toName, + subject, + body, + getEmailConfig().smtp.from, + getEmailConfig().smtp.fromName + ); + }); } // =========================================================================== diff --git a/scripts/server/event.js b/scripts/server/event.js index 6aea77aa..ffdf3e9d 100644 --- a/scripts/server/event.js +++ b/scripts/server/event.js @@ -56,7 +56,7 @@ function onPlayerConnect(event, ipAddress, port) { function onPlayerJoin(event, client) { logToConsole(LOG_INFO, `[VRR.Event] Client ${getPlayerName(client)}[${getPlayerId(client)}] joining from ${getPlayerIP(client)}`); - if(isFadeCameraSupported()) { + if (isFadeCameraSupported()) { fadeCamera(client, true, 1.0); } @@ -68,7 +68,7 @@ function onPlayerJoin(event, client) { messageDiscordEventChannel(messageText); let clients = getClients(); - for(let i in clients) { + for (let i in clients) { messagePlayerNormal(clients[i], getLocaleString(clients[i], "PlayerConnecting", getPlayerName(client))); } @@ -88,8 +88,8 @@ function onElementStreamIn(event, element, client) { // event.preventDefault(); //} - if(getPlayerData(getClientFromIndex(element.owner)) != false ) { - if(hasBitFlag(getPlayerData(getClientFromIndex(element.owner)).accountData.flags.moderation, getModerationFlagValue("DontSyncClientElements"))) { + if (getPlayerData(getClientFromIndex(element.owner)) != false) { + if (hasBitFlag(getPlayerData(getClientFromIndex(element.owner)).accountData.flags.moderation, getModerationFlagValue("DontSyncClientElements"))) { event.preventDefault(); destroyGameElement(element); } @@ -109,8 +109,10 @@ function onPlayerQuit(event, client, quitReasonId) { updateConnectionLogOnQuit(client, quitReasonId); let reasonText = disconnectReasons[quitReasonId]; - if(getPlayerData(client).customDisconnectReason != "" && getPlayerData(client).customDisconnectReason != undefined && getPlayerData(client).customDisconnectReason != false && getPlayerData(client).customDisconnectReason != null) { - reasonText = getPlayerData(client).customDisconnectReason; + if (getPlayerData(client) != false) { + if (getPlayerData(client).customDisconnectReason != "") { + reasonText = getPlayerData(client).customDisconnectReason; + } } messageDiscordEventChannel(`👋 ${getPlayerName(client)} has left the server (${reasonText})`); @@ -121,7 +123,7 @@ function onPlayerQuit(event, client, quitReasonId) { }); //messagePlayerNormal(null, `👋 ${getPlayerName(client)} has left the server (${reasonText})`, getColourByName("softYellow")); - if(isPlayerLoggedIn(client)) { + if (isPlayerLoggedIn(client)) { savePlayerToDatabase(client); resetClientStuff(client); getServerData().clients[getPlayerId(client)] = null; @@ -159,17 +161,17 @@ function onEntityProcess(event, entity) { // =========================================================================== function onPedEnteringVehicle(event, ped, vehicle, seat) { - if(ped.isType(ELEMENT_PLAYER)) { + if (ped.isType(ELEMENT_PLAYER)) { let client = getClientFromPlayerElement(ped); getPlayerData(client).pedState = VRR_PEDSTATE_ENTERINGVEHICLE; - if(!getVehicleData(vehicle)) { + if (!getVehicleData(vehicle)) { return false; } - if(getVehicleData(vehicle).locked) { - if(doesPlayerHaveVehicleKeys(client, vehicle)) { - if(!doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForCommand(client, "lock")) { + if (getVehicleData(vehicle).locked) { + if (doesPlayerHaveVehicleKeys(client, vehicle)) { + if (!doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForCommand(client, "lock")) { messagePlayerTip(client, `🔒 This ${getVehicleName(vehicle)} is locked. Press {ALTCOLOUR}${toUpperCase(getKeyNameFromId(getPlayerKeyBindForCommand(client, "lock").key))} {MAINCOLOUR}to unlock it.`); } else { messagePlayerNormal(client, `🔒 This ${getVehicleName(vehicle)} is locked. Use /lock to unlock it`); @@ -190,16 +192,16 @@ function onPedEnteringVehicle(event, ped, vehicle, seat) { // =========================================================================== function onPedExitingVehicle(event, ped, vehicle) { - if(!getVehicleData(vehicle)) { + if (!getVehicleData(vehicle)) { return false; } - if(ped.isType(ELEMENT_PLAYER)) { + if (ped.isType(ELEMENT_PLAYER)) { let client = getClientFromPlayerElement(ped); getPlayerData(client).pedState = VRR_PEDSTATE_EXITINGVEHICLE; } - if(!getVehicleData(vehicle).spawnLocked) { + if (!getVehicleData(vehicle).spawnLocked) { getVehicleData(vehicle).spawnPosition = getVehiclePosition(vehicle); getVehicleData(vehicle).spawnRotation = getVehicleHeading(vehicle); getVehicleData(vehicle).needsSaved = true; @@ -225,7 +227,7 @@ function onResourceStop(event, resource) { // messageAdmins(`{MAINCOLOUR}Resource {ALTCOLOUR}${resource.name}{MAINCOLOUR} stopped!`); //} - if(resource == thisResource) { + if (resource == thisResource) { kickAllClients(); saveServerDataToDatabase(); collectAllGarbage(); @@ -247,16 +249,16 @@ function onPlayerExitedSphere(client, sphere) { // =========================================================================== async function onPlayerEnteredVehicle(client, clientVehicle, seat) { - if(client == null) { + if (client == null) { return false; } let vehicle = null; - if(getGame() == VRR_GAME_GTA_IV) { + if (getGame() == VRR_GAME_GTA_IV) { vehicle = getVehicleFromIVNetworkId(clientVehicle); } else { - if(getPlayerPed(client) == null) { + if (getPlayerPed(client) == null) { return false; } @@ -265,7 +267,7 @@ async function onPlayerEnteredVehicle(client, clientVehicle, seat) { vehicle = getPlayerVehicle(client); } - if(!getVehicleData(vehicle)) { + if (!getVehicleData(vehicle)) { return false; } @@ -274,14 +276,14 @@ async function onPlayerEnteredVehicle(client, clientVehicle, seat) { getPlayerData(client).lastVehicle = vehicle; getVehicleData(vehicle).lastActiveTime = getCurrentUnixTimestamp(); - if(getPlayerVehicleSeat(client) == VRR_VEHSEAT_DRIVER) { + if (getPlayerVehicleSeat(client) == VRR_VEHSEAT_DRIVER) { vehicle.engine = getVehicleData(vehicle).engine; - if(getVehicleData(vehicle).buyPrice > 0) { + if (getVehicleData(vehicle).buyPrice > 0) { messagePlayerAlert(client, getLocaleString(client, "VehicleForSale", getVehicleName(vehicle), `{ALTCOLOUR}$${makeLargeNumberReadable(getVehicleData(vehicle).buyPrice)}{MAINCOLOUR}`, `{ALTCOLOUR}/vehbuy{MAINCOLOUR}`)); resetVehiclePosition(vehicle); - } else if(getVehicleData(vehicle).rentPrice > 0) { - if(getVehicleData(vehicle).rentedBy != client) { + } else if (getVehicleData(vehicle).rentPrice > 0) { + if (getVehicleData(vehicle).rentedBy != client) { messagePlayerAlert(client, getLocaleString(client, "VehicleForRent", getVehicleName(vehicle), `{ALTCOLOUR}$${makeLargeNumberReadable(getVehicleData(vehicle).rentPrice)}{MAINCOLOUR}`, `{ALTCOLOUR}/vehrent{MAINCOLOUR}`)); resetVehiclePosition(vehicle); } else { @@ -291,7 +293,7 @@ async function onPlayerEnteredVehicle(client, clientVehicle, seat) { let ownerName = "Nobody"; let ownerType = "None"; ownerType = toLowerCase(getVehicleOwnerTypeText(getVehicleData(vehicle).ownerType)); - switch(getVehicleData(vehicle).ownerType) { + switch (getVehicleData(vehicle).ownerType) { case VRR_VEHOWNER_CLAN: ownerName = getClanData(getClanIdFromDatabaseId(getVehicleData(vehicle).ownerId)).name; ownerType = "clan"; @@ -319,10 +321,10 @@ async function onPlayerEnteredVehicle(client, clientVehicle, seat) { messagePlayerAlert(client, `This ${getVehicleName(vehicle)} belongs to {ALTCOLOUR}${ownerName} (${ownerType})`); } - if(!getVehicleData(vehicle).engine) { - if(getVehicleData(vehicle).buyPrice == 0 && getVehicleData(vehicle).rentPrice == 0) { - if(doesPlayerHaveVehicleKeys(client, vehicle)) { - if(!doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForCommand(client, "engine")) { + if (!getVehicleData(vehicle).engine) { + if (getVehicleData(vehicle).buyPrice == 0 && getVehicleData(vehicle).rentPrice == 0) { + if (doesPlayerHaveVehicleKeys(client, vehicle)) { + if (!doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForCommand(client, "engine")) { messagePlayerTip(client, `This ${getVehicleName(vehicle)}'s engine is off. Press {ALTCOLOUR}${toUpperCase(getKeyNameFromId(getPlayerKeyBindForCommand(client, "engine").key))} {MAINCOLOUR}to start it.`); } else { messagePlayerAlert(client, `This ${getVehicleName(vehicle)}'s engine is off. Use /engine to start it`); @@ -337,26 +339,26 @@ async function onPlayerEnteredVehicle(client, clientVehicle, seat) { let currentSubAccount = getPlayerCurrentSubAccount(client); - if(isPlayerWorking(client)) { - if(getVehicleData(vehicle).ownerType == VRR_VEHOWNER_JOB) { - if(getVehicleData(vehicle).ownerId == getPlayerCurrentSubAccount(client).job) { + if (isPlayerWorking(client)) { + if (getVehicleData(vehicle).ownerType == VRR_VEHOWNER_JOB) { + if (getVehicleData(vehicle).ownerId == getPlayerCurrentSubAccount(client).job) { getPlayerCurrentSubAccount(client).lastJobVehicle = vehicle; messagePlayerInfo(client, `Use /startroute to start working in this vehicle`); } } } - if(isPlayerWorking(client)) { - if(isPlayerOnJobRoute(client)) { - if(vehicle == getPlayerJobRouteVehicle(client)) { + if (isPlayerWorking(client)) { + if (isPlayerOnJobRoute(client)) { + if (vehicle == getPlayerJobRouteVehicle(client)) { stopReturnToJobVehicleCountdown(client); } } } } - if(getVehicleData(vehicle).streamingRadioStation != -1) { - if(getPlayerData(client).streamingRadioStation != getVehicleData(vehicle).streamingRadioStation) { + if (getVehicleData(vehicle).streamingRadioStation != -1) { + if (getPlayerData(client).streamingRadioStation != getVehicleData(vehicle).streamingRadioStation) { playRadioStreamForPlayer(client, getServerData().radioStations[getVehicleData(vehicle).streamingRadioStation].url, true, getPlayerStreamingRadioVolume(client)); } } @@ -369,13 +371,13 @@ function onPlayerExitedVehicle(client, vehicle) { stopRadioStreamForPlayer(client); - if(!getVehicleData(vehicle)) { + if (!getVehicleData(vehicle)) { return false; } - if(isPlayerWorking(client)) { - if(isPlayerOnJobRoute(client)) { - if(vehicle == getPlayerJobRouteVehicle(client)) { + if (isPlayerWorking(client)) { + if (isPlayerOnJobRoute(client)) { + if (vehicle == getPlayerJobRouteVehicle(client)) { startReturnToJobVehicleCountdown(client); } } @@ -393,56 +395,58 @@ function onPlayerDeath(client, position) { getPlayerData(client).pedState = VRR_PEDSTATE_DEAD; updatePlayerSpawnedState(client, false); setPlayerControlState(client, false); - setTimeout(function() { - if(isFadeCameraSupported()) { + setTimeout(function () { + if (isFadeCameraSupported()) { fadeCamera(client, false, 1.0); } - setTimeout(function() { - if(getPlayerCurrentSubAccount(client).inJail) { + setTimeout(function () { + if (getPlayerCurrentSubAccount(client).inJail) { let closestJail = getClosestPoliceStation(getPlayerPosition(client)); despawnPlayer(client); getPlayerCurrentSubAccount(client).interior = closestJail.interior; getPlayerCurrentSubAccount(client).dimension = closestJail.dimension; - if(isPlayerWorking(client)) { + if (isPlayerWorking(client)) { stopWorking(client); } - if(getGame() == VRR_GAME_MAFIA_ONE) { + if (getGame() == VRR_GAME_MAFIA_ONE) { spawnPlayer(client, getGameConfig().skins[getGame()][getPlayerCurrentSubAccount(client).skin][0], closestJail.position, closestJail.heading); } else { spawnPlayer(client, closestJail.position, closestJail.heading, getGameConfig().skins[getGame()][getPlayerCurrentSubAccount(client).skin][0]); } - if(isFadeCameraSupported()) { + if (isFadeCameraSupported()) { fadeCamera(client, true, 1.0); } updatePlayerSpawnedState(client, true); makePlayerStopAnimation(client); setPlayerControlState(client, true); + resetPlayerBlip(client); } else { let closestHospital = getClosestHospital(getPlayerPosition(client)); despawnPlayer(client); getPlayerCurrentSubAccount(client).interior = closestHospital.interior; getPlayerCurrentSubAccount(client).dimension = closestHospital.dimension; - if(isPlayerWorking(client)) { + if (isPlayerWorking(client)) { stopWorking(client); } - if(getGame() == VRR_GAME_MAFIA_ONE) { + if (getGame() == VRR_GAME_MAFIA_ONE) { spawnPlayer(client, getGameConfig().skins[getGame()][getPlayerCurrentSubAccount(client).skin][0], closestHospital.position, closestHospital.heading); } else { spawnPlayer(client, closestHospital.position, closestHospital.heading, getGameConfig().skins[getGame()][getPlayerCurrentSubAccount(client).skin][0]); } - if(isFadeCameraSupported()) { + if (isFadeCameraSupported()) { fadeCamera(client, true, 1.0); } updatePlayerSpawnedState(client, true); makePlayerStopAnimation(client); setPlayerControlState(client, true); + resetPlayerBlip(client); } }, 2000); }, 1000); @@ -455,14 +459,14 @@ function onPlayerDeath(client, position) { ["log_death_pos_y", position.y], ["log_death_pos_z", position.x], ]; - let queryString = createDatabaseInsertQuery("log_death", data); + let queryString = createDatabaseInsertQuery("log_death", queryData); addToQueryQueue(queryString); } // =========================================================================== function onPedSpawn(ped) { - if(ped.type == ELEMENT_PLAYER) { + if (ped.type == ELEMENT_PLAYER) { //setTimeout(onPlayerSpawn, 250, ped); onPlayerSpawn(); } @@ -470,40 +474,46 @@ function onPedSpawn(ped) { // =========================================================================== -function onPlayerSpawn(client) { - logToConsole(LOG_DEBUG, `[VRR.Event] Checking for ${getPlayerDisplayForConsole(client)}'s player ped`); +async function onPlayerSpawn(client) { + //logToConsole(LOG_DEBUG, `[VRR.Event] Checking for ${getPlayerDisplayForConsole(client)}'s player ped`); //if(getPlayerPed(client) == null) { // logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)}'s player element not set yet. Rechecking ...`); // setTimeout(onPlayerSpawn, 500, client); // return false; //} + //logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)}'s player ped is valid. Continuing spawn processing ...`); - logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)}'s player ped is valid. Continuing spawn processing ...`); + if (areServerElementsSupported()) { + await waitUntil(() => client != null && getPlayerPed(client) != null); + } logToConsole(LOG_DEBUG, `[VRR.Event] Checking ${getPlayerDisplayForConsole(client)}'s player data`); - if(!getPlayerData(client)) { + if (!getPlayerData(client)) { logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)}'s player data is invalid. Kicking them from server.`); + getPlayerData(targetClient).customDisconnectReason = `Kicked - Spawn bug. Data invalid.`; disconnectPlayer(client); return false; } logToConsole(LOG_DEBUG, `[VRR.Event] Checking ${getPlayerDisplayForConsole(client)}'s login status`); - if(!isPlayerLoggedIn(client)) { + if (!isPlayerLoggedIn(client)) { logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)} is NOT logged in. Despawning their player.`); + getPlayerData(targetClient).customDisconnectReason = `Kicked - Tried to force spawn without logging in.`; disconnectPlayer(client); return false; } logToConsole(LOG_DEBUG, `[VRR.Event] Checking ${getPlayerDisplayForConsole(client)}'s selected character status`); - if(getPlayerData(client).currentSubAccount == -1) { + if (getPlayerData(client).currentSubAccount == -1) { logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)} has NOT selected a character. Despawning their player.`); + getPlayerData(targetClient).customDisconnectReason = `Kicked - Tried to force spawn without selecting a character.`; disconnectPlayer(client); return false; } logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)}'s player data is valid. Continuing spawn processing ...`); - if(getGame() == VRR_GAME_GTA_IV) { + if (getGame() == VRR_GAME_GTA_IV) { logToConsole(LOG_DEBUG, `[VRR.Event] Setting ${getPlayerDisplayForConsole(client)}'s ped body parts and props`); setEntityData(getPlayerPed(client), "vrr.bodyParts", getPlayerCurrentSubAccount(client).bodyParts, true); setEntityData(getPlayerPed(client), "vrr.bodyProps", getPlayerCurrentSubAccount(client).bodyProps, true); @@ -512,17 +522,17 @@ function onPlayerSpawn(client) { logToConsole(LOG_DEBUG, `[VRR.Event] Setting ${getPlayerDisplayForConsole(client)}'s ped scale (${getPlayerCurrentSubAccount(client).pedScale})`); setEntityData(getPlayerPed(client), "vrr.scale", getPlayerCurrentSubAccount(client).pedScale, true); - if(isPlayerSwitchingCharacter(client) || isPlayerCreatingCharacter(client)) { + if (isPlayerSwitchingCharacter(client) || isPlayerCreatingCharacter(client)) { logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)}'s ped is being used for character selection/creation. No further spawn processing needed'`); return false; } - if(isCustomCameraSupported()) { + if (isCustomCameraSupported()) { restorePlayerCamera(client); } logToConsole(LOG_DEBUG, `[VRR.Event] Storing ${getPlayerDisplayForConsole(client)} ped in client data `); - if(areServerElementsSupported()) { + if (areServerElementsSupported()) { getPlayerData(client).ped = getPlayerPed(client); } @@ -531,6 +541,12 @@ function onPlayerSpawn(client) { //messagePlayerNormal(client, "This server is in early development and may restart at any time for updates.", getColourByName("orange")); //messagePlayerNormal(client, "Please report any bugs using /bug and suggestions using /idea", getColourByName("yellow")); + if (getGame() == VRR_GAME_MAFIA_ONE) { + setPlayerPosition(client, getPlayerCurrentSubAccount(client).spawnPosition); + setPlayerHeading(client, getPlayerCurrentSubAccount(client).spawnHeading); + setPlayerDimension(client, getPlayerCurrentSubAccount(client).dimension); + } + logToConsole(LOG_DEBUG, `[VRR.Event] Setting player interior for ${getPlayerDisplayForConsole(client)} to ${getPlayerCurrentSubAccount(client).interior}`); setPlayerInterior(client, getPlayerCurrentSubAccount(client).interior); @@ -554,11 +570,11 @@ function onPlayerSpawn(client) { setPlayer2DRendering(client, true, true, true, true, true, true); logToConsole(LOG_DEBUG, `[VRR.Event] Sending snow states to ${getPlayerDisplayForConsole(client)}`); - if(isSnowSupported()) { + if (isSnowSupported()) { updatePlayerSnowState(client); } - if(areServerElementsSupported() && getGame() == VRR_GAME_GTA_SA) { + if (areServerElementsSupported() && getGame() == VRR_GAME_GTA_SA) { logToConsole(LOG_DEBUG, `[VRR.Event] Setting player walk and fightstyle for ${getPlayerDisplayForConsole(client)}`); setEntityData(getPlayerPed(client), "vrr.walkStyle", getPlayerCurrentSubAccount(client).walkStyle, true); @@ -566,7 +582,7 @@ function onPlayerSpawn(client) { } logToConsole(LOG_DEBUG, `[VRR.Event] Updating logo state for ${getPlayerDisplayForConsole(client)}`); - if(getServerConfig().showLogo && doesPlayerHaveLogoEnabled(client)) { + if (getServerConfig().showLogo && doesPlayerHaveLogoEnabled(client)) { updatePlayerShowLogoState(client, true); } @@ -579,7 +595,7 @@ function onPlayerSpawn(client) { logToConsole(LOG_DEBUG, `[VRR.Event] Setting ${getPlayerDisplayForConsole(client)}'s switchchar state to false`); getPlayerData(client).switchingCharacter = false; - if(!doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForCommand(client, "enter")) { + if (!doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForCommand(client, "enter")) { let keyId = getPlayerKeyBindForCommand(client, "enter"); logToConsole(LOG_DEBUG, `[VRR.Event] Sending custom enter property key ID (${keyId.key}, ${toUpperCase(getKeyNameFromId(keyId.key))}) to ${getPlayerDisplayForConsole(client)}`); sendPlayerEnterPropertyKey(client, keyId.key); @@ -602,14 +618,14 @@ function onPlayerSpawn(client) { // setEntityData(getPlayerPed(client), "vrr.bodyPartRightFoot", getPlayerCurrentSubAccount(client).bodyProps.rightFoot, true); //} - if(isGTAIV()) { + if (isGTAIV()) { //sendPlayerPedPartsAndProps(client); } logToConsole(LOG_DEBUG, `[VRR.Event] Setting ${getPlayerDisplayForConsole(client)}'s ped state to ready`); getPlayerData(client).pedState = VRR_PEDSTATE_READY; - if(areServerElementsSupported()) { + if (areServerElementsSupported()) { syncPlayerProperties(client); //setTimeout(function() { // syncPlayerProperties(client); @@ -625,7 +641,7 @@ function onPlayerSpawn(client) { logToConsole(LOG_DEBUG, `[VRR.Event] Sending player nametag distance to ${getPlayerDisplayForConsole(client)}`); sendNameTagDistanceToClient(client, getServerConfig().nameTagDistance); - if(!areServerElementsSupported()) { + if (!areServerElementsSupported()) { sendAllBusinessesToPlayer(client); sendAllHousesToPlayer(client); //sendAllJobsToPlayer(client); @@ -638,29 +654,33 @@ function onPlayerSpawn(client) { getPlayerData(client).payDayTickStart = sdl.ticks; + //sendPlayerLocaleStrings(client); + // Stop playing intro music and any other radio stopRadioStreamForPlayer(client); // Start playing business/house radio if in one let businessId = getPlayerBusiness(client); let houseId = getPlayerHouse(client); - if(businessId != -1) { - if(getBusinessData(businessId).streamingRadioStation != -1) { + if (businessId != -1) { + if (getBusinessData(businessId).streamingRadioStation != -1) { playRadioStreamForPlayer(client, getRadioStationData(getBusinessData(businessId).streamingRadioStation).url, true, getPlayerStreamingRadioVolume(client), null); } - } else if(houseId != -1) { - if(getHouseData(houseId).streamingRadioStation != -1) { + } else if (houseId != -1) { + if (getHouseData(houseId).streamingRadioStation != -1) { playRadioStreamForPlayer(client, getRadioStationData(getHouseData(houseId).streamingRadioStation).url, true, getPlayerStreamingRadioVolume(client), null); } } + resetPlayerBlip(client) + messageDiscordEventChannel(`🧍 ${getPlayerName(client)} spawned as ${getCharacterFullName(client)}`); } // =========================================================================== function onPlayerCommand(event, client, command, params) { - if(!doesCommandExist(command)) { + if (!doesCommandExist(command)) { processPlayerCommand(command, params, client); } } diff --git a/scripts/server/gui.js b/scripts/server/gui.js index 686a8e13..2238ae5a 100644 --- a/scripts/server/gui.js +++ b/scripts/server/gui.js @@ -15,31 +15,32 @@ function initGUIScript() { // =========================================================================== function playerPromptAnswerNo(client) { - if(getPlayerData(client).promptType == VRR_PROMPT_NONE) { + if (getPlayerData(client).promptType == VRR_PROMPT_NONE) { return false; } logToConsole(LOG_DEBUG, `[VRR.GUI] ${getPlayerDisplayForConsole(client)} answered NO to their prompt (${getPlayerData(client).promptType})`); - switch(getPlayerData(client).promptType) { + switch (getPlayerData(client).promptType) { case VRR_PROMPT_CREATEFIRSTCHAR: logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)} chose not to create a first character. Kicking them from the server ...`); showPlayerErrorGUI(client, "You don't have a character to play. Goodbye!", "No Characters"); - setTimeout(function() { disconnectPlayer(client); }, 5000); + getPlayerData(targetClient).customDisconnectReason = `Kicked - Didn't create a character`; + setTimeout(function () { disconnectPlayer(client); }, 5000); break; - case VRR_PROMPT_BIZORDER: - if(getPlayerData(client).businessOrderAmount > 0) { - if(canPlayerUseGUI(client)) { - showPlayerErrorGUI(client, "You canceled the order.", "Business Order Canceled"); - } else { - logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)} canceled the order of ${getPlayerData(client).businessOrderAmount} ${getPlayerData(client).businessOrderItem} at ${getPlayerData(client).businessOrderCost/getPlayerData(client).businessOrderAmount} each for business ${getBusinessData(getPlayerData(client).businessOrderBusiness)}`); - messagePlayerError(client, "You canceled the order!"); - } + case VRR_PROMPT_BIZORDER: + if (getPlayerData(client).businessOrderAmount > 0) { + if (canPlayerUseGUI(client)) { + showPlayerErrorGUI(client, "You canceled the order.", "Business Order Canceled"); } else { - showPlayerErrorGUI(client, "You aren't ordering anything for a business!", "Business Order Canceled"); + logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)} canceled the order of ${getPlayerData(client).businessOrderAmount} ${getPlayerData(client).businessOrderItem} at ${getPlayerData(client).businessOrderCost / getPlayerData(client).businessOrderAmount} each for business ${getBusinessData(getPlayerData(client).businessOrderBusiness)}`); + messagePlayerError(client, "You canceled the order!"); } - break; + } else { + showPlayerErrorGUI(client, "You aren't ordering anything for a business!", "Business Order Canceled"); + } + break; default: break; @@ -51,29 +52,29 @@ function playerPromptAnswerNo(client) { // =========================================================================== function playerPromptAnswerYes(client) { - if(getPlayerData(client).promptType == VRR_PROMPT_NONE) { + if (getPlayerData(client).promptType == VRR_PROMPT_NONE) { return false; } logToConsole(LOG_DEBUG, `[VRR.GUI] ${getPlayerDisplayForConsole(client)} answered YES to their prompt (${getPlayerData(client).promptType})`); - switch(getPlayerData(client).promptType) { + switch (getPlayerData(client).promptType) { case VRR_PROMPT_CREATEFIRSTCHAR: { showPlayerNewCharacterGUI(client); break; } case VRR_PROMPT_BIZORDER: { - if(getPlayerData(client).businessOrderAmount > 0) { - if(getBusinessData(getPlayerData(client).businessOrderBusiness).till < getPlayerData(client).businessOrderCost) { - logToConsole(LOG_DEBUG, `[VRR.GUI] ${getPlayerDisplayForConsole(client)} failed to order ${getPlayerData(client).businessOrderAmount} ${getItemTypeData(getPlayerData(client).businessOrderItem).name} at ${getPlayerData(client).businessOrderCost/getPlayerData(client).businessOrderAmount} each for business ${getBusinessData(getPlayerData(client).businessOrderBusiness).name} (Reason: Not enough money in business till)`); + if (getPlayerData(client).businessOrderAmount > 0) { + if (getBusinessData(getPlayerData(client).businessOrderBusiness).till < getPlayerData(client).businessOrderCost) { + logToConsole(LOG_DEBUG, `[VRR.GUI] ${getPlayerDisplayForConsole(client)} failed to order ${getPlayerData(client).businessOrderAmount} ${getItemTypeData(getPlayerData(client).businessOrderItem).name} at ${getPlayerData(client).businessOrderCost / getPlayerData(client).businessOrderAmount} each for business ${getBusinessData(getPlayerData(client).businessOrderBusiness).name} (Reason: Not enough money in business till)`); showPlayerErrorGUI(client, "This business doesn't have enough money! Deposit some using /bizdeposit", "Business Order Canceled"); getPlayerData(client).businessOrderAmount = 0; getPlayerData(client).businessOrderBusiness = false; getPlayerData(client).businessOrderItem = -1; getPlayerData(client).businessOrderValue = -1; } else { - logToConsole(LOG_DEBUG, `[VRR.GUI] ${getPlayerDisplayForConsole(client)} successfully ordered ${getPlayerData(client).businessOrderAmount} ${getItemTypeData(getPlayerData(client).businessOrderItem).name} at ${getPlayerData(client).businessOrderCost/getPlayerData(client).businessOrderAmount} each for business ${getBusinessData(getPlayerData(client).businessOrderBusiness).name}`); + logToConsole(LOG_DEBUG, `[VRR.GUI] ${getPlayerDisplayForConsole(client)} successfully ordered ${getPlayerData(client).businessOrderAmount} ${getItemTypeData(getPlayerData(client).businessOrderItem).name} at ${getPlayerData(client).businessOrderCost / getPlayerData(client).businessOrderAmount} each for business ${getBusinessData(getPlayerData(client).businessOrderBusiness).name}`); showPlayerInfoGUI(client, `You ordered ${getPlayerData(client).businessOrderAmount} ${getItemTypeData(getPlayerData(client).businessOrderItem).name} (${getItemValueDisplay(getPlayerData(client).businessOrderItem, getPlayerData(client).businessOrderValue)}) for ${getPlayerData(client).businessOrderCost}!`, "Business Order Successful"); createItem(getPlayerData(client).businessOrderItem, getPlayerData(client).businessOrderValue, VRR_ITEM_OWNER_BIZFLOOR, getBusinessData(getPlayerData(client).businessOrderBusiness).databaseId, getPlayerData(client).businessOrderAmount); cacheBusinessItems(getPlayerData(client).businessOrderBusiness); @@ -91,22 +92,22 @@ function playerPromptAnswerYes(client) { } case VRR_PROMPT_GIVEVEHTOCLAN: { - if(!isPlayerInAnyVehicle(client)) { + if (!isPlayerInAnyVehicle(client)) { messagePlayerError(client, getLocaleString(client, "MustBeInVehicle")); return false; } - if(!getVehicleData(getPlayerVehicle(client))) { + if (!getVehicleData(getPlayerVehicle(client))) { messagePlayerError(client, getLocaleString(client, "RandomVehicleCommandsDisabled")); return false; } - if(getVehicleData(getPlayerVehicle(client)).ownerType != VRR_VEHOWNER_PLAYER) { + if (getVehicleData(getPlayerVehicle(client)).ownerType != VRR_VEHOWNER_PLAYER) { messagePlayerError(client, getLocaleString(client, "MustOwnVehicle")); return false; } - if(getVehicleData(getPlayerVehicle(client)).ownerId != getPlayerCurrentSubAccount(client).databaseId) { + if (getVehicleData(getPlayerVehicle(client)).ownerId != getPlayerCurrentSubAccount(client).databaseId) { messagePlayerError(client, getLocaleString(client, "MustOwnVehicle")); return false; } @@ -120,17 +121,17 @@ function playerPromptAnswerYes(client) { case VRR_PROMPT_GIVEHOUSETOCLAN: { let houseId = getPlayerHouse(client); - if(!houseId) { + if (!houseId) { messagePlayerError(client, getLocaleString(client, "InvalidHouse")); return false; } - if(getHouseData(houseId).ownerType != VRR_VEHOWNER_PLAYER) { + if (getHouseData(houseId).ownerType != VRR_VEHOWNER_PLAYER) { messagePlayerError(client, getLocaleString(client, "MustOwnHouse")); return false; } - if(getHouseData(houseId).ownerId != getPlayerCurrentSubAccount(client).databaseId) { + if (getHouseData(houseId).ownerId != getPlayerCurrentSubAccount(client).databaseId) { messagePlayerError(client, getLocaleString(client, "MustOwnHouse")); return false; } @@ -144,17 +145,17 @@ function playerPromptAnswerYes(client) { case VRR_PROMPT_GIVEBIZTOCLAN: { let businessId = getPlayerBusiness(client); - if(!businessId) { + if (!businessId) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } - if(getBusinessData(businessId).ownerType != VRR_VEHOWNER_PLAYER) { + if (getBusinessData(businessId).ownerType != VRR_VEHOWNER_PLAYER) { messagePlayerError(client, getLocaleString(client, "MustOwnBusiness")); return false; } - if(getBusinessData(businessId).ownerId != getPlayerCurrentSubAccount(client).databaseId) { + if (getBusinessData(businessId).ownerId != getPlayerCurrentSubAccount(client).databaseId) { messagePlayerError(client, getLocaleString(client, "MustOwnBusiness")); return false; } @@ -168,17 +169,17 @@ function playerPromptAnswerYes(client) { case VRR_PROMPT_BUYHOUSE: { let houseId = getPlayerHouse(client); - if(!houseId) { + if (!houseId) { messagePlayerError(client, getLocaleString(client, "InvalidHouse")); return false; } - if(getHouseData(houseId).buyPrice <= 0) { + if (getHouseData(houseId).buyPrice <= 0) { messagePlayerError(client, getLocaleString(client, "HouseNotForSale")); return false; } - if(getPlayerCurrentSubAccount(client).cash < getHouseData(houseId).buyPrice) { + if (getPlayerCurrentSubAccount(client).cash < getHouseData(houseId).buyPrice) { messagePlayerError(client, getLocaleString(client, "HousePurchaseNotEnoughMoney")); return false; } @@ -196,17 +197,17 @@ function playerPromptAnswerYes(client) { case VRR_PROMPT_BUYBIZ: { let businessId = getPlayerBusiness(client); - if(!businessId) { + if (!businessId) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } - if(getBusinessData(businessId).buyPrice <= 0) { + if (getBusinessData(businessId).buyPrice <= 0) { messagePlayerError(client, getLocaleString(client, "BusinessNotForSale")); return false; } - if(getPlayerCurrentSubAccount(client).cash < getBusinessData(businessId).buyPrice) { + if (getPlayerCurrentSubAccount(client).cash < getBusinessData(businessId).buyPrice) { messagePlayerError(client, getLocaleString(client, "BusinessPurchaseNotEnoughMoney")); return false; } diff --git a/scripts/server/house.js b/scripts/server/house.js index 2c1b6953..a80fada2 100644 --- a/scripts/server/house.js +++ b/scripts/server/house.js @@ -21,11 +21,11 @@ function loadHousesFromDatabase() { let dbConnection = connectToDatabase(); let dbAssoc; - if(dbConnection) { - let dbQuery = queryDatabase(dbConnection, `SELECT * FROM house_main WHERE house_server = ${getServerId()}`); - if(dbQuery) { - if(dbQuery.numRows > 0) { - while(dbAssoc = fetchQueryAssoc(dbQuery)) { + if (dbConnection) { + let dbQuery = queryDatabase(dbConnection, `SELECT * FROM house_main WHERE house_deleted = 0 AND house_server = ${getServerId()}`); + if (dbQuery) { + if (dbQuery.numRows > 0) { + while (dbAssoc = fetchQueryAssoc(dbQuery)) { let tempHouseData = new HouseData(dbAssoc); tempHouses.push(tempHouseData); logToConsole(LOG_VERBOSE, `[VRR.House]: House '${tempHouseData.description}' (ID ${tempHouseData.databaseId}) loaded!`); @@ -51,7 +51,7 @@ function loadHousesFromDatabase() { * */ function createHouseCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -71,10 +71,10 @@ function createHouseCommand(command, params, client) { * @return {bool} Whether or not the command was successful * */ - function toggleHouseInteriorLightsCommand(command, params, client) { +function toggleHouseInteriorLightsCommand(command, params, client) { let houseId = getPlayerHouse(client); - if(!getHouseData(houseId)) { + if (!getHouseData(houseId)) { messagePlayerError(client, getLocaleString(client, "InvalidHouse")); return false; } @@ -103,7 +103,7 @@ function setHouseDescriptionCommand(command, params, client) { let houseId = getPlayerHouse(client); - if(!getHouseData(houseId)) { + if (!getHouseData(houseId)) { messagePlayerError(client, getLocaleString(client, "InvalidHouse")); return false; } @@ -133,18 +133,18 @@ function setHouseOwnerCommand(command, params, client) { let newHouseOwner = getPlayerFromParams(params); let houseId = getPlayerHouse(client); - if(!newHouseOwner) { + if (!newHouseOwner) { messagePlayerError(client, getLocaleString(client, "InvalidPlayer")); return false; } - if(!getHouseData(houseId)) { + if (!getHouseData(houseId)) { messagePlayerError(client, getLocaleString(client, "InvalidHouse")); return false; } - if(!doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageHouses"))) { - if(getHouseData(houseId).ownerType == VRR_HOUSEOWNER_PLAYER && getHouseData(houseId).ownerId == getPlayerCurrentSubAccount(client).databaseId) { + if (!doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageHouses"))) { + if (getHouseData(houseId).ownerType == VRR_HOUSEOWNER_PLAYER && getHouseData(houseId).ownerId == getPlayerCurrentSubAccount(client).databaseId) { messagePlayerError(client, getLocaleString(client, "CantModifyHouse")); return false; } @@ -166,16 +166,16 @@ function setHouseOwnerCommand(command, params, client) { * @return {bool} Whether or not the command was successful * */ - function removeHouseOwnerCommand(command, params, client) { +function removeHouseOwnerCommand(command, params, client) { let houseId = getPlayerHouse(client); - if(!getHouseData(houseId)) { + if (!getHouseData(houseId)) { messagePlayerError(client, getLocaleString(client, "InvalidHouse")); return false; } - if(!doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageHouses"))) { - if(getHouseData(houseId).ownerType == VRR_HOUSEOWNER_PLAYER && getHouseData(houseId).ownerId == getPlayerCurrentSubAccount(client).databaseId) { + if (!doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageHouses"))) { + if (getHouseData(houseId).ownerType == VRR_HOUSEOWNER_PLAYER && getHouseData(houseId).ownerId == getPlayerCurrentSubAccount(client).databaseId) { messagePlayerError(client, getLocaleString(client, "CantModifyHouse")); return false; } @@ -202,24 +202,24 @@ function setHouseOwnerCommand(command, params, client) { function setHouseClanCommand(command, params, client) { let houseId = getPlayerHouse(client); - if(!getHouseData(houseId)) { + if (!getHouseData(houseId)) { messagePlayerError(client, getLocaleString(client, "InvalidHouse")); return false; } let clanId = getPlayerClan(params); - if(!getClanData(clanId)) { + if (!getClanData(clanId)) { messagePlayerError(client, getLocaleString(client, "InvalidClan")); return false; } - if(getHouseData(houseId).ownerType != VRR_VEHOWNER_PLAYER) { + if (getHouseData(houseId).ownerType != VRR_VEHOWNER_PLAYER) { messagePlayerError(client, getLocaleString(client, "MustOwnHouse")); return false; } - if(getHouseData(houseId).ownerId != getPlayerCurrentSubAccount(client).databaseId) { + if (getHouseData(houseId).ownerId != getPlayerCurrentSubAccount(client).databaseId) { messagePlayerError(client, getLocaleString(client, "MustOwnHouse")); return false; } @@ -241,17 +241,17 @@ function setHouseClanCommand(command, params, client) { * @return {bool} Whether or not the command was successful * */ - function setHouseRankCommand(command, params, client) { +function setHouseRankCommand(command, params, client) { let houseId = getPlayerHouse(client); - if(!getHouseData(houseId)) { + if (!getHouseData(houseId)) { messagePlayerError(client, getLocaleString(client, "InvalidHouse")); return false; } let clanId = getPlayerClan(params); - if(!getClanData(clanId)) { + if (!getClanData(clanId)) { messagePlayerError(client, getLocaleString(client, "InvalidClan")); return false; } @@ -276,22 +276,22 @@ function setHousePickupCommand(command, params, client) { let typeParam = params || "house"; let houseId = getPlayerHouse(client); - if(!getHouseData(houseId)) { + if (!getHouseData(houseId)) { messagePlayerError(client, getLocaleString(client, "InvalidHouse")); return false; } - if(isNaN(typeParam)) { - if(toLowerCase(typeParam) == "None") { + if (isNaN(typeParam)) { + if (toLowerCase(typeParam) == "None") { getHouseData(houseId).entrancePickupModel = -1; } else { - if(isNull(getGameConfig().pickupModels[getGame()][typeParam])) { + if (isNull(getGameConfig().pickupModels[getGame()][typeParam])) { messagePlayerError(client, "Invalid pickup type! Use a pickup type name or a model ID"); let pickupTypes = Object.keys(getGameConfig().pickupModels[getGame()]); let chunkedList = splitArrayIntoChunks(pickupTypes, 10); messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderPickupTypes"))); - for(let i in chunkedList) { + for (let i in chunkedList) { messagePlayerInfo(client, chunkedList[i].join(", ")); } return false; @@ -326,20 +326,20 @@ function setHouseInteriorTypeCommand(command, params, client) { let typeParam = getParam(params, " ", 1) || "None"; let houseId = getPlayerHouse(client); - if(!getHouseData(houseId)) { + if (!getHouseData(houseId)) { messagePlayerError(client, getLocaleString(client, "InvalidHouse")); return false; } - if(typeof getGameConfig().interiors[getGame()] == "undefined") { + if (typeof getGameConfig().interiors[getGame()] == "undefined") { messagePlayerError(client, `There are no interiors available for this game!`); return false; } - if(isNaN(typeParam)) { + if (isNaN(typeParam)) { let tempHouseLocation = new HouseLocationData(false); - if(toLowerCase(typeParam) == "None") { + if (toLowerCase(typeParam) == "None") { tempHouseLocation.exitPosition = toVector3(0.0, 0.0, 0.0); tempHouseLocation.exitInterior = -1; getHouseData(houseId).exitPickupModel = -1; @@ -348,13 +348,13 @@ function setHouseInteriorTypeCommand(command, params, client) { return false; } - if(isNull(getGameConfig().interiors[getGame()][typeParam])) { + if (isNull(getGameConfig().interiors[getGame()][typeParam])) { messagePlayerError(client, "Invalid interior type! Use an interior type name"); let interiorTypesList = Object.keys(getGameConfig().interiors[getGame()]); let chunkedList = splitArrayIntoChunks(interiorTypesList, 10); messagePlayerNormal(client, makeChatBoxSectionHeader("InteriorTypes")); - for(let i in chunkedList) { + for (let i in chunkedList) { messagePlayerInfo(client, chunkedList[i].join(", ")); } return false; @@ -362,7 +362,7 @@ function setHouseInteriorTypeCommand(command, params, client) { getHouseData(houseId).exitPosition = getGameConfig().interiors[getGame()][typeParam][0]; getHouseData(houseId).exitInterior = getGameConfig().interiors[getGame()][typeParam][1]; - getHouseData(houseId).exitDimension = getHouseData(houseId).databaseId+getGlobalConfig().houseDimensionStart; + getHouseData(houseId).exitDimension = getHouseData(houseId).databaseId + getGlobalConfig().houseDimensionStart; getHouseData(houseId).exitPickupModel = getGameConfig().pickupModels[getGame()].Exit; getHouseData(houseId).hasInterior = true; } @@ -392,21 +392,21 @@ function setHouseBlipCommand(command, params, client) { let typeParam = params || "house"; let houseId = getPlayerHouse(client); - if(!getHouseData(houseId)) { + if (!getHouseData(houseId)) { messagePlayerError(client, getLocaleString(client, "InvalidHouse")); return false; } - if(isNaN(typeParam)) { - if(toLowerCase(typeParam) == "None") { + if (isNaN(typeParam)) { + if (toLowerCase(typeParam) == "None") { getHouseData(houseId).entranceBlipModel = -1; } else { - if(isNull(getGameConfig().blipSprites[getGame()][typeParam])) { + if (isNull(getGameConfig().blipSprites[getGame()][typeParam])) { let blipTypes = Object.keys(getGameConfig().blipSprites[getGame()]); let chunkedList = splitArrayIntoChunks(blipTypes, 10); messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderBlipTypes"))); - for(let i in chunkedList) { + for (let i in chunkedList) { messagePlayerInfo(client, chunkedList[i].join(", ")); } return false; @@ -418,7 +418,7 @@ function setHouseBlipCommand(command, params, client) { getHouseData(houseId).entranceBlipModel = toInteger(typeParam); } - if(getHouseData(houseId).entranceBlip != null) { + if (getHouseData(houseId).entranceBlip != null) { deleteGameElement(getHouseData(houseId).entranceBlip); } @@ -442,7 +442,7 @@ function setHouseBlipCommand(command, params, client) { function moveHouseEntranceCommand(command, params, client) { let houseId = getPlayerHouse(client); - if(!getHouseData(houseId)) { + if (!getHouseData(houseId)) { messagePlayerError(client, getLocaleString(client, "InvalidHouse")); return false; } @@ -478,7 +478,7 @@ function moveHouseEntranceCommand(command, params, client) { function moveHouseExitCommand(command, params, client) { let houseId = getClosestHouseEntrance(getPlayerPosition(client), getPlayerDimension(client)); - if(!getHouseData(houseId)) { + if (!getHouseData(houseId)) { messagePlayerError(client, getLocaleString(client, "InvalidHouse")); return false; } @@ -518,7 +518,7 @@ function moveHouseExitCommand(command, params, client) { function deleteHouseCommand(command, params, client) { let houseId = getPlayerHouse(client); - if(!getHouseData(houseId)) { + if (!getHouseData(houseId)) { messagePlayerError(client, getLocaleString(client, "InvalidHouse")); return false; } @@ -543,9 +543,9 @@ function deleteHouse(houseId, whoDeleted = 0) { let dbConnection = connectToDatabase(); let dbQuery = null; - if(dbConnection) { - dbQuery = queryDatabase(dbConnection, `DELETE FROM house_main WHERE house_id = ${tempHouseData.databaseId}`); - if(dbQuery) { + if (dbConnection) { + dbQuery = queryDatabase(dbConnection, `UPDATE house_main SET house_deleted = 1, house_when_deleted = UNIX_TIMESTAMP(), house_who_deleted = ${whoDeleted} WHERE house_id = ${tempHouseData.databaseId}`); + if (dbQuery) { freeDatabaseQuery(dbQuery); } disconnectFromDatabase(dbConnection); @@ -609,20 +609,20 @@ function createHouse(description, entrancePosition, exitPosition, entrancePickup let houseId = getServerData().houses.push(tempHouseData); - saveHouseToDatabase(houseId-1); + saveHouseToDatabase(houseId - 1); setHouseDataIndexes(); - createHousePickups(houseId-1); - createHouseBlips(houseId-1); + createHousePickups(houseId - 1); + createHouseBlips(houseId - 1); - return houseId-1; + return houseId - 1; } // =========================================================================== function getHouseDataFromDatabaseId(databaseId) { let matchingHouses = getServerData().houses.filter(b => b.databaseId == databaseId) - if(matchingHouses.length == 1) { + if (matchingHouses.length == 1) { return matchingHouses[0]; } return false; @@ -632,9 +632,9 @@ function getHouseDataFromDatabaseId(databaseId) { function getClosestHouseEntrance(position, dimension) { let closest = 0; - for(let i in getServerData().houses) { - if(getServerData().houses[i].entranceDimension == dimension) { - if(getDistance(getServerData().houses[i].entrancePosition, position) <= getDistance(getServerData().houses[closest].entrancePosition, position)) { + for (let i in getServerData().houses) { + if (getServerData().houses[i].entranceDimension == dimension) { + if (getDistance(getServerData().houses[i].entrancePosition, position) <= getDistance(getServerData().houses[closest].entrancePosition, position)) { closest = i; } } @@ -646,9 +646,9 @@ function getClosestHouseEntrance(position, dimension) { function getClosestHouseExit(position, dimension) { let closest = 0; - for(let i in getServerData().houses) { - if(getServerData().houses[i].entranceDimension == dimension) { - if(getDistance(getServerData().houses[i].exitPosition, position) <= getDistance(getServerData().houses[closest].exitPosition, position)) { + for (let i in getServerData().houses) { + if (getServerData().houses[i].entranceDimension == dimension) { + if (getDistance(getServerData().houses[i].exitPosition, position) <= getDistance(getServerData().houses[closest].exitPosition, position)) { closest = i; } } @@ -659,22 +659,24 @@ function getClosestHouseExit(position, dimension) { // =========================================================================== function getPlayerHouse(client) { - if(getServerData().houses.length > 0) { - if(getPlayerDimension(client) == getGameConfig().mainWorldDimension[getGame()]) { - let closestEntrance = getClosestHouseEntrance(getPlayerPosition(client), getPlayerDimension(client)); - if(getDistance(getPlayerPosition(client), getHouseData(closestEntrance).entrancePosition) <= getGlobalConfig().enterPropertyDistance) { - return getHouseData(closestEntrance).index; - } - } else { - let closestEntrance = getClosestHouseEntrance(getPlayerPosition(client), getPlayerDimension(client)); - if(getDistance(getPlayerPosition(client), getHouseData(closestEntrance).entrancePosition) <= getGlobalConfig().enterPropertyDistance) { - return getHouseData(closestEntrance).index; - } + if (getServerData().houses.length == 0) { + return -1; + } - for(let i in getServerData().houses) { - if(getServerData().houses[i].hasInterior && getServerData().houses[i].exitDimension == getPlayerDimension(client)) { - return i; - } + if (getPlayerDimension(client) == getGameConfig().mainWorldDimension[getGame()]) { + let closestEntrance = getClosestHouseEntrance(getPlayerPosition(client), getPlayerDimension(client)); + if (getDistance(getPlayerPosition(client), getHouseData(closestEntrance).entrancePosition) <= getGlobalConfig().enterPropertyDistance) { + return getHouseData(closestEntrance).index; + } + } else { + let closestEntrance = getClosestHouseEntrance(getPlayerPosition(client), getPlayerDimension(client)); + if (getDistance(getPlayerPosition(client), getHouseData(closestEntrance).entrancePosition) <= getGlobalConfig().enterPropertyDistance) { + return getHouseData(closestEntrance).index; + } + + for (let i in getServerData().houses) { + if (getServerData().houses[i].hasInterior && getServerData().houses[i].exitDimension == getPlayerDimension(client)) { + return i; } } } @@ -685,13 +687,13 @@ function getPlayerHouse(client) { // =========================================================================== function saveAllHousesToDatabase() { - if(getServerConfig().devServer) { + if (getServerConfig().devServer) { return false; } logToConsole(LOG_INFO, `[VRR.House]: Saving all server houses to database ...`); - for(let i in getServerData().houses) { - if(getServerData().houses[i].needsSaved) { + for (let i in getServerData().houses) { + if (getServerData().houses[i].needsSaved) { saveHouseToDatabase(i); } } @@ -703,13 +705,13 @@ function saveAllHousesToDatabase() { function saveHouseToDatabase(houseId) { let tempHouseData = getServerData().houses[houseId]; - if(!tempHouseData.needsSaved) { + if (!tempHouseData.needsSaved) { return false; } logToConsole(LOG_VERBOSE, `[VRR.House]: Saving house '${tempHouseData.databaseId}' to database ...`); let dbConnection = connectToDatabase(); - if(dbConnection) { + if (dbConnection) { let safeHouseDescription = escapeDatabaseString(dbConnection, tempHouseData.description); let data = [ @@ -745,7 +747,7 @@ function saveHouseToDatabase(houseId) { ]; let dbQuery = null; - if(tempHouseData.databaseId == 0) { + if (tempHouseData.databaseId == 0) { let queryString = createDatabaseInsertQuery("house_main", data); logToConsole(queryString); dbQuery = queryDatabase(dbConnection, queryString); @@ -770,13 +772,13 @@ function saveHouseToDatabase(houseId) { function saveHouseLocationToDatabase(houseId, locationId) { let tempHouseLocationData = getServerData().houses[houseId].locations[locationId]; - if(!tempHouseLocationData.needsSaved) { + if (!tempHouseLocationData.needsSaved) { return false; } logToConsole(LOG_VERBOSE, `[VRR.House]: Saving house location '${locationId}' for house '${getHouseData(houseId).databaseId}' to database ...`); let dbConnection = connectToDatabase(); - if(dbConnection) { + if (dbConnection) { let safeHouseDescription = escapeDatabaseString(dbConnection, getHouseData(houseId).description); let data = [ @@ -797,13 +799,13 @@ function saveHouseLocationToDatabase(houseId, locationId) { ["house_loc_pos2_z", tempHouseLocationData.positionTwo.z], ["house_loc_rot2_z", tempHouseLocationData.rotationTwo], ["house_loc_int2", tempHouseLocationData.interiorTwo], - ["house_loc_vw2", getHouseData(houseId).databaseId+getGlobalConfig().houseDimensionStart], + ["house_loc_vw2", getHouseData(houseId).databaseId + getGlobalConfig().houseDimensionStart], ["house_loc_pickup2", tempHouseLocationData.pickupTwo], ["house_loc_blip2", tempHouseLocationData.blipTwo], ]; let dbQuery = null; - if(tempHouseData.databaseId == 0) { + if (tempHouseData.databaseId == 0) { let queryString = createDatabaseInsertQuery("house_loc", data); dbQuery = queryDatabase(dbConnection, queryString); getServerData().houses[houseId].locations[locationId].databaseId = getDatabaseInsertId(dbConnection); @@ -825,7 +827,7 @@ function saveHouseLocationToDatabase(houseId, locationId) { // =========================================================================== function createAllHousePickups() { - for(let i in getServerData().houses) { + for (let i in getServerData().houses) { createHouseEntrancePickup(i); createHouseExitPickup(i); } @@ -834,7 +836,7 @@ function createAllHousePickups() { // =========================================================================== function createAllHouseBlips() { - for(let i in getServerData().houses) { + for (let i in getServerData().houses) { createHouseEntranceBlip(i); createHouseExitBlip(i); } @@ -843,11 +845,15 @@ function createAllHouseBlips() { // =========================================================================== function createHouseEntrancePickup(houseId) { - if(!getServerConfig().createHousePickups) { + if (!getServerConfig().createHousePickups) { return false; } - if(!getHouseData(houseId)) { + if (!isGameFeatureSupported("pickups")) { + return false; + } + + if (!getHouseData(houseId)) { return false; } @@ -857,19 +863,19 @@ function createHouseEntrancePickup(houseId) { // return false; //} - if(houseData.entrancePickupModel == -1) { + if (houseData.entrancePickupModel == -1) { return false; } let pickupModelId = getGameConfig().pickupModels[getGame()].House; - if(getServerData().houses[houseId].entrancePickupModel != 0) { + if (getServerData().houses[houseId].entrancePickupModel != 0) { pickupModelId = getHouseData(houseId).entrancePickupModel; } - if(areServerElementsSupported()) { + if (areServerElementsSupported()) { let entrancePickup = createGamePickup(pickupModelId, getHouseData(houseId).entrancePosition, getGameConfig().pickupTypes[getGame()].house); - if(entrancePickup != null) { + if (entrancePickup != null) { setElementOnAllDimensions(entrancePickup, false); setElementDimension(entrancePickup, getHouseData(houseId).entranceDimension); setElementStreamInDistance(entrancePickup, getGlobalConfig().housePickupStreamInDistance); @@ -882,7 +888,7 @@ function createHouseEntrancePickup(houseId) { } else { let pickupModelId = getGameConfig().pickupModels[getGame()].House; - if(houseData.entrancePickupModel != 0) { + if (houseData.entrancePickupModel != 0) { pickupModelId = houseData.entrancePickupModel; } sendHouseToPlayer(null, houseId, houseId.description, houseId.entrancePosition, blipModelId, pickupModelId, houseId.hasInterior); @@ -892,15 +898,19 @@ function createHouseEntrancePickup(houseId) { // =========================================================================== function createHouseEntranceBlip(houseId) { - if(!areServerElementsSupported()) { + if (!areServerElementsSupported()) { return false; } - if(!getServerConfig().createHouseBlips) { + if (!getServerConfig().createHouseBlips) { return false; } - if(!getHouseData(houseId)) { + if (!isGameFeatureSupported("blips")) { + return false; + } + + if (!getHouseData(houseId)) { return false; } @@ -910,25 +920,25 @@ function createHouseEntranceBlip(houseId) { // return false; //} - if(houseData.entranceBlipModel == -1) { + if (houseData.entranceBlipModel == -1) { return false; } let blipModelId = getGameConfig().blipSprites[getGame()].House; - if(getServerData().houses[houseId].entranceBlipModel != 0) { + if (getServerData().houses[houseId].entranceBlipModel != 0) { blipModelId = getHouseData(houseId).entranceBlipModel; } let entranceBlip = createGameBlip(houseData.entrancePosition, blipModelId, 1, getColourByName("houseGreen")); - if(entranceBlip != null) { - if(houseData.exitDimension != -1) { + if (entranceBlip != null) { + if (houseData.exitDimension != -1) { setElementDimension(entranceBlip, houseData.entranceDimension); setElementOnAllDimensions(entranceBlip, false); } else { setElementOnAllDimensions(entranceBlip, true); } - if(getGlobalConfig().houseBlipStreamInDistance == -1 || getGlobalConfig().houseBlipStreamOutDistance == -1) { + if (getGlobalConfig().houseBlipStreamInDistance == -1 || getGlobalConfig().houseBlipStreamOutDistance == -1) { entranceBlip.netFlags.distanceStreaming = false; } else { setElementStreamInDistance(entranceBlip, getGlobalConfig().houseBlipStreamInDistance); @@ -945,15 +955,19 @@ function createHouseEntranceBlip(houseId) { // =========================================================================== function createHouseExitPickup(houseId) { - if(!areServerElementsSupported()) { + if (!areServerElementsSupported()) { return false; } - if(!getServerConfig().createHousePickups) { + if (!getServerConfig().createHousePickups) { return false; } - if(!getHouseData(houseId)) { + if (!isGameFeatureSupported("pickups")) { + return false; + } + + if (!getHouseData(houseId)) { return false; } @@ -963,18 +977,18 @@ function createHouseExitPickup(houseId) { // return false; //} - if(houseData.exitPickupModel == -1) { + if (houseData.exitPickupModel == -1) { return false; } let pickupModelId = getGameConfig().pickupModels[getGame()].Exit; - if(getServerData().houses[houseId].exitPickupModel != 0) { + if (getServerData().houses[houseId].exitPickupModel != 0) { pickupModelId = houseData.exitPickupModel; } let exitPickup = createGamePickup(pickupModelId, houseData.exitPosition, getGameConfig().pickupTypes[getGame()].house); - if(exitPickup != null) { + if (exitPickup != null) { setElementDimension(exitPickup, houseData.exitDimension); setElementOnAllDimensions(exitPickup, false); setElementStreamInDistance(exitPickup, getGlobalConfig().housePickupStreamInDistance); @@ -989,15 +1003,19 @@ function createHouseExitPickup(houseId) { // =========================================================================== function createHouseExitBlip(houseId) { - if(!areServerElementsSupported()) { + if (!areServerElementsSupported()) { return false; } - if(!getServerConfig().createHouseBlips) { + if (!getServerConfig().createHouseBlips) { return false; } - if(!getHouseData(houseId)) { + if (!isGameFeatureSupported("blips")) { + return false; + } + + if (!getHouseData(houseId)) { return false; } @@ -1007,26 +1025,26 @@ function createHouseExitBlip(houseId) { // return false; //} - if(houseData.exitBlipModel == -1) { + if (houseData.exitBlipModel == -1) { return false; } let blipModelId = getGameConfig().blipSprites[getGame()].Exit; - if(getServerData().houses[houseId].exitBlipModel != 0) { + if (getServerData().houses[houseId].exitBlipModel != 0) { blipModelId = houseData.exitBlipModel; } let exitBlip = createGameBlip(houseData.exitPosition, blipModelId, 1, getColourByName("houseGreen")); - if(exitBlip != null) { - if(houseData.exitDimension != -1) { + if (exitBlip != null) { + if (houseData.exitDimension != -1) { setElementDimension(exitBlip, houseData.exitDimension); setElementOnAllDimensions(exitBlip, false); } else { setElementOnAllDimensions(entranceBlip, true); } - if(getGlobalConfig().houseBlipStreamInDistance == -1 || getGlobalConfig().houseBlipStreamOutDistance == -1) { + if (getGlobalConfig().houseBlipStreamInDistance == -1 || getGlobalConfig().houseBlipStreamOutDistance == -1) { exitBlip.netFlags.distanceStreaming = false; } else { setElementStreamInDistance(exitBlip, getGlobalConfig().houseBlipStreamInDistance); @@ -1042,7 +1060,7 @@ function createHouseExitBlip(houseId) { // =========================================================================== function getHouseOwnerTypeText(ownerType) { - switch(ownerType) { + switch (ownerType) { case VRR_HOUSEOWNER_CLAN: return "clan"; @@ -1080,11 +1098,11 @@ function getHouseOwnerTypeText(ownerType) { function getHouseInfoCommand(command, params, client) { let houseId = getPlayerHouse(client); - if(!areParamsEmpty(params)) { + if (!areParamsEmpty(params)) { houseId = toInteger(params); } - if(!getHouseData(houseId)) { + if (!getHouseData(houseId)) { messagePlayerError(client, getLocaleString(client, "InvalidHouse")); return false; } @@ -1092,7 +1110,7 @@ function getHouseInfoCommand(command, params, client) { let houseData = getHouseData(houseId); let ownerName = "Unknown"; - switch(getHouseData(houseId).ownerType) { + switch (getHouseData(houseId).ownerType) { case VRR_HOUSEOWNER_CLAN: ownerName = getClanData(houseData).name; break; @@ -1137,7 +1155,7 @@ function getHouseInfoCommand(command, params, client) { messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderHouseInfo", houseData.description))); let chunkedList = splitArrayIntoChunks(stats, 6); - for(let i in chunkedList) { + for (let i in chunkedList) { messagePlayerInfo(client, chunkedList[i].join(", ")); } @@ -1156,7 +1174,7 @@ function getHouseInfoCommand(command, params, client) { * */ function setHouseBuyPriceCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -1166,12 +1184,12 @@ function setHouseBuyPriceCommand(command, params, client) { let amount = toInteger(getParam(params, " ", 1)) || 0; let houseId = getPlayerHouse(client); - if(!getHouseData(houseId)) { + if (!getHouseData(houseId)) { messagePlayerError(client, getLocaleString(client, "InvalidHouse")); return false; } - if(amount < 0) { + if (amount < 0) { messagePlayerError(client, `The amount can't be less than 0!`); return false; } @@ -1194,7 +1212,7 @@ function setHouseBuyPriceCommand(command, params, client) { * */ function setHouseRentPriceCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -1204,12 +1222,12 @@ function setHouseRentPriceCommand(command, params, client) { let amount = toInteger(getParam(params, " ", 1)) || 0; let houseId = getPlayerHouse(client); - if(!getHouseData(houseId)) { + if (!getHouseData(houseId)) { messagePlayerError(client, getLocaleString(client, "InvalidHouse")); return false; } - if(amount < 0) { + if (amount < 0) { messagePlayerError(client, `The amount can't be less than 0!`); return false; } @@ -1234,17 +1252,17 @@ function setHouseRentPriceCommand(command, params, client) { function buyHouseCommand(command, params, client) { let houseId = getPlayerHouse(client); - if(!getHouseData(houseId)) { + if (!getHouseData(houseId)) { messagePlayerError(client, getLocaleString(client, "InvalidHouse")); return false; } - if(getHouseData(houseId).buyPrice <= 0) { + if (getHouseData(houseId).buyPrice <= 0) { messagePlayerError(client, getLocaleString(client, "HouseNotForSale")); return false; } - if(getPlayerCurrentSubAccount(client).cash < getHouseData(houseId).buyPrice) { + if (getPlayerCurrentSubAccount(client).cash < getHouseData(houseId).buyPrice) { messagePlayerError(client, getLocaleString(client, "HousePurchaseNotEnoughMoney")); return false; } @@ -1260,7 +1278,7 @@ function buyHouseCommand(command, params, client) { * @return {HouseData} The house's data (class instance) */ function getHouseData(houseId) { - if(typeof getServerData().houses[houseId] != "undefined") { + if (typeof getServerData().houses[houseId] != "undefined") { return getServerData().houses[houseId]; } } @@ -1274,11 +1292,11 @@ function doesHouseHaveInterior(houseId) { // =========================================================================== function deleteHouseEntrancePickup(houseId) { - if(!areServerElementsSupported()) { + if (!areServerElementsSupported()) { return false; } - if(getHouseData(houseId).entrancePickup != null) { + if (getHouseData(houseId).entrancePickup != null) { //removeFromWorld(getHouseData(houseId).entrancePickup); deleteGameElement(getHouseData(houseId).entrancePickup); getHouseData(houseId).entrancePickup = null; @@ -1288,11 +1306,11 @@ function deleteHouseEntrancePickup(houseId) { // =========================================================================== function deleteHouseExitPickup(houseId) { - if(!areServerElementsSupported()) { + if (!areServerElementsSupported()) { return false; } - if(getHouseData(houseId).exitPickup != null) { + if (getHouseData(houseId).exitPickup != null) { //removeFromWorld(getHouseData(houseId).exitPickup); deleteGameElement(getHouseData(houseId).exitPickup); getHouseData(houseId).exitPickup = null; @@ -1302,11 +1320,11 @@ function deleteHouseExitPickup(houseId) { // =========================================================================== function deleteHouseEntranceBlip(houseId) { - if(!areServerElementsSupported()) { + if (!areServerElementsSupported()) { return false; } - if(getHouseData(houseId).entranceBlip != null) { + if (getHouseData(houseId).entranceBlip != null) { //removeFromWorld(getHouseData(houseId).entranceBlip); deleteGameElement(getHouseData(houseId).entranceBlip); getHouseData(houseId).entranceBlip = null; @@ -1316,11 +1334,11 @@ function deleteHouseEntranceBlip(houseId) { // =========================================================================== function deleteHouseExitBlip(houseId) { - if(!areServerElementsSupported()) { + if (!areServerElementsSupported()) { return false; } - if(getHouseData(houseId).exitBlip != null) { + if (getHouseData(houseId).exitBlip != null) { //removeFromWorld(getHouseData(houseId).exitBlip); deleteGameElement(getHouseData(houseId).exitBlip); getHouseData(houseId).exitBlip = null; @@ -1340,13 +1358,13 @@ function deleteHouseExitBlip(houseId) { */ function reloadAllHousesCommand(command, params, client) { let clients = getClients(); - for(let i in clients) { - if(getPlayerHouse(clients[i]) != -1) { + for (let i in clients) { + if (getPlayerHouse(clients[i]) != -1) { removePlayerFromHouse(clients[i]); } } - for(let i in getServerData().houses) { + for (let i in getServerData().houses) { deleteHouseExitBlip(i); deleteHouseEntranceBlip(i); deleteHouseExitPickup(i); @@ -1365,7 +1383,7 @@ function reloadAllHousesCommand(command, params, client) { function exitHouse(client) { let houseId = getPlayerHouse(client); - if(isPlayerSpawned(client)) { + if (isPlayerSpawned(client)) { setPlayerInterior(client, getServerData().house[houseId].entranceInterior); setPlayerDimension(client, getServerData().house[houseId].entranceDimension); setPlayerPosition(client, getServerData().house[houseId].entrancePosition); @@ -1375,7 +1393,7 @@ function exitHouse(client) { // =========================================================================== function setHouseDataIndexes() { - for(let i in getServerData().houses) { + for (let i in getServerData().houses) { getServerData().houses[i].index = i; //for(let j in getServerData().houses[i].locations) { @@ -1393,7 +1411,7 @@ function setHouseDataIndexes() { // =========================================================================== function cacheAllHouseItems() { - for(let i in getServerData().houses) { + for (let i in getServerData().houses) { cacheHouseItems(i); } } @@ -1403,8 +1421,8 @@ function cacheAllHouseItems() { function cacheHouseItems(houseId) { getHouseData(houseId).itemCache = []; - for(let i in getServerData().items) { - if(getItemData(i).ownerType == VRR_ITEM_OWNER_HOUSE && getItemData(i).ownerId == getHouseData(houseId).databaseId) { + for (let i in getServerData().items) { + if (getItemData(i).ownerType == VRR_ITEM_OWNER_HOUSE && getItemData(i).ownerId == getHouseData(houseId).databaseId) { getHouseData(houseId).itemCache.push(i); } } @@ -1414,8 +1432,8 @@ function cacheHouseItems(houseId) { function getHouseIdFromDatabaseId(databaseId) { let houses = getServerData().houses; - for(let i in houses) { - if(houses[i].databaseId == databaseId) { + for (let i in houses) { + if (houses[i].databaseId == databaseId) { return i; } } @@ -1441,8 +1459,8 @@ function getHouseIdFromDatabaseId(databaseId) { function updateHouseInteriorLightsForOccupants(houseId) { let clients = getClients() - for(let i in clients) { - if(getPlayerHouse(clients[i]) == houseId) { + for (let i in clients) { + if (getPlayerHouse(clients[i]) == houseId) { updateInteriorLightsForPlayer(clients[i], getHouseData(houseId).interiorLights); } } @@ -1451,16 +1469,16 @@ function updateHouseInteriorLightsForOccupants(houseId) { // =========================================================================== function canPlayerSetHouseInteriorLights(client, houseId) { - if(doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageHouses"))) { + if (doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageHouses"))) { return true; } - if(getHouseData(houseId).ownerType == VRR_HOUSEOWNER_PLAYER && getHouseData(houseId).ownerId == getPlayerCurrentSubAccount(client).databaseId) { + if (getHouseData(houseId).ownerType == VRR_HOUSEOWNER_PLAYER && getHouseData(houseId).ownerId == getPlayerCurrentSubAccount(client).databaseId) { return true; } - if(getHouseData(houseId).ownerType == VRR_HOUSEOWNER_CLAN && getHouseData(houseId).ownerId == getClanData(getPlayerClan(client)).databaseId) { - if(doesPlayerHaveClanPermission(client, getClanFlagValue("ManageHouses"))) { + if (getHouseData(houseId).ownerType == VRR_HOUSEOWNER_CLAN && getHouseData(houseId).ownerId == getClanData(getPlayerClan(client)).databaseId) { + if (doesPlayerHaveClanPermission(client, getClanFlagValue("ManageHouses"))) { return true; } } @@ -1471,16 +1489,16 @@ function canPlayerSetHouseInteriorLights(client, houseId) { // =========================================================================== function canPlayerLockUnlockHouse(client, houseId) { - if(doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageHouses"))) { + if (doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageHouses"))) { return true; } - if(getHouseData(houseId).ownerType == VRR_HOUSEOWNER_PLAYER && getHouseData(houseId).ownerId == getPlayerCurrentSubAccount(client).databaseId) { + if (getHouseData(houseId).ownerType == VRR_HOUSEOWNER_PLAYER && getHouseData(houseId).ownerId == getPlayerCurrentSubAccount(client).databaseId) { return true; } - if(getHouseData(houseId).ownerType == VRR_HOUSEOWNER_CLAN && getHouseData(houseId).ownerId == getClanData(getPlayerClan(client)).databaseId) { - if(doesPlayerHaveClanPermission(client, getClanFlagValue("ManageHouses"))) { + if (getHouseData(houseId).ownerType == VRR_HOUSEOWNER_CLAN && getHouseData(houseId).ownerId == getClanData(getPlayerClan(client)).databaseId) { + if (doesPlayerHaveClanPermission(client, getClanFlagValue("ManageHouses"))) { return true; } } @@ -1509,7 +1527,7 @@ function resetHouseBlips(houseId) { // =========================================================================== function resetAllHousePickups() { - for(let i in getServerData().houses) { + for (let i in getServerData().houses) { resetHousePickups(i); } } @@ -1517,7 +1535,7 @@ function resetAllHousePickups() { // =========================================================================== function resetAllHouseBlips() { - for(let i in getServerData().houses) { + for (let i in getServerData().houses) { resetHouseBlips(i); } } @@ -1525,19 +1543,19 @@ function resetAllHouseBlips() { // =========================================================================== function canPlayerManageHouse(client, houseId) { - if(doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageHouses"))) { + if (doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageHouses"))) { return true; } - if(getHouseData(houseId).ownerType == VRR_HOUSEOWNER_PLAYER) { - if(getHouseData(houseId).ownerId == getPlayerCurrentSubAccount(client).databaseId) { + if (getHouseData(houseId).ownerType == VRR_HOUSEOWNER_PLAYER) { + if (getHouseData(houseId).ownerId == getPlayerCurrentSubAccount(client).databaseId) { return true; } } - if(getHouseData(houseId).ownerType == VRR_HOUSEOWNER_CLAN) { - if(getHouseData(houseId).ownerId == getPlayerClan(client)) { - if(doesPlayerHaveClanPermission(client, getClanFlagValue("ManageHouses"))) { + if (getHouseData(houseId).ownerType == VRR_HOUSEOWNER_CLAN) { + if (getHouseData(houseId).ownerId == getPlayerClan(client)) { + if (doesPlayerHaveClanPermission(client, getClanFlagValue("ManageHouses"))) { return true; } //if(getHouseData(houseId).clanRank <= getClanRankData(getPlayerClan(client), getPlayerClanRank(client)).level) { @@ -1552,14 +1570,14 @@ function canPlayerManageHouse(client, houseId) { // =========================================================================== function getHouseFromParams(params) { - if(isNaN(params)) { - for(let i in getServerData().houses) { - if(toLowerCase(getServerData().houses[i].description).indexOf(toLowerCase(params)) != -1) { + if (isNaN(params)) { + for (let i in getServerData().houses) { + if (toLowerCase(getServerData().houses[i].description).indexOf(toLowerCase(params)) != -1) { return i; } } } else { - if(typeof getServerData().houses[params] != "undefined") { + if (typeof getServerData().houses[params] != "undefined") { return toInteger(params); } } @@ -1569,30 +1587,30 @@ function getHouseFromParams(params) { // =========================================================================== function updateHousePickupLabelData(houseId) { - if(!areServerElementsSupported()) { + if (!areServerElementsSupported()) { return false; } let houseData = getHouseData(houseId); - if(houseData.entrancePickup != null) { + if (houseData.entrancePickup != null) { setEntityData(houseData.entrancePickup, "vrr.owner.type", VRR_PICKUP_HOUSE_ENTRANCE, false); setEntityData(houseData.entrancePickup, "vrr.owner.id", houseId, false); setEntityData(houseData.entrancePickup, "vrr.label.type", VRR_LABEL_HOUSE, true); setEntityData(houseData.entrancePickup, "vrr.label.name", houseData.description, true); setEntityData(houseData.entrancePickup, "vrr.label.locked", houseData.locked, true); - if(houseData.buyPrice > 0) { + if (houseData.buyPrice > 0) { setEntityData(houseData.entrancePickup, "vrr.label.price", houseData.buyPrice, true); setEntityData(houseData.entrancePickup, "vrr.label.help", VRR_PROPLABEL_INFO_BUYHOUSE, true); } else { - if(houseData.rentPrice > 0) { + if (houseData.rentPrice > 0) { setEntityData(houseData.entrancePickup, "vrr.label.rentprice", houseData.rentPrice, true); setEntityData(houseData.entrancePickup, "vrr.label.help", VRR_PROPLABEL_INFO_RENTHOUSE, true); } } } - if(houseData.exitPickup != null) { + if (houseData.exitPickup != null) { setEntityData(houseData.exitPickup, "vrr.owner.type", VRR_PICKUP_HOUSE_EXIT, false); setEntityData(houseData.exitPickup, "vrr.owner.id", houseId, false); setEntityData(houseData.exitPickup, "vrr.label.type", VRR_LABEL_EXIT, true); @@ -1602,7 +1620,7 @@ function updateHousePickupLabelData(houseId) { // =========================================================================== function deleteAllHouseBlips() { - for(let i in getServerData().houses) { + for (let i in getServerData().houses) { deleteHouseEntranceBlip(i); deleteHouseExitBlip(i); } @@ -1611,7 +1629,7 @@ function deleteAllHouseBlips() { // =========================================================================== function deleteAllHousePickups() { - for(let i in getServerData().houses) { + for (let i in getServerData().houses) { deleteHouseEntrancePickup(i); deleteHouseExitPickup(i); } diff --git a/scripts/server/index.js b/scripts/server/index.js deleted file mode 100644 index 67fbcb04..00000000 --- a/scripts/server/index.js +++ /dev/null @@ -1,86 +0,0 @@ -// Shared Scripts -require("../scripts/shared/const.js"); -require("../scripts/shared/utilities.js"); -require("../scripts/shared/gamedata.js"); - -// Multiplayer Mod (Wrapped Natives) -require("scripts/server/native/ragemp.js"); - -// Server Scripts -require("scripts/server/class.js"); -require("scripts/server/accent.js"); -require("scripts/server/account.js"); -require("scripts/server/animation.js"); -require("scripts/server/anticheat.js"); -require("scripts/server/ban.js"); -require("scripts/server/bitflag.js"); -require("scripts/server/business.js"); -require("scripts/server/chat.js"); -require("scripts/server/clan.js"); -require("scripts/server/client.js"); -require("scripts/server/colour.js"); -require("scripts/server/const.js"); -require("scripts/server/database.js"); -require("scripts/server/developer.js"); -require("scripts/server/discord.js"); -require("scripts/server/economy.js"); -require("scripts/server/email.js"); -require("scripts/server/event.js"); -require("scripts/server/fishing.js"); -require("scripts/server/gui.js"); -require("scripts/server/help.js"); -require("scripts/server/house.js"); -require("scripts/server/item.js"); -require("scripts/server/job.js"); -require("scripts/server/keybind.js"); -require("scripts/server/locale.js"); -require("scripts/server/messaging.js"); -require("scripts/server/misc.js"); -require("scripts/server/npc.js"); -require("scripts/server/staff.js"); -require("scripts/server/race.js"); -require("scripts/server/radio.js"); -require("scripts/server/security.js"); -require("scripts/server/subaccount.js"); -require("scripts/server/timers.js"); -require("scripts/server/trigger.js"); -require("scripts/server/utilities.js"); -require("scripts/server/vehicle.js"); -require("scripts/server/config.js"); -require("scripts/server/core.js"); -require("scripts/server/command.js"); - -// Server Business Scripts -require("scripts/server/business/bakery.js"); -require("scripts/server/business/bar.js"); -require("scripts/server/business/burger.js"); -require("scripts/server/business/clothing.js"); -require("scripts/server/business/club.js"); -require("scripts/server/business/fuel.js"); -require("scripts/server/business/mechanic.js"); -require("scripts/server/business/pizza.js"); -require("scripts/server/business/restaurant.js"); -require("scripts/server/business/vehicle.js"); -require("scripts/server/business/weapon.js"); - -// Server Job Scripts -require("scripts/server/job/bus.js"); -require("scripts/server/job/drug.js"); -require("scripts/server/job/fire.js"); -require("scripts/server/job/garbage.js"); -require("scripts/server/job/medic.js"); -require("scripts/server/job/police.js"); -require("scripts/server/job/taxi.js"); -require("scripts/server/job/weapon.js"); - -// Server Item Scripts -require("scripts/server/item/food.js"); -require("scripts/server/item/drink.js"); -require("scripts/server/item/walkie-talkie.js"); -require("scripts/server/item/phone.js"); -require("scripts/server/item/handcuff.js"); -require("scripts/server/item/rope.js"); -require("scripts/server/item/tazer.js"); - -// Startup -require("scripts/server/startup.js"); \ No newline at end of file diff --git a/scripts/server/item.js b/scripts/server/item.js index cf9bb58e..65471b75 100644 --- a/scripts/server/item.js +++ b/scripts/server/item.js @@ -19,11 +19,11 @@ function loadItemsFromDatabase() { let tempItems = []; let dbConnection = connectToDatabase(); let dbFetchAssoc; - if(dbConnection) { - let dbQuery = queryDatabase(dbConnection, `SELECT * FROM item_main WHERE item_server = ${getServerId()}`); - if(dbQuery) { - if(dbQuery.numRows > 0) { - while(dbFetchAssoc = fetchQueryAssoc(dbQuery)) { + if (dbConnection) { + let dbQuery = queryDatabase(dbConnection, `SELECT * FROM item_main WHERE item_deleted = 0 AND item_server = ${getServerId()}`); + if (dbQuery) { + if (dbQuery.numRows > 0) { + while (dbFetchAssoc = fetchQueryAssoc(dbQuery)) { let tempItemData = new ItemData(dbFetchAssoc); tempItems.push(tempItemData); } @@ -41,11 +41,11 @@ function loadItemTypesFromDatabase() { let tempItemTypes = []; let dbConnection = connectToDatabase(); let dbFetchAssoc; - if(dbConnection) { - let dbQuery = queryDatabase(dbConnection, `SELECT * FROM item_type WHERE item_type_enabled = 1 AND item_type_server = ${getServerId()}`); - if(dbQuery) { - if(getQueryNumRows(dbQuery) > 0) { - while(dbFetchAssoc = fetchQueryAssoc(dbQuery)) { + if (dbConnection) { + let dbQuery = queryDatabase(dbConnection, `SELECT * FROM item_type WHERE item_type_deleted = 0 AND item_type_enabled = 1 AND item_type_server = ${getServerId()}`); + if (dbQuery) { + if (getQueryNumRows(dbQuery) > 0) { + while (dbFetchAssoc = fetchQueryAssoc(dbQuery)) { let tempItemTypeData = new ItemTypeData(dbFetchAssoc); tempItemTypes.push(tempItemTypeData); } @@ -60,7 +60,7 @@ function loadItemTypesFromDatabase() { // =========================================================================== -function createItem(itemTypeId, value, ownerType, ownerId, amount=1) { +function createItem(itemTypeId, value, ownerType, ownerId, amount = 1) { let tempItemData = new ItemData(false); tempItemData.itemType = getItemTypeData(itemTypeId).databaseId; tempItemData.ownerType = ownerType; @@ -69,9 +69,9 @@ function createItem(itemTypeId, value, ownerType, ownerId, amount=1) { tempItemData.value = value; tempItemData.needsSaved = true; let slot = getServerData().items.push(tempItemData); - let index = slot-1; - getServerData().items[slot-1].index = index; - getServerData().items[slot-1].itemTypeIndex = itemTypeId; + let index = slot - 1; + getServerData().items[slot - 1].index = index; + getServerData().items[slot - 1].itemTypeIndex = itemTypeId; return index; } @@ -88,16 +88,16 @@ function createGroundItem(itemTypeId, value, position, dimension = 0) { // =========================================================================== function createGroundItemObject(itemId) { - if(!getItemData(itemId)) { + if (!getItemData(itemId)) { return false; } - if(getItemData(itemId).object != null) { + if (getItemData(itemId).object != null) { deleteGroundItemObject(itemId); } let object = createGameObject(getItemTypeData(getItemData(itemId).itemTypeIndex).dropModel, applyOffsetToPos(getItemData(itemId).position, getItemTypeData(getItemData(itemId).itemTypeIndex).dropPosition)); - if(object != false) { + if (object != false) { getItemData(itemId).object = object; setElementRotation(getItemData(itemId).object, getItemTypeData(getItemData(itemId).itemTypeIndex).dropRotation); setElementOnAllDimensions(getItemData(itemId).object, false); @@ -112,11 +112,11 @@ function createGroundItemObject(itemId) { // =========================================================================== function deleteGroundItemObject(itemId) { - if(getServerData().groundItemCache.indexOf(itemId) != -1) { + if (getServerData().groundItemCache.indexOf(itemId) != -1) { getServerData().groundItemCache.splice(getServerData().groundItemCache.indexOf(itemId), 1); } - if(getItemData(itemId).object != null) { + if (getItemData(itemId).object != null) { destroyGameElement(getItemData(itemId).object); getItemData(itemId).object = null; } @@ -138,7 +138,7 @@ function createGroundItemCommand(command, params, client) { let itemType = getItemTypeFromParams(splitParams.slice(0, -1).join(" ")); let value = splitParams.slice(-1) || 1; - if(!getItemTypeData(itemType)) { + if (!getItemTypeData(itemType)) { messagePlayerError(client, getLocaleString(client, "InvalidItemType")); return false; } @@ -169,7 +169,7 @@ function createItemCommand(command, params, client) { let itemType = getItemTypeFromParams(splitParams.slice(0, -1).join(" ")); let value = splitParams.slice(-1) || 1; - if(!getItemTypeData(itemType)) { + if (!getItemTypeData(itemType)) { messagePlayerError(client, getLocaleString(client, "InvalidItemType")); return false; } @@ -199,44 +199,44 @@ function useItemCommand(command, params, client) { clearPlayerItemActionState(client); let hotBarSlot = getPlayerData(client).activeHotBarSlot; - if(!areParamsEmpty(params)) { + if (!areParamsEmpty(params)) { hotBarSlot = toInteger(params); - hotBarSlot = hotBarSlot-1; + hotBarSlot = hotBarSlot - 1; } - if(hotBarSlot == -1) { + if (hotBarSlot == -1) { return false; } - if(getPlayerData(client).hotBarItems[hotBarSlot] == -1) { + if (getPlayerData(client).hotBarItems[hotBarSlot] == -1) { return false; } let itemId = getPlayerData(client).hotBarItems[hotBarSlot]; - if(!getItemData(itemId)) { + if (!getItemData(itemId)) { messagePlayerError(client, getLocaleString(client, "UseItemBug")); submitBugReport(client, `(AUTOMATED REPORT) Use Item: Getting item data for item ${itemId} in player hotbar slot ${hotBarSlot} (cache ${getPlayerData(client).hotBarItems[hotBarSlot]}) returned false.`); return false; } - if(!getItemTypeData(getItemData(itemId).itemTypeIndex)) { + if (!getItemTypeData(getItemData(itemId).itemTypeIndex)) { messagePlayerError(client, getLocaleString(client, "UseItemBug")); submitBugReport(client, `(AUTOMATED REPORT) Use Item: Getting item type ${getItemData(itemId).itemType} data for item ${itemId}/${getItemData(itemId).databaseId} in player hotbar slot ${hotBarSlot} (cache ${getPlayerData(client).hotBarItems[hotBarSlot]}) returned false.`); return false; } - if(getPlayerData(client).itemActionState != VRR_ITEM_ACTION_NONE) { + if (getPlayerData(client).itemActionState != VRR_ITEM_ACTION_NONE) { messagePlayerError(client, getLocaleString(client, "HandsBusy")); return false; } - if(getPlayerData(client).usingSkinSelect) { + if (getPlayerData(client).usingSkinSelect) { messagePlayerError(client, getLocaleString(client, "CantUseItemInSkinChange")); return false; } - if(getItemTypeData(getItemData(itemId).itemTypeIndex).useAnimationIndex != false) { + if (getItemTypeData(getItemData(itemId).itemTypeIndex).useAnimationIndex != false) { forcePlayerPlayAnimation(client, getItemTypeData(getItemData(itemId).itemTypeIndex).useAnimationIndex, 0.0); } @@ -261,13 +261,13 @@ function useItemCommand(command, params, client) { function deleteGroundItemCommand(command, params, client) { let itemId = getClosestItemOnGround(getPlayerPosition(client)); - if(!getItemData(itemId)) { + if (!getItemData(itemId)) { messagePlayerError(client, `The item you're trying to delete is bugged. A bug report has been sent to the server developers.`); submitBugReport(client, `(AUTOMATED REPORT) Delete Ground Item: Getting item data for item ${itemId} on ground returned false.`); return false; } - if(!getItemTypeData(getItemData(itemId).itemTypeIndex)) { + if (!getItemTypeData(getItemData(itemId).itemTypeIndex)) { messagePlayerError(client, `The item you're trying to delete is bugged. A bug report has been sent to the server developers.`); submitBugReport(client, `(AUTOMATED REPORT) Delete Ground Item: Getting item type ${getItemData(itemId).itemType} data for item ${itemId}/${getItemData(itemId).databaseId} on ground returned false.`); return false; @@ -294,40 +294,42 @@ function pickupItemCommand(command, params, client) { let itemId = getClosestItemOnGround(getPlayerPosition(client)); - if(!getItemData(itemId)) { + if (!getItemData(itemId)) { //messagePlayerError(client, `The item you're trying to pick up is bugged. A bug report has been sent to the server developers.`); + messagePlayerError(client, getPlayerLocale(client, "NoItemCloseEnough")); submitBugReport(client, `(AUTOMATED REPORT) Pickup Item: Getting item data for item ${itemId} on ground returned false.`); return false; } - if(!getItemTypeData(getItemData(itemId).itemTypeIndex)) { + if (!getItemTypeData(getItemData(itemId).itemTypeIndex)) { //messagePlayerError(client, `The item you're trying to pick up is bugged. A bug report has been sent to the server developers.`); + messagePlayerError(client, getPlayerLocale(client, "NoItemCloseEnough")); submitBugReport(client, `(AUTOMATED REPORT) Pickup Item: Getting item type ${getItemData(itemId).itemType} data for item ${itemId}/${getItemData(itemId).databaseId} on ground returned false.`); return false; } - if(getDistance(getPlayerPosition(client), getItemData(itemId).position) > getGlobalConfig().droppedItemPickupRange) { - messagePlayerError(client, `You're too far away!`); + if (getDistance(getPlayerPosition(client), getItemData(itemId).position) > getGlobalConfig().droppedItemPickupRange) { + messagePlayerError(client, getPlayerLocale(client, "NoItemCloseEnough")); return false; } let firstSlot = getPlayerFirstEmptyHotBarSlot(client); - if(firstSlot == -1) { - messagePlayerError(client, `You don't have any space to carry this (full inventory)!`); + if (firstSlot == -1) { + messagePlayerError(client, getPlayerLocale(client, "NoSpaceSelfInventory")); return false; } - if(getPlayerData(client).itemActionState != VRR_ITEM_ACTION_NONE) { + if (getPlayerData(client).itemActionState != VRR_ITEM_ACTION_NONE) { messagePlayerError(client, getLocaleString(client, "HandsBusy")); return false; } - if(getPlayerData(client).usingSkinSelect) { + if (getPlayerData(client).usingSkinSelect) { messagePlayerError(client, getLocaleString(client, "CantPickupItemInSkinChange")); return false; } - if(getItemTypeData(getItemData(itemId).itemTypeIndex).dropAnimationIndex != false) { + if (getItemTypeData(getItemData(itemId).itemTypeIndex).dropAnimationIndex != false) { forcePlayerPlayAnimation(client, getItemTypeData(getItemData(itemId).itemTypeIndex).pickupAnimationIndex, 0.0); } @@ -353,51 +355,51 @@ function dropItemCommand(command, params, client) { clearPlayerItemActionState(client); let hotBarSlot = getPlayerData(client).activeHotBarSlot; - if(!areParamsEmpty(params)) { + if (!areParamsEmpty(params)) { hotBarSlot = toInteger(params); - hotBarSlot = hotBarSlot-1; + hotBarSlot = hotBarSlot - 1; } - if(hotBarSlot == -1) { - messagePlayerError(client, `You don't have any item selected/equipped.`); + if (hotBarSlot == -1) { + messagePlayerError(client, getLocaleString(client, "NoItemEquipped")); return false; } - if(getPlayerData(client).hotBarItems[hotBarSlot] == -1) { - messagePlayerError(client, `You don't have an item in your active slot.`); + if (getPlayerData(client).hotBarItems[hotBarSlot] == -1) { + messagePlayerError(client, getLocaleString(client, "NoItemInActiveSlot")); return false; } let itemId = getPlayerData(client).hotBarItems[hotBarSlot]; - if(!getItemData(itemId)) { - messagePlayerError(client, `The item you're trying to drop is bugged. A bug report has been sent to the server developers.`); + if (!getItemData(itemId)) { + messagePlayerError(client, getLocaleString(client, "DropItemBugged")); submitBugReport(client, `(AUTOMATED REPORT) Drop Item: Getting item data for item ${itemId} in player hotbar slot ${hotBarSlot} (cache ${getPlayerData(client).hotBarItems[hotBarSlot]}) returned false.`); return false; } - if(!getItemTypeData(getItemData(itemId).itemTypeIndex)) { - messagePlayerError(client, `The item you're trying to drop is bugged. A bug report has been sent to the server developers.`); + if (!getItemTypeData(getItemData(itemId).itemTypeIndex)) { + messagePlayerError(client, getLocaleString(client, "DropItemBugged")); submitBugReport(client, `(AUTOMATED REPORT) Drop Item: Getting item type ${getItemData(itemId).itemType} data for item ${itemId}/${getItemData(itemId).databaseId} in player hotbar slot ${hotBarSlot} (cache ${getPlayerData(client).hotBarItems[hotBarSlot]}) returned false.`); return false; } - if(getPlayerData(client).itemActionState != VRR_ITEM_ACTION_NONE) { + if (getPlayerData(client).itemActionState != VRR_ITEM_ACTION_NONE) { messagePlayerError(client, getLocaleString(client, "HandsBusy")); return false; } - if(getPlayerData(client).usingSkinSelect) { + if (getPlayerData(client).usingSkinSelect) { messagePlayerError(client, getLocaleString(client, "CantDropItemInSkinChange")); return false; } - if(isPlayerItemFromJobEquipment(client, hotBarSlot)) { - messagePlayerError(client, `You can't drop job items`); + if (isPlayerItemFromJobEquipment(client, hotBarSlot)) { + messagePlayerError(client, getLocaleString(client, "CantDropJobEquipmentItem")); return false; } - if(getItemTypeData(getItemData(itemId).itemTypeIndex).dropAnimationIndex != false) { + if (getItemTypeData(getItemData(itemId).itemTypeIndex).dropAnimationIndex != false) { forcePlayerPlayAnimation(client, getItemTypeData(getItemData(itemId).itemTypeIndex).dropAnimationIndex, 0.0); } @@ -426,34 +428,34 @@ function putItemCommand(command, params, client) { let itemId = getPlayerData(client).hotBarItems[hotBarSlot]; - if(!getItemData(itemId)) { + if (!getItemData(itemId)) { messagePlayerError(client, `The item you're trying to store is bugged. A bug report has been sent to the server developers.`); submitBugReport(client, `(AUTOMATED REPORT) Put Item: Getting item data for item ${itemId} in player hotbar slot ${hotBarSlot} (cache ${getPlayerData(client).hotBarItems[hotBarSlot]}) returned false.`); return false; } - if(!getItemTypeData(getItemData(itemId).itemTypeIndex)) { + if (!getItemTypeData(getItemData(itemId).itemTypeIndex)) { messagePlayerError(client, `The item you're trying to store is bugged. A bug report has been sent to the server developers.`); submitBugReport(client, `(AUTOMATED REPORT) Put Item: Getting item type ${getItemData(itemId).itemType} data for item ${itemId}/${getItemData(itemId).databaseId} in player hotbar slot ${hotBarSlot} (cache ${getPlayerData(client).hotBarItems[hotBarSlot]}) returned false.`); return false; } - if(getPlayerData(client).itemActionState != VRR_ITEM_ACTION_NONE) { + if (getPlayerData(client).itemActionState != VRR_ITEM_ACTION_NONE) { messagePlayerError(client, getLocaleString(client, "HandsBusy")); return false; } - if(getPlayerData(client).usingSkinSelect) { + if (getPlayerData(client).usingSkinSelect) { messagePlayerError(client, getLocaleString(client, "CantPutItemInSkinChange")); return false; } - if(isPlayerItemFromJobEquipment(client, hotBarSlot)) { - messagePlayerError(client, `You can't put job items`); + if (isPlayerItemFromJobEquipment(client, hotBarSlot)) { + messagePlayerError(client, getLocaleString(client, "CantPutJobEquipmentItem")); return false; } - if(getItemTypeData(getItemData(itemId).itemTypeIndex).putAnimationIndex != false) { + if (getItemTypeData(getItemData(itemId).itemTypeIndex).putAnimationIndex != false) { forcePlayerPlayAnimation(client, getItemTypeData(getItemData(itemId).itemTypeIndex).putAnimationIndex, 0.0); } @@ -479,27 +481,27 @@ function takeItemCommand(command, params, client) { clearPlayerItemActionState(client); let firstSlot = getPlayerFirstEmptyHotBarSlot(client); - if(firstSlot == -1) { - messagePlayerError(client, `You don't have any space to hold another item (full inventory)!`); + if (firstSlot == -1) { + messagePlayerError(client, getLocaleString(client, "NoSpaceSelfInventory")); return false; } let itemSlot = toInteger(params) || 0; - let bestOwner = getBestItemToTake(client, itemSlot); + let bestOwner = getBestItemToTake(client, itemSlot); let itemId = bestOwner[2]; - if(bestOwner[1] == VRR_ITEM_OWNER_NONE) { - messagePlayerError(client, `You aren't near anything to take items from!`); + if (bestOwner[1] == VRR_ITEM_OWNER_NONE) { + messagePlayerError(client, getLocaleString(client, "NothingToTakeItemFrom")); return false; } - if(getPlayerData(client).itemActionState != VRR_ITEM_ACTION_NONE) { + if (getPlayerData(client).itemActionState != VRR_ITEM_ACTION_NONE) { messagePlayerError(client, getLocaleString(client, "HandsBusy")); return false; } - if(getPlayerData(client).usingSkinSelect) { + if (getPlayerData(client).usingSkinSelect) { messagePlayerError(client, getLocaleString(client, "CantTakeItemInSkinChange")); return false; } @@ -509,7 +511,7 @@ function takeItemCommand(command, params, client) { // return false; //} - if(getItemTypeData(getItemData(itemId).itemTypeIndex).takeAnimationIndex != false) { + if (getItemTypeData(getItemData(itemId).itemTypeIndex).takeAnimationIndex != false) { forcePlayerPlayAnimation(client, getItemTypeData(getItemData(itemId).itemTypeIndex).takeAnimationIndex, 0.0); } @@ -532,7 +534,7 @@ function takeItemCommand(command, params, client) { * */ function createItemTypeCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -553,21 +555,22 @@ function createItemTypeCommand(command, params, client) { * */ function setItemTypeDropModelCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } - let itemTypeIndex = getItemTypeFromParams(splitParams.slice(0,-1).join(" ")); - let modelId = splitParams[splitParams.length-1]; + let itemTypeIndex = getItemTypeFromParams(splitParams.slice(0, -1).join(" ")); + let modelIndex = getObjectModelIndexFromParams(splitParams.slice(-1).join(" ")); - if(!getItemTypeData(itemTypeIndex)) { + if (!getItemTypeData(itemTypeIndex)) { messagePlayerError(client, getLocaleString(client, "InvalidItemType")); return false; } - getItemTypeData(itemTypeIndex).dropModel = modelId; - messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} set item type {ALTCOLOUR}${getItemTypeData(itemTypeIndex).name} dropped object model to ${modelId}`); + getItemTypeData(itemTypeIndex).dropModel = modelIndex; + getItemTypeData(itemTypeIndex).needsSaved = true; + messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} set item type {ALTCOLOUR}${getItemTypeData(itemTypeIndex).name}'s dropped object model index to ${modelIndex}`); } // =========================================================================== @@ -582,20 +585,21 @@ function setItemTypeDropModelCommand(command, params, client) { * */ function setItemTypeOrderPriceCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } - let itemTypeIndex = getItemTypeFromParams(splitParams.slice(0,-1).join(" ")); - let orderPrice = splitParams[splitParams.length-1]; + let itemTypeIndex = getItemTypeFromParams(splitParams.slice(0, -1).join(" ")); + let orderPrice = splitParams[splitParams.length - 1]; - if(!getItemTypeData(itemTypeIndex)) { + if (!getItemTypeData(itemTypeIndex)) { messagePlayerError(client, getLocaleString(client, "InvalidItemType")); return false; } getItemTypeData(itemTypeIndex).orderPrice = orderPrice; + getItemTypeData(itemTypeIndex).needsSaved = true; messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} set item type {ALTCOLOUR}${getItemTypeData(itemTypeIndex).name} {MAINCOLOUR}base price to {ALTCOLOUR}$${orderPrice}`); } @@ -611,21 +615,22 @@ function setItemTypeOrderPriceCommand(command, params, client) { * */ function setItemTypeRiskMultiplierCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } - let itemTypeIndex = getItemTypeFromParams(splitParams.slice(0,-1).join(" ")); - let riskMultiplier = splitParams[splitParams.length-1]; + let itemTypeIndex = getItemTypeFromParams(splitParams.slice(0, -1).join(" ")); + let riskMultiplier = splitParams[splitParams.length - 1]; - if(!getItemTypeData(itemTypeIndex)) { + if (!getItemTypeData(itemTypeIndex)) { messagePlayerError(client, getLocaleString(client, "InvalidItemType")); return false; } getItemTypeData(itemTypeIndex).riskMultiplier = riskMultiplier; - messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} set item type {ALTCOLOUR}${getItemTypeData(itemTypeIndex).name} {MAINCOLOUR}risk multilier to {ALTCOLOUR}$${riskMultiplier}`); + getItemTypeData(itemTypeIndex).needsSaved = true; + messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} set item type {ALTCOLOUR}${getItemTypeData(itemTypeIndex).name}{MAINCOLOUR} risk multiplier to {ALTCOLOUR}$${riskMultiplier}`); } // =========================================================================== @@ -640,19 +645,20 @@ function setItemTypeRiskMultiplierCommand(command, params, client) { * */ function toggleItemTypeEnabledCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } let itemTypeIndex = getItemTypeFromParams(params); - if(!getItemTypeData(itemTypeIndex)) { + if (!getItemTypeData(itemTypeIndex)) { messagePlayerError(client, getLocaleString(client, "InvalidItemType")); return false; } getItemTypeData(itemTypeIndex).enabled = !getItemTypeData(itemTypeIndex).enabled; + getItemTypeData(itemTypeIndex).needsSaved = true; messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} ${getEnabledDisabledFromBool(getItemTypeData(itemTypeIndex).enabled)} item type {ALTCOLOUR}${getItemTypeData(itemTypeIndex).name}`); } @@ -668,21 +674,22 @@ function toggleItemTypeEnabledCommand(command, params, client) { * */ function setItemTypeUseTypeCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } - let itemTypeIndex = getItemTypeFromParams(splitParams.slice(0,-1).join(" ")); - let useType = splitParams[splitParams.length-1]; + let itemTypeIndex = getItemTypeFromParams(splitParams.slice(0, -1).join(" ")); + let useType = splitParams[splitParams.length - 1]; - if(!getItemTypeData(itemTypeIndex)) { + if (!getItemTypeData(itemTypeIndex)) { messagePlayerError(client, getLocaleString(client, "InvalidItemType")); return false; } getItemTypeData(itemTypeIndex).useType = useType; - messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} set item type {ALTCOLOUR}${getItemTypeData(itemTypeIndex).name} {MAINCOLOUR}use type to {ALTCOLOUR}$${useType}`); + getItemTypeData(itemTypeIndex).needsSaved = true; + messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} set item type {ALTCOLOUR}${getItemTypeData(itemTypeIndex).name}{MAINCOLOUR} use type to {ALTCOLOUR}$${useType}`); } // =========================================================================== @@ -697,21 +704,22 @@ function setItemTypeUseTypeCommand(command, params, client) { * */ function setItemTypeUseValueCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } - let itemTypeIndex = getItemTypeFromParams(splitParams.slice(0,-1).join(" ")); - let useValue = splitParams[splitParams.length-1]; + let itemTypeIndex = getItemTypeFromParams(splitParams.slice(0, -1).join(" ")); + let useValue = splitParams[splitParams.length - 1]; - if(!getItemTypeData(itemTypeIndex)) { + if (!getItemTypeData(itemTypeIndex)) { messagePlayerError(client, getLocaleString(client, "InvalidItemType")); return false; } getItemTypeData(itemTypeIndex).useValue = useValue; - messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} set item type {ALTCOLOUR}${getItemTypeData(itemTypeIndex).name} {MAINCOLOUR}use value to {ALTCOLOUR}$${useValue}`); + getItemTypeData(itemTypeIndex).needsSaved = true; + messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} set item type {ALTCOLOUR}${getItemTypeData(itemTypeIndex).name}{MAINCOLOUR} use value to {ALTCOLOUR}$${useValue}`); } // =========================================================================== @@ -719,17 +727,24 @@ function setItemTypeUseValueCommand(command, params, client) { function playerUseItem(client, hotBarSlot) { let itemIndex = getPlayerData(client).hotBarItems[hotBarSlot]; - if(itemIndex == -1) { + if (itemIndex == -1) { + logToConsole(LOG_DEBUG | LOG_WARN, `[VRR.Item] ${getPlayerDisplayForConsole(client)} tried to use an empty hotbar slot ${hotBarSlot}`); return false; } - if(!getItemData(itemIndex)) { + if (!getItemData(itemIndex)) { submitBugReport(client, `[AUTOMATED REPORT] Tried to use invalid item (index ${itemIndex} in player slot ${hotBarSlot})`); cachePlayerHotBarItems(client); return false; } - switch(getItemTypeData(getItemData(itemIndex).itemTypeIndex).useType) { + let itemData = getItemData(itemIndex); + let itemTypeData = getItemTypeData(itemData.itemTypeIndex); + let hotBarItems = getPlayerData(client).hotBarItems; + + logToConsole(LOG_DEBUG, `[VRR.Item] ${getPlayerDisplayForConsole(client)} used a ${itemTypeData.name} (use type ${itemTypeData.useType} - ${typeof itemTypeData.useType}) item (ID: ${itemData.index}/${itemData.databaseId}, TypeID: ${itemTypeData.index}/${itemTypeData.databaseId})`); + + switch (toInteger(itemTypeData.useType)) { case VRR_ITEM_USETYPE_SKIN: { getPlayerData(client).itemActionItem = itemIndex; forcePlayerIntoSkinSelect(client); @@ -737,27 +752,33 @@ function playerUseItem(client, hotBarSlot) { } case VRR_ITEM_USETYPE_WEAPON: { - for(let i in getPlayerData(client).hotBarItems) { - if(getPlayerData(client).hotBarItems[i] != -1) { - if(getItemData(getPlayerData(client).hotBarItems[i]) != false) { - if(getItemTypeData(getItemData(getPlayerData(client).hotBarItems[i]).itemTypeIndex).useType == VRR_ITEM_USETYPE_AMMO_CLIP) { - if(getItemTypeData(getItemData(getPlayerData(client).hotBarItems[i]).itemTypeIndex).useId == getItemTypeData(getItemData(itemIndex).itemTypeIndex).databaseId) { - givePlayerWeaponAmmo(client, getItemData(getPlayerData(client).hotBarItems[i]).value); - getItemData(getPlayerData(client).hotBarItems[hotBarSlot]).value = getItemData(getPlayerData(client).hotBarItems[hotBarSlot]).value + getItemData(getPlayerData(client).hotBarItems[i]).value; - deleteItem(getPlayerData(client).hotBarItems[i]); - meActionToNearbyPlayers(client, `loads some ammo into their ${getItemTypeData(getItemData(itemIndex).itemTypeIndex).name}`); + for (let i in hotBarItems) { + if (hotBarItems[i] != -1) { + if (getItemData(hotBarItems[i]) != false) { + if (getItemTypeData(getItemData(hotBarItems[i]).itemTypeIndex).useType == VRR_ITEM_USETYPE_AMMO_CLIP) { + let ammoItemData = getItemData(hotBarItems[i]); + let ammoItemTypeData = getItemTypeData(ammoItemData.itemTypeIndex); + if (ammoItemTypeData.useId == itemTypeData.databaseId) { + givePlayerWeaponAmmo(client, ammoItemData.value); + itemData.value = itemData.value + ammoItemData.value; + deleteItem(hotBarItems[i]); + meActionToNearbyPlayers(client, `loads some ammo into their ${itemTypeData.name}`); return true; } } } } } - messagePlayerError(client, `You don't have any ammo to load into your ${getItemTypeData(getItemData(itemIndex).itemTypeIndex).name}!`); + messagePlayerError(client, getLocaleString(client, "NoAmmoToLoadIntoWeapon", itemTypeData.name)); break; } case VRR_ITEM_USETYPE_AMMO_CLIP: { - messagePlayerError(client, `To load this ammo into a weapon, equip the weapon and ${(doesPlayerHaveKeyBindForCommand(client, "use")) ? `press {ALTCOLOUR}${toUpperCase(getKeyNameFromId(getPlayerKeyBindForCommand(client, "use").key))}` : `{ALTCOLOUR}/use`}`); + if (doesPlayerHaveKeyBindForCommand(client, "use")) { + messagePlayerError(client, getLocaleString(client, "LoadAmmoIntoWeaponHelpKeyPress", `{ALTCOLOUR}${toUpperCase(getKeyNameFromId(getPlayerKeyBindForCommand(client, "use").key))}{MAINCOLOUR}`)); + } else { + messagePlayerError(client, getLocaleString(client, "LoadAmmoIntoWeaponHelpCommand", `{ALTCOLOUR}/use{MAINCOLOUR}`)); + } break; } @@ -767,10 +788,10 @@ function playerUseItem(client, hotBarSlot) { } case VRR_ITEM_USETYPE_FOOD: { - meActionToNearbyPlayers(client, `eats some of their ${getItemName(itemIndex)}`); - givePlayerHealth(client, getItemTypeData(getItemData(itemIndex).itemTypeIndex).useValue); - getItemData(itemIndex).value = getItemData(itemIndex).value - getItemTypeData(getItemData(itemIndex).itemTypeIndex).useValue; - if(getItemData(itemIndex).value <= 0) { + meActionToNearbyPlayers(client, `eats some of their ${itemTypeData.name}`); + givePlayerHealth(client, itemTypeData.useValue); + itemData.value = itemData.value - tempItemTypeData.useValue; + if (getItemData(itemIndex).value <= 0) { deleteItem(itemIndex); switchPlayerActiveHotBarSlot(client, -1); } @@ -778,10 +799,10 @@ function playerUseItem(client, hotBarSlot) { } case VRR_ITEM_USETYPE_DRINK: { - meActionToNearbyPlayers(client, `drinks some of their ${getItemName(itemIndex)}`); - givePlayerHealth(client, getItemTypeData(getItemData(itemIndex).itemTypeIndex).useValue); - getItemData(itemIndex).value = getItemData(itemIndex).value - getItemTypeData(getItemData(itemIndex).itemTypeIndex).useValue; - if(getItemData(itemIndex).value <= 0) { + meActionToNearbyPlayers(client, `drinks some of their ${itemTypeData.name}`); + givePlayerHealth(client, itemTypeData.useValue); + itemData.value = itemData.value - itemTypeData.useValue; + if (itemData.value <= 0) { deleteItem(itemIndex); switchPlayerActiveHotBarSlot(client, -1); } @@ -789,8 +810,8 @@ function playerUseItem(client, hotBarSlot) { } case VRR_ITEM_USETYPE_ARMOUR: { - meActionToNearbyPlayers(client, `puts on a ${getItemName(itemIndex)}`); - givePlayerArmour(client, getItemData(itemIndex).useValue); + meActionToNearbyPlayers(client, `puts on a ${itemTypeData.name}`); + givePlayerArmour(client, itemTypeData.useValue); deleteItem(itemIndex); switchPlayerActiveHotBarSlot(client, -1); break; @@ -799,26 +820,26 @@ function playerUseItem(client, hotBarSlot) { case VRR_ITEM_USETYPE_ROPE: { let closestPlayer = getClosestPlayer(getPlayerPosition(client), client); - if(!getPlayerData(closestPlayer)) { - messagePlayerError(client, "There isn't anyone close enough to tie up!"); + if (!getPlayerData(closestPlayer)) { + messagePlayerError(client, getLocaleString(client, "NobodyCloseEnoughToTie")); return false; } - if(getDistance(getPlayerPosition(closestPlayer), getPlayerPosition(client)) > getGlobalConfig().handcuffPlayerDistance) { - messagePlayerError(client, "There isn't anyone close enough to tie up!"); + if (getDistance(getPlayerPosition(closestPlayer), getPlayerPosition(client)) > getGlobalConfig().handcuffPlayerDistance) { + messagePlayerError(client, getLocaleString(client, "NobodyCloseEnoughToTie")); return false; } - if(!isPlayerSurrendered(closestPlayer)) { - messagePlayerError(client, `${getCharacterFullName(closestPlayer)} can't be tied! They either need to have their hands up, be knocked out, or tazed`); + if (!isPlayerSurrendered(closestPlayer)) { + messagePlayerError(client, getLocaleString(client, "PlayerNotSurrenderedTie", getCharacterFullName(closestPlayer))); return false; } - if(isPlayerHandCuffed(closestPlayer)) { + if (isPlayerHandCuffed(closestPlayer)) { ropeUnTiePlayer(closestPlayer); meActionToNearbyPlayers(client, `unties the rope from ${getCharacterFullName(closestPlayer)}'s hands and feet`); } else { - if(!isPlayerSurrendered(closestPlayer)) { + if (!isPlayerSurrendered(closestPlayer)) { messagePlayerError(client, `${getCharacterFullName(closestPlayer)} can't be tied up! They either need to have their hands up, be knocked out, or tazed`); return false; } @@ -832,22 +853,22 @@ function playerUseItem(client, hotBarSlot) { case VRR_ITEM_USETYPE_HANDCUFF: { let closestPlayer = getClosestPlayer(getPlayerPosition(client), client); - if(!getPlayerData(closestPlayer)) { - messagePlayerError(client, "There isn't anyone close enough to handcuff!"); + if (!getPlayerData(closestPlayer)) { + messagePlayerError(client, getLocaleString(client, "NobodyCloseEnoughToHandcuff")); return false; } - if(getDistance(getPlayerPosition(closestPlayer), getPlayerPosition(client)) > getGlobalConfig().handcuffPlayerDistance) { - messagePlayerError(client, "There isn't anyone close enough to handcuff!"); + if (getDistance(getPlayerPosition(closestPlayer), getPlayerPosition(client)) > getGlobalConfig().handcuffPlayerDistance) { + messagePlayerError(client, getLocaleString(client, "NobodyCloseEnoughToHandcuff")); return false; } - if(isPlayerHandCuffed(closestPlayer)) { + if (isPlayerHandCuffed(closestPlayer)) { unHandCuffPlayer(closestPlayer); meActionToNearbyPlayers(client, `takes their key and removes the handcuffs from ${getCharacterFullName(closestPlayer)}`); } else { - if(!isPlayerSurrendered(closestPlayer)) { - messagePlayerError(client, `${getCharacterFullName(closestPlayer)} can't be cuffed! They either need to have their hands up, be knocked out, or tazed`); + if (!isPlayerSurrendered(closestPlayer)) { + messagePlayerError(client, getLocaleString(client, "PlayerNotSurrenderedHandcuffed", getCharacterFullName(closestPlayer))); return false; } @@ -857,19 +878,14 @@ function playerUseItem(client, hotBarSlot) { break; } - case VRR_ITEM_USETYPE_NONE: { - messagePlayerError(client, `The ${getItemName(itemIndex)} doesn't do anything when you try to use it.`); - break; - } - case VRR_ITEM_USETYPE_VEHREPAIR: { let vehicle = getClosestVehicle(getPlayerPosition(client)); - if(getDistance(getPlayerPosition(client), getVehiclePosition(vehicle)) <= getGlobalConfig().vehicleRepairDistance) { + if (getDistance(getPlayerPosition(client), getVehiclePosition(vehicle)) <= getGlobalConfig().vehicleRepairDistance) { meActionToNearbyPlayers(client, `takes their repair kit and fixes the vehicle`); repairVehicle(vehicle); - getItemData(itemIndex).value = getItemData(itemIndex).value - getItemTypeData(getItemData(itemIndex).itemTypeIndex).useValue; - if(getItemData(itemIndex).value <= 0) { + itemData.value = itemData.value - itemTypeData.useValue; + if (itemData.value <= 0) { destroyItem(itemIndex); } } else { @@ -880,32 +896,32 @@ function playerUseItem(client, hotBarSlot) { case VRR_ITEM_USETYPE_VEHUPGRADE_PART: { let vehicle = getClosestVehicle(getPlayerPosition(client)); - if(getDistance(getPlayerPosition(client), getVehiclePosition(vehicle)) <= getGlobalConfig().vehicleRepairDistance) { - meActionToNearbyPlayers(client, `takes their upgrade kit and adds a ${getItemName(itemIndex)} to the vehicle.`); - addVehicleUpgrade(vehicle, getItemData(itemIndex).useId); + if (getDistance(getPlayerPosition(client), getVehiclePosition(vehicle)) <= getGlobalConfig().vehicleRepairDistance) { + meActionToNearbyPlayers(client, `takes their upgrade kit and adds a ${itemTypeData.name} to the vehicle.`); + addVehicleUpgrade(vehicle, itemTypeData.useId); } break; } case VRR_ITEM_USETYPE_VEHLIVERY: { let vehicle = getClosestVehicle(getPlayerPosition(client)); - if(getDistance(getPlayerPosition(client), getVehiclePosition(vehicle)) <= getGlobalConfig().vehicleRepairDistance) { + if (getDistance(getPlayerPosition(client), getVehiclePosition(vehicle)) <= getGlobalConfig().vehicleRepairDistance) { meActionToNearbyPlayers(client, `takes their decal kit and adds some decals to the vehicle.`); - setVehicleLivery(vehicle, getItemData(itemIndex).value); + setVehicleLivery(vehicle, itemData.value); } break; } case VRR_ITEM_USETYPE_VEHCOLOUR: { let vehicle = getClosestVehicle(getPlayerPosition(client)); - if(getDistance(getPlayerPosition(client), getVehiclePosition(vehicle)) <= getGlobalConfig().vehicleRepairDistance) { - if(getItemData(itemIndex).useId == 1) { + if (getDistance(getPlayerPosition(client), getVehiclePosition(vehicle)) <= getGlobalConfig().vehicleRepairDistance) { + if (itemData.useId == 1) { meActionToNearbyPlayers(client, `takes their vehicle colour kit and changes the primary colour of the vehicle.`); - vehicle.colour1 = getItemData(itemIndex).value; + vehicle.colour1 = itemData.value; } else { - if(getItemData(itemIndex).useId == 1) { + if (itemTypeData.useId == 1) { meActionToNearbyPlayers(client, `takes their vehicle colour kit and changes the secondary colour of the vehicle.`); - vehicle.colour2 = getItemData(itemIndex).value; + vehicle.colour2 = itemData.value; } } } @@ -915,29 +931,29 @@ function playerUseItem(client, hotBarSlot) { case VRR_ITEM_USETYPE_FUELCAN: { let vehicle = getClosestVehicle(getPlayerPosition(client)); let fuelPump = getClosestFuelPump(getPlayerPosition(client)); - if(getDistance(getPlayerPosition(client), getVehiclePosition(vehicle)) <= getDistance(getPlayerPosition(client), getFuelPumpData(fuelPump).position)) { - if(getDistance(getPlayerPosition(client), getVehiclePosition(vehicle)) <= getGlobalConfig().vehicleRepairDistance) { + if (getDistance(getPlayerPosition(client), getVehiclePosition(vehicle)) <= getDistance(getPlayerPosition(client), getFuelPumpData(fuelPump).position)) { + if (getDistance(getPlayerPosition(client), getVehiclePosition(vehicle)) <= getGlobalConfig().vehicleRepairDistance) { meActionToNearbyPlayers(client, `takes their fuel can and refills the vehicle`); - if(getItemData(itemIndex).value < getItemTypeData(getItemData(itemIndex).itemTypeIndex).useValue) { - getVehicleData(vehicle).fuel += getItemData(itemIndex).value; + if (itemData.value < itemTypeData.useValue) { + getVehicleData(vehicle).fuel += itemData.value; } else { - getVehicleData(vehicle).fuel += getItemTypeData(getItemData(itemIndex).itemTypeIndex).useValue; + getVehicleData(vehicle).fuel += itemTypeData.useValue; } - getItemData(itemIndex).value = getItemData(itemIndex).value - getItemTypeData(getItemData(itemIndex).itemTypeIndex).useValue; - //if(getItemData(itemIndex).value <= 0) { + itemData.value = itemData.value - itemTypeData.useValue; + //if(itemData.value <= 0) { // destroyItem(itemIndex); //} } } else { - if(getDistance(getPlayerPosition(client), getFuelPumpData(fuelPump).position) <= getGlobalConfig().vehicleRepairDistance) { - if(getItemData(itemIndex).useId == 1) { + if (getDistance(getPlayerPosition(client), getFuelPumpData(fuelPump).position) <= getGlobalConfig().vehicleRepairDistance) { + if (itemData.useId == 1) { meActionToNearbyPlayers(client, `takes their vehicle colour kit and changes the primary colour of the vehicle.`); - vehicle.colour1 = getItemTypeData(itemIndex).value; + vehicle.colour1 = itemTypeData.value; } else { - if(getItemData(itemIndex).useId == 1) { + if (itemData.useId == 1) { meActionToNearbyPlayers(client, `takes their vehicle colour kit and changes the secondary colour of the vehicle.`); - vehicle.colour2 = getItemData(itemIndex).value; + vehicle.colour2 = itemData.value; } } } @@ -946,20 +962,19 @@ function playerUseItem(client, hotBarSlot) { } case VRR_ITEM_USETYPE_WALKIETALKIE: { - getItemData(itemIndex).enabled = !getItemData(itemIndex).enabled; - //messagePlayerAlert(client, `You turned ${getBoolRedGreenInlineColour(getItemData(itemIndex).enabled)}${toUpperCase(getOnOffFromBool(getItemData(itemIndex).enabled))} {MAINCOLOUR}your walkie talkie in slot ${getPlayerData(client).activeHotBarSlot+1} {ALTCOLOUR}${getItemValueDisplayForItem(itemIndex)}`); - meActionToNearbyPlayers(client, `turns ${toLowerCase(getOnOffFromBool(getItemData(itemIndex).enabled))} their walkie-talkie`); + itemData.enabled = !itemData.enabled; + meActionToNearbyPlayers(client, `turns ${toLowerCase(getOnOffFromBool(itemData.enabled))} their walkie-talkie`); break; } case VRR_ITEM_USETYPE_PHONE: { - if(getItemData(itemIndex).value == 0) { + if (itemData.value == 0) { let phoneNumber = generateRandomPhoneNumber(); - getItemData(itemIndex).value = phoneNumber; - messagePlayerAlert(client, `Your ${getItemName(itemIndex)} has been set up with number ${phoneNumber}`); + itemData.value = phoneNumber; + messagePlayerAlert(client, `Your ${itemTypeData.name} has been set up with number ${phoneNumber}`); } else { - getItemData(itemIndex).enabled = !getItemData(itemIndex).enabled; - if(getItemData(itemIndex).enabled) { + itemData.enabled = !itemData.enabled; + if (itemData.enabled) { //messagePlayerAlert(client, `You turned on your phone in slot ${getPlayerData(client).activeHotBarSlot+1} ${getItemValueDisplayForItem(itemIndex)}`); meActionToNearbyPlayers(client, `turns on their phone`); } else { @@ -971,9 +986,9 @@ function playerUseItem(client, hotBarSlot) { } case VRR_ITEM_USETYPE_SMOKEDRUG: { - meActionToNearbyPlayers(client, `smokes some ${getItemName(itemIndex)}`); - getPlayerData(client).incomingDamageMultiplier = getPlayerData(client).incomingDamageMultiplier-(getItemTypeData(getItemData(itemIndex).itemTypeIndex).useValue/100); - if(getPlayerData(client).incomingDamageMultiplier < 0.25) { + meActionToNearbyPlayers(client, `smokes some ${itemTypeData.name}`); + getPlayerData(client).incomingDamageMultiplier = getPlayerData(client).incomingDamageMultiplier - (itemTypeData.useValue / 100); + if (getPlayerData(client).incomingDamageMultiplier < 0.25) { getPlayerData(client).incomingDamageMultiplier = 0.25; } deleteItem(itemIndex); @@ -982,9 +997,9 @@ function playerUseItem(client, hotBarSlot) { } case VRR_ITEM_USETYPE_SNORTDRUG: { - meActionToNearbyPlayers(client, `snorts some ${getItemName(itemIndex)}`); - getPlayerData(client).incomingDamageMultiplier = getPlayerData(client).incomingDamageMultiplier-(getItemTypeData(getItemData(itemIndex).itemTypeIndex).useValue/100); - if(getPlayerData(client).incomingDamageMultiplier < 0.25) { + meActionToNearbyPlayers(client, `snorts some ${itemTypeData.name}`); + getPlayerData(client).incomingDamageMultiplier = getPlayerData(client).incomingDamageMultiplier - (itemTypeData.useValue / 100); + if (getPlayerData(client).incomingDamageMultiplier < 0.25) { getPlayerData(client).incomingDamageMultiplier = 0.25; } deleteItem(itemIndex); @@ -993,9 +1008,9 @@ function playerUseItem(client, hotBarSlot) { } case VRR_ITEM_USETYPE_INJECTDRUG: { - meActionToNearbyPlayers(client, `shoots up some ${getItemName(itemIndex)}`); - getPlayerData(client).incomingDamageMultiplier = getPlayerData(client).incomingDamageMultiplier-(getItemTypeData(getItemData(itemIndex).itemTypeIndex).useValue/100); - if(getPlayerData(client).incomingDamageMultiplier < 0.25) { + meActionToNearbyPlayers(client, `shoots up some ${itemTypeData.name}`); + getPlayerData(client).incomingDamageMultiplier = getPlayerData(client).incomingDamageMultiplier - (itemTypeData.useValue / 100); + if (getPlayerData(client).incomingDamageMultiplier < 0.25) { getPlayerData(client).incomingDamageMultiplier = 0.25; } deleteItem(itemIndex); @@ -1004,9 +1019,9 @@ function playerUseItem(client, hotBarSlot) { } case VRR_ITEM_USETYPE_PLANT: { - meActionToNearbyPlayers(client, `bends down and plants a ${getItemName(itemIndex)} in the ground`); + meActionToNearbyPlayers(client, `bends down and plants a ${itemTypeData.name} in the ground`); createGroundPlant(itemIndex); - if(getItemData(itemIndex).value == 0) { + if (itemData.value == 0) { destroyItem(itemIndex); switchPlayerActiveHotBarSlot(client, -1); } @@ -1016,8 +1031,8 @@ function playerUseItem(client, hotBarSlot) { case VRR_ITEM_USETYPE_BADGE: { meActionToNearbyPlayers(client, `shows their badge to everyone nearby.`); let clients = getClients(); - for(let i in clients) { - if(getDistance(getPlayerPosition(client), getPlayerPosition(clients[i])) <= 7) { + for (let i in clients) { + if (getDistance(getPlayerPosition(client), getPlayerPosition(clients[i])) <= 7) { makeChatBoxSectionHeader(clients[i], getLocaleString(client, "HeaderBadgeInfo", getCharacterFullName(client))); messagePlayerNormal(client, `{clanOrange}Type:{MAINCOLOUR} ${getJobData(getPlayerJob(client)).name}`); messagePlayerNormal(client, `{clanOrange}ID:{MAINCOLOUR} ${addPrefixNumberFill(getPlayerCurrentSubAccount(client).databaseId, 5)}`); @@ -1035,12 +1050,12 @@ function playerUseItem(client, hotBarSlot) { case VRR_ITEM_USETYPE_HEALTH: { let closestPlayer = getClosestPlayer(getPlayerPosition(client), client); - if(!getPlayerData(closestPlayer)) { + if (!getPlayerData(closestPlayer)) { messagePlayerError(client, "There isn't anyone close enough to heal!"); return false; } - if(getDistance(getPlayerPosition(closestPlayer), getPlayerPosition(client)) > getGlobalConfig().firstAidKitPlayerDistance) { + if (getDistance(getPlayerPosition(closestPlayer), getPlayerPosition(client)) > getGlobalConfig().firstAidKitPlayerDistance) { messagePlayerError(client, "There isn't anyone close enough to heal!"); return false; } @@ -1048,30 +1063,36 @@ function playerUseItem(client, hotBarSlot) { } case VRR_ITEM_USETYPE_LOTTOTICKET: { - + messagePlayerError(client, getLocaleString(client, "ItemDoesntDoAnythingOnUse", itemTypeData.name)); break; } case VRR_ITEM_USETYPE_AREARADIO: { - let state = getItemData(itemIndex) - meActionToNearbyPlayers(client, `turns ${getOnOffFromBool(state)} the boombox radio`); - messagePlayerAlert(client, `Use /radiostation to set the radio station and drop it on the ground to play`); + itemData.enabled = !itemData.enabled; + meActionToNearbyPlayers(client, `turns ${getOnOffFromBool(itemData.enabled)} the boombox radio`); + messagePlayerAlert(client, getLocaleString(client, "ItemRadioStationTip", `{ALTCOLOUR}/radiostation{MAINCOLOUR}`)); break; } case VRR_ITEM_USETYPE_PERSONALRADIO: { - meActionToNearbyPlayers(client, `turns ${getOnOffFromBool(state)} the boombox radio`); - messagePlayerAlert(client, `Use /radiostation to set the radio station`); + itemData.enabled = !itemData.enabled; + meActionToNearbyPlayers(client, `turns ${getOnOffFromBool(itemData.enabled)} their personal radio`); + messagePlayerAlert(client, getLocaleString(client, "ItemRadioStationTip", `{ALTCOLOUR}/radiostation{MAINCOLOUR}`)); + break; + } + + case VRR_ITEM_USETYPE_NONE: { + messagePlayerError(client, getLocaleString(client, "ItemDoesntDoAnythingOnUse", itemTypeData.name)); break; } default: { - messagePlayerError(client, `The ${getItemName(itemIndex)} doesn't do anything when you try to use it.`); + messagePlayerError(client, getLocaleString(client, "ItemDoesntDoAnythingOnUse", itemTypeData.name)); break; } } - if(getItemData(itemIndex) != false) { + if (getItemData(itemIndex) != false) { getItemData(itemIndex).needsSaved = true; } @@ -1083,7 +1104,7 @@ function playerUseItem(client, hotBarSlot) { function playerDropItem(client, hotBarSlot) { let itemId = getPlayerData(client).hotBarItems[hotBarSlot]; - if(itemId != -1) { + if (itemId != -1) { meActionToNearbyPlayers(client, `drops ${getProperDeterminerForName(getItemName(itemId))} ${getItemName(itemId)} on the ground`); resyncWeaponItemAmmo(client); @@ -1106,7 +1127,7 @@ function playerDropItem(client, hotBarSlot) { function playerPutItem(client, hotBarSlot) { let itemId = getPlayerData(client).hotBarItems[hotBarSlot]; - let bestNewOwner = getBestNewOwnerToPutItem(client); + let bestNewOwner = getBestNewOwnerToPutItem(client); getItemData(itemId).ownerType = bestNewOwner[0]; getItemData(itemId).ownerId = bestNewOwner[1]; @@ -1120,7 +1141,7 @@ function playerPutItem(client, hotBarSlot) { getPlayerData(client).hotBarItems[hotBarSlot] = -1; updatePlayerHotBar(client); - switch(bestNewOwner[0]) { + switch (bestNewOwner[0]) { case VRR_ITEM_OWNER_HOUSE: meActionToNearbyPlayers(client, `places ${getProperDeterminerForName(getItemName(itemId))} ${getItemName(itemId)} in the house`); break; @@ -1145,7 +1166,7 @@ function playerPickupItem(client, itemId) { meActionToNearbyPlayers(client, `picks up ${getProperDeterminerForName(getItemName(itemId))} ${getItemName(itemId)} from the ground`); let firstSlot = getPlayerFirstEmptyHotBarSlot(client); - if(firstSlot != -1) { + if (firstSlot != -1) { getItemData(itemId).ownerType = VRR_ITEM_OWNER_PLAYER; getItemData(itemId).ownerId = getPlayerCurrentSubAccount(client).databaseId; getItemData(itemId).position = toVector3(0.0, 0.0, 0.0); @@ -1161,7 +1182,7 @@ function playerPickupItem(client, itemId) { function playerTakeItem(client, itemId) { let firstSlot = getPlayerFirstEmptyHotBarSlot(client); - if(firstSlot == -1) { + if (firstSlot == -1) { messagePlayerError(client, getLocaleString(client, "NoSpaceSelfInventory")); return false; } @@ -1174,7 +1195,7 @@ function playerTakeItem(client, itemId) { getPlayerData(client).hotBarItems[firstSlot] = itemId; updatePlayerHotBar(client); - switch(bestOwner[1]) { + switch (bestOwner[1]) { case VRR_ITEM_OWNER_HOUSE: meActionToNearbyPlayers(client, getLocaleString(client, "TakeItemFromHouse", getItemName(itemId))); break; @@ -1204,7 +1225,7 @@ function playerTakeItem(client, itemId) { // =========================================================================== function playerSwitchItem(client, newHotBarSlot) { - if(newHotBarSlot < -1 || newHotBarSlot > 9) { + if (newHotBarSlot < -1 || newHotBarSlot > 9) { return false; } @@ -1216,17 +1237,17 @@ function playerSwitchItem(client, newHotBarSlot) { // Check if new slot is the same as the current one // If true, clear active item slot (puts current item away) - if(currentHotBarSlot != -1 && newHotBarSlot != -1) { - if(currentHotBarSlot == newHotBarSlot) { + if (currentHotBarSlot != -1 && newHotBarSlot != -1) { + if (currentHotBarSlot == newHotBarSlot) { newHotBarSlot = -1; } } - if(currentHotBarSlot != -1) { + if (currentHotBarSlot != -1) { currentHotBarItem = getPlayerData(client).hotBarItems[currentHotBarSlot]; } - if(newHotBarSlot != -1) { + if (newHotBarSlot != -1) { newHotBarItem = getPlayerData(client).hotBarItems[newHotBarSlot]; } @@ -1241,16 +1262,16 @@ function playerSwitchItem(client, newHotBarSlot) { // } //} - if(newHotBarItem != -1) { - if(getItemData(newHotBarItem)) { - if(getItemTypeData(getItemData(newHotBarItem).itemTypeIndex).useType == VRR_ITEM_USETYPE_WEAPON) { - if(getItemData(newHotBarItem).value > 0 || isMeleeWeapon(toInteger(getItemTypeData(getItemData(newHotBarItem).itemTypeIndex).useId))) { + if (newHotBarItem != -1) { + if (getItemData(newHotBarItem)) { + if (getItemTypeData(getItemData(newHotBarItem).itemTypeIndex).useType == VRR_ITEM_USETYPE_WEAPON) { + if (getItemData(newHotBarItem).value > 0 || isMeleeWeapon(toInteger(getItemTypeData(getItemData(newHotBarItem).itemTypeIndex).useId))) { givePlayerWeapon(client, toInteger(getItemTypeData(getItemData(newHotBarItem).itemTypeIndex).useId), toInteger(getItemData(newHotBarItem).value), true, true); setPlayerWeaponDamageEnabled(client, true); setPlayerWeaponDamageEvent(client, VRR_WEAPON_DAMAGE_EVENT_NORMAL); } else { let ammoItemSlot = getPlayerFirstAmmoItemForWeapon(client, getItemTypeData(getItemData(newHotBarItem).itemTypeIndex).useId); - if(ammoItemSlot != false) { + if (ammoItemSlot != false) { getItemData(newHotBarItem).value = getItemData(getPlayerData(client).hotBarItems[ammoItemSlot]).value; givePlayerWeapon(client, toInteger(getItemTypeData(getItemData(newHotBarItem).itemTypeIndex).useId), toInteger(getItemData(newHotBarItem).value), true, true); setPlayerWeaponDamageEnabled(client, true); @@ -1260,8 +1281,8 @@ function playerSwitchItem(client, newHotBarSlot) { messagePlayerError(client, getLocaleString(client, "ItemUnequippableNoAmmo", getItemName(newHotBarItem), newHotBarSlot)); } } - } else if(getItemTypeData(getItemData(newHotBarItem).itemTypeIndex).useType == VRR_ITEM_USETYPE_TAZER) { - if(getItemData(newHotBarItem).value > 0) { + } else if (getItemTypeData(getItemData(newHotBarItem).itemTypeIndex).useType == VRR_ITEM_USETYPE_TAZER) { + if (getItemData(newHotBarItem).value > 0) { givePlayerWeapon(client, toInteger(getItemTypeData(getItemData(newHotBarItem).itemTypeIndex).useId), toInteger(getItemData(newHotBarItem).value), true, true); setPlayerWeaponDamageEnabled(client, false); setPlayerWeaponDamageEvent(client, VRR_WEAPON_DAMAGE_EVENT_TAZER); @@ -1272,13 +1293,13 @@ function playerSwitchItem(client, newHotBarSlot) { } } - if(currentHotBarItem != -1 && newHotBarItem != -1) { + if (currentHotBarItem != -1 && newHotBarItem != -1) { // Player switches from item to item meActionToNearbyPlayers(client, `puts away ${getProperDeterminerForName(getItemName(currentHotBarItem))} ${getItemName(currentHotBarItem)} and pulls out ${getProperDeterminerForName(getItemName(newHotBarItem))} ${getItemName(newHotBarItem)}`); - } else if(currentHotBarItem != -1 && newHotBarItem == -1) { + } else if (currentHotBarItem != -1 && newHotBarItem == -1) { // Player switches from item to none meActionToNearbyPlayers(client, `puts away ${getProperDeterminerForName(getItemName(currentHotBarItem))} ${getItemName(currentHotBarItem)}`); - } else if(currentHotBarItem == -1 && newHotBarItem != -1) { + } else if (currentHotBarItem == -1 && newHotBarItem != -1) { // Player switches from none to item meActionToNearbyPlayers(client, `pulls out ${getProperDeterminerForName(getItemName(newHotBarItem))} ${getItemName(newHotBarItem)}`); } else { @@ -1303,36 +1324,36 @@ function playerSwitchItem(client, newHotBarSlot) { function playerSwitchHotBarSlotCommand(command, params, client) { clearPlayerItemActionState(client); - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } let hotBarSlot = toInteger(params); - if(hotBarSlot < 0 || hotBarSlot > 9) { + if (hotBarSlot < 0 || hotBarSlot > 9) { messagePlayerError(client, getLocaleString(client, "ItemSlotMustBeBetween", "1", "9")); return false; } - if(hotBarSlot == 0) { + if (hotBarSlot == 0) { hotBarSlot = -1; } else { - hotBarSlot = hotBarSlot-1; + hotBarSlot = hotBarSlot - 1; } - if(hotBarSlot != -1) { - if(getPlayerData(client).activeHotBarSlot == hotBarSlot) { + if (hotBarSlot != -1) { + if (getPlayerData(client).activeHotBarSlot == hotBarSlot) { hotBarSlot = -1; } } - if(getPlayerData(client).itemActionState != VRR_ITEM_ACTION_NONE) { + if (getPlayerData(client).itemActionState != VRR_ITEM_ACTION_NONE) { messagePlayerError(client, getLocaleString(client, "HandsBusy")); return false; } - if(getPlayerData(client).usingSkinSelect) { + if (getPlayerData(client).usingSkinSelect) { messagePlayerError(client, getLocaleString(client, "CantSwitchItemInSkinChange")); return false; } @@ -1345,8 +1366,8 @@ function playerSwitchHotBarSlotCommand(command, params, client) { function getClosestItemOnGround(position) { let items = getServerData().groundItemCache; let closest = 0; - for(let i in items) { - if(getDistance(getItemData(items[i]).position, position) <= getDistance(getItemData(items[closest]).position, position)) { + for (let i in items) { + if (getDistance(getItemData(items[i]).position, position) <= getDistance(getItemData(items[closest]).position, position)) { closest = i; } } @@ -1357,8 +1378,8 @@ function getClosestItemOnGround(position) { // =========================================================================== function setAllItemDataIndexes() { - for(let i in getServerData().items) { - if(getServerData().items[i]) { + for (let i in getServerData().items) { + if (getServerData().items[i]) { getServerData().items[i].index = i; getServerData().items[i].itemTypeIndex = getItemTypeIndexFromDatabaseId(getServerData().items[i].itemType); } @@ -1368,8 +1389,8 @@ function setAllItemDataIndexes() { // =========================================================================== function setAllItemTypeDataIndexes() { - for(let i in getServerData().itemTypes) { - if(getServerData().itemTypes[i]) { + for (let i in getServerData().itemTypes) { + if (getServerData().itemTypes[i]) { getServerData().itemTypes[i].index = i; getServerData().itemTypes[i].useAnimationIndex = getAnimationFromParams(getServerData().itemTypes[i].useAnimationName); getServerData().itemTypes[i].switchAnimationIndex = getAnimationFromParams(getServerData().itemTypes[i].switchAnimationName); @@ -1386,8 +1407,8 @@ function setAllItemTypeDataIndexes() { function cacheAllGroundItems() { clearArray(getServerData().groundItemCache); - for(let i in getServerData().items) { - if(getServerData().items[i].ownerType == VRR_ITEM_OWNER_GROUND) { + for (let i in getServerData().items) { + if (getServerData().items[i].ownerType == VRR_ITEM_OWNER_GROUND) { getServerData().groundItemCache.push(i); } } @@ -1396,7 +1417,7 @@ function cacheAllGroundItems() { // =========================================================================== function createAllGroundItemObjects() { - for(let i in getServerData().groundItemCache) { + for (let i in getServerData().groundItemCache) { createGroundItemObject(i); } } @@ -1410,8 +1431,8 @@ function syncPlayerInventoryWeapons(client) { // =========================================================================== function getPlayerFirstEmptyHotBarSlot(client) { - for(let i in getPlayerData(client).hotBarItems) { - if(getPlayerData(client).hotBarItems[i] == -1) { + for (let i in getPlayerData(client).hotBarItems) { + if (getPlayerData(client).hotBarItems[i] == -1) { return i; } } @@ -1422,19 +1443,19 @@ function getPlayerFirstEmptyHotBarSlot(client) { // =========================================================================== function cachePlayerHotBarItems(client) { - if(isPlayerWorking(client)) { + if (isPlayerWorking(client)) { return false; } - for(let i = 0 ; i < 9 ; 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) { + 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) { + if (firstSlot != -1) { getPlayerData(client).hotBarItems[firstSlot] = i; } } @@ -1444,10 +1465,10 @@ function cachePlayerHotBarItems(client) { // =========================================================================== -function deleteItem(itemId) { +function deleteItem(itemId, whoDeleted = -1) { let owner = -1; let ownerTypeString = "Unknown"; - switch(getItemData(itemId).ownerType) { + switch (getItemData(itemId).ownerType) { case VRR_ITEM_OWNER_GROUND: ownerTypeString = "Ground/Dropped"; deleteGroundItemObject(itemId); @@ -1457,7 +1478,7 @@ function deleteItem(itemId) { case VRR_ITEM_OWNER_PLAYER: ownerTypeString = "Player"; owner = getPlayerFromCharacterId(getItemData(itemId).ownerId); - if(getPlayerData(owner) != false) { + if (getPlayerData(owner) != false) { switchPlayerActiveHotBarSlot(owner, -1); getPlayerData(owner).hotBarItems[getPlayerData(owner).hotBarItems.indexOf(itemId)] = -1; updatePlayerHotBar(owner); @@ -1467,7 +1488,7 @@ function deleteItem(itemId) { case VRR_ITEM_OWNER_JOBLOCKER: ownerTypeString = "Job Locker"; owner = getPlayerFromCharacterId(getItemData(itemId).ownerId); - if(getPlayerData(owner) != false) { + if (getPlayerData(owner) != false) { getPlayerData(owner).jobLockerCache.splice(getPlayerData(owner).jobLockerCache.indexOf(itemId), 1); } break; @@ -1475,7 +1496,7 @@ function deleteItem(itemId) { case VRR_ITEM_OWNER_LOCKER: ownerTypeString = "Locker"; owner = getPlayerFromCharacterId(getItemData(itemId).ownerId); - if(getPlayerData(owner) != false) { + if (getPlayerData(owner) != false) { getPlayerData(owner).lockerCache.splice(getPlayerData(owner).lockerCache.indexOf(itemId), 1); } break; @@ -1483,7 +1504,7 @@ function deleteItem(itemId) { case VRR_ITEM_OWNER_VEHTRUNK: ownerTypeString = "Vehicle Trunk"; owner = getVehicleFromDatabaseId(getItemData(itemId).ownerId) - if(getVehicleData(owner) != false) { + if (getVehicleData(owner) != false) { getVehicleDataIndex(getItemData(itemId).ownerId).trunkItemCache.splice(getVehicleData(owner).trunkItemCache.indexOf(itemId), 1); } break; @@ -1491,7 +1512,7 @@ function deleteItem(itemId) { case VRR_ITEM_OWNER_BIZFLOOR: ownerTypeString = "Business Floor"; owner = getBusinessIdFromDatabaseId(getItemData(itemId).ownerId); - if(getBusinessData(owner) != false) { + if (getBusinessData(owner) != false) { getBusinessData(owner).floorItemCache.splice(getBusinessData(owner).floorItemCache.indexOf(itemId), 1); } break; @@ -1499,7 +1520,7 @@ function deleteItem(itemId) { case VRR_ITEM_OWNER_BIZSTORAGE: ownerTypeString = "Business Storage"; owner = getBusinessIdFromDatabaseId(getItemData(itemId).ownerId); - if(getBusinessData(owner) != false) { + if (getBusinessData(owner) != false) { getBusinessData(owner).storageItemCache.splice(getBusinessData(owner).storageItemCache.indexOf(itemId), 1); } break; @@ -1507,15 +1528,15 @@ function deleteItem(itemId) { case VRR_ITEM_OWNER_HOUSE: ownerTypeString = "House"; owner = getHouseIdFromDatabaseId(getItemData(itemId).ownerId); - if(getHouseData(owner) != false) { + if (getHouseData(owner) != false) { getHouseData(owner).itemCache.splice(getHouseData(owner).itemCache.indexOf(itemId), 1); } break; } logToConsole(LOG_DEBUG, `Deleted item ${itemId} (DBID: ${getItemData(itemId).databaseId}, Owner Type: ${ownerTypeString}, Owner ID: ${getItemData(itemId).ownerId})`); - if(getItemData(itemId).databaseId > 0) { - quickDatabaseQuery(`DELETE FROM item_main WHERE item_id = ${getItemData(itemId).databaseId}`); + if (getItemData(itemId).databaseId > 0) { + quickDatabaseQuery(`UPDATE item_main SET item_deleted = 1, item_when_deleted = UNIX_TIMESTAMP() WHERE item_id = ${getItemData(itemId).databaseId}`); } getServerData().items[itemId] = false; setAllItemDataIndexes(); @@ -1528,17 +1549,17 @@ function getBestNewOwnerToPutItem(client) { let position = getPlayerPosition(client); let possibleHouse = getPlayerHouse(client); - if(getHouseData(possibleHouse)) { + if (getHouseData(possibleHouse)) { return [VRR_ITEM_OWNER_HOUSE, possibleHouse]; } let possibleBusiness = getPlayerBusiness(client); - if(getBusinessData(possibleBusiness)) { + if (getBusinessData(possibleBusiness)) { return [VRR_ITEM_OWNER_BIZSTORAGE, possibleBusiness]; } let possibleVehicle = getClosestVehicle(position); - if(getDistance(getVehicleTrunkPosition(possibleVehicle), position) <= closestDistance) { + if (getDistance(getVehicleTrunkPosition(possibleVehicle), position) <= closestDistance) { return [VRR_ITEM_OWNER_VEHTRUNK, possibleVehicle]; } @@ -1555,8 +1576,8 @@ function getBestItemToTake(client, slot) { let ownerId = 0; let possibleHouse = getPlayerHouse(client); - if(getHouseData(possibleHouse)) { - if(typeof getHouseData(possibleHouse).itemCache[slot] != "undefined") { + if (getHouseData(possibleHouse)) { + if (typeof getHouseData(possibleHouse).itemCache[slot] != "undefined") { itemId = getHouseData(possibleHouse).itemCache[slot]; ownerType = VRR_ITEM_OWNER_HOUSE; ownerId = possibleHouse; @@ -1564,8 +1585,8 @@ function getBestItemToTake(client, slot) { } let possibleBusiness = getPlayerBusiness(client); - if(getBusinessData(possibleBusiness)) { - if(typeof getBusinessData(possibleBusiness).floorItemCache[slot] != "undefined") { + if (getBusinessData(possibleBusiness)) { + if (typeof getBusinessData(possibleBusiness).floorItemCache[slot] != "undefined") { itemId = getBusinessData(possibleBusiness).floorItemCache[slot]; ownerType = VRR_ITEM_OWNER_BIZFLOOR; ownerId = possibleBusiness; @@ -1573,9 +1594,9 @@ function getBestItemToTake(client, slot) { } let possibleVehicle = getClosestVehicle(position); - if(getVehicleData(possibleVehicle)) { - if(getDistance(getVehicleTrunkPosition(possibleVehicle), position) <= closestDistance) { - if(typeof getVehicleData(possibleVehicle).trunkItemCache[slot] != "undefined") { + if (getVehicleData(possibleVehicle)) { + if (getDistance(getVehicleTrunkPosition(possibleVehicle), position) <= closestDistance) { + if (typeof getVehicleData(possibleVehicle).trunkItemCache[slot] != "undefined") { itemId = getVehicleData(possibleVehicle).trunkItemCache[slot]; ownerType = VRR_ITEM_OWNER_VEHTRUNK; ownerId = possibleVehicle; @@ -1628,12 +1649,12 @@ function listPlayerInventoryCommand(command, params, client) { function listBusinessStorageInventoryCommand(command, params, client) { let businessId = getPlayerBusiness(client); - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } - if(getBusinessData(businessId).locked) { + if (getBusinessData(businessId).locked) { messagePlayerError(client, "This business is closed!"); return false; } @@ -1655,12 +1676,12 @@ function listBusinessStorageInventoryCommand(command, params, client) { function listBusinessFloorInventoryCommand(command, params, client) { let businessId = getPlayerBusiness(client); - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } - if(getBusinessData(businessId).locked) { + if (getBusinessData(businessId).locked) { messagePlayerError(client, "This business is closed!"); return false; } @@ -1682,12 +1703,12 @@ function listBusinessFloorInventoryCommand(command, params, client) { function listHouseInventoryCommand(command, params, client) { let houseId = getPlayerHouse(client); - if(!getHouseData(houseId)) { + if (!getHouseData(houseId)) { messagePlayerError(client, getLocaleString(client, "InvalidHouse")); return false; } - if(getHouseData(houseId).locked) { + if (getHouseData(houseId).locked) { messagePlayerError(client, "This house is locked!"); return false; } @@ -1709,12 +1730,12 @@ function listHouseInventoryCommand(command, params, client) { function listItemInventoryCommand(command, params, client) { let itemId = getClosestItemOnGround(getPlayerPosition(client)); - if(getDistance(getPlayerPosition(client), getItemData(itemId).position) > getGlobalConfig().droppedItemPickupRange) { + if (getDistance(getPlayerPosition(client), getItemData(itemId).position) > getGlobalConfig().droppedItemPickupRange) { messagePlayerError(client, `You're too far away!`); return false; } - if(getItemTypeData(getItemData(itemId).itemTypeIndex).useType != VRR_ITEM_USETYPE_STORAGE) { + if (getItemTypeData(getItemData(itemId).itemTypeIndex).useType != VRR_ITEM_USETYPE_STORAGE) { messagePlayerError(client, "This item can't hold anything!"); return false; } @@ -1729,7 +1750,7 @@ function listItemInventoryCommand(command, params, client) { * @return {ItemData} The item's data (class instance) */ function getItemData(itemId) { - if(typeof getServerData().items[itemId] != "undefined") { + if (typeof getServerData().items[itemId] != "undefined") { return getServerData().items[itemId]; } @@ -1743,7 +1764,7 @@ function getItemData(itemId) { * @return {ItemTypeData} The item type's data (class instance) */ function getItemTypeData(itemTypeId) { - if(typeof getServerData().itemTypes[itemTypeId] != "undefined") { + if (typeof getServerData().itemTypes[itemTypeId] != "undefined") { return getServerData().itemTypes[itemTypeId]; } @@ -1753,11 +1774,11 @@ function getItemTypeData(itemTypeId) { // =========================================================================== function saveAllItemsToDatabase() { - if(getServerConfig().devServer) { + if (getServerConfig().devServer) { return false; } - for(let i in getServerData().items) { + for (let i in getServerData().items) { saveItemToDatabase(i); } } @@ -1765,11 +1786,11 @@ function saveAllItemsToDatabase() { // =========================================================================== function saveAllItemTypesToDatabase() { - if(getServerConfig().devServer) { + if (getServerConfig().devServer) { return false; } - for(let i in getServerData().itemTypes) { + for (let i in getServerData().itemTypes) { saveItemTypeToDatabase(i); } } @@ -1778,22 +1799,22 @@ function saveAllItemTypesToDatabase() { function saveItemToDatabase(itemId) { let itemData = getItemData(itemId); - if(itemData == false) { + if (itemData == false) { return false; } - if(itemData.databaseId == -1) { + if (itemData.databaseId == -1) { return false; } - if(!itemData.needsSaved) { + if (!itemData.needsSaved) { return false; } logToConsole(LOG_VERBOSE, `[VRR.Item]: Saving item '${itemData.index}' to database ...`); let dbConnection = connectToDatabase(); - if(dbConnection) { + if (dbConnection) { let data = [ ["item_server", getServerId()], ["item_type", itemData.itemType], @@ -1811,7 +1832,7 @@ function saveItemToDatabase(itemId) { ]; let dbQuery = null; - if(itemData.databaseId == 0) { + if (itemData.databaseId == 0) { let queryString = createDatabaseInsertQuery("item_main", data); dbQuery = queryDatabase(dbConnection, queryString); itemData.databaseId = getDatabaseInsertId(dbConnection); @@ -1833,22 +1854,22 @@ function saveItemToDatabase(itemId) { function saveItemTypeToDatabase(itemTypeId) { let itemTypeData = getItemTypeData(itemTypeId); - if(itemTypeData == false) { + if (itemTypeData == false) { return false; } - if(itemTypeData.databaseId == -1) { + if (itemTypeData.databaseId == -1) { return false; } - if(!itemTypeData.needsSaved) { + if (!itemTypeData.needsSaved) { return false; } logToConsole(LOG_VERBOSE, `[VRR.Item]: Saving item type '${itemTypeData.name}' to database ...`); let dbConnection = connectToDatabase(); - if(dbConnection) { + if (dbConnection) { let safeItemTypeName = escapeDatabaseString(dbConnection, itemTypeData.name); let safeAnimationUse = escapeDatabaseString(dbConnection, itemTypeData.useAnimationName); let safeAnimationDrop = escapeDatabaseString(dbConnection, itemTypeData.dropAnimationName); @@ -1900,7 +1921,7 @@ function saveItemTypeToDatabase(itemTypeId) { ]; let dbQuery = null; - if(itemTypeData.databaseId == 0) { + if (itemTypeData.databaseId == 0) { let queryString = createDatabaseInsertQuery("item_type", data); dbQuery = queryDatabase(dbConnection, queryString); itemTypeData.databaseId = getDatabaseInsertId(dbConnection); @@ -1921,7 +1942,7 @@ function saveItemTypeToDatabase(itemTypeId) { // =========================================================================== function storePlayerItemsInJobLocker(client) { - for(let i = 0 ; i < 9 ; i++) { + for (let i = 0; i < 9; i++) { getPlayerData(client).jobLockerCache[i] = getPlayerData(client).hotBarItems[i]; getPlayerData(client).hotBarItems[i] = -1; } @@ -1933,13 +1954,13 @@ function storePlayerItemsInJobLocker(client) { // =========================================================================== function restorePlayerJobLockerItems(client) { - for(let i in getPlayerData(client).jobEquipmentCache) { - if(getPlayerData(client).jobEquipmentCache[i] != -1) { + for (let i in getPlayerData(client).jobEquipmentCache) { + if (getPlayerData(client).jobEquipmentCache[i] != -1) { deleteItem(getPlayerData(client).jobEquipmentCache[i]); } } - for(let i = 0 ; i < 9 ; i++) { + for (let i = 0; i < 9; i++) { getPlayerData(client).hotBarItems[i] = getPlayerData(client).jobLockerCache[i]; getPlayerData(client).jobLockerCache[i] = -1; } @@ -1951,8 +1972,8 @@ function restorePlayerJobLockerItems(client) { // =========================================================================== function getItemIndexFromDatabaseId(databaseId) { - for(let i in getServerData().items) { - if(getServerData().items[i].databaseId == databaseId) { + for (let i in getServerData().items) { + if (getServerData().items[i].databaseId == databaseId) { return i; } } @@ -1962,8 +1983,8 @@ function getItemIndexFromDatabaseId(databaseId) { // =========================================================================== function getItemTypeIndexFromDatabaseId(databaseId) { - for(let i in getServerData().itemTypes) { - if(getServerData().itemTypes[i].databaseId == databaseId) { + for (let i in getServerData().itemTypes) { + if (getServerData().itemTypes[i].databaseId == databaseId) { return i; } } @@ -1974,7 +1995,7 @@ function getItemTypeIndexFromDatabaseId(databaseId) { function playerItemActionDelayComplete(client) { logToConsole(LOG_VERBOSE, `[VRR.Item]: Player ${getPlayerDisplayForConsole(client)} item action delay complete (State: ${getPlayerData(client).itemActionState})`); - switch(getPlayerData(client).itemActionState) { + switch (getPlayerData(client).itemActionState) { case VRR_ITEM_ACTION_USE: playerUseItem(client, getPlayerData(client).itemActionItem); break; @@ -2009,11 +2030,11 @@ function playerItemActionDelayComplete(client) { // =========================================================================== function getItemValueDisplayForItem(itemId) { - if(!getItemData(itemId)) { + if (!getItemData(itemId)) { return "[unknown]"; } - if(isMeleeWeapon(getItemTypeData(getItemData(itemId).itemTypeIndex).useId)) { + if (isMeleeWeapon(getItemTypeData(getItemData(itemId).itemTypeIndex).useId)) { return ""; } @@ -2023,20 +2044,20 @@ function getItemValueDisplayForItem(itemId) { // =========================================================================== function getItemValueDisplay(itemType, value) { - if(getItemTypeData(itemType).useType == VRR_ITEM_USETYPE_SKIN) { + if (getItemTypeData(itemType).useType == VRR_ITEM_USETYPE_SKIN) { return "any"; - } else if(getItemTypeData(itemType).useType == VRR_ITEM_USETYPE_FOOD || getItemTypeData(itemType).useType == VRR_ITEM_USETYPE_DRINK || getItemTypeData(itemType).useType == VRR_ITEM_USETYPE_EXTINGUISHER || getItemTypeData(itemType).useType == VRR_ITEM_USETYPE_SPRAYPAINT || getItemTypeData(itemType).useType == VRR_ITEM_USETYPE_PEPPERSPRAY) { - return getPercentage(toString(value), getItemTypeData(itemType).capacity)+"%"; - } else if(getItemTypeData(itemType).useType == VRR_ITEM_USETYPE_PHONE) { + } else if (getItemTypeData(itemType).useType == VRR_ITEM_USETYPE_FOOD || getItemTypeData(itemType).useType == VRR_ITEM_USETYPE_DRINK || getItemTypeData(itemType).useType == VRR_ITEM_USETYPE_EXTINGUISHER || getItemTypeData(itemType).useType == VRR_ITEM_USETYPE_SPRAYPAINT || getItemTypeData(itemType).useType == VRR_ITEM_USETYPE_PEPPERSPRAY) { + return getPercentage(toString(value), getItemTypeData(itemType).capacity) + "%"; + } else if (getItemTypeData(itemType).useType == VRR_ITEM_USETYPE_PHONE) { return toString(value); - } else if(getItemTypeData(itemType).useType == VRR_ITEM_USETYPE_WEAPON || getItemTypeData(itemType).useType == VRR_ITEM_USETYPE_TAZER) { - if(isMeleeWeapon(getItemTypeData(itemType).useId)) { + } else if (getItemTypeData(itemType).useType == VRR_ITEM_USETYPE_WEAPON || getItemTypeData(itemType).useType == VRR_ITEM_USETYPE_TAZER) { + if (isMeleeWeapon(getItemTypeData(itemType).useId)) { return false; } - return toString(value)+" rounds"; - } else if(getItemTypeData(itemType).useType == VRR_ITEM_USETYPE_WALKIETALKIE) { - return toString(toString(value).slice(0,-2)+"."+toString(value).slice(-1)+"MHz"); - } else if(getItemTypeData(itemType).useType == VRR_ITEM_USETYPE_VEHCOLOUR) { + return toString(value) + " rounds"; + } else if (getItemTypeData(itemType).useType == VRR_ITEM_USETYPE_WALKIETALKIE) { + return toString(toString(value).slice(0, -2) + "." + toString(value).slice(-1) + "MHz"); + } else if (getItemTypeData(itemType).useType == VRR_ITEM_USETYPE_VEHCOLOUR) { return `[${getGameConfig().vehicleColourHex[value]}]SAMPLE[#FFFFFF]`; } else { return value; @@ -2047,10 +2068,10 @@ function getItemValueDisplay(itemType, value) { // =========================================================================== function getPlayerFirstItemSlotByUseType(client, useType) { - for(let i in getPlayerData(client).hotBarItems) { - if(getPlayerData(client).hotBarItems[i] != -1) { - if(getItemData(getPlayerData(client).hotBarItems[i])) { - if(getItemTypeData(getItemData(getPlayerData(client).hotBarItems[i]).itemTypeIndex).useType == useType) { + for (let i in getPlayerData(client).hotBarItems) { + if (getPlayerData(client).hotBarItems[i] != -1) { + if (getItemData(getPlayerData(client).hotBarItems[i])) { + if (getItemTypeData(getItemData(getPlayerData(client).hotBarItems[i]).itemTypeIndex).useType == useType) { return i; } } @@ -2072,12 +2093,12 @@ function getPlayerFirstItemSlotByUseType(client, useType) { * */ function toggleItemEnabledCommand(command, params, client) { - if(!getPlayerActiveItem(client)) { + if (!getPlayerActiveItem(client)) { messagePlayerError(client, `You aren't holding anything!`); return false; } - if(!getItemData(getPlayerActiveItem(client))) { + if (!getItemData(getPlayerActiveItem(client))) { messagePlayerError(client, `You aren't holding anything!`); return false; } @@ -2098,7 +2119,7 @@ function toggleItemEnabledCommand(command, params, client) { * */ function deleteItemInPlayerInventoryCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -2106,33 +2127,33 @@ function deleteItemInPlayerInventoryCommand(command, params, client) { let targetClient = getPlayerFromParams(getParam(params, " ", 1)); let hotBarSlot = getParam(params, " ", 2); - if(!targetClient) { + if (!targetClient) { messagePlayerError(client, getLocaleString(client, "InvalidPlayer")); return false; } - if(isNaN(hotBarSlot)) { + if (isNaN(hotBarSlot)) { messagePlayerError(client, getLocaleString(client, "ItemSlotNotNumber")); return false; } - if(toInteger(hotBarSlot) <= 0 || toInteger(hotBarSlot) > 9) { + if (toInteger(hotBarSlot) <= 0 || toInteger(hotBarSlot) > 9) { messagePlayerError(client, getLocaleString(client, "ItemSlotMustBeBetween", "1", "9")); return false; } - if(getPlayerData(targetClient).hotBarItems[hotBarSlot-1] == -1) { + if (getPlayerData(targetClient).hotBarItems[hotBarSlot - 1] == -1) { messagePlayerError(client, `${getCharacterFullName(targetClient)} doesn't have anything in that slot!`); return false; } - if(!getItemData(getPlayerData(targetClient).hotBarItems[hotBarSlot-1])) { + if (!getItemData(getPlayerData(targetClient).hotBarItems[hotBarSlot - 1])) { messagePlayerError(client, `${getCharacterFullName(targetClient)} doesn't have anything in that slot!`); return false; } - let tempName = getItemTypeData(getItemData(getPlayerData(targetClient).hotBarItems[hotBarSlot-1]).itemTypeIndex).name - deleteItem(getPlayerData(targetClient).hotBarItems[hotBarSlot-1]); + let tempName = getItemTypeData(getItemData(getPlayerData(targetClient).hotBarItems[hotBarSlot - 1]).itemTypeIndex).name + deleteItem(getPlayerData(targetClient).hotBarItems[hotBarSlot - 1]); messagePlayerSuccess(client, `You deleted the {ALTCOLOUR}${tempName} {MAINCOLOUR}item in {ALTCOLOUR}${getCharacterFullName(targetClient)}'s {MAINCOLOUR}inventory`); } @@ -2148,7 +2169,7 @@ function deleteItemInPlayerInventoryCommand(command, params, client) { * */ function deleteAllItemsInPlayerInventoryCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -2156,12 +2177,12 @@ function deleteAllItemsInPlayerInventoryCommand(command, params, client) { let targetClient = getPlayerFromParams(getParam(params, " ", 1)); let hotBarSlot = getParam(params, " ", 2); - if(!targetClient) { + if (!targetClient) { messagePlayerError(client, getLocaleString(client, "InvalidPlayer")); return false; } - for(let i = 0; i < 9; i++) { + for (let i = 0; i < 9; i++) { deleteItem(getPlayerData(targetClient).hotBarItems[i]); } @@ -2171,7 +2192,7 @@ function deleteAllItemsInPlayerInventoryCommand(command, params, client) { // =========================================================================== function getItemName(itemId) { - if(getItemData(itemId)) { + if (getItemData(itemId)) { return getItemTypeData(getItemData(itemId).itemTypeIndex).name; } } @@ -2179,8 +2200,8 @@ function getItemName(itemId) { // =========================================================================== function getPlayerActiveItem(client) { - if(getPlayerData(client).activeHotBarSlot != -1) { - if(getPlayerData(client).hotBarItems[getPlayerData(client).activeHotBarSlot] != -1) { + if (getPlayerData(client).activeHotBarSlot != -1) { + if (getPlayerData(client).hotBarItems[getPlayerData(client).activeHotBarSlot] != -1) { return getPlayerData(client).hotBarItems[getPlayerData(client).activeHotBarSlot]; } } @@ -2189,8 +2210,8 @@ function getPlayerActiveItem(client) { // =========================================================================== function getPlayerItemSlot(client, slot) { - if(slot != -1) { - if(getPlayerData(client).hotBarItems[slot] != -1) { + if (slot != -1) { + if (getPlayerData(client).hotBarItems[slot] != -1) { return getPlayerData(client).hotBarItems[slot]; } } @@ -2199,11 +2220,11 @@ function getPlayerItemSlot(client, slot) { // =========================================================================== function resyncWeaponItemAmmo(client) { - if(getPlayerData(client).currentHotBarItem != -1) { - if(getPlayerData(client).hotBarItems[getPlayerData(client).currentHotBarItem] != -1) { - if(getItemData(getPlayerData(client).hotBarItems[getPlayerData(client).currentHotBarItem])) { - if(getGlobalConfig().weaponEquippableTypes.indexOf(getItemTypeData(getItemData(getPlayerData(client).hotBarItems[getPlayerData(client).currentHotBarItem]).itemTypeIndex).useType)) { - if(getPlayerWeaponAmmo(client) <= getItemData(getPlayerData(client).hotBarItems[getPlayerData(client).currentHotBarItem]).value) { + if (getPlayerData(client).currentHotBarItem != -1) { + if (getPlayerData(client).hotBarItems[getPlayerData(client).currentHotBarItem] != -1) { + if (getItemData(getPlayerData(client).hotBarItems[getPlayerData(client).currentHotBarItem])) { + if (getGlobalConfig().weaponEquippableTypes.indexOf(getItemTypeData(getItemData(getPlayerData(client).hotBarItems[getPlayerData(client).currentHotBarItem]).itemTypeIndex).useType)) { + if (getPlayerWeaponAmmo(client) <= getItemData(getPlayerData(client).hotBarItems[getPlayerData(client).currentHotBarItem]).value) { getItemData(getPlayerData(client).hotBarItems[getPlayerData(client).currentHotBarItem]).value = getPlayerWeaponAmmo(client); } else { setPlayerWeaponAmmo(client, getItemTypeData(getItemData(getPlayerData(client).hotBarItems[getPlayerData(client).currentHotBarItem]).itemTypeIndex).useId, getItemData(getPlayerData(client).hotBarItems[getPlayerData(client).currentHotBarItem]).value); @@ -2217,21 +2238,66 @@ function resyncWeaponItemAmmo(client) { // =========================================================================== function getOrderPriceForItemType(itemType) { - return getItemTypeData(itemType).orderPrice*getServerConfig().inflationMultiplier*getItemTypeData(itemType).demandMultiplier*getItemTypeData(itemType).supplyMultiplier*getItemTypeData(itemType).riskMultiplier; + return getItemTypeData(itemType).orderPrice * getServerConfig().inflationMultiplier * getItemTypeData(itemType).demandMultiplier * getItemTypeData(itemType).supplyMultiplier * getItemTypeData(itemType).riskMultiplier; } // =========================================================================== function clearPlayerItemActionState(client) { + if (getPlayerData(client).itemActionItem != -1) { + switch (getPlayerData(client).itemActionState) { + case VRR_ITEM_ACTION_DROP: { + if (getItemTypeData(getItemData(getPlayerData(client).itemActionItem).itemTypeIndex).dropAnimationIndex != -1) { + makePlayerStopAnimation(client); + } + break; + } + + case VRR_ITEM_ACTION_USE: { + if (getItemTypeData(getItemData(getPlayerData(client).itemActionItem).itemTypeIndex).useAnimationIndex != -1) { + makePlayerStopAnimation(client); + } + break; + } + + case VRR_ITEM_ACTION_PICKUP: { + if (getItemTypeData(getItemData(getPlayerData(client).itemActionItem).itemTypeIndex).pickupAnimationIndex != -1) { + makePlayerStopAnimation(client); + } + break; + } + + case VRR_ITEM_ACTION_TAKE: { + if (getItemTypeData(getItemData(getPlayerData(client).itemActionItem).itemTypeIndex).takeAnimationIndex != -1) { + makePlayerStopAnimation(client); + } + break; + } + + case VRR_ITEM_ACTION_PUT: { + if (getItemTypeData(getItemData(getPlayerData(client).itemActionItem).itemTypeIndex).putAnimationIndex != -1) { + makePlayerStopAnimation(client); + } + break; + } + + case VRR_ITEM_ACTION_SWITCH: { + if (getItemTypeData(getItemData(getPlayerData(client).itemActionItem).itemTypeIndex).switchAnimationIndex != -1) { + makePlayerStopAnimation(client); + } + break; + } + } + } + getPlayerData(client).itemActionState = VRR_ITEM_ACTION_NONE; getPlayerData(client).itemActionItem = -1; - makePlayerStopAnimation(client); } // =========================================================================== function clearPlayerItemActionStateAfterDelay(client, delay) { - setTimeout(function() { + setTimeout(function () { clearPlayerItemActionState(client); }, delay); } @@ -2241,17 +2307,17 @@ function clearPlayerItemActionStateAfterDelay(client, delay) { function showBusinessFloorInventoryToPlayer(client, businessId) { let itemDisplay = []; - for(let i in getBusinessData(businessId).floorItemCache) { - if(getBusinessData(businessId).floorItemCache == -1) { - itemDisplay.push(`{MAINCOLOUR}${toInteger(i)+1}{ALTCOLOUR}(Empty)`); + for (let i in getBusinessData(businessId).floorItemCache) { + if (getBusinessData(businessId).floorItemCache == -1) { + itemDisplay.push(`{MAINCOLOUR}${toInteger(i) + 1}{ALTCOLOUR}(Empty)`); } else { - itemDisplay.push(`{MAINCOLOUR}${toInteger(i)+1}: {ALTCOLOUR}${getItemTypeData(getItemData(getBusinessData(businessId).floorItemCache[i]).itemTypeIndex).name} - ${(getPlayerCurrentSubAccount(client).cash > getItemData(getBusinessData(businessId).floorItemCache[i]).buyPrice) ? "{softGreen}" : "{softRed}"}$${getItemData(getBusinessData(businessId).floorItemCache[i]).buyPrice}`); + itemDisplay.push(`{MAINCOLOUR}${toInteger(i) + 1}: {ALTCOLOUR}${getItemTypeData(getItemData(getBusinessData(businessId).floorItemCache[i]).itemTypeIndex).name} - ${(getPlayerCurrentSubAccount(client).cash > getItemData(getBusinessData(businessId).floorItemCache[i]).buyPrice) ? "{softGreen}" : "{softRed}"}$${getItemData(getBusinessData(businessId).floorItemCache[i]).buyPrice}`); } } messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderBusinessFloorItemList"))); let chunkedList = splitArrayIntoChunks(itemDisplay, 5); - for(let i in chunkedList) { + for (let i in chunkedList) { messagePlayerNormal(client, chunkedList[i].join(`{MAINCOLOUR} • `), COLOUR_WHITE); } } @@ -2260,18 +2326,18 @@ function showBusinessFloorInventoryToPlayer(client, businessId) { function showBusinessStorageInventoryToPlayer(client, businessId) { let itemDisplay = []; - for(let i in getBusinessData(businessId).storageItemCache) { - if(getBusinessData(businessId).storageItemCache == -1) { - itemDisplay.push(`{MAINCOLOUR}${toInteger(i)+1}{ALTCOLOUR}(Empty)`); + for (let i in getBusinessData(businessId).storageItemCache) { + if (getBusinessData(businessId).storageItemCache == -1) { + itemDisplay.push(`{MAINCOLOUR}${toInteger(i) + 1}{ALTCOLOUR}(Empty)`); } else { - itemDisplay.push(`{MAINCOLOUR}${toInteger(i)+1}: {ALTCOLOUR}${getItemTypeData(getItemData(getBusinessData(businessId).storageItemCache[i]).itemTypeIndex).name}`); + itemDisplay.push(`{MAINCOLOUR}${toInteger(i) + 1}: {ALTCOLOUR}${getItemTypeData(getItemData(getBusinessData(businessId).storageItemCache[i]).itemTypeIndex).name}`); } } messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderBusinessStorageItemList"))); let chunkedList = splitArrayIntoChunks(itemDisplay, 5); - for(let i in chunkedList) { + for (let i in chunkedList) { messagePlayerNormal(client, chunkedList[i].join(`{MAINCOLOUR} • `), COLOUR_WHITE); } } @@ -2280,18 +2346,18 @@ function showBusinessStorageInventoryToPlayer(client, businessId) { function showItemInventoryToPlayer(client, itemId) { let itemDisplay = []; - for(let i in getItemData(itemId).itemCache) { - if(getItemData(itemId).itemCache == -1) { - itemDisplay.push(`{MAINCOLOUR}${toInteger(i)+1}{ALTCOLOUR}(Empty)`); + for (let i in getItemData(itemId).itemCache) { + if (getItemData(itemId).itemCache == -1) { + itemDisplay.push(`{MAINCOLOUR}${toInteger(i) + 1}{ALTCOLOUR}(Empty)`); } else { - itemDisplay.push(`{MAINCOLOUR}${toInteger(i)+1}: {ALTCOLOUR}${getItemTypeData(getItemData(getItemData(itemId).itemCache[i]).itemTypeIndex).name}`); + itemDisplay.push(`{MAINCOLOUR}${toInteger(i) + 1}: {ALTCOLOUR}${getItemTypeData(getItemData(getItemData(itemId).itemCache[i]).itemTypeIndex).name}`); } } messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderItemItemsList"))); let chunkedList = splitArrayIntoChunks(itemDisplay, 5); - for(let i in chunkedList) { + for (let i in chunkedList) { messagePlayerNormal(client, chunkedList[i].join(`{MAINCOLOUR} • `), COLOUR_WHITE); } } @@ -2301,31 +2367,31 @@ function showItemInventoryToPlayer(client, itemId) { function showPlayerInventoryToPlayer(showToClient, targetClient) { resyncWeaponItemAmmo(targetClient); let itemDisplay = []; - for(let i in getPlayerData(targetClient).hotBarItems) { + for (let i in getPlayerData(targetClient).hotBarItems) { let colour = "{ALTCOLOUR}"; - if(getPlayerData(targetClient).activeHotBarSlot == i) { + if (getPlayerData(targetClient).activeHotBarSlot == i) { colour = "{yellow}"; } - if(getPlayerData(targetClient).hotBarItems[i] == -1) { - itemDisplay.push(`{MAINCOLOUR}${toInteger(i)+1}: ${colour}(Empty)`); + if (getPlayerData(targetClient).hotBarItems[i] == -1) { + itemDisplay.push(`{MAINCOLOUR}${toInteger(i) + 1}: ${colour}(Empty)`); } else { let itemTypeData = getItemTypeData(getItemData(getPlayerData(targetClient).hotBarItems[i]).itemTypeIndex); - if(itemTypeData != false) { - itemDisplay.push(`{MAINCOLOUR}${toInteger(i)+1}: ${colour}${itemTypeData.name}`); + if (itemTypeData != false) { + itemDisplay.push(`{MAINCOLOUR}${toInteger(i) + 1}: ${colour}${itemTypeData.name}`); } else { - itemDisplay.push(`{MAINCOLOUR}${toInteger(i)+1}: ${colour}(Empty)`); + itemDisplay.push(`{MAINCOLOUR}${toInteger(i) + 1}: ${colour}(Empty)`); } } } - if(showToClient == targetClient) { + if (showToClient == targetClient) { messagePlayerNormal(showToClient, makeChatBoxSectionHeader(getLocaleString(showToClient, "HeaderSelfItemList"))); } else { messagePlayerNormal(showToClient, makeChatBoxSectionHeader(getLocaleString(showToClient, "HeaderPlayerItemList", getCharacterFullName(targetClient)))); } let chunkedList = splitArrayIntoChunks(itemDisplay, 5); - for(let i in chunkedList) { + for (let i in chunkedList) { messagePlayerNormal(showToClient, chunkedList[i].join(`{MAINCOLOUR} • `), COLOUR_WHITE); } } @@ -2334,18 +2400,18 @@ function showPlayerInventoryToPlayer(showToClient, targetClient) { function showHouseInventoryToPlayer(client, houseId) { let itemDisplay = []; - for(let i in getHouseData(houseId).itemCache) { - if(getHouseData(houseId).itemCache == -1) { - itemDisplay.push(`{MAINCOLOUR}${toInteger(i)+1}{ALTCOLOUR}(Empty)`); + for (let i in getHouseData(houseId).itemCache) { + if (getHouseData(houseId).itemCache == -1) { + itemDisplay.push(`{MAINCOLOUR}${toInteger(i) + 1}{ALTCOLOUR}(Empty)`); } else { - itemDisplay.push(`{MAINCOLOUR}${toInteger(i)+1}: {ALTCOLOUR}${getItemTypeData(getItemData(getHouseData(houseId).itemCache[i]).itemTypeIndex).name}`); + itemDisplay.push(`{MAINCOLOUR}${toInteger(i) + 1}: {ALTCOLOUR}${getItemTypeData(getItemData(getHouseData(houseId).itemCache[i]).itemTypeIndex).name}`); } } messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderHouseItemList"))); let chunkedList = splitArrayIntoChunks(itemDisplay, 5); - for(let i in chunkedList) { + for (let i in chunkedList) { messagePlayerNormal(client, chunkedList[i].join(`{MAINCOLOUR} • `), COLOUR_WHITE); } } @@ -2355,7 +2421,7 @@ function showHouseInventoryToPlayer(client, houseId) { function switchPlayerActiveHotBarSlot(client, slotId) { getPlayerData(client).itemActionItem = slotId; getPlayerData(client).itemActionState = VRR_ITEM_ACTION_SWITCH; - if(slotId != -1) { + if (slotId != -1) { showPlayerItemSwitchDelay(client, slotId); } //clearPlayerItemActionStateAfterDelay(client, getGlobalConfig().itemActionStateReset); @@ -2365,11 +2431,11 @@ function switchPlayerActiveHotBarSlot(client, slotId) { function isPlayerItemFromJobEquipment(client, hotBarSlot) { let itemId = getPlayerData(client).hotBarItems[hotBarSlot]; - if(!getItemData(itemId)) { + if (!getItemData(itemId)) { return false; } - if(getItemData(itemId).databaseId == -1) { + if (getItemData(itemId).databaseId == -1) { return true; } @@ -2379,7 +2445,7 @@ function isPlayerItemFromJobEquipment(client, hotBarSlot) { // =========================================================================== function getItemPosition(itemId) { - switch(getItemData(itemId).ownerType) { + switch (getItemData(itemId).ownerType) { case VRR_ITEM_OWNER_PLAYER: return getPlayerPosition(getPlayerFromCharacterId(getItemData(itemId).ownerId)); @@ -2403,14 +2469,14 @@ function createGroundPlant(itemId) { // =========================================================================== function getItemTypeFromParams(params) { - if(isNaN(params)) { - for(let i in getServerData().itemTypes) { - if(toLowerCase(getServerData().itemTypes[i].name).indexOf(toLowerCase(params)) != -1) { + if (isNaN(params)) { + for (let i in getServerData().itemTypes) { + if (toLowerCase(getServerData().itemTypes[i].name).indexOf(toLowerCase(params)) != -1) { return i; } } } else { - if(typeof getServerData().itemTypes[params] != "undefined") { + if (typeof getServerData().itemTypes[params] != "undefined") { return toInteger(params); } } @@ -2420,11 +2486,11 @@ function getItemTypeFromParams(params) { // =========================================================================== function getPlayerFirstAmmoItemForWeapon(client, weaponId) { - for(let i in getPlayerData(client).hotBarItems) { - if(getPlayerData(client).hotBarItems[i] != -1) { - if(getItemData(getPlayerData(client).hotBarItems[i]) != false) { - if(getItemTypeData(getItemData(getPlayerData(client).hotBarItems[i]).itemTypeIndex).useType == VRR_ITEM_USETYPE_AMMO_CLIP) { - if(getItemTypeData(getItemData(getPlayerData(client).hotBarItems[i]).itemTypeIndex).useId == weaponId) { + for (let i in getPlayerData(client).hotBarItems) { + if (getPlayerData(client).hotBarItems[i] != -1) { + if (getItemData(getPlayerData(client).hotBarItems[i]) != false) { + if (getItemTypeData(getItemData(getPlayerData(client).hotBarItems[i]).itemTypeIndex).useType == VRR_ITEM_USETYPE_AMMO_CLIP) { + if (getItemTypeData(getItemData(getPlayerData(client).hotBarItems[i]).itemTypeIndex).useId == weaponId) { return i; } } diff --git a/scripts/server/job.js b/scripts/server/job.js index 821a48a9..7a4c39fa 100644 --- a/scripts/server/job.js +++ b/scripts/server/job.js @@ -23,11 +23,11 @@ function loadJobsFromDatabase() { let dbQuery = null; let dbAssoc; - if(dbConnection) { - dbQuery = queryDatabase(dbConnection, `SELECT * FROM job_main WHERE job_enabled = 1 AND job_server = ${getServerId()}`); - if(dbQuery) { - if(dbQuery.numRows > 0) { - while(dbAssoc = fetchQueryAssoc(dbQuery)) { + if (dbConnection) { + dbQuery = queryDatabase(dbConnection, `SELECT * FROM job_main WHERE job_deleted = 0 AND job_enabled = 1 AND job_server = ${getServerId()}`); + if (dbQuery) { + if (dbQuery.numRows > 0) { + while (dbAssoc = fetchQueryAssoc(dbQuery)) { let tempJobData = new JobData(dbAssoc); tempJobData.locations = loadJobLocationsFromDatabase(tempJobData.databaseId); tempJobData.equipment = loadJobEquipmentsFromDatabase(tempJobData.databaseId); @@ -49,7 +49,7 @@ function loadJobsFromDatabase() { // =========================================================================== function loadAllJobEquipmentFromDatabase() { - for(let i in getServerData().jobs) { + for (let i in getServerData().jobs) { getServerData().jobs[i].equipment = loadJobEquipmentsFromDatabase(getServerData().jobs[i].databaseId); } } @@ -57,7 +57,7 @@ function loadAllJobEquipmentFromDatabase() { // =========================================================================== function loadAllJobUniformsFromDatabase() { - for(let i in getServerData().jobs) { + for (let i in getServerData().jobs) { getServerData().jobs[i].uniforms = loadJobUniformsFromDatabase(getServerData().jobs[i].databaseId); } } @@ -65,7 +65,7 @@ function loadAllJobUniformsFromDatabase() { // =========================================================================== function loadAllJobRoutesFromDatabase() { - for(let i in getServerData().jobs) { + for (let i in getServerData().jobs) { getServerData().jobs[i].routes = loadJobRoutesFromDatabase(getServerData().jobs[i].databaseId); } } @@ -73,7 +73,7 @@ function loadAllJobRoutesFromDatabase() { // =========================================================================== function loadAllJobLocationsFromDatabase() { - for(let i in getServerData().jobs) { + for (let i in getServerData().jobs) { getServerData().jobs[i].locations = loadJobLocationsFromDatabase(getServerData().jobs[i].databaseId); } } @@ -88,11 +88,11 @@ function loadJobRoutesFromDatabase(jobDatabaseId) { let dbQuery = null; let dbAssoc; - if(dbConnection) { - dbQuery = queryDatabase(dbConnection, `SELECT * FROM job_route WHERE job_route_enabled = 1 AND job_route_job = ${jobDatabaseId}`); - if(dbQuery) { - if(dbQuery.numRows > 0) { - while(dbAssoc = fetchQueryAssoc(dbQuery)) { + if (dbConnection) { + dbQuery = queryDatabase(dbConnection, `SELECT * FROM job_route WHERE job_route_deleted = 0 AND job_route_enabled = 1 AND job_route_job = ${jobDatabaseId}`); + if (dbQuery) { + if (dbQuery.numRows > 0) { + while (dbAssoc = fetchQueryAssoc(dbQuery)) { let tempJobRouteData = new JobRouteData(dbAssoc); tempJobRouteData.locations = loadJobRouteLocationsFromDatabase(tempJobRouteData.databaseId); tempJobRoutes.push(tempJobRouteData); @@ -118,11 +118,11 @@ function loadJobRouteLocationsFromDatabase(jobRouteId) { let dbQuery = null; let dbAssoc; - if(dbConnection) { - dbQuery = queryDatabase(dbConnection, `SELECT * FROM job_route_loc WHERE job_route_loc_enabled = 1 AND job_route_loc_route = ${jobRouteId}`); - if(dbQuery) { - if(dbQuery.numRows > 0) { - while(dbAssoc = fetchQueryAssoc(dbQuery)) { + if (dbConnection) { + dbQuery = queryDatabase(dbConnection, `SELECT * FROM job_route_loc WHERE job_route_loc_deleted = 0 AND job_route_loc_enabled = 1 AND job_route_loc_route = ${jobRouteId}`); + if (dbQuery) { + if (dbQuery.numRows > 0) { + while (dbAssoc = fetchQueryAssoc(dbQuery)) { let tempJobRouteLocationData = new JobRouteLocationData(dbAssoc); tempJobRouteLocations.push(tempJobRouteLocationData); logToConsole(LOG_DEBUG, `[VRR.Job]: Job route location '${tempJobRouteLocationData.databaseId}' loaded from database successfully!`); @@ -147,11 +147,11 @@ function loadJobEquipmentsFromDatabase(jobDatabaseId) { let dbQuery = null; let dbAssoc; - if(dbConnection) { - dbQuery = queryDatabase(dbConnection, "SELECT * FROM `job_equip` WHERE `job_equip_enabled` = 1 AND `job_equip_job` = " + toString(jobDatabaseId)); - if(dbQuery) { - if(dbQuery.numRows > 0) { - while(dbAssoc = fetchQueryAssoc(dbQuery)) { + if (dbConnection) { + dbQuery = queryDatabase(dbConnection, `SELECT * FROM job_equip WHERE job_equip_deleted = 0 AND job_equip_enabled = 1 AND job_equip_job = ${jobDatabaseId}`); + if (dbQuery) { + if (dbQuery.numRows > 0) { + while (dbAssoc = fetchQueryAssoc(dbQuery)) { let tempJobEquipmentData = new JobEquipmentData(dbAssoc); tempJobEquipmentData.items = loadJobEquipmentItemsFromDatabase(tempJobEquipmentData.databaseId); tempJobEquipments.push(tempJobEquipmentData); @@ -177,11 +177,11 @@ function loadJobLocationsFromDatabase(jobDatabaseId) { let dbQuery = null; let dbAssoc; - if(dbConnection) { - dbQuery = queryDatabase(dbConnection, "SELECT * FROM `job_loc` WHERE `job_loc_enabled` = 1 AND `job_loc_job` = " + toString(jobDatabaseId)); - if(dbQuery) { - if(dbQuery.numRows > 0) { - while(dbAssoc = fetchQueryAssoc(dbQuery)) { + if (dbConnection) { + dbQuery = queryDatabase(dbConnection, `SELECT * FROM job_loc WHERE job_loc_deleted = 0 AND job_loc_enabled = 1 AND job_loc_job = ${jobDatabaseId}`); + if (dbQuery) { + if (dbQuery.numRows > 0) { + while (dbAssoc = fetchQueryAssoc(dbQuery)) { let tempJobLocationData = new JobLocationData(dbAssoc); tempJobLocations.push(tempJobLocationData); logToConsole(LOG_DEBUG, `[VRR.Job]: Job location '${tempJobLocationData.databaseId}' loaded from database successfully!`); @@ -206,11 +206,11 @@ function loadJobUniformsFromDatabase(jobDatabaseId) { let dbQuery = null; let dbAssoc; - if(dbConnection) { + if (dbConnection) { dbQuery = queryDatabase(dbConnection, "SELECT * FROM `job_uniform` WHERE `job_uniform_enabled` = 1 AND `job_uniform_job` = " + toString(jobDatabaseId)); - if(dbQuery) { - if(dbQuery.numRows > 0) { - while(dbAssoc = fetchQueryAssoc(dbQuery)) { + if (dbQuery) { + if (dbQuery.numRows > 0) { + while (dbAssoc = fetchQueryAssoc(dbQuery)) { let tempJobUniformData = new JobUniformData(dbAssoc); tempJobUniforms.push(tempJobUniformData); logToConsole(LOG_DEBUG, `[VRR.Job]: Job uniform '${tempJobUniformData.databaseId}' loaded from database successfully!`); @@ -235,11 +235,11 @@ function loadJobEquipmentItemsFromDatabase(jobEquipmentDatabaseId) { let dbQuery = null; let dbAssoc; - if(dbConnection) { + if (dbConnection) { dbQuery = queryDatabase(dbConnection, "SELECT * FROM `job_equip_item` WHERE `job_equip_item_enabled` = 1 AND `job_equip_item_equip` = " + toString(jobEquipmentDatabaseId)); - if(dbQuery) { - if(dbQuery.numRows > 0) { - while(dbAssoc = fetchQueryAssoc(dbQuery)) { + if (dbQuery) { + if (dbQuery.numRows > 0) { + while (dbAssoc = fetchQueryAssoc(dbQuery)) { let tempJobEquipmentItemData = new JobEquipmentItemData(dbAssoc); tempJobEquipmentItems.push(tempJobEquipmentItemData); logToConsole(LOG_DEBUG, `[VRR.Job]: Job equipment item '${tempJobEquipmentItemData.databaseId}' loaded from database successfully!`); @@ -257,13 +257,13 @@ function loadJobEquipmentItemsFromDatabase(jobEquipmentDatabaseId) { // =========================================================================== function createAllJobBlips() { - if(!getServerConfig().createJobBlips) { + if (!getServerConfig().createJobBlips) { return false; } logToConsole(LOG_DEBUG, `[VRR.Job] Spawning all job location blips ...`); - for(let i in getServerData().jobs) { - for(let j in getServerData().jobs[i].locations) { + for (let i in getServerData().jobs) { + for (let j in getServerData().jobs[i].locations) { createJobLocationBlip(i, j); } } @@ -273,15 +273,15 @@ function createAllJobBlips() { // =========================================================================== function createAllJobPickups() { - if(!getServerConfig().createJobPickups) { + if (!getServerConfig().createJobPickups) { return false; } logToConsole(LOG_DEBUG, `[VRR.Job] Spawning all job location pickups ...`); let pickupCount = 0; - for(let i in getServerData().jobs) { - if(getServerData().jobs[i].pickupModel != 0) { - for(let j in getServerData().jobs[i].locations) { + for (let i in getServerData().jobs) { + if (getServerData().jobs[i].pickupModel != 0) { + for (let j in getServerData().jobs[i].locations) { pickupCount++; getServerData().jobs[i].locations[j].pickup = game.createPickup(getServerData().jobs[i].pickupModel, getServerData().jobs[i].locations[j].position); setEntityData(getServerData().jobs[i].locations[j].pickup, "vrr.owner.type", VRR_PICKUP_JOB, false); @@ -303,18 +303,18 @@ function createAllJobPickups() { // =========================================================================== function showJobInformationToPlayer(client, jobType) { - if(!canPlayerUseJobs(client)){ + if (!canPlayerUseJobs(client)) { return false; } - if(jobType == getPlayerCurrentSubAccount(client).job) { + if (jobType == getPlayerCurrentSubAccount(client).job) { messagePlayerInfo("Welcome back to your job. Use /startwork to begin."); return false; } - switch(jobType) { + switch (jobType) { case VRR_JOB_POLICE: - if(!canPlayerUsePoliceJob(client)) { + if (!canPlayerUsePoliceJob(client)) { return false; } @@ -331,12 +331,12 @@ function showJobInformationToPlayer(client, jobType) { messagePlayerInfo(client, "- Paramedics help people by healing them."); messagePlayerInfo(client, "- Use /startwork at the hospital to work as a Paramedic."); messagePlayerInfo(client, "- People can enter your ambulance to get healed."); - messagePlayerInfo(client, "- The pay depends on the player's health before healing them."); + messagePlayerInfo(client, "- The pay depends on the player's health before healing them."); messagePlayerInfo(client, "- When finished, use /stopwork to stop working."); break; case VRR_JOB_FIRE: - if(!canClientUseFireJob(client)) { + if (!canClientUseFireJob(client)) { return false; } messagePlayerInfo(client, "== Job Help ================================="); @@ -391,16 +391,16 @@ function showJobInformationToPlayer(client, jobType) { // =========================================================================== function jobListCommand(command, params, client) { - if(!canPlayerUseJobs(client)) { + if (!canPlayerUseJobs(client)) { messagePlayerError(client, "You are not allowed to use any jobs!"); return false; } - let jobList = getServerData().jobs.map(function(x) { return `${x.name}`}); + let jobList = getServerData().jobs.map(function (x) { return `${x.name}` }); let chunkedList = splitArrayIntoChunks(jobList, 4); messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderJobList"))); - for(let i in chunkedList) { + for (let i in chunkedList) { messagePlayerInfo(client, chunkedList[i].join(", ")); } return true; @@ -409,7 +409,7 @@ function jobListCommand(command, params, client) { // =========================================================================== function takeJobCommand(command, params, client) { - if(!canPlayerUseJobs(client)) { + if (!canPlayerUseJobs(client)) { messagePlayerError(client, "You are not allowed to use any jobs!"); return false; } @@ -417,17 +417,17 @@ function takeJobCommand(command, params, client) { let closestJobLocation = getClosestJobLocation(getPlayerPosition(client), getPlayerDimension(client)); let jobData = getJobData(closestJobLocation.jobIndex); - if(closestJobLocation.position.distance(getPlayerPosition(client)) > getGlobalConfig().takeJobDistance) { + if (closestJobLocation.position.distance(getPlayerPosition(client)) > getGlobalConfig().takeJobDistance) { messagePlayerError(client, "There are no job points close enough!"); return false; } - if(getPlayerCurrentSubAccount(client).job > VRR_JOB_NONE) { + if (getPlayerCurrentSubAccount(client).job > VRR_JOB_NONE) { messagePlayerInfo(client, getLocaleString(client, "QuitJobToTakeAnother", "{ALTCOLOUR}/quitjob{MAINCOLOUR}")); return false; } - if(!canPlayerUseJob(client, closestJobLocation.jobIndex)) { + if (!canPlayerUseJob(client, closestJobLocation.jobIndex)) { messagePlayerError(client, "You can't use this job!"); return false; } @@ -440,39 +440,39 @@ function takeJobCommand(command, params, client) { // =========================================================================== function startWorkingCommand(command, params, client) { - if(!canPlayerUseJobs(client)){ + if (!canPlayerUseJobs(client)) { return false; } let closestJobLocation = getClosestJobLocation(getPlayerPosition(client), getPlayerDimension(client)); let jobData = false; - if(closestJobLocation.position.distance(getPlayerPosition(client)) > getGlobalConfig().startWorkingDistance) { + if (closestJobLocation.position.distance(getPlayerPosition(client)) > getGlobalConfig().startWorkingDistance) { let closestVehicle = getClosestVehicle(getPlayerPosition(client)); - if(getDistance(getVehiclePosition(closestVehicle), getPlayerPosition(client)) > getGlobalConfig().startWorkingDistance) { + if (getDistance(getVehiclePosition(closestVehicle), getPlayerPosition(client)) > getGlobalConfig().startWorkingDistance) { messagePlayerError(client, "You need to be near your job site or vehicle that belongs to your job!"); return false; } - if(getVehicleData(closestVehicle).ownerType != VRR_VEHOWNER_JOB) { + if (getVehicleData(closestVehicle).ownerType != VRR_VEHOWNER_JOB) { messagePlayerError(client, getLocaleString(client, "NotAJobVehicle")); return false; } - if(getPlayerCurrentSubAccount(client).job != getVehicleData(closestVehicle).ownerId) { + if (getPlayerCurrentSubAccount(client).job != getVehicleData(closestVehicle).ownerId) { messagePlayerError(client, getLocaleString(client, "NotYourJobVehicle")); return false; } jobData = getJobData(getJobIdFromDatabaseId(getVehicleData(closestVehicle).ownerId)); } else { - if(getPlayerCurrentSubAccount(client).job == VRR_JOB_NONE) { + if (getPlayerCurrentSubAccount(client).job == VRR_JOB_NONE) { messagePlayerError(client, "You don't have a job!"); messagePlayerInfo(client, "You can get a job by going the yellow points on the map."); return false; } - if(getPlayerCurrentSubAccount(client).job != closestJobLocation.jobId) { + if (getPlayerCurrentSubAccount(client).job != closestJobLocation.jobId) { messagePlayerError(client, "This is not your job!"); messagePlayerInfo(client, getLocaleString(client, "QuitJobToTakeAnother", "{ALTCOLOUR}/quitjob{MAINCOLOUR}")); return false; @@ -481,7 +481,7 @@ function startWorkingCommand(command, params, client) { jobData = getJobData(closestJobLocation.jobIndex); } - if(!jobData.enabled) { + if (!jobData.enabled) { messagePlayerError(client, getLocaleString(client, "JobDisabled", jobData.name)); return false; } @@ -497,11 +497,11 @@ function startWorkingCommand(command, params, client) { // =========================================================================== function stopWorkingCommand(command, params, client) { - if(!canPlayerUseJobs(client)) { + if (!canPlayerUseJobs(client)) { return false; } - if(!isPlayerWorking(client)) { + if (!isPlayerWorking(client)) { messagePlayerError(client, "You are not working!"); return false; } @@ -515,7 +515,7 @@ function stopWorkingCommand(command, params, client) { // =========================================================================== function startWorking(client) { - if(!canPlayerUseJobs(client)){ + if (!canPlayerUseJobs(client)) { return false; } @@ -527,7 +527,7 @@ function startWorking(client) { getPlayerCurrentSubAccount(client).isWorking = true; let jobId = getPlayerCurrentSubAccount(client).job; - switch(getJobIndexFromDatabaseId(jobId)) { + switch (getJobIndexFromDatabaseId(jobId)) { case VRR_JOB_POLICE: messagePlayerInfo(client, getLocaleString(client, "JobEquipAndUniformLabel", `{ALTCOLOUR}/uniform{MAINCOLOUR}, {ALTCOLOUR}/equip{MAINCOLOUR}`)); break; @@ -586,15 +586,15 @@ function getJobLocationInfoCommand(command, params, client) { // =========================================================================== function givePlayerJobEquipment(client, equipmentId) { - if(!canPlayerUseJobs(client)) { + if (!canPlayerUseJobs(client)) { return false; } let jobId = getPlayerJob(client); - for(let i in getJobData(jobId).equipment[equipmentId].items) { + for (let i in getJobData(jobId).equipment[equipmentId].items) { let value = getJobData(jobId).equipment[equipmentId].items[i].value - if(getItemTypeData(getItemTypeIndexFromDatabaseId(getJobData(jobId).equipment[equipmentId].items[i].itemType)).useType == VRR_ITEM_USETYPE_WALKIETALKIE) { + if (getItemTypeData(getItemTypeIndexFromDatabaseId(getJobData(jobId).equipment[equipmentId].items[i].itemType)).useType == VRR_ITEM_USETYPE_WALKIETALKIE) { value = getJobData(jobId).walkieTalkieFrequency; } let itemId = createItem(getItemTypeIndexFromDatabaseId(getJobData(jobId).equipment[equipmentId].items[i].itemType), value, VRR_ITEM_OWNER_PLAYER, getPlayerCurrentSubAccount(client).databaseId); @@ -612,11 +612,11 @@ function givePlayerJobEquipment(client, equipmentId) { // =========================================================================== function stopWorking(client) { - if(!canPlayerUseJobs(client)){ + if (!canPlayerUseJobs(client)) { return false; } - if(!isPlayerWorking(client)) { + if (!isPlayerWorking(client)) { return false; } @@ -625,8 +625,8 @@ function stopWorking(client) { setPlayerSkin(client, getPlayerCurrentSubAccount(client).skin); let jobVehicle = getPlayerData(client).lastJobVehicle; - if(jobVehicle) { - if(getPlayerVehicle(client) == jobVehicle) { + if (jobVehicle) { + if (getPlayerVehicle(client) == jobVehicle) { removePlayerFromVehicle(client); //getPlayerPed(client).removeFromVehicle(); } @@ -643,9 +643,9 @@ function stopWorking(client) { sendPlayerStopJobRoute(client); let jobId = getPlayerJob(client); - messageDiscordEventChannel(`💼 ${getPlayerName(client)} has stopped working as a ${getJobData(jobId).name}`); + messageDiscordEventChannel(`💼 ${getCharacterFullName(client)} has stopped working as a ${getJobData(jobId).name}`); - switch(getJobType(jobId)) { + switch (getJobType(jobId)) { case VRR_JOB_POLICE: messagePlayerInfo(client, "Your uniform, equipment, and vehicle have been returned to the police station"); break; @@ -692,12 +692,12 @@ function stopWorking(client) { // =========================================================================== function jobUniformCommand(command, params, client) { - if(!getPlayerJob(client)) { + if (!getPlayerJob(client)) { messagePlayerError(client, "You don't have a job!"); return false; } - if(!isPlayerWorking(client)) { + if (!isPlayerWorking(client)) { messagePlayerError(client, "You are not working! Use /startwork at your job location or a job vehicle."); return false; } @@ -705,32 +705,32 @@ function jobUniformCommand(command, params, client) { let closestJobLocation = getClosestJobLocation(getPlayerPosition(client), getPlayerDimension(client)); let jobData = false; - if(closestJobLocation.position.distance(getPlayerPosition(client)) > getGlobalConfig().startWorkingDistance) { + if (closestJobLocation.position.distance(getPlayerPosition(client)) > getGlobalConfig().startWorkingDistance) { let closestVehicle = getClosestVehicle(getPlayerPosition(client)); - if(getDistance(getVehiclePosition(closestVehicle), getPlayerPosition(client)) > getGlobalConfig().startWorkingDistance) { + if (getDistance(getVehiclePosition(closestVehicle), getPlayerPosition(client)) > getGlobalConfig().startWorkingDistance) { messagePlayerError(client, "You need to be near your job site or vehicle that belongs to your job!"); return false; } - if(getVehicleData(closestVehicle).ownerType != VRR_VEHOWNER_JOB) { + if (getVehicleData(closestVehicle).ownerType != VRR_VEHOWNER_JOB) { messagePlayerError(client, getLocaleString(client, "NotAJobVehicle")); return false; } - if(getPlayerCurrentSubAccount(client).job != getVehicleData(closestVehicle).ownerId) { + if (getPlayerCurrentSubAccount(client).job != getVehicleData(closestVehicle).ownerId) { messagePlayerError(client, getLocaleString(client, "NotYourJobVehicle")); return false; } jobData = getJobData(getJobIdFromDatabaseId(getVehicleData(closestVehicle).ownerId)); } else { - if(getPlayerCurrentSubAccount(client).job == VRR_JOB_NONE) { + if (getPlayerCurrentSubAccount(client).job == VRR_JOB_NONE) { messagePlayerError(client, getLocaleString(client, "NotYourJob")); messagePlayerInfo(client, getLocaleString(client, "JobPoints")); return false; } - if(getPlayerCurrentSubAccount(client).job != closestJobLocation.jobId) { + if (getPlayerCurrentSubAccount(client).job != closestJobLocation.jobId) { messagePlayerError(client, getLocaleString(client, "NotYourJob")); messagePlayerInfo(client, getLocaleString(client, "QuitJobToTakeAnother", "{ALTCOLOUR}/quitjob{MAINCOLOUR}")); return false; @@ -739,50 +739,50 @@ function jobUniformCommand(command, params, client) { jobData = getJobData(closestJobLocation.jobIndex); } - if(!jobData.enabled) { + if (!jobData.enabled) { messagePlayerError(client, getLocaleString(client, "JobDisabled", jobData.name)); return false; } let uniforms = jobData.uniforms; - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); - let uniformList = jobData.uniforms.map(function(x) { return `{MAINCOLOUR}${toInteger(x.index)+1}: {ALTCOLOUR}${x.name}`}); + let uniformList = jobData.uniforms.map(function (x) { return `{MAINCOLOUR}${toInteger(x.index) + 1}: {ALTCOLOUR}${x.name}` }); let chunkedList = splitArrayIntoChunks(uniformList, 4); messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderJobUniformList"))); - for(let i in chunkedList) { + for (let i in chunkedList) { messagePlayerInfo(client, chunkedList[i].join(", ")); } return false; } let uniformId = toInteger(params) || 1; - if(uniformId < 0 || uniformId > uniforms.length) { + if (uniformId < 0 || uniformId > uniforms.length) { messagePlayerError(client, getLocaleString(client, "InvalidJobUniform")); return false; } - if(uniformId == 0) { + if (uniformId == 0) { setPlayerSkin(client, getPlayerCurrentSubAccount(client).skin); meActionToNearbyPlayers(client, `takes off their uniform`); } else { - setPlayerSkin(client, jobData.uniforms[uniformId-1].skin); - meActionToNearbyPlayers(client, `puts on ${getProperDeterminerForName(jobData.uniforms[uniformId-1].name)} ${jobData.uniforms[uniformId-1].name} uniform`); + setPlayerSkin(client, jobData.uniforms[uniformId - 1].skin); + meActionToNearbyPlayers(client, `puts on ${getProperDeterminerForName(jobData.uniforms[uniformId - 1].name)} ${jobData.uniforms[uniformId - 1].name} uniform`); } } // =========================================================================== function jobEquipmentCommand(command, params, client) { - if(!getPlayerJob(client)) { + if (!getPlayerJob(client)) { messagePlayerError(client, "You don't have a job!"); return false; } - if(!isPlayerWorking(client)) { + if (!isPlayerWorking(client)) { messagePlayerError(client, "You are not working! Use /startwork at your job location."); return false; } @@ -790,32 +790,32 @@ function jobEquipmentCommand(command, params, client) { let closestJobLocation = getClosestJobLocation(getPlayerPosition(client), getPlayerDimension(client)); let jobData = false; - if(closestJobLocation.position.distance(getPlayerPosition(client)) > getGlobalConfig().startWorkingDistance) { + if (closestJobLocation.position.distance(getPlayerPosition(client)) > getGlobalConfig().startWorkingDistance) { let closestVehicle = getClosestVehicle(getPlayerPosition(client)); - if(getDistance(getVehiclePosition(closestVehicle), getPlayerPosition(client)) > getGlobalConfig().startWorkingDistance) { + if (getDistance(getVehiclePosition(closestVehicle), getPlayerPosition(client)) > getGlobalConfig().startWorkingDistance) { messagePlayerError(client, "You need to be near your job site or vehicle that belongs to your job!"); return false; } - if(getVehicleData(closestVehicle).ownerType != VRR_VEHOWNER_JOB) { + if (getVehicleData(closestVehicle).ownerType != VRR_VEHOWNER_JOB) { messagePlayerError(client, getLocaleString(client, "NotAJobVehicle")); return false; } - if(getPlayerCurrentSubAccount(client).job != getVehicleData(closestVehicle).ownerId) { + if (getPlayerCurrentSubAccount(client).job != getVehicleData(closestVehicle).ownerId) { messagePlayerError(client, getLocaleString(client, "NotYourJobVehicle")); return false; } jobData = getJobData(getJobIdFromDatabaseId(getVehicleData(closestVehicle).ownerId)); } else { - if(getPlayerCurrentSubAccount(client).job == VRR_JOB_NONE) { + if (getPlayerCurrentSubAccount(client).job == VRR_JOB_NONE) { messagePlayerError(client, getLocaleString(client, "NotYourJob")); messagePlayerInfo(client, getLocaleString(client, "JobPoints")); return false; } - if(getPlayerCurrentSubAccount(client).job != closestJobLocation.jobId) { + if (getPlayerCurrentSubAccount(client).job != closestJobLocation.jobId) { messagePlayerError(client, "This is not your job!"); messagePlayerInfo(client, getLocaleString(client, "QuitJobToTakeAnother", "{ALTCOLOUR}/quitjob{MAINCOLOUR}")); return false; @@ -824,39 +824,39 @@ function jobEquipmentCommand(command, params, client) { jobData = getJobData(closestJobLocation.jobIndex); } - if(!jobData.enabled) { + if (!jobData.enabled) { messagePlayerError(client, getLocaleString(client, "JobDisabled", jobData.name)); return false; } let equipments = jobData.equipment; - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); messagePlayerNormal(client, `0: No equipment`); - for(let i in equipments) { - messagePlayerNormal(client, `${toInteger(i)+1}: ${equipments[i].name} (Requires rank ${equipments[i].requiredRank})`); + for (let i in equipments) { + messagePlayerNormal(client, `${toInteger(i) + 1}: ${equipments[i].name} (Requires rank ${equipments[i].requiredRank})`); } return false; } let equipmentId = toInteger(params) || 1; - if(equipmentId == 0) { + if (equipmentId == 0) { meActionToNearbyPlayers(client, `puts their equipment into the locker`); return true; } - if(equipmentId < 1 || equipmentId > equipments.length) { + if (equipmentId < 1 || equipmentId > equipments.length) { messagePlayerError(client, "That equipment ID is invalid!"); return false; } deleteJobItems(client); - givePlayerJobEquipment(client, equipmentId-1); + givePlayerJobEquipment(client, equipmentId - 1); //messagePlayerSuccess(client, `You have been given the ${equipments[equipmentId-1].name} equipment`); - meActionToNearbyPlayers(client, `grabs the ${jobData.equipment[equipmentId-1].name} equipment from the locker`); - if(doesPlayerHaveKeyBindForCommand(client, "inv")) { + meActionToNearbyPlayers(client, `grabs the ${jobData.equipment[equipmentId - 1].name} equipment from the locker`); + if (doesPlayerHaveKeyBindForCommand(client, "inv")) { messagePlayerTip(client, getLocaleString(client, "JobEquipmentInventoryKeyBindTip", toUpperCase(getKeyNameFromId(getPlayerKeyBindForCommand(client, "inv").key)))); } else { messagePlayerTip(client, getLocaleString(client, "JobEquipmentInventoryCommandTip", "/inv")); @@ -866,7 +866,7 @@ function jobEquipmentCommand(command, params, client) { // =========================================================================== function quitJobCommand(command, params, client) { - if(!canPlayerUseJobs(client)){ + if (!canPlayerUseJobs(client)) { return false; } @@ -879,7 +879,7 @@ function quitJobCommand(command, params, client) { // =========================================================================== function jobRadioCommand(command, params, client) { - if(!canPlayerUseJobs(client)){ + if (!canPlayerUseJobs(client)) { return false; } @@ -889,7 +889,7 @@ function jobRadioCommand(command, params, client) { // =========================================================================== function jobDepartmentRadioCommand(command, params, client) { - if(!canPlayerUseJobs(client)){ + if (!canPlayerUseJobs(client)) { return false; } @@ -915,7 +915,7 @@ function doesPlayerHaveJobType(client, jobType) { * @return {JobData} The job's data (class instance) */ function getJobData(jobId) { - if(typeof getServerData().jobs[jobId] != "undefined") { + if (typeof getServerData().jobs[jobId] != "undefined") { return getServerData().jobs[jobId]; } @@ -950,9 +950,9 @@ function reloadAllJobsCommand(command, params, client) { Promise.resolve().then(() => { getServerData().jobs = loadJobsFromDatabase(); - createJobLocationPickup(i, j); - createJobLocationBlip(i, j); - }); + createAllJobPickups(); + createAllJobBlips(); + }); announceAdminAction("AllJobsReloaded"); } @@ -986,14 +986,14 @@ function createJob(name) { // =========================================================================== function createJobLocationCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } let jobId = getJobFromParams(params); - if(!getJobData(jobId)) { + if (!getJobData(jobId)) { messagePlayerError(client, "That job was not found!"); return false; } @@ -1017,7 +1017,7 @@ function deleteJobLocationCommand(command, params, client) { // =========================================================================== function toggleJobLocationEnabledCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -1031,7 +1031,7 @@ function toggleJobLocationEnabledCommand(command, params, client) { // =========================================================================== function toggleJobEnabledCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -1045,12 +1045,12 @@ function toggleJobEnabledCommand(command, params, client) { // =========================================================================== function addJobUniformCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } - if(!areThereEnoughParams(params, 4, " ")) { + if (!areThereEnoughParams(params, 4, " ")) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -1080,12 +1080,12 @@ function createJobUniform(jobId, skinIndex, rankLevel) { // =========================================================================== function setJobColourCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } - if(!areThereEnoughParams(params, 4, " ")) { + if (!areThereEnoughParams(params, 4, " ")) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -1106,12 +1106,12 @@ function setJobColourCommand(command, params, client) { // =========================================================================== function setJobBlipCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } - if(!areThereEnoughParams(params, 4, " ")) { + if (!areThereEnoughParams(params, 4, " ")) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -1122,15 +1122,15 @@ function setJobBlipCommand(command, params, client) { let blipId = getJobData(jobId).blipModel; let blipString = "unchanged"; - if(isNaN(blipParam)) { - if(toLowerCase(blipParam) == "none") { + if (isNaN(blipParam)) { + if (toLowerCase(blipParam) == "none") { blipId = -1; } else { let blipTypes = Object.keys(getGameConfig().blipSprites[getGame()]).join(", "); let chunkedList = splitArrayIntoChunks(blipTypes, 10); messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderBlipTypes"))); - for(let i in chunkedList) { + for (let i in chunkedList) { messagePlayerInfo(client, chunkedList[i].join(", ")); } @@ -1151,12 +1151,12 @@ function setJobBlipCommand(command, params, client) { // =========================================================================== function setJobPickupCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } - if(!areThereEnoughParams(params, 4, " ")) { + if (!areThereEnoughParams(params, 4, " ")) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -1167,15 +1167,15 @@ function setJobPickupCommand(command, params, client) { let pickupId = getJobData(jobId).pickupModel; let pickupString = "unchanged"; - if(isNaN(pickupParam)) { - if(toLowerCase(pickupParam) == "none") { + if (isNaN(pickupParam)) { + if (toLowerCase(pickupParam) == "none") { pickupId = -1; } else { let pickupTypes = Object.keys(getGameConfig().pickupModels[getGame()]).join(", "); let chunkedList = splitArrayIntoChunks(pickupTypes, 10); messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderPickupTypes"))); - for(let i in chunkedList) { + for (let i in chunkedList) { messagePlayerInfo(client, chunkedList[i].join(", ")); } @@ -1200,10 +1200,10 @@ function toggleJobRouteEnabledCommand(command, params, client) { let jobRoute = getPlayerJobRoute(client); let clients = getClients(); - for(let i in clients) { - if(isPlayerWorking(clients[i])) { - if(isPlayerOnJobRoute(clients[i])) { - if(getPlayerJob(clients[i]) == jobId && getPlayerJobRoute(clients[i]) == jobRoute) { + for (let i in clients) { + if (isPlayerWorking(clients[i])) { + if (isPlayerOnJobRoute(clients[i])) { + if (getPlayerJob(clients[i]) == jobId && getPlayerJobRoute(clients[i]) == jobRoute) { stopJobRoute(clients[i], true, false); messagePlayerAlert(clients[i], "The job route you were on has been disabled by an admin"); } @@ -1218,17 +1218,17 @@ function toggleJobRouteEnabledCommand(command, params, client) { // =========================================================================== function setJobRouteNameCommand(command, params, client) { - if(!isPlayerWorking(client)) { + if (!isPlayerWorking(client)) { messagePlayerError(client, getLocaleString(client, "NeedToBeWorking", "{ALTCOLOUR}/startwork{MAINCOLOUR}")); return false; } - if(!isPlayerOnJobRoute(client)) { + if (!isPlayerOnJobRoute(client)) { messagePlayerError(client, getLocaleString(client, "NeedToBeOnJobRoute", "{ALTCOLOUR}/startroute{MAINCOLOUR}")); return false; } - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -1244,17 +1244,17 @@ function setJobRouteNameCommand(command, params, client) { // =========================================================================== function setJobRouteAllLocationDelaysCommand(command, params, client) { - if(!isPlayerWorking(client)) { + if (!isPlayerWorking(client)) { messagePlayerError(client, getLocaleString(client, "NeedToBeWorking", "{ALTCOLOUR}/startwork{MAINCOLOUR}")); return false; } - if(!isPlayerOnJobRoute(client)) { + if (!isPlayerOnJobRoute(client)) { messagePlayerError(client, getLocaleString(client, "NeedToBeOnJobRoute", "{ALTCOLOUR}/startroute{MAINCOLOUR}")); return false; } - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -1263,33 +1263,33 @@ function setJobRouteAllLocationDelaysCommand(command, params, client) { let jobRoute = getPlayerJobRoute(client); let delay = getParam(params, " ", 1); - if(isNaN(delay)) { + if (isNaN(delay)) { messagePlayerError(client, getLocaleString(client, "TimeNotNumber")) return false; } - for(let i in getJobData(jobId).routes[jobRoute].locations) { + for (let i in getJobData(jobId).routes[jobRoute].locations) { getJobData(jobId).routes[jobRoute].locations[i].stopDelay = delay; getJobData(jobId).routes[jobRoute].locations[i].needsSaved = true; } - messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} set route {ALTCOLOUR}${oldName}{MAINCOLOUR} location's stop delays to {ALTCOLOUR}${delay/1000}{MAINCOLOUR} seconds for the {jobYellow}${getJobData(jobId).name}{MAINCOLOUR} job`); + messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} set route {ALTCOLOUR}${oldName}{MAINCOLOUR} location's stop delays to {ALTCOLOUR}${delay / 1000}{MAINCOLOUR} seconds for the {jobYellow}${getJobData(jobId).name}{MAINCOLOUR} job`); } // =========================================================================== function setJobRouteVehicleColoursCommand(command, params, client) { - if(!isPlayerWorking(client)) { + if (!isPlayerWorking(client)) { messagePlayerError(client, getLocaleString(client, "NeedToBeWorking", "{ALTCOLOUR}/startwork{MAINCOLOUR}")); return false; } - if(!isPlayerOnJobRoute(client)) { + if (!isPlayerOnJobRoute(client)) { messagePlayerError(client, getLocaleString(client, "NeedToBeOnJobRoute", "{ALTCOLOUR}/startroute{MAINCOLOUR}")); return false; } - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -1305,10 +1305,10 @@ function setJobRouteVehicleColoursCommand(command, params, client) { getJobRouteData(getPlayerJob(client), getPlayerJobRoute(client)).needsSaved = true; let clients = getClients(); - for(let i in clients) { - if(isPlayerWorking(clients[i])) { - if(isPlayerOnJobRoute(clients[i])) { - if(getPlayerJob(clients[i]) == jobId && getPlayerJobRoute(clients[i]) == jobRoute) { + for (let i in clients) { + if (isPlayerWorking(clients[i])) { + if (isPlayerOnJobRoute(clients[i])) { + if (getPlayerJob(clients[i]) == jobId && getPlayerJobRoute(clients[i]) == jobRoute) { setVehicleColours(getPlayerVehicle(clients[i]), toInteger(colour1), toInteger(colour2), 1, 1); messagePlayerAlert(clients[i], getLocaleString(client, "CurrentJobRouteVehicleColoursChanged")); } @@ -1322,17 +1322,17 @@ function setJobRouteVehicleColoursCommand(command, params, client) { // =========================================================================== function setJobRouteFinishMessageCommand(command, params, client) { - if(!isPlayerWorking(client)) { + if (!isPlayerWorking(client)) { messagePlayerError(client, getLocaleString(client, "NeedToBeWorking", "{ALTCOLOUR}/startwork{MAINCOLOUR}")); return false; } - if(!isPlayerOnJobRoute(client)) { + if (!isPlayerOnJobRoute(client)) { messagePlayerError(client, getLocaleString(client, "NeedToBeOnJobRoute", "{ALTCOLOUR}/startroute{MAINCOLOUR}")); return false; } - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -1348,17 +1348,17 @@ function setJobRouteFinishMessageCommand(command, params, client) { // =========================================================================== function setJobRouteStartMessageCommand(command, params, client) { - if(!isPlayerWorking(client)) { + if (!isPlayerWorking(client)) { messagePlayerError(client, getLocaleString(client, "NeedToBeWorking", "{ALTCOLOUR}/startwork{MAINCOLOUR}")); return false; } - if(!isPlayerOnJobRoute(client)) { + if (!isPlayerOnJobRoute(client)) { messagePlayerError(client, getLocaleString(client, "NeedToBeOnJobRoute", "{ALTCOLOUR}/startroute{MAINCOLOUR}")); return false; } - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -1374,17 +1374,17 @@ function setJobRouteStartMessageCommand(command, params, client) { // =========================================================================== function setJobRouteLocationPositionCommand(command, params, client) { - if(!isPlayerWorking(client)) { + if (!isPlayerWorking(client)) { messagePlayerError(client, getLocaleString(client, "NeedToBeWorking", "{ALTCOLOUR}/startwork{MAINCOLOUR}")); return false; } - if(!isPlayerOnJobRoute(client)) { + if (!isPlayerOnJobRoute(client)) { messagePlayerError(client, getLocaleString(client, "NeedToBeOnJobRoute", "{ALTCOLOUR}/startroute{MAINCOLOUR}")); return false; } - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -1402,17 +1402,17 @@ function setJobRouteLocationPositionCommand(command, params, client) { // =========================================================================== function setJobRouteLocationArriveMessageCommand(command, params, client) { - if(!isPlayerWorking(client)) { + if (!isPlayerWorking(client)) { messagePlayerError(client, getLocaleString(client, "NeedToBeWorking", "{ALTCOLOUR}/startwork{MAINCOLOUR}")); return false; } - if(!isPlayerOnJobRoute(client)) { + if (!isPlayerOnJobRoute(client)) { messagePlayerError(client, getLocaleString(client, "NeedToBeOnJobRoute", "{ALTCOLOUR}/startroute{MAINCOLOUR}")); return false; } - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -1428,17 +1428,17 @@ function setJobRouteLocationArriveMessageCommand(command, params, client) { // =========================================================================== function setJobRouteLocationNextMessageCommand(command, params, client) { - if(!isPlayerWorking(client)) { + if (!isPlayerWorking(client)) { messagePlayerError(client, getLocaleString(client, "NeedToBeWorking", "{ALTCOLOUR}/startwork{MAINCOLOUR}")); return false; } - if(!isPlayerOnJobRoute(client)) { + if (!isPlayerOnJobRoute(client)) { messagePlayerError(client, getLocaleString(client, "NeedToBeOnJobRoute", "{ALTCOLOUR}/startroute{MAINCOLOUR}")); return false; } - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -1454,17 +1454,17 @@ function setJobRouteLocationNextMessageCommand(command, params, client) { // =========================================================================== function setJobRoutePayCommand(command, params, client) { - if(!isPlayerWorking(client)) { + if (!isPlayerWorking(client)) { messagePlayerError(client, getLocaleString(client, "NeedToBeWorking", "{ALTCOLOUR}/startwork{MAINCOLOUR}")); return false; } - if(!isPlayerOnJobRoute(client)) { + if (!isPlayerOnJobRoute(client)) { messagePlayerError(client, getLocaleString(client, "NeedToBeOnJobRoute", "{ALTCOLOUR}/startroute{MAINCOLOUR}")); return false; } - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -1474,7 +1474,7 @@ function setJobRoutePayCommand(command, params, client) { let amount = getParam(params, " ", 1); - if(isNaN(amount)) { + if (isNaN(amount)) { getLocaleString(client, "MustBeNumber", "amount"); return false; } @@ -1487,7 +1487,7 @@ function setJobRoutePayCommand(command, params, client) { // =========================================================================== function toggleJobWhiteListCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -1501,7 +1501,7 @@ function toggleJobWhiteListCommand(command, params, client) { // =========================================================================== function toggleJobBlackListCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -1515,7 +1515,7 @@ function toggleJobBlackListCommand(command, params, client) { // =========================================================================== function addPlayerToJobBlackListCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -1523,17 +1523,17 @@ function addPlayerToJobBlackListCommand(command, params, client) { let targetClient = getPlayerFromParams(getParam(params, " ", 1)); let jobId = getJobFromParams(getParam(params, " ", 2)) || getClosestJobLocation(getPlayerPosition(client), getPlayerDimension(client)).jobIndex; - if(!targetClient) { + if (!targetClient) { messagePlayerError(client, getLocaleString(client, "InvalidPlayer")); return false; } - if(!getJobData(jobId)) { + if (!getJobData(jobId)) { messagePlayerError(client, getLocaleString(client, "InvalidJob")); return false; } - if(isPlayerOnJobBlackList(targetClient, jobId)) { + if (isPlayerOnJobBlackList(targetClient, jobId)) { messagePlayerError(client, `That player is already blacklisted from that job!`); return false; } @@ -1545,7 +1545,7 @@ function addPlayerToJobBlackListCommand(command, params, client) { // =========================================================================== function removePlayerFromJobBlackListCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -1553,17 +1553,17 @@ function removePlayerFromJobBlackListCommand(command, params, client) { let targetClient = getPlayerFromParams(getParam(params, " ", 1)); let jobId = getJobFromParams(getParam(params, " ", 2)) || getClosestJobLocation(getPlayerPosition(client), getPlayerDimension(client)).jobIndex; - if(!targetClient) { + if (!targetClient) { messagePlayerError(client, getLocaleString(client, "InvalidPlayer")); return false; } - if(!getJobData(jobId)) { + if (!getJobData(jobId)) { messagePlayerError(client, getLocaleString(client, "InvalidJob")); return false; } - if(!isPlayerOnJobBlackList(targetClient, jobId)) { + if (!isPlayerOnJobBlackList(targetClient, jobId)) { messagePlayerError(client, `That player is not blacklisted from that job!`); return false; } @@ -1575,7 +1575,7 @@ function removePlayerFromJobBlackListCommand(command, params, client) { // =========================================================================== function addPlayerToJobWhiteListCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -1583,17 +1583,17 @@ function addPlayerToJobWhiteListCommand(command, params, client) { let targetClient = getPlayerFromParams(getParam(params, " ", 1)); let jobId = getJobFromParams(getParam(params, " ", 2)) || getClosestJobLocation(getPlayerPosition(client), getPlayerDimension(client)).jobIndex; - if(!targetClient) { + if (!targetClient) { messagePlayerError(client, getLocaleString(client, "InvalidPlayer")); return false; } - if(!getJobData(jobId)) { + if (!getJobData(jobId)) { messagePlayerError(client, getLocaleString(client, "InvalidJob")); return false; } - if(isPlayerOnJobWhiteList(targetClient, jobId)) { + if (isPlayerOnJobWhiteList(targetClient, jobId)) { messagePlayerError(client, `That player is already whitelisted from that job!`); return false; } @@ -1605,7 +1605,7 @@ function addPlayerToJobWhiteListCommand(command, params, client) { // =========================================================================== function removePlayerFromJobWhiteListCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -1613,17 +1613,17 @@ function removePlayerFromJobWhiteListCommand(command, params, client) { let targetClient = getPlayerFromParams(getParam(params, " ", 1)); let jobId = getJobFromParams(getParam(params, " ", 2)) || getClosestJobLocation(getPlayerPosition(client), getPlayerDimension(client)).jobIndex; - if(!targetClient) { + if (!targetClient) { messagePlayerError(client, getLocaleString(client, "InvalidPlayer")); return false; } - if(!getJobData(jobId)) { + if (!getJobData(jobId)) { messagePlayerError(client, getLocaleString(client, "InvalidJob")); return false; } - if(!isPlayerOnJobWhiteList(targetClient, jobId)) { + if (!isPlayerOnJobWhiteList(targetClient, jobId)) { messagePlayerError(client, `That player is not whitelisted from that job!`); return false; } @@ -1635,8 +1635,8 @@ function removePlayerFromJobWhiteListCommand(command, params, client) { // =========================================================================== function forceAllPlayersToStopWorking() { - getClients().forEach(function(client) { - if(!client.console) { + getClients().forEach(function (client) { + if (!client.console) { stopWorking(client); } }); @@ -1645,36 +1645,36 @@ function forceAllPlayersToStopWorking() { // =========================================================================== function jobStartRouteCommand(command, params, client) { - if(!canPlayerUseJobs(client)) { + if (!canPlayerUseJobs(client)) { messagePlayerError(client, "You are not allowed to use jobs."); return false; } - if(!isPlayerWorking(client)) { + if (!isPlayerWorking(client)) { messagePlayerError(client, "You aren't working yet! Use /startwork first."); return false; } - if(getJobData(getPlayerJob(client)).routes.length == 0) { + if (getJobData(getPlayerJob(client)).routes.length == 0) { messagePlayerError(client, "Your job doesn't have any routes for this location!"); return false; } - if(!isPlayerInJobVehicle(client)) { + if (!isPlayerInJobVehicle(client)) { messagePlayerError(client, "You need to be in a vehicle that belongs to your job!"); return false; } - if(isPlayerOnJobRoute(client)) { + if (isPlayerOnJobRoute(client)) { messagePlayerError(client, "You're already on a job route! Finish the route or use /stoproute"); return false; } let forceRoute = -1; - if(doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageJobs"))) { - if(!areParamsEmpty(params)) { + if (doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageJobs"))) { + if (!areParamsEmpty(params)) { let tempRoute = getJobRouteFromParams(params, getPlayerJob(client)); - if(tempRoute != false) { + if (tempRoute != false) { forceRoute = tempRoute; } } @@ -1687,12 +1687,12 @@ function jobStartRouteCommand(command, params, client) { // =========================================================================== function jobStopRouteCommand(command, params, client) { - if(!canPlayerUseJobs(client)) { + if (!canPlayerUseJobs(client)) { messagePlayerError(client, "You are not allowed to use jobs."); return false; } - if(!isPlayerWorking(client)) { + if (!isPlayerWorking(client)) { messagePlayerError(client, "You aren't working yet! Use /startwork first."); return false; } @@ -1702,12 +1702,12 @@ function jobStopRouteCommand(command, params, client) { // return false; //} - if(!isPlayerOnJobRoute(client)) { + if (!isPlayerOnJobRoute(client)) { messagePlayerError(client, "You aren't on a job route!"); return false; } - if(!getJobRouteData(getPlayerJob(client), getPlayerJobRoute(client)).enabled) { + if (!getJobRouteData(getPlayerJob(client), getPlayerJobRoute(client)).enabled) { setAllJobDataIndexes(); getJobRouteData(getPlayerJob(client), getPlayerJobRoute(client)).enabled = true; } @@ -1719,9 +1719,9 @@ function jobStopRouteCommand(command, params, client) { // =========================================================================== function isPlayerInJobVehicle(client) { - if(getPlayerVehicle(client)) { + if (getPlayerVehicle(client)) { let vehicle = getPlayerVehicle(client); - if(isVehicleOwnedByJob(vehicle, getPlayerCurrentSubAccount(client).job)) { + if (isVehicleOwnedByJob(vehicle, getPlayerCurrentSubAccount(client).job)) { return true; } } @@ -1732,7 +1732,7 @@ function isPlayerInJobVehicle(client) { // =========================================================================== function isPlayerWorking(client) { - if(!getPlayerCurrentSubAccount(client)) { + if (!getPlayerCurrentSubAccount(client)) { return false; } return getPlayerCurrentSubAccount(client).isWorking; @@ -1744,13 +1744,13 @@ function startJobRoute(client, forceRoute = -1) { let jobId = getPlayerJob(client); let jobRoute = 0; - if(forceRoute == -1) { + if (forceRoute == -1) { jobRoute = getRandomJobRouteForLocation(getClosestJobLocationForJob(getPlayerPosition(client), jobId)); } else { jobRoute = forceRoute; } - if(jobRoute == -1) { + if (jobRoute == -1) { messagePlayerError(client, `There are no routes for this location.`); return false; } @@ -1767,11 +1767,11 @@ function startJobRoute(client, forceRoute = -1) { messagePlayerNormal(client, replaceJobRouteStringsInMessage(getJobRouteData(jobId, jobRoute).startMessage, jobId, jobRoute)); // Don't announce routes that an admin just created - if(forceRoute == -1) { + if (forceRoute == -1) { messageDiscordEventChannel(`💼 ${getCharacterFullName(client)} started the ${getJobRouteData(jobId, jobRoute).name} route for the ${getJobData(jobId).name} job`); } - if(getJobRouteData(jobId, jobRoute).locations.length > 0) { + if (getJobRouteData(jobId, jobRoute).locations.length > 0) { showCurrentJobLocation(client); } else { messagePlayerError(client, `There are no locations for this route.`); @@ -1784,11 +1784,11 @@ function stopJobRoute(client, successful = false, alertPlayer = true) { let jobId = getPlayerJob(client); let routeId = getPlayerJobRoute(client); - if(alertPlayer) { + if (alertPlayer) { messagePlayerAlert(client, replaceJobRouteStringsInMessage(getJobRouteData(jobId, routeId).finishMessage, jobId, routeId)); } - if(successful == true) { + if (successful == true) { finishSuccessfulJobRoute(client); return false; } @@ -1807,7 +1807,7 @@ function stopJobRoute(client, successful = false, alertPlayer = true) { // =========================================================================== function isPlayerOnJobRoute(client) { - if(getPlayerData(client).jobRoute != -1) { + if (getPlayerData(client).jobRoute != -1) { return true; } @@ -1817,7 +1817,7 @@ function isPlayerOnJobRoute(client) { // =========================================================================== function getPlayerJobRouteVehicle(client) { - if(!isPlayerOnJobRoute(client)) { + if (!isPlayerOnJobRoute(client)) { return false; } @@ -1828,9 +1828,9 @@ function getPlayerJobRouteVehicle(client) { function startReturnToJobVehicleCountdown(client) { getPlayerData(client).returnToJobVehicleTick = getGlobalConfig().returnToJobVehicleTime; - getPlayerData(client).returnToJobVehicleTimer = setInterval(function() { + getPlayerData(client).returnToJobVehicleTimer = setInterval(function () { //logToConsole(LOG_DEBUG, getPlayerData(client).returnToJobVehicleTick); - if(getPlayerData(client).returnToJobVehicleTick > 0) { + if (getPlayerData(client).returnToJobVehicleTick > 0) { getPlayerData(client).returnToJobVehicleTick = getPlayerData(client).returnToJobVehicleTick - 1; //logToConsole(LOG_WARN, `You have ${getPlayerData(client).returnToJobVehicleTick} seconds to return to your job vehicle!`); showGameMessage(client, `You have ${getPlayerData(client).returnToJobVehicleTick} seconds to return to your job vehicle!`, getColourByName("softRed"), 1500); @@ -1846,7 +1846,7 @@ function startReturnToJobVehicleCountdown(client) { // =========================================================================== function stopReturnToJobVehicleCountdown(client) { - if(getPlayerData(client).returnToJobVehicleTimer != null) { + if (getPlayerData(client).returnToJobVehicleTimer != null) { clearInterval(getPlayerData(client).returnToJobVehicleTimer); getPlayerData(client).returnToJobVehicleTimer = null; } @@ -1857,22 +1857,22 @@ function stopReturnToJobVehicleCountdown(client) { // =========================================================================== function canPlayerUseJob(client, jobId) { - if(doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageJobs"))) { + if (doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageJobs"))) { return true; } - if(!getJobData(jobId)) { + if (!getJobData(jobId)) { return false; } - if(isJobWhiteListed(jobId)) { - if(!isPlayerOnJobWhiteList(client, jobId)) { + if (isJobWhiteListed(jobId)) { + if (!isPlayerOnJobWhiteList(client, jobId)) { return false; } } - if(!isJobBlackListed(jobId)) { - if(isPlayerOnJobBlackList(client, jobId)) { + if (!isJobBlackListed(jobId)) { + if (isPlayerOnJobBlackList(client, jobId)) { return false; } } @@ -1883,7 +1883,7 @@ function canPlayerUseJob(client, jobId) { // =========================================================================== function deleteJobLocation(jobLocationData) { - if(jobLocationData.databaseId > 0) { + if (jobLocationData.databaseId > 0) { quickDatabaseQuery(`DELETE FROM job_loc WHERE job_loc_id = ${jobLocationData.databaseId}`); } @@ -1912,8 +1912,8 @@ function unFreezePlayerJobVehicleForRouteLocation(client) { // =========================================================================== function getJobIdFromDatabaseId(databaseId) { - for(let i in getServerData().jobs) { - if(getServerData().jobs[i].databaseId == databaseId) { + for (let i in getServerData().jobs) { + if (getServerData().jobs[i].databaseId == databaseId) { return i; } } @@ -1923,45 +1923,45 @@ function getJobIdFromDatabaseId(databaseId) { // =========================================================================== function setAllJobDataIndexes() { - for(let i in getServerData().jobs) { + for (let i in getServerData().jobs) { getServerData().jobs[i].index = i; - for(let j in getServerData().jobs[i].locations) { + for (let j in getServerData().jobs[i].locations) { getServerData().jobs[i].locations[j].index = j; getServerData().jobs[i].locations[j].jobIndex = i; - for(let u in getServerData().jobs[i].routes) { - if(getServerData().jobs[i].routes[u].locationId == getServerData().jobs[i].locations[j].databaseId) { + for (let u in getServerData().jobs[i].routes) { + if (getServerData().jobs[i].routes[u].locationId == getServerData().jobs[i].locations[j].databaseId) { getServerData().jobs[i].locations[j].routeCache.push(u); } } } - for(let k in getServerData().jobs[i].uniforms) { + for (let k in getServerData().jobs[i].uniforms) { getServerData().jobs[i].uniforms[k].index = k; getServerData().jobs[i].uniforms[k].jobIndex = i; } - for(let m in getServerData().jobs[i].equipment) { + for (let m in getServerData().jobs[i].equipment) { getServerData().jobs[i].equipment[m].index = m; getServerData().jobs[i].equipment[m].jobIndex = i; - for(let n in getServerData().jobs[i].equipment[m].items) { + for (let n in getServerData().jobs[i].equipment[m].items) { getServerData().jobs[i].equipment[m].items[n].index = n; getServerData().jobs[i].equipment[m].items[n].jobIndex = i; getServerData().jobs[i].equipment[m].items[n].equipmentIndex = m; } } - for(let o in getServerData().jobs[i].blackList) { + for (let o in getServerData().jobs[i].blackList) { getServerData().jobs[i].blackList[o].index = o; getServerData().jobs[i].blackList[o].jobIndex = i; } - for(let v in getServerData().jobs[i].whiteList) { + for (let v in getServerData().jobs[i].whiteList) { getServerData().jobs[i].blackList[v].index = v; getServerData().jobs[i].blackList[v].jobIndex = i; } - for(let t in getServerData().jobs[i].routes) { + for (let t in getServerData().jobs[i].routes) { getServerData().jobs[i].routes[t].index = t; getServerData().jobs[i].routes[t].jobIndex = i; } @@ -1981,7 +1981,7 @@ function createJobLocation(jobId, position, interior, dimension) { jobLocationData.needsSaved = true; getServerData().jobs[jobId].locations.push(jobLocationData); - let newSlot = getServerData().jobs[jobId].locations.length-1; + let newSlot = getServerData().jobs[jobId].locations.length - 1; getServerData().jobs[jobId].locations[newSlot].index = newSlot; createJobLocationPickup(jobId, newSlot); saveJobLocationToDatabase(jobLocationData); @@ -1990,19 +1990,19 @@ function createJobLocation(jobId, position, interior, dimension) { // =========================================================================== function saveJobToDatabase(jobData) { - if(jobData == null) { + if (jobData == null) { // Invalid job data return false; } - if(jobData.needsSaved == false) { + if (jobData.needsSaved == false) { logToConsole(LOG_DEBUG, `[VRR.Job]: Job ${jobData.name} doesn't need saved. Skipping ...`); return false; } logToConsole(LOG_DEBUG, `[VRR.Job]: Saving job ${jobData.name} to database ...`); let dbConnection = connectToDatabase(); - if(dbConnection) { + if (dbConnection) { let safeName = escapeDatabaseString(dbConnection, jobData.name); let colour = rgbaArrayFromToColour(jobData.colour); let data = [ @@ -2021,7 +2021,7 @@ function saveJobToDatabase(jobData) { ]; let dbQuery = null; - if(jobData.databaseId == 0) { + if (jobData.databaseId == 0) { let queryString = createDatabaseInsertQuery("job_main", data); dbQuery = queryDatabase(dbConnection, queryString); jobData.databaseId = getDatabaseInsertId(dbConnection); @@ -2043,19 +2043,19 @@ function saveJobToDatabase(jobData) { // =========================================================================== function saveJobRouteToDatabase(jobRouteData) { - if(!jobRouteData) { + if (!jobRouteData) { // Invalid job route data return false; } - if(jobRouteData.needsSaved == false) { + if (jobRouteData.needsSaved == false) { logToConsole(LOG_DEBUG, `[VRR.Job]: Job route ${jobRouteData.name} (DB ID ${jobRouteData.databaseId}) doesn't need saved. Skipping ...`); return false; } logToConsole(LOG_DEBUG, `[VRR.Job]: Saving job route ${jobRouteData.name} to database ...`); let dbConnection = connectToDatabase(); - if(dbConnection) { + if (dbConnection) { let safeName = escapeDatabaseString(dbConnection, jobRouteData.name); let safeStartMessage = escapeDatabaseString(dbConnection, jobRouteData.startMessage); let safeFinishMessage = escapeDatabaseString(dbConnection, jobRouteData.finishMessage); @@ -2078,7 +2078,7 @@ function saveJobRouteToDatabase(jobRouteData) { ]; let dbQuery = null; - if(jobRouteData.databaseId == 0) { + if (jobRouteData.databaseId == 0) { let queryString = createDatabaseInsertQuery("job_route", data); dbQuery = queryDatabase(dbConnection, queryString); jobRouteData.databaseId = getDatabaseInsertId(dbConnection); @@ -2100,19 +2100,19 @@ function saveJobRouteToDatabase(jobRouteData) { // =========================================================================== function saveJobRouteLocationToDatabase(jobRouteLocationData) { - if(!jobRouteLocationData) { + if (!jobRouteLocationData) { // Invalid job route position data return false; } - if(jobRouteLocationData.needsSaved == false) { + if (jobRouteLocationData.needsSaved == false) { logToConsole(LOG_DEBUG, `[VRR.Job]: Job route location ${jobRouteLocationData.name} (DB ID ${jobRouteLocationData.databaseId}) doesn't need saved. Skipping ...`); return false; } logToConsole(LOG_DEBUG, `[VRR.Job]: Saving job route location ${jobRouteLocationData.name} to database ...`); let dbConnection = connectToDatabase(); - if(dbConnection) { + if (dbConnection) { let safeName = escapeDatabaseString(dbConnection, jobRouteLocationData.name); let data = [ ["job_route_loc_route", jobRouteLocationData.routeId], @@ -2127,7 +2127,7 @@ function saveJobRouteLocationToDatabase(jobRouteLocationData) { ]; let dbQuery = null; - if(jobRouteLocationData.databaseId == 0) { + if (jobRouteLocationData.databaseId == 0) { let queryString = createDatabaseInsertQuery("job_route_loc", data); dbQuery = queryDatabase(dbConnection, queryString); jobRouteLocationData.databaseId = getDatabaseInsertId(dbConnection); @@ -2149,19 +2149,19 @@ function saveJobRouteLocationToDatabase(jobRouteLocationData) { // =========================================================================== function saveJobLocationToDatabase(jobLocationData) { - if(jobLocationData == null) { + if (jobLocationData == null) { // Invalid job location data return false; } - if(!jobLocationData.needsSaved) { + if (!jobLocationData.needsSaved) { logToConsole(LOG_DEBUG, `[VRR.Job]: Job location ${jobLocationData.name} (${jobLocationData.databaseId}) doesn't need saved. Skipping ...`); return false; } logToConsole(LOG_DEBUG, `[VRR.Job]: Saving job location ${jobLocationData.databaseId} to database ...`); let dbConnection = connectToDatabase(); - if(dbConnection) { + if (dbConnection) { let data = [ ["job_loc_job", jobLocationData.jobId], ["job_loc_enabled", boolToInt(jobLocationData.enabled)], @@ -2173,7 +2173,7 @@ function saveJobLocationToDatabase(jobLocationData) { ]; let dbQuery = null; - if(jobLocationData.databaseId == 0) { + if (jobLocationData.databaseId == 0) { let queryString = createDatabaseInsertQuery("job_loc", data); dbQuery = queryDatabase(dbConnection, queryString); jobLocationData.databaseId = getDatabaseInsertId(dbConnection); @@ -2196,19 +2196,19 @@ function saveJobLocationToDatabase(jobLocationData) { // =========================================================================== function saveJobEquipmentToDatabase(jobEquipmentData) { - if(jobEquipmentData == null) { + if (jobEquipmentData == null) { // Invalid job equipment data return false; } - if(!jobEquipmentData.needsSaved) { + if (!jobEquipmentData.needsSaved) { logToConsole(LOG_DEBUG, `[VRR.Job]: Job equipment ${jobEquipmentData.name} (${jobEquipmentData.databaseId}) doesn't need saved. Skipping ...`); return false; } logToConsole(LOG_DEBUG, `[VRR.Job]: Saving job equipment ${jobEquipmentData.databaseId} to database ...`); let dbConnection = connectToDatabase(); - if(dbConnection) { + if (dbConnection) { let safeName = escapeDatabaseString(dbConnection, jobEquipmentData.name); let data = [ ["job_equip_job", jobEquipmentData.job], @@ -2218,7 +2218,7 @@ function saveJobEquipmentToDatabase(jobEquipmentData) { ]; let dbQuery = null; - if(tempJobRouteData.databaseId == 0) { + if (tempJobRouteData.databaseId == 0) { let queryString = createDatabaseInsertQuery("job_equip", data); dbQuery = queryDatabase(dbConnection, queryString); jobEquipmentData.databaseId = getDatabaseInsertId(dbConnection); @@ -2240,19 +2240,19 @@ function saveJobEquipmentToDatabase(jobEquipmentData) { // =========================================================================== function saveJobEquipmentItemToDatabase(jobEquipmentItemData) { - if(jobEquipmentItemData == null) { + if (jobEquipmentItemData == null) { // Invalid job equipment weapon data return false; } - if(!jobEquipmentItemData.needsSaved) { + if (!jobEquipmentItemData.needsSaved) { logToConsole(LOG_DEBUG, `[VRR.Job]: Job equipment item ${jobEquipmentItemData.databaseId} doesn't need saved. Skipping ...`); return false; } logToConsole(LOG_DEBUG, `[VRR.Job]: Saving job equipment weapon ${jobEquipmentItemData.databaseId} to database ...`); let dbConnection = connectToDatabase(); - if(dbConnection) { + if (dbConnection) { let data = [ ["job_equip_item_equip", jobEquipmentItemData.equipmentId], ["job_equip_item_enabled", boolToInt(jobEquipmentItemData.enabled)], @@ -2261,7 +2261,7 @@ function saveJobEquipmentItemToDatabase(jobEquipmentItemData) { ]; let dbQuery = null; - if(tempJobRouteData.databaseId == 0) { + if (tempJobRouteData.databaseId == 0) { let queryString = createDatabaseInsertQuery("job_equip_item", data); dbQuery = queryDatabase(dbConnection, queryString); jobEquipmentItemData.databaseId = getDatabaseInsertId(dbConnection); @@ -2283,19 +2283,19 @@ function saveJobEquipmentItemToDatabase(jobEquipmentItemData) { // =========================================================================== function saveJobUniformToDatabase(jobUniformData) { - if(jobUniformData == null) { + if (jobUniformData == null) { // Invalid job uniform data return false; } - if(!jobUniformData.needSaved) { + if (!jobUniformData.needSaved) { logToConsole(LOG_DEBUG, `[VRR.Job]: Job uniform ${jobUniformData.databaseId} doesn't need saved. Skipping ...`); return false; } logToConsole(LOG_DEBUG, `[VRR.Job]: Saving job uniform ${jobUniformData.databaseId} to database ...`); let dbConnection = connectToDatabase(); - if(dbConnection) { + if (dbConnection) { let safeName = escapeDatabaseString(dbConnection, jobUniformData.name); let data = [ ["job_uniform_job", jobUniformData.jobId], @@ -2305,7 +2305,7 @@ function saveJobUniformToDatabase(jobUniformData) { ]; let dbQuery = null; - if(tempJobRouteData.databaseId == 0) { + if (tempJobRouteData.databaseId == 0) { let queryString = createDatabaseInsertQuery("job_uniform", data); dbQuery = queryDatabase(dbConnection, queryString); jobUniformData.databaseId = getDatabaseInsertId(dbConnection); @@ -2327,29 +2327,29 @@ function saveJobUniformToDatabase(jobUniformData) { // =========================================================================== function saveAllJobsToDatabase() { - for(let i in getServerData().jobs) { + for (let i in getServerData().jobs) { saveJobToDatabase(getServerData().jobs[i]); - for(let j in getServerData().jobs[i].locations) { + for (let j in getServerData().jobs[i].locations) { saveJobLocationToDatabase(getServerData().jobs[i].locations[j]); } - for(let k in getServerData().jobs[i].uniforms) { + for (let k in getServerData().jobs[i].uniforms) { saveJobUniformToDatabase(getServerData().jobs[i].uniforms[k]); } - for(let m in getServerData().jobs[i].equipment) { + for (let m in getServerData().jobs[i].equipment) { saveJobEquipmentToDatabase(getServerData().jobs[i].equipment[m]); - for(let n in getServerData().jobs[i].equipment[m].items) { + for (let n in getServerData().jobs[i].equipment[m].items) { saveJobEquipmentItemToDatabase(getServerData().jobs[i].equipment[m].items[n]); } } - for(let p in getServerData().jobs[i].routes) { + for (let p in getServerData().jobs[i].routes) { saveJobRouteToDatabase(getServerData().jobs[i].routes[p]); - for(let q in getServerData().jobs[i].routes[p].locations) { + for (let q in getServerData().jobs[i].routes[p].locations) { saveJobRouteLocationToDatabase(getServerData().jobs[i].routes[p].locations[q]); } } @@ -2359,7 +2359,7 @@ function saveAllJobsToDatabase() { // =========================================================================== function deleteJobLocationBlip(jobId, locationId) { - if(getJobData(jobId).locations[locationId].blip != null) { + if (getJobData(jobId).locations[locationId].blip != null) { deleteGameElement(getJobData(jobId).locations[locationId].blip); getJobData(jobId).locations[locationId].blip = null; } @@ -2368,7 +2368,7 @@ function deleteJobLocationBlip(jobId, locationId) { // =========================================================================== function deleteJobLocationPickup(jobId, locationId) { - if(getServerData().jobs[jobId].locations[locationId].pickup != null) { + if (getServerData().jobs[jobId].locations[locationId].pickup != null) { deleteGameElement(getJobData(jobId).locations[locationId].pickup); getServerData().jobs[jobId].locations[locationId].pickup = null; } @@ -2377,24 +2377,28 @@ function deleteJobLocationPickup(jobId, locationId) { // =========================================================================== function createJobLocationPickup(jobId, locationId) { - if(!getServerConfig().createJobPickups) { + if (!getServerConfig().createJobPickups) { + return false; + } + + if (!isGameFeatureSupported("pickups")) { return false; } let tempJobData = getJobData(jobId); - if(tempJobData.pickupModel != -1) { + if (tempJobData.pickupModel != -1) { let pickupModelId = getGameConfig().pickupModels[getGame()].Job; - if(tempJobData.pickupModel != 0) { + if (tempJobData.pickupModel != 0) { pickupModelId = tempJobData.pickupModel; } logToConsole(LOG_VERBOSE, `[VRR.Job]: Creating pickup for location ${locationId} of the ${tempJobData.name} job`); - if(areServerElementsSupported()) { + if (areServerElementsSupported()) { let pickup = createGamePickup(pickupModelId, tempJobData.locations[locationId].position, getGameConfig().pickupTypes[getGame()].job); - if(pickup != false) { + if (pickup != false) { tempJobData.locations[locationId].pickup = pickup; setElementDimension(pickup, tempJobData.locations[locationId].dimension); setElementOnAllDimensions(pickup, false); @@ -2414,43 +2418,47 @@ function createJobLocationPickup(jobId, locationId) { // =========================================================================== function createJobLocationBlip(jobId, locationId) { - if(!getServerConfig().createJobBlips) { + if (!getServerConfig().createJobBlips) { + return false; + } + + if (!isGameFeatureSupported("blips")) { return false; } let tempJobData = getJobData(jobId); - if(getJobData(jobId).blipModel == -1) { + if (getJobData(jobId).blipModel == -1) { return false; } let blipModelId = getGameConfig().blipSprites[getGame()].Job; - if(getJobData(jobId).blipModel != 0) { + if (getJobData(jobId).blipModel != 0) { blipModelId = getJobData(jobId).blipModel; } - if(areServerElementsSupported()) { + if (areServerElementsSupported()) { let blip = createGameBlip(tempJobData.locations[locationId].position, blipModelId, 1, getColourByName("yellow")); - if(blip != false) { + if (blip != false) { tempJobData.locations[locationId].blip = blip; - if(getGlobalConfig().jobBlipStreamInDistance == -1 || getGlobalConfig().jobBlipStreamOutDistance == -1) { + if (getGlobalConfig().jobBlipStreamInDistance == -1 || getGlobalConfig().jobBlipStreamOutDistance == -1) { blip.netFlags.distanceStreaming = false; } else { - setElementStreamInDistance(getServerData().jobs[i].locations[j].blip, getGlobalConfig().jobBlipStreamInDistance); - setElementStreamOutDistance(getServerData().jobs[i].locations[j].blip, getGlobalConfig().jobBlipStreamOutDistance); + setElementStreamInDistance(blip, getGlobalConfig().jobBlipStreamInDistance); + setElementStreamOutDistance(blip, getGlobalConfig().jobBlipStreamOutDistance); } setElementOnAllDimensions(blip, false); setElementDimension(blip, tempJobData.locations[locationId].dimension); - let clients = getClients(); - for(let i in clients) { - if(getPlayerJob(client) == false) { + let clients = getClients(); + for (let i in clients) { + if (getPlayerJob(client) == false) { showElementForPlayer(blip, clients[i]); } else { - if(getPlayerJob(clients[i]) == getServerData().jobs[i].databaseId) { + if (getPlayerJob(clients[i]) == getServerData().jobs[i].databaseId) { showElementForPlayer(blip, clients[i]); } else { hideElementForPlayer(blip, clients[i]); @@ -2467,8 +2475,8 @@ function createJobLocationBlip(jobId, locationId) { function getPlayerJob(client) { let jobDatabaseId = getPlayerCurrentSubAccount(client).job; - for(let i in getServerData().jobs) { - if(jobDatabaseId == getServerData().jobs[i].databaseId) { + for (let i in getServerData().jobs) { + if (jobDatabaseId == getServerData().jobs[i].databaseId) { return i; } } @@ -2479,7 +2487,7 @@ function getPlayerJob(client) { // =========================================================================== function canPlayerUseJobs(client) { - if(hasBitFlag(getPlayerData(client).accountData.flags.moderation, getServerBitFlags().moderationFlags.JobBanned)) { + if (hasBitFlag(getPlayerData(client).accountData.flags.moderation, getServerBitFlags().moderationFlags.JobBanned)) { return false; } @@ -2489,8 +2497,8 @@ function canPlayerUseJobs(client) { // =========================================================================== function getJobIndexFromDatabaseId(databaseId) { - for(let i in getServerData().jobs) { - if(getServerData().jobs[i].databaseId == databaseId) { + for (let i in getServerData().jobs) { + if (getServerData().jobs[i].databaseId == databaseId) { return i; } } @@ -2506,8 +2514,8 @@ function isJobWhiteListed(jobId) { // =========================================================================== function isPlayerOnJobWhiteList(client, jobId) { - for(let i in getJobData(jobId).whiteList) { - if(getJobData(jobId).whiteList[i].subAccount == getPlayerCurrentSubAccount(client).databaseId) { + for (let i in getJobData(jobId).whiteList) { + if (getJobData(jobId).whiteList[i].subAccount == getPlayerCurrentSubAccount(client).databaseId) { return true; } } @@ -2524,8 +2532,8 @@ function isJobBlackListed(jobId) { // =========================================================================== function isPlayerOnJobBlackList(client, jobId) { - for(let i in getJobData(jobId).blackList) { - if(getJobData(jobId).blackList[i].subAccount == getPlayerCurrentSubAccount(client).databaseId) { + for (let i in getJobData(jobId).blackList) { + if (getJobData(jobId).blackList[i].subAccount == getPlayerCurrentSubAccount(client).databaseId) { return true; } } @@ -2538,24 +2546,24 @@ function isPlayerOnJobBlackList(client, jobId) { function playerArrivedAtJobRouteLocation(client) { let jobId = getPlayerJob(client); - if(!isPlayerOnJobRoute(client)) { + if (!isPlayerOnJobRoute(client)) { return false; } - if(isLastLocationOnJobRoute(jobId, getPlayerJobRoute(client), getPlayerJobRouteLocation(client))) { + if (isLastLocationOnJobRoute(jobId, getPlayerJobRoute(client), getPlayerJobRouteLocation(client))) { finishSuccessfulJobRoute(client); return false; } showGameMessage(client, replaceJobRouteStringsInMessage(removeColoursInMessage(getJobRouteData(jobId, getPlayerJobRoute(client)).locationArriveMessage), jobId, getPlayerJobRoute(client)), getJobData(jobId).colour, 3500); - if(getJobRouteLocationData(jobId, getPlayerJobRoute(client),getPlayerJobRouteLocation(client)).stopDelay > 0) { + if (getJobRouteLocationData(jobId, getPlayerJobRoute(client), getPlayerJobRouteLocation(client)).stopDelay > 0) { freezePlayerJobVehicleForRouteLocation(client); getPlayerData(client).jobRouteLocation = getNextLocationOnJobRoute(jobId, getPlayerJobRoute(client), getPlayerJobRouteLocation(client)); - setTimeout(function() { + setTimeout(function () { showCurrentJobLocation(client); showGameMessage(client, replaceJobRouteStringsInMessage(removeColoursInMessage(getJobRouteData(jobId, getPlayerJobRoute(client)).locationNextMessage), jobId, getPlayerJobRoute(client)), getJobData(jobId).colour, 3500); unFreezePlayerJobVehicleForRouteLocation(client); - }, getJobRouteLocationData(jobId, getPlayerJobRoute(client),getPlayerJobRouteLocation(client)).stopDelay); + }, getJobRouteLocationData(jobId, getPlayerJobRoute(client), getPlayerJobRouteLocation(client)).stopDelay); } else { getPlayerData(client).jobRouteLocation = getNextLocationOnJobRoute(jobId, getPlayerJobRoute(client), getPlayerJobRouteLocation(client)); showCurrentJobLocation(client); @@ -2566,7 +2574,7 @@ function playerArrivedAtJobRouteLocation(client) { // =========================================================================== function deleteJobItems(client) { - for(let i in getPlayerData(client).jobEquipmentCache) { + for (let i in getPlayerData(client).jobEquipmentCache) { deleteItem(getPlayerData(client).jobEquipmentCache[i]); } @@ -2583,7 +2591,7 @@ function getJobRankName(jobId, rankId) { // =========================================================================== function respawnPlayerLastJobVehicle(client) { - if(getPlayerCurrentSubAccount(client).lastJobVehicle == null) { + if (getPlayerCurrentSubAccount(client).lastJobVehicle == null) { return false; } respawnVehicle(getPlayerCurrentSubAccount(client).lastJobVehicle); @@ -2606,7 +2614,7 @@ function resetAllJobPickups() { // =========================================================================== function deleteAllJobBlips() { - for(let i in getServerData().jobs) { + for (let i in getServerData().jobs) { deleteJobBlips(i); } } @@ -2614,7 +2622,7 @@ function deleteAllJobBlips() { // =========================================================================== function deleteAllJobPickups() { - for(let i in getServerData().jobs) { + for (let i in getServerData().jobs) { deleteJobPickups(i); } } @@ -2622,7 +2630,7 @@ function deleteAllJobPickups() { // =========================================================================== function deleteJobBlips(jobId) { - for(let j in getServerData().jobs[jobId].locations) { + for (let j in getServerData().jobs[jobId].locations) { deleteJobLocationBlip(jobId, j); } } @@ -2630,7 +2638,7 @@ function deleteJobBlips(jobId) { // =========================================================================== function deleteJobPickups(jobId) { - for(let j in getServerData().jobs[jobId].locations) { + for (let j in getServerData().jobs[jobId].locations) { deleteJobLocationPickup(jobId, j); } } @@ -2638,7 +2646,7 @@ function deleteJobPickups(jobId) { // =========================================================================== function createJobRouteCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -2646,17 +2654,17 @@ function createJobRouteCommand(command, params, client) { let jobId = getPlayerJob(client); let closestJobLocation = getClosestJobLocation(getPlayerPosition(client), getPlayerDimension(client)); - if(!getJobData(jobId)) { + if (!getJobData(jobId)) { messagePlayerError(client, `You need to take the job that you want to make a route for.`); return false; } - if(!isPlayerWorking(client)) { + if (!isPlayerWorking(client)) { messagePlayerError(client, getLocaleString(client, "NeedToBeWorking", "{ALTCOLOUR}/startwork{MAINCOLOUR}")); return false; } - if(isPlayerOnJobRoute(client)) { + if (isPlayerOnJobRoute(client)) { messagePlayerError(client, getLocaleString(client, "AlreadyOnJobRoute", "{ALTCOLOUR}/startroute{MAINCOLOUR}")); return false; } @@ -2670,24 +2678,24 @@ function createJobRouteCommand(command, params, client) { // =========================================================================== function createJobRouteLocationCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } let jobId = getPlayerJob(client); - if(!getJobData(jobId)) { + if (!getJobData(jobId)) { messagePlayerError(client, `You need to take the job that you want to make a route location for.`); return false; } - if(!isPlayerWorking(client)) { + if (!isPlayerWorking(client)) { messagePlayerError(client, getLocaleString(client, "NeedToBeWorking", "{ALTCOLOUR}/startwork{MAINCOLOUR}")); return false; } - if(!isPlayerOnJobRoute(client)) { + if (!isPlayerOnJobRoute(client)) { messagePlayerError(client, getLocaleString(client, "NeedToBeOnJobRoute", "{ALTCOLOUR}/startroute{MAINCOLOUR}")); return false; } @@ -2704,7 +2712,7 @@ function createJobRouteLocationCommand(command, params, client) { // =========================================================================== function createJobUniformCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -2712,12 +2720,12 @@ function createJobUniformCommand(command, params, client) { let jobId = getJobFromParams(getParam(params, " ", 1)); let skinIndex = getSkinModelIndexFromParams(splitParams.slice(1).join(" "), getGame()); - if(!getJobData(jobId)) { + if (!getJobData(jobId)) { messagePlayerError(client, getLocaleString(client, "InvalidJob")); return false; } - if(!skinIndex) { + if (!skinIndex) { messagePlayerError(client, getLocaleString(client, "InvalidSkin")); return false; } @@ -2748,7 +2756,7 @@ function createJobRoute(routeName, closestJobLocation) { let routeId = getJobData(closestJobLocation.jobIndex).routes.push(tempJobRouteData); saveJobRouteToDatabase(tempJobRouteData); setAllJobDataIndexes(); - return routeId-1; + return routeId - 1; } // =========================================================================== @@ -2787,7 +2795,7 @@ function deleteJobRouteLocationCommand(command, params, client) { messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} deleted route location {ALTCOLOUR}${closestJobRouteLocation.index} (DB ID ${closestJobRouteLocation.databaseId}){MAINCOLOUR} for the {ALTCOLOUR}${closestJobRouteLocation.name}{jobYellow} route of the {jobYellow}${getJobData(closestJobLocation.jobIndex).name}{MAINCOLOUR} job`); - if(closestJobRouteLocation.databaseId > 0) { + if (closestJobRouteLocation.databaseId > 0) { quickDatabaseQuery(`DELETE FROM job_route_loc WHERE job_route_loc_id = ${closestJobRouteLocation.databaseId}`); } @@ -2805,17 +2813,17 @@ function deleteJobRouteCommand(command, params, client) { let jobId = getPlayerJob(client); let jobRoute = getPlayerData(client).jobRoute; - if(!areParamsEmpty(client)) { + if (!areParamsEmpty(client)) { jobRoute = getJobRouteFromParams(params, jobId); } let jobRouteData = getServerData().jobs[jobId].routes[jobRoute]; let clients = getClients(); - for(let i in clients) { - if(isPlayerWorking(clients[i])) { - if(isPlayerOnJobRoute(clients[i])) { - if(getPlayerJob(clients[i]) == jobId && getPlayerData(clients[i]).jobRoute == jobRoute) { + for (let i in clients) { + if (isPlayerWorking(clients[i])) { + if (isPlayerOnJobRoute(clients[i])) { + if (getPlayerJob(clients[i]) == jobId && getPlayerData(clients[i]).jobRoute == jobRoute) { stopJobRoute(clients[i], true, false); messagePlayerAlert(clients[i], getLocaleString(client, "CurrentJobRouteDeleted")); } @@ -2825,7 +2833,7 @@ function deleteJobRouteCommand(command, params, client) { messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} deleted route {ALTCOLOUR}${jobRouteData.name} (DB ID ${jobRouteData.databaseId}){MAINCOLOUR} for the {jobYellow}${getJobData(jobId).name}{MAINCOLOUR} job`); - if(jobRouteData.databaseId > 0) { + if (jobRouteData.databaseId > 0) { quickDatabaseQuery(`DELETE FROM job_route WHERE job_route_id = ${jobRouteData.databaseId}`); quickDatabaseQuery(`DELETE FROM job_route_loc WHERE job_route_loc_route = ${jobRouteData.databaseId}`); } @@ -2843,17 +2851,17 @@ function deleteJobUniformCommand(command, params, client) { let jobId = getJobFromParams(getParam(params, " ", 1)); let uniformIndex = getParam(params, " ", 1); - if(!getJobData(jobId)) { + if (!getJobData(jobId)) { messagePlayerError(client, getLocaleString(client, "InvalidJob")); return false; } - if(isNaN(uniformIndex)) { + if (isNaN(uniformIndex)) { messagePlayerError(client, getLocaleString(client, "MustBeNumber", "uniform ID")); return false; } - if(typeof getJobData(jobId).uniforms[uniformIndex] == "undefined") { + if (typeof getJobData(jobId).uniforms[uniformIndex] == "undefined") { messagePlayerError(client, getLocaleString(client, "InvalidJobUniform")); return false; } @@ -2868,14 +2876,14 @@ function deleteJobUniformCommand(command, params, client) { // =========================================================================== function getJobFromParams(params) { - if(isNaN(params)) { - for(let i in getServerData().jobs) { - if(toLowerCase(getServerData().jobs[i].name).indexOf(toLowerCase(params)) != -1) { + if (isNaN(params)) { + for (let i in getServerData().jobs) { + if (toLowerCase(getServerData().jobs[i].name).indexOf(toLowerCase(params)) != -1) { return i; } } } else { - if(typeof getServerData().jobs[params] != "undefined") { + if (typeof getServerData().jobs[params] != "undefined") { return params; } } @@ -2893,19 +2901,19 @@ function getJobFromParams(params) { function getClosestJobLocation(position, dimension = 0) { let closestJobLocation = false; let jobs = getServerData().jobs; - for(let i in jobs) { + for (let i in jobs) { let locations = jobs[i].locations; - for(let j in locations) { - if(locations[j].dimension != dimension) { + for (let j in locations) { + if (locations[j].dimension != dimension) { let businessId = getClosestBusinessExit(locations[j].position, locations[j].dimension); - if(getBusinessData(businessId) != false) { - if(!closestJobLocation || getBusinessData(businessId).entrancePosition.distance(position) < closestJobLocation.position.distance(position)) { + if (getBusinessData(businessId) != false) { + if (!closestJobLocation || getBusinessData(businessId).entrancePosition.distance(position) < closestJobLocation.position.distance(position)) { closestJobLocation = locations[j]; } } } - if(!closestJobLocation || locations[j].position.distance(position) < closestJobLocation.position.distance(position)) { + if (!closestJobLocation || locations[j].position.distance(position) < closestJobLocation.position.distance(position)) { closestJobLocation = locations[j]; } } @@ -2921,10 +2929,10 @@ function getClosestJobLocation(position, dimension = 0) { */ function getClosestJobRouteLocation(position) { let closestJobRouteLocation = false; - for(let i in getServerData().jobs) { - for(let j in getServerData().jobs[i].routes) { - for(let k in getServerData().jobs[i].routes[j].locations) { - if(!closestJobRouteLocation || getServerData().jobs[i].routes[j].locations[k].position.distance(position) < closestJobRouteLocation.position.distance(position)) { + for (let i in getServerData().jobs) { + for (let j in getServerData().jobs[i].routes) { + for (let k in getServerData().jobs[i].routes[j].locations) { + if (!closestJobRouteLocation || getServerData().jobs[i].routes[j].locations[k].position.distance(position) < closestJobRouteLocation.position.distance(position)) { closestJobRouteLocation = getServerData().jobs[i].routes[j].locations[k]; } } @@ -2954,10 +2962,10 @@ function getPlayerJobVehicle(client) { // =========================================================================== function getRandomJobRouteForLocation(closestJobLocation) { - if(closestJobLocation.routeCache.length > 0) { - let randomRoute = getRandom(0, closestJobLocation.routeCache.length-1); + if (closestJobLocation.routeCache.length > 0) { + let randomRoute = getRandom(0, closestJobLocation.routeCache.length - 1); let routeId = closestJobLocation.routeCache[randomRoute]; - if(!getJobRouteData(closestJobLocation.jobIndex, routeId).enabled) { + if (!getJobRouteData(closestJobLocation.jobIndex, routeId).enabled) { return getRandomJobRouteForLocation(closestJobLocation); } return getJobRouteData(closestJobLocation.jobIndex, routeId).index; @@ -2983,7 +2991,7 @@ function getJobRouteData(jobId, routeId) { * @param {number} routeIndex - The data index of the job route * @return {JobRouteLocationData} The jobroutes's data (class instance) */ - function getJobRouteLocationData(jobId, routeId, routeLocationId) { +function getJobRouteLocationData(jobId, routeId, routeLocationId) { return getServerData().jobs[jobId].routes[routeId].locations[routeLocationId]; } @@ -2991,8 +2999,8 @@ function getJobRouteData(jobId, routeId) { function getClosestJobLocationForJob(position, jobId) { let closestJobLocation = false; - for(let i in getServerData().jobs[jobId].locations) { - if(!closestJobLocation || getServerData().jobs[jobId].locations[i].position.distance(position) < closestJobLocation.position.distance(position)) { + for (let i in getServerData().jobs[jobId].locations) { + if (!closestJobLocation || getServerData().jobs[jobId].locations[i].position.distance(position) < closestJobLocation.position.distance(position)) { closestJobLocation = getServerData().jobs[jobId].locations[i]; } } @@ -3041,17 +3049,17 @@ function finishSuccessfulJobRoute(client) { // =========================================================================== function getNextLocationOnJobRoute(jobId, routeId, currentLocationId) { - if(!isLastLocationOnJobRoute(jobId, routeId, currentLocationId)) { - return currentLocationId+1; + if (!isLastLocationOnJobRoute(jobId, routeId, currentLocationId)) { + return currentLocationId + 1; } else { - return getJobRouteData(jobId, routeId).locations.length-1; + return getJobRouteData(jobId, routeId).locations.length - 1; } } // =========================================================================== function isLastLocationOnJobRoute(jobId, routeId, currentLocationId) { - if(currentLocationId == getJobRouteData(jobId, routeId).locations.length-1) { + if (currentLocationId == getJobRouteData(jobId, routeId).locations.length - 1) { return true; } return false; @@ -3060,14 +3068,14 @@ function isLastLocationOnJobRoute(jobId, routeId, currentLocationId) { // =========================================================================== function getJobRouteFromParams(params, jobId) { - if(isNaN(params)) { - for(let i in getServerData().jobs[jobId].routes) { - if(toLowerCase(getServerData().jobs[jobId].routes[i].name).indexOf(toLowerCase(params)) != -1) { + if (isNaN(params)) { + for (let i in getServerData().jobs[jobId].routes) { + if (toLowerCase(getServerData().jobs[jobId].routes[i].name).indexOf(toLowerCase(params)) != -1) { return i; } } } else { - if(typeof getServerData().jobs[jobId].routes[params] != "undefined") { + if (typeof getServerData().jobs[jobId].routes[params] != "undefined") { return toInteger(params); } } @@ -3098,9 +3106,13 @@ function replaceJobRouteStringsInMessage(messageText, jobId, jobRouteId) { // =========================================================================== function updateJobBlipsForPlayer(client) { - for(let i in getServerData().jobs) { - for(let j in getServerData().jobs[i].locations) { - if(getPlayerJob(client) == 0 || getPlayerJob(client) == i) { + if (!areServerElementsSupported()) { + return false; + } + + for (let i in getServerData().jobs) { + for (let j in getServerData().jobs[i].locations) { + if (getPlayerJob(client) == 0 || getPlayerJob(client) == i) { showElementForPlayer(getServerData().jobs[i].locations[j].blip, client); } else { hideElementForPlayer(getServerData().jobs[i].locations[j].blip, client); diff --git a/scripts/server/locale.js b/scripts/server/locale.js index 966aa1e5..67ef21ff 100644 --- a/scripts/server/locale.js +++ b/scripts/server/locale.js @@ -170,7 +170,7 @@ function setLocaleCommand(command, params, client) { getPlayerData(client).accountData.locale = localeId; getPlayerData(client).locale = localeId; messagePlayerSuccess(client, getLocaleString(client, "LocaleChanged1", getLocaleString(client, "LocaleNativeName"))); - sendPlayerLocaleId(client, localeId); + sendPlayerLocaleStrings(client); } // =========================================================================== @@ -195,7 +195,9 @@ function reloadLocaleConfigurationCommand(command, params, client) { getServerData().cachedTranslationFrom.fill([]); getServerData().cachedTranslations.fill(getServerData().cachedTranslationFrom); - messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} has reloaded the locale settings and texts`); + getGlobalConfig().locale.defaultLanguageId = getLocaleFromParams(getGlobalConfig().locale.defaultLanguage); + + messageAdmins(`${getPlayerName(client)}{MAINCOLOUR} has reloaded the locale settings and texts`); } // =========================================================================== diff --git a/scripts/server/misc.js b/scripts/server/misc.js index 1ae25e1a..86eeefde 100644 --- a/scripts/server/misc.js +++ b/scripts/server/misc.js @@ -35,7 +35,7 @@ function toggleMouseCursorCommand(command, params, client) { // =========================================================================== function toggleMouseCameraCommand(command, params, client) { - if(getGame() != VRR_GAME_GTA_VC) { + if (getGame() != VRR_GAME_GTA_VC) { sendPlayerMouseCameraToggle(client); } return true; @@ -58,12 +58,12 @@ function setNewCharacterSpawnPositionCommand(command, params, client) { // =========================================================================== function setNewCharacterMoneyCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } -let amount = toInteger(getParam(params, " ", 1)) || 1000; + let amount = toInteger(getParam(params, " ", 1)) || 1000; getServerConfig().newCharacter.cash = amount; getServerConfig().needsSaved = true; @@ -75,7 +75,7 @@ let amount = toInteger(getParam(params, " ", 1)) || 1000; // =========================================================================== function setNewCharacterSkinCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -92,7 +92,7 @@ function setNewCharacterSkinCommand(command, params, client) { // =========================================================================== function submitIdeaCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -106,7 +106,7 @@ function submitIdeaCommand(command, params, client) { // =========================================================================== function submitBugReportCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -124,15 +124,15 @@ function enterExitPropertyCommand(command, params, client) { let isEntrance = false; let isBusiness = false; - if(areServerElementsSupported()) { - if(!getPlayerData(client).currentPickup) { + if (areServerElementsSupported()) { + if (!getPlayerData(client).currentPickup) { return false; } let ownerType = getEntityData(getPlayerData(client).currentPickup, "vrr.owner.type"); let ownerId = getEntityData(getPlayerData(client).currentPickup, "vrr.owner.id"); - switch(ownerType) { + switch (ownerType) { case VRR_PICKUP_BUSINESS_ENTRANCE: isBusiness = true; isEntrance = true; @@ -161,8 +161,8 @@ function enterExitPropertyCommand(command, params, client) { return false; } } else { - for(let i in getServerData().businesses) { - if(getPlayerDimension(client) == getGameConfig().mainWorldDimension[getGame()] && getPlayerInterior(client) == getGameConfig().mainWorldInterior[getGame()]) { + for (let i in getServerData().businesses) { + if (getPlayerDimension(client) == getGameConfig().mainWorldDimension[getGame()] && getPlayerInterior(client) == getGameConfig().mainWorldInterior[getGame()]) { let businessId = getClosestBusinessEntrance(getPlayerPosition(client), getPlayerDimension(client)); isBusiness = true; isEntrance = true; @@ -175,8 +175,8 @@ function enterExitPropertyCommand(command, params, client) { } } - for(let j in getServerData().houses) { - if(getPlayerDimension(client) == getGameConfig().mainWorldDimension[getGame()] && getPlayerInterior(client) == getGameConfig().mainWorldInterior[getGame()]) { + for (let j in getServerData().houses) { + if (getPlayerDimension(client) == getGameConfig().mainWorldDimension[getGame()] && getPlayerInterior(client) == getGameConfig().mainWorldInterior[getGame()]) { let houseId = getClosestHouseEntrance(getPlayerPosition(client), getPlayerDimension(client)); isBusiness = false; isEntrance = true; @@ -190,20 +190,20 @@ function enterExitPropertyCommand(command, params, client) { } } - if(closestProperty == null) { + if (closestProperty == null) { return false; } logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)}'s closest door is ${(isBusiness) ? closestProperty.name : closestProperty.description} ${(isEntrance) ? "entrance" : "exit"}`); - if(isEntrance) { - if(getDistance(closestProperty.entrancePosition, getPlayerPosition(client)) <= getGlobalConfig().enterPropertyDistance) { - if(closestProperty.locked) { + if (isEntrance) { + if (getDistance(closestProperty.entrancePosition, getPlayerPosition(client)) <= getGlobalConfig().enterPropertyDistance) { + if (closestProperty.locked) { meActionToNearbyPlayers(client, getLocaleString(client, "EnterExitPropertyDoorLocked", (isBusiness) ? getLocaleString(client, "Business") : getLocaleString(client, "House"))); return false; } - if(!closestProperty.hasInterior) { + if (!closestProperty.hasInterior) { messagePlayerAlert(client, getLocaleString(client, "PropertyNoInterior", (isBusiness) ? getLocaleString(client, "Business") : getLocaleString(client, "House"))); return false; } @@ -212,18 +212,18 @@ function enterExitPropertyCommand(command, params, client) { getPlayerData(client).pedState = VRR_PEDSTATE_ENTERINGPROPERTY; meActionToNearbyPlayers(client, getLocaleString(client, "EntersProperty", (isBusiness) ? getLocaleString(client, "Business") : getLocaleString(client, "House"))); - if(isFadeCameraSupported()) { + if (isFadeCameraSupported()) { fadeCamera(client, false, 1.0); } - setTimeout(function() { + setTimeout(function () { setPlayerInCutsceneInterior(client, closestProperty.exitCutscene); - setPlayerPosition(client, closestProperty.exitPosition); - setPlayerHeading(client, closestProperty.exitRotation); setPlayerDimension(client, closestProperty.exitDimension); setPlayerInterior(client, closestProperty.exitInterior); - setTimeout(function() { - if(isFadeCameraSupported()) { + setPlayerPosition(client, closestProperty.exitPosition); + setPlayerHeading(client, closestProperty.exitRotation); + setTimeout(function () { + if (isFadeCameraSupported()) { fadeCamera(client, true, 1.0); } updateInteriorLightsForPlayer(client, closestProperty.interiorLights); @@ -231,8 +231,8 @@ function enterExitPropertyCommand(command, params, client) { //setPlayerInCutsceneInterior(client, closestProperty.exitCutscene); //updateAllInteriorVehiclesForPlayer(client, closestProperty.exitInterior, closestProperty.exitDimension); }, 1100); - if(closestProperty.streamingRadioStation != -1) { - if(getRadioStationData(closestProperty.streamingRadioStation)) { + if (closestProperty.streamingRadioStation != -1) { + if (getRadioStationData(closestProperty.streamingRadioStation)) { playRadioStreamForPlayer(client, getRadioStationData(closestProperty.streamingRadioStation).url); getPlayerData(client).streamingRadioStation = closestProperty.streamingRadioStation; } @@ -240,8 +240,8 @@ function enterExitPropertyCommand(command, params, client) { return true; } } else { - if(getDistance(closestProperty.exitPosition, getPlayerPosition(client)) <= getGlobalConfig().exitPropertyDistance) { - if(closestProperty.locked) { + if (getDistance(closestProperty.exitPosition, getPlayerPosition(client)) <= getGlobalConfig().exitPropertyDistance) { + if (closestProperty.locked) { meActionToNearbyPlayers(client, getLocaleString(client, "EnterExitPropertyDoorLocked", (isBusiness) ? getLocaleString(client, "Business") : getLocaleString(client, "House"))); return false; } @@ -249,19 +249,19 @@ function enterExitPropertyCommand(command, params, client) { clearPlayerStateToEnterExitProperty(client) meActionToNearbyPlayers(client, getLocaleString(client, "ExitsProperty", (isBusiness) ? getLocaleString(client, "Business") : getLocaleString(client, "House"))); - if(isFadeCameraSupported()) { + if (isFadeCameraSupported()) { fadeCamera(client, false, 1.0); } disableCityAmbienceForPlayer(client, true); - setTimeout(function() { + setTimeout(function () { setPlayerInCutsceneInterior(client, closestProperty.entranceCutscene); setPlayerPosition(client, closestProperty.entrancePosition); setPlayerHeading(client, closestProperty.entranceRotation); setPlayerDimension(client, closestProperty.entranceDimension); setPlayerInterior(client, closestProperty.entranceInterior); - setTimeout(function() { - if(isFadeCameraSupported()) { + setTimeout(function () { + if (isFadeCameraSupported()) { fadeCamera(client, true, 1.0); } @@ -285,11 +285,11 @@ function enterExitPropertyCommand(command, params, client) { function getPlayerInfoCommand(command, params, client) { let targetClient = client; - if(!areParamsEmpty(params)) { - if(doesPlayerHaveStaffPermission(client, getStaffFlagValue("BasicModeration"))) { + if (!areParamsEmpty(params)) { + if (doesPlayerHaveStaffPermission(client, getStaffFlagValue("BasicModeration"))) { targetClient = getPlayerFromParams(params); - if(!getPlayerData(targetClient)) { + if (!getPlayerData(targetClient)) { messagePlayerError(client, getLocaleString(client, "InvalidPlayer")); return false; } @@ -317,7 +317,7 @@ function getPlayerInfoCommand(command, params, client) { let stats = tempStats.map(stat => `{MAINCOLOUR}${stat[0]}: {ALTCOLOUR}${stat[1]}{MAINCOLOUR}`); let chunkedList = splitArrayIntoChunks(stats, 6); - for(let i in chunkedList) { + for (let i in chunkedList) { messagePlayerInfo(client, chunkedList[i].join(", ")); } } @@ -325,7 +325,7 @@ function getPlayerInfoCommand(command, params, client) { // =========================================================================== function playerChangeAFKState(client, afkState) { - if(!getPlayerData(client)) { + if (!getPlayerData(client)) { return false; } @@ -337,12 +337,12 @@ function playerChangeAFKState(client, afkState) { function checkPlayerSpawning() { let clients = getClients(); - for(let i in clients) { - if(!isConsole(clients[i])) { - if(getPlayerData(clients[i])) { - if(isPlayerLoggedIn(clients[i])) { - if(!getPlayerData(clients[i]).ped) { - if(clients[i].player != null) { + for (let i in clients) { + if (!isConsole(clients[i])) { + if (getPlayerData(clients[i])) { + if (isPlayerLoggedIn(clients[i])) { + if (!getPlayerData(clients[i]).ped) { + if (clients[i].player != null) { //getPlayerData(clients[i]).ped = clients[i].player; onPlayerSpawn(clients[i].player); } @@ -356,7 +356,7 @@ function checkPlayerSpawning() { // =========================================================================== function showPlayerPrompt(client, promptMessage, promptTitle, yesButtonText, noButtonText) { - if(canPlayerUseGUI(client)) { + if (canPlayerUseGUI(client)) { showPlayerPromptGUI(client, promptMessage, promptTitle, yesButtonText, noButtonText); } else { messagePlayerNormal(client, `❓ ${promptMessage}`); @@ -376,7 +376,7 @@ function showPlayerPrompt(client, promptMessage, promptTitle, yesButtonText, noB * */ function updateServerGameTime() { - if(isTimeSupported()) { + if (isTimeSupported()) { game.time.hour = getServerConfig().hour; game.time.minute = getServerConfig().minute; } @@ -399,10 +399,10 @@ function listOnlineAdminsCommand(command, params, client) { let admins = []; let clients = getClients(); - for(let i in clients) { - if(getPlayerData(clients[i])) { - if(typeof getPlayerData(clients[i]).accountData.flags.admin != "undefined") { - if(getPlayerData(clients[i]).accountData.flags.admin > 0 || getPlayerData(clients[i]).accountData.flags.admin == -1) { + for (let i in clients) { + if (getPlayerData(clients[i])) { + if (typeof getPlayerData(clients[i]).accountData.flags.admin != "undefined") { + if (getPlayerData(clients[i]).accountData.flags.admin > 0 || getPlayerData(clients[i]).accountData.flags.admin == -1) { admins.push(`{ALTCOLOUR}[${getPlayerData(clients[i]).accountData.staffTitle}] {MAINCOLOUR}${getCharacterFullName(clients[i])}`); } } @@ -410,7 +410,7 @@ function listOnlineAdminsCommand(command, params, client) { } let chunkedList = splitArrayIntoChunks(admins, 3); - for(let i in chunkedList) { + for (let i in chunkedList) { messagePlayerInfo(client, chunkedList[i].join(", ")); } } @@ -433,7 +433,7 @@ function gpsCommand(command, params, client) { let useType = VRR_ITEM_USETYPE_NONE; let blipColour = "white"; - switch(toLowerCase(params)) { + switch (toLowerCase(params)) { case "police": case "policestation": blipColour = "mediumGrey" @@ -512,32 +512,32 @@ function gpsCommand(command, params, client) { default: { let itemTypeId = getItemTypeFromParams(params); - if(getItemTypeData(itemTypeId) != false) { + if (getItemTypeData(itemTypeId) != false) { locationType = VRR_GPS_TYPE_BUSINESS; blipColour = "mediumGrey"; useType = getItemTypeData(itemTypeId).useType; } else { let gameLocationId = getGameLocationFromParams(params); - if(gameLocationId != false) { + if (gameLocationId != false) { position = getGameConfig().locations[getGame()][gameLocationId][1] } } } } - if(locationType == VRR_GPS_TYPE_NONE) { + if (locationType == VRR_GPS_TYPE_NONE) { messagePlayerError(client, getLocaleString(client, "InvalidGPSLocation")); return false; } - if(locationType == VRR_GPS_TYPE_BUSINESS) { + if (locationType == VRR_GPS_TYPE_BUSINESS) { let businessId = getClosestBusinessWithBuyableItemOfUseType(useType); - if(!businessId) { + if (!businessId) { messagePlayerError(client, getLocaleString(client, "NoBusinessWithItemType")); return false; } - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "NoBusinessWithItemType")); return false; } @@ -547,7 +547,7 @@ function gpsCommand(command, params, client) { messagePlayerSuccess(client, "Look for the blinking icon on your mini map"); } - if(locationType == VRR_GPS_TYPE_GAMELOC) { + if (locationType == VRR_GPS_TYPE_GAMELOC) { hideAllBlipsForPlayerGPS(client); blinkGenericGPSBlipForPlayer(client, position, 0, getColourByType(blipColour), 10); messagePlayerSuccess(client, "Look for the blinking icon on your mini map"); @@ -567,7 +567,7 @@ function gpsCommand(command, params, client) { * */ function stuckPlayerCommand(command, params, client) { - if((getCurrentUnixTimestamp()-getPlayerData(client).lastStuckCommand) < getGlobalConfig().stuckCommandInterval) { + if ((getCurrentUnixTimestamp() - getPlayerData(client).lastStuckCommand) < getGlobalConfig().stuckCommandInterval) { messagePlayerError(client, "CantUseCommandYet"); return false; } @@ -577,8 +577,8 @@ function stuckPlayerCommand(command, params, client) { messagePlayerAlert(client, getLocaleString(client, "FixingStuck")); - if(getGameConfig().skinChangePosition[getGame()].length > 0) { - if(getPlayerData(client).returnToPosition != null && getPlayerData(client).returnToType == VRR_RETURNTO_TYPE_SKINSELECT) { + if (getGameConfig().skinChangePosition[getGame()].length > 0) { + if (getPlayerData(client).returnToPosition != null && getPlayerData(client).returnToType == VRR_RETURNTO_TYPE_SKINSELECT) { messagePlayerAlert(client, "You canceled the skin change."); restorePlayerCamera(client); @@ -601,10 +601,10 @@ function stuckPlayerCommand(command, params, client) { // return false; //} - if(dimension > 0) { + if (dimension > 0) { let businesses = getServerData().businesses; - for(let i in businesses) { - if(businesses[i].exitDimension == dimension) { + for (let i in businesses) { + if (businesses[i].exitDimension == dimension) { setPlayerPosition(client, businesses[i].entrancePosition); setPlayerDimension(client, businesses[i].entranceDimension); setPlayerInterior(client, businesses[i].entranceInterior); @@ -614,8 +614,8 @@ function stuckPlayerCommand(command, params, client) { } let houses = getServerData().houses; - for(let i in houses) { - if(houses[i].exitDimension == dimension) { + for (let i in houses) { + if (houses[i].exitDimension == dimension) { setPlayerPosition(client, houses[i].entrancePosition); setPlayerDimension(client, houses[i].entranceDimension); setPlayerInterior(client, houses[i].entranceInterior); @@ -646,7 +646,7 @@ function stuckPlayerCommand(command, params, client) { * */ function playerPedSpeakCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -666,15 +666,15 @@ function playerPedSpeakCommand(command, params, client) { * */ function lockCommand(command, params, client) { - if(isPlayerInAnyVehicle(client)) { + if (isPlayerInAnyVehicle(client)) { let vehicle = getPlayerVehicle(client); - if(!getVehicleData(vehicle)) { + if (!getVehicleData(vehicle)) { messagePlayerError(client, getLocaleString(client, "RandomVehicleCommandsDisabled")); return false; } - if(!isPlayerInFrontVehicleSeat(client)) { + if (!isPlayerInFrontVehicleSeat(client)) { messagePlayerError(client, getLocaleString(client, "MustBeInVehicleFrontSeat")); return false; } @@ -687,13 +687,13 @@ function lockCommand(command, params, client) { return true; } else { let vehicle = getClosestVehicle(getPlayerPosition(client)); - if(getDistance(getPlayerPosition(client), getVehiclePosition(vehicle)) <= getGlobalConfig().vehicleLockDistance) { - if(!getVehicleData(vehicle)) { + if (getDistance(getPlayerPosition(client), getVehiclePosition(vehicle)) <= getGlobalConfig().vehicleLockDistance) { + if (!getVehicleData(vehicle)) { messagePlayerError(client, getLocaleString(client, "RandomVehicleCommandsDisabled")); return false; } - if(!doesPlayerHaveVehicleKeys(client, vehicle)) { + if (!doesPlayerHaveVehicleKeys(client, vehicle)) { messagePlayerError(client, getLocaleString(client, "DontHaveVehicleKey")); return false; } @@ -708,8 +708,8 @@ function lockCommand(command, params, client) { } let businessId = getPlayerBusiness(client); - if(businessId != -1) { - if(!canPlayerManageBusiness(client, businessId)) { + if (businessId != -1) { + if (!canPlayerManageBusiness(client, businessId)) { messagePlayerError(client, getLocaleString(client, "CantModifyBusiness")); return false; } @@ -723,8 +723,8 @@ function lockCommand(command, params, client) { } let houseId = getPlayerHouse(client); - if(houseId != -1) { - if(!canPlayerManageHouse(client, houseId)) { + if (houseId != -1) { + if (!canPlayerManageHouse(client, houseId)) { messagePlayerError(client, getLocaleString(client, "CantModifyHouse")); return false; } @@ -750,16 +750,16 @@ function lockCommand(command, params, client) { * @return {bool} Whether or not the command was successful * */ - function lightsCommand(command, params, client) { - if(isPlayerInAnyVehicle(client)) { +function lightsCommand(command, params, client) { + if (isPlayerInAnyVehicle(client)) { let vehicle = getPlayerVehicle(client); - if(!getVehicleData(vehicle)) { + if (!getVehicleData(vehicle)) { messagePlayerError(client, getLocaleString(client, "RandomVehicleCommandsDisabled")); return false; } - if(!isPlayerInFrontVehicleSeat(client)) { + if (!isPlayerInFrontVehicleSeat(client)) { messagePlayerError(client, getLocaleString(client, "MustBeInVehicleFrontSeat")); return false; } @@ -797,8 +797,8 @@ function lockCommand(command, params, client) { */ let businessId = getPlayerBusiness(client); - if(businessId != -1) { - if(!canPlayerManageBusiness(client, businessId)) { + if (businessId != -1) { + if (!canPlayerManageBusiness(client, businessId)) { messagePlayerError(client, getLocaleString(client, "CantModifyBusiness")); return false; } @@ -807,8 +807,8 @@ function lockCommand(command, params, client) { getBusinessData(businessId).needsSaved = true; let clients = getClients(); - for(let i in clients) { - if(getPlayerBusiness(client) == getPlayerBusiness(clients[i]) && getPlayerDimension(clients[i]) == getBusinessData(businessId).exitDimension) { + for (let i in clients) { + if (getPlayerBusiness(client) == getPlayerBusiness(clients[i]) && getPlayerDimension(clients[i]) == getBusinessData(businessId).exitDimension) { updateInteriorLightsForPlayer(clients[i], getBusinessData(businessId).interiorLights); } } @@ -818,8 +818,8 @@ function lockCommand(command, params, client) { } let houseId = getPlayerHouse(client); - if(houseId != -1) { - if(!canPlayerManageHouse(client, houseId)) { + if (houseId != -1) { + if (!canPlayerManageHouse(client, houseId)) { messagePlayerError(client, getLocaleString(client, "CantModifyHouse")); return false; } @@ -828,8 +828,8 @@ function lockCommand(command, params, client) { getHouseData(houseId).needsSaved = true; let clients = getClients(); - for(let i in clients) { - if(getPlayerHouse(client) == getPlayerHouse(clients[i]) && getPlayerDimension(clients[i]) == getHouseData(houseId).exitDimension) { + for (let i in clients) { + if (getPlayerHouse(client) == getPlayerHouse(clients[i]) && getPlayerDimension(clients[i]) == getHouseData(houseId).exitDimension) { updateInteriorLightsForPlayer(clients[i], getHouseData(houseId).interiorLights); } } @@ -838,4 +838,53 @@ function lockCommand(command, params, client) { return true; } } -} \ No newline at end of file +} + +// =========================================================================== + +function resetPlayerBlip(client) { + deletePlayerBlip(client); + createPlayerBlip(client); +} + +// =========================================================================== + +function createPlayerBlip(client) { + if (!areServerElementsSupported()) { + return false; + } + + if (!isGameFeatureSupported("attachedBlips")) { + return false; + } + + if (getServerConfig().createPlayerBlips) { + return false; + } + + let blip = createAttachedGameBlip(getPlayerPed(client), 0, 1, getPlayerColour(client)); + if (blip) { + if (getGlobalConfig().playerBlipStreamInDistance == -1 || getGlobalConfig().playerBlipStreamOutDistance == -1) { + blip.netFlags.distanceStreaming = false; + } else { + setElementStreamInDistance(blip, getGlobalConfig().playerBlipStreamInDistance); + setElementStreamOutDistance(blip, getGlobalConfig().playerBlipStreamOutDistance); + } + getPlayerData(client).playerBlip = blip; + } +} + +// =========================================================================== + +function deletePlayerBlip(client) { + if (!isGameFeatureSupported("attachedBlips")) { + return false; + } + + if (getPlayerData(client).playerBlip != null) { + deleteGameElement(getPlayerData(client).playerBlip); + getPlayerData(client).playerBlip = null; + } +} + +// =========================================================================== \ No newline at end of file diff --git a/scripts/server/native/connected.js b/scripts/server/native/connected.js index 34ef4254..5892ae69 100644 --- a/scripts/server/native/connected.js +++ b/scripts/server/native/connected.js @@ -40,10 +40,10 @@ let disconnectReasons = [ // =========================================================================== function getPlayerPosition(client) { - if(!areServerElementsSupported()) { + if (!areServerElementsSupported()) { return getPlayerData(client).syncPosition; } else { - if(getPlayerPed(client) != null) { + if (getPlayerPed(client) != null) { return getPlayerPed(client).position; } } @@ -59,10 +59,10 @@ function setPlayerPosition(client, position) { // =========================================================================== function getPlayerHeading(client) { - if(!areServerElementsSupported()) { + if (!areServerElementsSupported()) { return getPlayerData(client).syncHeading; } else { - if(getPlayerPed(client) != null) { + if (getPlayerPed(client) != null) { return getPlayerPed(client).heading; } } @@ -78,10 +78,10 @@ function setPlayerHeading(client, heading) { // =========================================================================== function getPlayerVehicle(client) { - if(!areServerElementsSupported()) { + if (!areServerElementsSupported()) { return getPlayerData().syncVehicle; } else { - if(getPlayerPed(client).vehicle) { + if (getPlayerPed(client).vehicle) { return getPlayerPed(client).vehicle; } } @@ -91,10 +91,10 @@ function getPlayerVehicle(client) { // =========================================================================== function getPlayerDimension(client) { - if(!areServerElementsSupported()) { + if (!areServerElementsSupported()) { return getPlayerData(client).syncDimension; } else { - if(getPlayerPed(client) != null) { + if (getPlayerPed(client) != null) { return getPlayerPed(client).dimension; } } @@ -110,10 +110,10 @@ function getPlayerInterior(client) { function setPlayerDimension(client, dimension) { logToConsole(LOG_VERBOSE, `Setting ${getPlayerDisplayForConsole(client)}'s dimension to ${dimension}`); - if(!areServerElementsSupported()) { + if (!areServerElementsSupported()) { getPlayerData(client).syncDimension = dimension; } else { - if(getPlayerPed(client) != null) { + if (getPlayerPed(client) != null) { getPlayerPed(client).dimension = dimension; } } @@ -124,7 +124,7 @@ function setPlayerDimension(client, dimension) { function setPlayerInterior(client, interior) { logToConsole(LOG_VERBOSE, `Setting ${getPlayerDisplayForConsole(client)}'s interior to ${interior}`); sendPlayerSetInterior(client, interior); - if(isPlayerLoggedIn(client) && isPlayerSpawned(client)) { + if (isPlayerLoggedIn(client) && isPlayerSpawned(client)) { getPlayerCurrentSubAccount(client).interior = interior; } } @@ -132,7 +132,7 @@ function setPlayerInterior(client, interior) { // =========================================================================== function isPlayerInAnyVehicle(client) { - if(!areServerElementsSupported()) { + if (!areServerElementsSupported()) { return (getPlayerData().syncVehicle != null); } else { return (getPlayerPed(client).vehicle != null); @@ -142,15 +142,15 @@ function isPlayerInAnyVehicle(client) { // =========================================================================== function getPlayerVehicleSeat(client) { - if(!isPlayerInAnyVehicle(client)) { + if (!isPlayerInAnyVehicle(client)) { return false; } - if(!areServerElementsSupported()) { + if (!areServerElementsSupported()) { return getPlayerData().syncVehicleSeat; } else { - for(let i = 0 ; i <= 8 ; i++) { - if(getPlayerVehicle(client).getOccupant(i) == getPlayerPed(client)) { + for (let i = 0; i <= 8; i++) { + if (getPlayerVehicle(client).getOccupant(i) == getPlayerPed(client)) { return i; } } @@ -180,7 +180,7 @@ function getVehicleHeading(vehicle) { // =========================================================================== function setVehicleHeading(vehicle, heading) { - if(getGame() == VRR_GAME_GTA_IV) { + if (getGame() == VRR_GAME_GTA_IV) { return sendNetworkEventToPlayer("vrr.vehPosition", null, getVehicleForNetworkEvent(vehicle), heading); } return vehicle.heading = heading; @@ -189,20 +189,20 @@ function setVehicleHeading(vehicle, heading) { // =========================================================================== function getElementTransient(element) { - if(typeof element.transient != "undefined") { + if (typeof element.transient != "undefined") { return element.transient; } - return false; + return false; } // =========================================================================== function setElementTransient(element, state) { - if(typeof element.transient != "undefined") { + if (typeof element.transient != "undefined") { element.transient = state; return true; } - return false; + return false; } // =========================================================================== @@ -214,8 +214,8 @@ function getVehicleSyncer(vehicle) { // =========================================================================== function getVehicleForNetworkEvent(vehicle) { - if(getGame() == VRR_GAME_GTA_IV) { - if(getVehicleData(vehicle).ivNetworkId != -1) { + if (getGame() == VRR_GAME_GTA_IV) { + if (getVehicleData(vehicle).ivNetworkId != -1) { return getVehicleData(vehicle).ivNetworkId; } return -1; @@ -227,11 +227,11 @@ function getVehicleForNetworkEvent(vehicle) { function deleteGameElement(element) { try { - if(element != null) { + if (element != null) { destroyElement(element); return true; } - } catch(error) { + } catch (error) { return false; } } @@ -254,7 +254,7 @@ function removePlayerFromVehicle(client) { function setPlayerSkin(client, skinIndex) { logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s skin to ${getGameConfig().skins[getGame()][skinIndex][0]} (Index: ${skinIndex}, Name: ${getGameConfig().skins[getGame()][skinIndex][1]})`); - if(getGame() == VRR_GAME_GTA_IV) { + if (getGame() == VRR_GAME_GTA_IV) { triggerNetworkEvent("vrr.localPlayerSkin", client, getGameConfig().skins[getGame()][skinIndex][0]); } else { getPlayerPed(client).modelIndex = getGameConfig().skins[getGame()][skinIndex][0]; @@ -292,7 +292,7 @@ function setPlayerArmour(client, armour) { // =========================================================================== function getPlayerArmour(client) { - if(areServerElementsSupported(client)) { + if (areServerElementsSupported(client)) { return getPlayerPed(client).armour; } else { return getPlayerData(client).syncArmour; @@ -302,11 +302,11 @@ function getPlayerArmour(client) { // =========================================================================== function setPlayerCash(client, amount) { - if(client == null) { + if (client == null) { return false; } - if(isNaN(amount)) { + if (isNaN(amount)) { return false; } @@ -317,11 +317,11 @@ function setPlayerCash(client, amount) { // =========================================================================== function givePlayerCash(client, amount) { - if(client == null) { + if (client == null) { return false; } - if(isNaN(amount)) { + if (isNaN(amount)) { return false; } @@ -332,11 +332,11 @@ function givePlayerCash(client, amount) { // =========================================================================== function takePlayerCash(client, amount) { - if(client == null) { + if (client == null) { return false; } - if(isNaN(amount)) { + if (isNaN(amount)) { return false; } @@ -368,7 +368,7 @@ function getPlayerWeaponAmmo(client) { function setPlayerVelocity(client, velocity) { logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s velocity to ${velocity.x}, ${velocity.y}, ${velocity.z}`); - if(typeof getPlayerPed(client).velocity != "undefined") { + if (typeof getPlayerPed(client).velocity != "undefined") { getPlayerPed(client).velocity = velocity; } } @@ -376,7 +376,7 @@ function setPlayerVelocity(client, velocity) { // =========================================================================== function getPlayerVelocity(client) { - if(typeof getPlayerPed(client).velocity != "undefined") { + if (typeof getPlayerPed(client).velocity != "undefined") { return getPlayerPed(client).velocity; } return toVector3(0.0, 0.0, 0.0); @@ -385,7 +385,7 @@ function getPlayerVelocity(client) { // =========================================================================== function getElementDimension(element) { - if(typeof element.dimension != "undefined") { + if (typeof element.dimension != "undefined") { return element.dimension; } return 0; @@ -394,18 +394,18 @@ function getElementDimension(element) { // =========================================================================== function setElementDimension(element, dimension) { - if(typeof element.dimension != "undefined") { + if (typeof element.dimension != "undefined") { logToConsole(LOG_VERBOSE, `Setting element ${element} (${element.id}) dimension to ${dimension}`); - element.dimension = dimension; - return true; - } - return false; + element.dimension = dimension; + return true; + } + return false; } // =========================================================================== function setElementRotation(element, rotation) { - if(typeof element.setRotation != "undefined") { + if (typeof element.setRotation != "undefined") { element.setRotation(rotation); } else { return element.rotation = rotation; @@ -415,24 +415,24 @@ function setElementRotation(element, rotation) { // =========================================================================== function givePlayerHealth(client, amount) { - if(getPlayerHealth(client)+amount > 100) { + if (getPlayerHealth(client) + amount > 100) { logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s health to 100`); setPlayerHealth(client, 100); } else { - logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s health to ${getPlayerHealth(client)+amount}`); - setPlayerHealth(client, getPlayerHealth(client)+amount); + logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s health to ${getPlayerHealth(client) + amount}`); + setPlayerHealth(client, getPlayerHealth(client) + amount); } } // =========================================================================== function givePlayerArmour(client, amount) { - if(getPlayerArmour(client)+amount > 100) { + if (getPlayerArmour(client) + amount > 100) { logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s armour to 100`); setPlayerArmour(client, 100); } else { - logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s armour to ${getPlayerArmour(client)+amount}`); - setPlayerArmour(client, getPlayerArmour(client)+amount); + logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s armour to ${getPlayerArmour(client) + amount}`); + setPlayerArmour(client, getPlayerArmour(client) + amount); } } @@ -469,7 +469,7 @@ function getServerName() { // =========================================================================== function createGamePickup(modelIndex, position, type) { - if(!isGameFeatureSupported("pickups")) { + if (!isGameFeatureSupported("pickups")) { return false; } return game.createPickup(modelIndex, position, type); @@ -478,7 +478,7 @@ function createGamePickup(modelIndex, position, type) { // =========================================================================== function createGameBlip(position, type = 0, size = 1, colour = toColour(255, 255, 255, 255)) { - if(!isGameFeatureSupported("blips")) { + if (!isGameFeatureSupported("blips")) { return false; } return game.createBlip(type, position, size, colour); @@ -487,7 +487,7 @@ function createGameBlip(position, type = 0, size = 1, colour = toColour(255, 255 // =========================================================================== function createGameObject(modelIndex, position) { - if(!isGameFeatureSupported("objects")) { + if (!isGameFeatureSupported("objects")) { return false; } return game.createObject(getGameConfig().objects[getGame()][modelIndex][0], position); @@ -496,13 +496,13 @@ function createGameObject(modelIndex, position) { // =========================================================================== function setElementOnAllDimensions(element, state) { - if(!isNull(element) && element != false) { - if(typeof element.netFlags != "undefined") { - if(typeof element.netFlags.onAllDimensions != "undefined") { + if (!isNull(element) && element != false) { + if (typeof element.netFlags != "undefined") { + if (typeof element.netFlags.onAllDimensions != "undefined") { element.netFlags.onAllDimensions = state; } } else { - if(typeof element.onAllDimensions != "undefined") { + if (typeof element.onAllDimensions != "undefined") { element.onAllDimensions = state; } } @@ -512,7 +512,7 @@ function setElementOnAllDimensions(element, state) { // =========================================================================== function destroyGameElement(element) { - if(!isNull(element) && element != false) { + if (!isNull(element) && element != false) { destroyElement(element); } } @@ -532,7 +532,7 @@ function getPlayerLastVehicle(client) { // =========================================================================== function isVehicleObject(vehicle) { - if(vehicle == null || vehicle == undefined) { + if (vehicle == null || vehicle == undefined) { return false; } return (vehicle.type == ELEMENT_VEHICLE); @@ -600,11 +600,11 @@ function setVehicleColours(vehicle, colour1, colour2, colour3 = -1, colour4 = -1 vehicle.colour1 = colour1; vehicle.colour2 = colour2; - if(colour3 != -1) { + if (colour3 != -1) { vehicle.colour3 = colour3; } - if(colour4 != -1) { + if (colour4 != -1) { vehicle.colour4 = colour4; } } @@ -612,7 +612,7 @@ function setVehicleColours(vehicle, colour1, colour2, colour3 = -1, colour4 = -1 // =========================================================================== function createGameVehicle(modelIndex, position, heading, toClient = null) { - if(areServerElementsSupported()) { + if (areServerElementsSupported()) { return game.createVehicle(getGameConfig().vehicles[getGame()][modelIndex][0], position, heading); } } @@ -620,9 +620,9 @@ function createGameVehicle(modelIndex, position, heading, toClient = null) { // =========================================================================== function createGamePed(modelIndex, position, heading, toClient = null) { - if(areServerElementsSupported()) { + if (areServerElementsSupported()) { let ped = game.createPed(getGameConfig().skins[getGame()][modelIndex][0], position); - if(ped) { + if (ped) { //ped.position = position; ped.heading = heading; return ped; @@ -635,10 +635,10 @@ function createGamePed(modelIndex, position, heading, toClient = null) { // =========================================================================== function getIsland(position) { - if(getGame() == VRR_GAME_GTA_III) { - if(position.x > 616) { + if (getGame() == VRR_GAME_GTA_III) { + if (position.x > 616) { return VRR_ISLAND_PORTLAND; - } else if(position.x < -283) { + } else if (position.x < -283) { return VRR_ISLAND_SHORESIDEVALE; } return VRR_ISLAND_STAUNTON; @@ -652,7 +652,7 @@ function getIsland(position) { // =========================================================================== function isValidVehicleModel(model) { - if(getVehicleModelIndexFromModel(model) != false) { + if (getVehicleModelIndexFromModel(model) != false) { return true; } @@ -662,7 +662,7 @@ function isValidVehicleModel(model) { // =========================================================================== function setGameTime(hour, minute, minuteDuration = 1000) { - if(isTimeSupported()) { + if (isTimeSupported()) { game.time.hour = hour; game.time.minute = minute; game.time.minuteDuration = minuteDuration; @@ -672,7 +672,7 @@ function setGameTime(hour, minute, minuteDuration = 1000) { // =========================================================================== function setGameWeather(weather) { - if(isWeatherSupported()) { + if (isWeatherSupported()) { mp.world.weather = weather; } } @@ -680,11 +680,11 @@ function setGameWeather(weather) { // =========================================================================== function setPlayerFightStyle(client, fightStyleId) { - if(!isPlayerSpawned(client)) { + if (!isPlayerSpawned(client)) { return false; } - if(!areFightStylesSupported()) { + if (!areFightStylesSupported()) { return false; } @@ -738,7 +738,7 @@ function setElementCollisionsEnabled(element, state) { // =========================================================================== function isTaxiVehicle(vehicle) { - if(taxiModels[getGame()].indexOf(vehicle.modelIndex) != -1) { + if (taxiModels[getGame()].indexOf(vehicle.modelIndex) != -1) { return true; } @@ -755,11 +755,11 @@ function getVehicleName(vehicle) { // =========================================================================== function getElementModel(element) { - if(typeof element.modelIndex != "undefined") { + if (typeof element.modelIndex != "undefined") { return element.modelIndex; } - if(typeof element.model != "undefined") { + if (typeof element.model != "undefined") { return element.model; } } @@ -773,7 +773,7 @@ function givePlayerWeaponAmmo(client, ammo) { // =========================================================================== function getPlayerWeapon(client) { - if(areServerElementsSupported(client)) { + if (areServerElementsSupported(client)) { return getPlayerPed(client).weapon; } else { return getPlayerData(client).syncWeapon; @@ -783,11 +783,11 @@ function getPlayerWeapon(client) { // =========================================================================== function connectToDatabase() { - if(getDatabaseConfig().usePersistentConnection) { - if(persistentDatabaseConnection == null) { + if (getDatabaseConfig().usePersistentConnection) { + if (persistentDatabaseConnection == null) { logToConsole(LOG_DEBUG, `[VRR.Database] Initializing database connection ...`); persistentDatabaseConnection = module.mysql.connect(getDatabaseConfig().host, getDatabaseConfig().user, getDatabaseConfig().pass, getDatabaseConfig().name, getDatabaseConfig().port); - if(persistentDatabaseConnection.error) { + if (persistentDatabaseConnection.error) { logToConsole(LOG_ERROR, `[VRR.Database] Database connection error: ${persistentDatabaseConnection.error}`); persistentDatabaseConnection = null; return false; @@ -801,7 +801,7 @@ function connectToDatabase() { } } else { let databaseConnection = module.mysql.connect(getDatabaseConfig().host, getDatabaseConfig().user, getDatabaseConfig().pass, getDatabaseConfig().name, getDatabaseConfig().port); - if(databaseConnection.error) { + if (databaseConnection.error) { logToConsole(LOG_ERROR, `[VRR.Database] Database connection error: ${persistentDatabaseConnection.error}`); return false; } else { @@ -813,11 +813,11 @@ function connectToDatabase() { // =========================================================================== function disconnectFromDatabase(dbConnection) { - if(!getDatabaseConfig().usePersistentConnection) { + if (!getDatabaseConfig().usePersistentConnection) { try { dbConnection.close(); logToConsole(LOG_DEBUG, `[VRR.Database] Database connection closed successfully`); - } catch(error) { + } catch (error) { logToConsole(LOG_ERROR, `[VRR.Database] Database connection could not be closed! (Error: ${error})`); } } @@ -828,7 +828,7 @@ function disconnectFromDatabase(dbConnection) { function queryDatabase(dbConnection, queryString, useThread = false) { logToConsole(LOG_DEBUG, `[VRR.Database] Query string: ${queryString}`); - if(useThread == true) { + if (useThread == true) { Promise.resolve().then(() => { let queryResult = dbConnection.query(queryString); return queryResult; @@ -841,11 +841,11 @@ function queryDatabase(dbConnection, queryString, useThread = false) { // =========================================================================== function escapeDatabaseString(dbConnection, unsafeString = "") { - if(!dbConnection) { + if (!dbConnection) { dbConnection = connectToDatabase(); } - if(typeof unsafeString == "string") { + if (typeof unsafeString == "string") { return dbConnection.escapeString(unsafeString); } return unsafeString; @@ -872,7 +872,7 @@ function getDatabaseError(dbConnection) { // =========================================================================== function freeDatabaseQuery(dbQuery) { - if(dbQuery != null) { + if (dbQuery != null) { dbQuery.free(); } return; @@ -889,26 +889,26 @@ function fetchQueryAssoc(dbQuery) { function quickDatabaseQuery(queryString) { let dbConnection = connectToDatabase(); let insertId = 0; - if(dbConnection) { + if (dbConnection) { //logToConsole(LOG_DEBUG, `[VRR.Database] Query string: ${queryString}`); let dbQuery = queryDatabase(dbConnection, queryString); - if(getDatabaseInsertId(dbConnection)) { + if (getDatabaseInsertId(dbConnection)) { insertId = getDatabaseInsertId(dbConnection); logToConsole(LOG_DEBUG, `[VRR.Database] Query returned insert id ${insertId}`); } - if(dbQuery) { + if (dbQuery) { try { freeDatabaseQuery(dbQuery); logToConsole(LOG_DEBUG, `[VRR.Database] Query result free'd successfully`); - } catch(error) { + } catch (error) { logToConsole(LOG_ERROR, `[VRR.Database] Query result could not be free'd! (Error: ${error})`); } } disconnectFromDatabase(dbConnection); - if(insertId != 0) { + if (insertId != 0) { return insertId; } @@ -920,26 +920,26 @@ function quickDatabaseQuery(queryString) { // =========================================================================== function executeDatabaseQueryCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } - if(!targetClient) { + if (!targetClient) { messagePlayerError(client, "That player was not found!"); return false; } - if(targetCode == "") { + if (targetCode == "") { messagePlayerError(client, "You didn't enter any code!"); return false; } let success = quickDatabaseQuery(params); - if(!success) { + if (!success) { messagePlayerAlert(client, `Database query failed to execute: {ALTCOLOUR}${query}`); - } else if(typeof success != "boolean") { + } else if (typeof success != "boolean") { messagePlayeSuccess(client, `Database query successful: {ALTCOLOUR}${query}`); messagePlayerInfo(client, `Returns: ${success}`); } else { @@ -953,9 +953,9 @@ function executeDatabaseQueryCommand(command, params, client) { function setConstantsAsGlobalVariablesInDatabase() { let dbConnection = connectToDatabase(); let entries = Object.entries(global); - for(let i in entries) { + for (let i in entries) { logToConsole(LOG_DEBUG, `[VRR.Database] Checking entry ${i} (${entries[i]})`); - if(toString(i).slice(0, 3).indexOf("VRR_") != -1) { + if (toString(i).slice(0, 3).indexOf("VRR_") != -1) { logToConsole(LOG_DEBUG, `[VRR.Database] Adding ${i} (${entries[i]}) to database global variables`); } } @@ -967,13 +967,13 @@ function createDatabaseInsertQuery(tableName, data) { let fields = []; let values = []; - for(let i in data) { - if(data[i][1] != "undefined" && data[i][1] != NaN && data[i][0] != 'NaN') { - if(data[i][1] != "undefined" && data[i][1] != NaN && data[i][1] != 'NaN') { + for (let i in data) { + if (data[i][1] != "undefined" && data[i][1] != NaN && data[i][0] != 'NaN') { + if (data[i][1] != "undefined" && data[i][1] != NaN && data[i][1] != 'NaN') { fields.push(data[i][0]); - if(typeof data[i][1] == "string") { - if(data[i][1] == "{UNIXTIMESTAMP}") { + if (typeof data[i][1] == "string") { + if (data[i][1] == "{UNIXTIMESTAMP}") { values.push("UNIX_TIMESTAMP()"); } else { values.push(`'${data[i][1]}'`); @@ -994,11 +994,11 @@ function createDatabaseInsertQuery(tableName, data) { function createDatabaseUpdateQuery(tableName, data, whereClause) { let values = []; - for(let i in data) { - if(data[i][0] != "undefined" && data[i][0] != NaN && data[i][0] != 'NaN') { - if(data[i][1] != "undefined" && data[i][1] != NaN && data[i][1] != 'NaN') { - if(typeof data[i][1] == "string") { - if(data[i][1] == "{UNIXTIMESTAMP}") { + for (let i in data) { + if (data[i][0] != "undefined" && data[i][0] != NaN && data[i][0] != 'NaN') { + if (data[i][1] != "undefined" && data[i][1] != NaN && data[i][1] != 'NaN') { + if (typeof data[i][1] == "string") { + if (data[i][1] == "{UNIXTIMESTAMP}") { values.push(`${data[i][0]}=UNIX_TIMESTAMP()`); } else { values.push(`${data[i][0]}='${data[i][1]}'`); @@ -1038,8 +1038,8 @@ function getElementId(element) { function getClientFromIndex(index) { let clients = getClients(); - for(let i in clients) { - if(clients[i].index == index) { + for (let i in clients) { + if (clients[i].index == index) { return clients[i]; } } @@ -1078,7 +1078,7 @@ function getClosestCivilian(position) { // =========================================================================== function getVehiclesInRange(position, range) { - if(getGame() == VRR_GAME_GTA_IV) { + if (getGame() == VRR_GAME_GTA_IV) { return getServerData().vehicles.reduce((i, j) => (getDistance(position, i.syncPosition) <= getDistance(position, j.syncPosition)) ? i : j); } return getElementsByTypeInRange(ELEMENT_VEHICLE, position, range); @@ -1093,8 +1093,8 @@ function getClosestElementByType(elementType, position) { // =========================================================================== function getVehicleFirstEmptySeat(vehicle) { - for(let i = 0; i <= 4; i++) { - if(vehicle.getOccupant(i) == null) { + for (let i = 0; i <= 4; i++) { + if (vehicle.getOccupant(i) == null) { return i; } } @@ -1105,8 +1105,8 @@ function getVehicleFirstEmptySeat(vehicle) { // =========================================================================== function isVehicleTrain(vehicle) { - if(getGame() == VRR_GAME_GTA_III) { - if(vehicle.modelIndex == 124) { + if (getGame() == VRR_GAME_GTA_III) { + if (vehicle.modelIndex == 124) { return true; } } @@ -1149,9 +1149,9 @@ function setPlayerWantedLevel(client, wantedLevel) { // =========================================================================== function setElementStreamInDistance(element, distance) { - if(!isNull(element) && element != false) { - if(typeof element == "Entity") { - if(typeof element.streamInDistance != "undefined") { + if (!isNull(element) && element != false) { + if (typeof element == "Entity") { + if (typeof element.streamInDistance != "undefined") { element.streamInDistance = distance; } } @@ -1161,9 +1161,9 @@ function setElementStreamInDistance(element, distance) { // =========================================================================== function setElementStreamOutDistance(element, distance) { - if(!isNull(element) && element != false) { - if(typeof element == "Entity") { - if(typeof element.streamOutDistance != "undefined") { + if (!isNull(element) && element != false) { + if (typeof element == "Entity") { + if (typeof element.streamOutDistance != "undefined") { element.streamOutDistance = distance; } } @@ -1173,7 +1173,7 @@ function setElementStreamOutDistance(element, distance) { // =========================================================================== function getPlayerPed(client) { - if(getGame() == VRR_GAME_GTA_IV) { + if (getGame() == VRR_GAME_GTA_IV) { return getPlayerData(client).ped; } else { return client.player; @@ -1183,8 +1183,8 @@ function getPlayerPed(client) { // =========================================================================== function setEntityData(entity, dataName, dataValue, syncToClients = true) { - if(entity != null) { - if(areServerElementsSupported()) { + if (entity != null) { + if (areServerElementsSupported()) { return entity.setData(dataName, dataValue, syncToClients); } } @@ -1194,8 +1194,8 @@ function setEntityData(entity, dataName, dataValue, syncToClients = true) { // =========================================================================== function removeEntityData(entity, dataName) { - if(entity != null) { - if(areServerElementsSupported()) { + if (entity != null) { + if (areServerElementsSupported()) { return entity.removeData(dataName); } } @@ -1205,8 +1205,8 @@ function removeEntityData(entity, dataName) { // =========================================================================== function doesEntityDataExist(entity, dataName) { - if(entity != null) { - if(areServerElementsSupported()) { + if (entity != null) { + if (areServerElementsSupported()) { return (entity.getData(dataName) != null); } else { return false; @@ -1260,7 +1260,7 @@ function getGame() { // =========================================================================== function getCountryNameFromIP(ip) { - if(module.geoip.getCountryName(ip)) { + if (module.geoip.getCountryName(ip)) { return module.geoip.getCountryName(ip); } return false; @@ -1325,9 +1325,9 @@ function addServerCommandHandler(command, handlerFunction) { // =========================================================================== function addServerEventHandler(eventName, handlerFunction) { - addEventHandler(eventName, function(event, ...args) { + addEventHandler(eventName, function (event, ...args) { let result = handlerFunction.apply(this, args); - if(result == false) { + if (result == false) { event.preventDefault(); } }); @@ -1336,9 +1336,9 @@ function addServerEventHandler(eventName, handlerFunction) { // =========================================================================== function bindServerEventHandler(eventName, bindTo, handlerFunction) { - addEventHandler(eventName, bindTo, function(event, ...args) { + addEventHandler(eventName, bindTo, function (event, ...args) { let result = handlerFunction.apply(this, args); - if(result == false) { + if (result == false) { event.preventDefault(); } }); @@ -1368,4 +1368,12 @@ function setElementShownByDefault(element, state) { element.netFlags.defaultExistance = state; } +// =========================================================================== + +function createAttachedGameBlip(element, type, size, colour = toColour(255, 255, 255, 255)) { + if (isGameFeatureSupported("attachedBlips")) { + return game.createBlipAttachedTo(element, type, size, colour, true, false); + } +} + // =========================================================================== \ No newline at end of file diff --git a/scripts/server/npc.js b/scripts/server/npc.js index bb646408..1efbae9e 100644 --- a/scripts/server/npc.js +++ b/scripts/server/npc.js @@ -19,7 +19,7 @@ function initNPCScript() { * @return {NPCData} The NPC's data (class instancee) */ function getNPCData(npcId) { - if(typeof getServerData().npcs[npcId] != "undefined") { + if (typeof getServerData().npcs[npcId] != "undefined") { return getServerData().npcs[npcId]; } return false; @@ -28,14 +28,14 @@ function getNPCData(npcId) { // =========================================================================== function createNPCCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } let skinIndex = getSkinModelIndexFromParams(params); - if(!skinIndex) { + if (!skinIndex) { messagePlayerError(client, getLocaleString(client, "InvalidSkin")); return false; } @@ -53,11 +53,11 @@ function loadNPCsFromDatabase() { let dbConnection = connectToDatabase(); let tempNPCs = []; let dbAssoc; - if(dbConnection) { + if (dbConnection) { let dbQueryString = `SELECT * FROM npc_main WHERE npc_server = ${getServerId()} AND npc_enabled = 1`; let dbQuery = queryDatabase(dbConnection, dbQueryString); - if(dbQuery) { - while(dbAssoc = fetchQueryAssoc(dbQuery)) { + if (dbQuery) { + while (dbAssoc = fetchQueryAssoc(dbQuery)) { let tempNPCData = new NPCData(dbAssoc); tempNPCData.triggers = loadNPCTriggersFromDatabase(tempNPCData.databaseId); tempNPCs.push(tempNPCData); @@ -78,11 +78,11 @@ function loadNPCTriggersFromDatabase(npcDatabaseId) { let dbConnection = connectToDatabase(); let tempNPCTriggers = []; let dbAssoc; - if(dbConnection) { + if (dbConnection) { let dbQueryString = `SELECT * FROM npc_trig WHERE npc_trig_npc = ${npcDatabaseId} AND npc_trig_enabled = 1`; let dbQuery = queryDatabase(dbConnection, dbQueryString); - if(dbQuery) { - while(dbAssoc = fetchQueryAssoc(dbQuery)) { + if (dbQuery) { + while (dbAssoc = fetchQueryAssoc(dbQuery)) { let tempNPCTriggerData = new NPCTriggerData(dbAssoc); tempNPCTriggerData.conditions = loadNPCTriggerConditionsFromDatabase(tempNPCTriggerData.databaseId); tempNPCTriggerData.responses = loadNPCTriggerResponsesFromDatabase(tempNPCTriggerData.databaseId); @@ -104,11 +104,11 @@ function loadNPCTriggerConditionsFromDatabase(npcTriggerDatabaseId) { let dbConnection = connectToDatabase(); let tempNPCTriggerConditions = []; let dbAssoc; - if(dbConnection) { + if (dbConnection) { let dbQueryString = `SELECT * FROM npc_cond WHERE npc_cond_trig = ${npcTriggerDatabaseId} AND npc_cond_enabled = 1`; let dbQuery = queryDatabase(dbConnection, dbQueryString); - if(dbQuery) { - while(dbAssoc = fetchQueryAssoc(dbQuery)) { + if (dbQuery) { + while (dbAssoc = fetchQueryAssoc(dbQuery)) { let tempNPCTriggerConditionData = new NPCTriggerConditionData(dbAssoc); tempNPCTriggerConditions.push(tempNPCTriggerConditionData); } @@ -128,11 +128,11 @@ function loadNPCTriggerResponsesFromDatabase(npcTriggerDatabaseId) { let dbConnection = connectToDatabase(); let tempNPCTriggerResponses = []; let dbAssoc; - if(dbConnection) { + if (dbConnection) { let dbQueryString = `SELECT * FROM npc_resp WHERE npc_resp_trig = ${npcTriggerDatabaseId} AND npc_resp_enabled = 1`; let dbQuery = queryDatabase(dbConnection, dbQueryString); - if(dbQuery) { - while(dbAssoc = fetchQueryAssoc(dbQuery)) { + if (dbQuery) { + while (dbAssoc = fetchQueryAssoc(dbQuery)) { let tempNPCTriggerResponseData = new NPCTriggerResponseData(dbAssoc); tempNPCTriggerResponses.push(tempNPCTriggerResponseData); } @@ -148,11 +148,11 @@ function loadNPCTriggerResponsesFromDatabase(npcTriggerDatabaseId) { // =========================================================================== function saveAllNPCsToDatabase() { - if(getServerConfig().devServer) { + if (getServerConfig().devServer) { return false; } - for(let i in getServerData().npcs) { + for (let i in getServerData().npcs) { saveNPCToDatabase(i); } } @@ -160,34 +160,34 @@ function saveAllNPCsToDatabase() { // =========================================================================== function saveNPCToDatabase(npcDataId) { - if(getServerConfig().devServer) { + if (getServerConfig().devServer) { logToConsole(LOG_VERBOSE, `[VRR.NPC]: NPC ${npcDataId} can't be saved because server is running as developer only. Aborting save ...`); return false; } - if(getNPCData(npcDataId) == false) { + if (getNPCData(npcDataId) == false) { logToConsole(LOG_VERBOSE, `[VRR.NPC]: NPC ${npcDataId} data is invalid. Aborting save ...`); return false; } let tempNPCData = getNPCData(npcDataId); - if(tempNPCData.databaseId == -1) { + if (tempNPCData.databaseId == -1) { logToConsole(LOG_VERBOSE, `[VRR.NPC]: NPC ${npcDataId} is a temp NPC. Aborting save ...`); return false; } - if(!tempNPCData.needsSaved) { + if (!tempNPCData.needsSaved) { logToConsole(LOG_VERBOSE, `[VRR.NPC]: NPC ${npcDataId} hasn't changed data. Aborting save ...`); return false; } logToConsole(LOG_VERBOSE, `[VRR.NPC]: Saving NPC ${tempNPCData.databaseId} to database ...`); let dbConnection = connectToDatabase(); - if(dbConnection) { - if(tempNPCData.ped != false) { - if(!tempNPCData.spawnLocked) { - if(areServerElementsSupported()) { + if (dbConnection) { + if (tempNPCData.ped != false) { + if (!tempNPCData.spawnLocked) { + if (areServerElementsSupported()) { tempNPCData.position = tempNPCData.ped.position; tempNPCData.heading = tempNPCData.ped.heading; } else { @@ -224,7 +224,7 @@ function saveNPCToDatabase(npcDataId) { ]; let dbQuery = null; - if(tempNPCData.databaseId == 0) { + if (tempNPCData.databaseId == 0) { let queryString = createDatabaseInsertQuery("npc_main", data); dbQuery = queryDatabase(dbConnection, queryString); tempNPCData.databaseId = getDatabaseInsertId(dbConnection); @@ -247,19 +247,19 @@ function saveNPCToDatabase(npcDataId) { // =========================================================================== function setNPCDataIndexes() { - for(let i in getServerData().npcs) { + for (let i in getServerData().npcs) { getServerData().npcs[i].index = i; - for(let j in getServerData().npcs[i].triggers) { + for (let j in getServerData().npcs[i].triggers) { getServerData().npcs[i].triggers[j].index = j; getServerData().npcs[i].triggers[j].npcIndex = i; - for(let k in getServerData().npcs[i].triggers[j].conditions) { + for (let k in getServerData().npcs[i].triggers[j].conditions) { getServerData().npcs[i].triggers[j].conditions[k].index = k; getServerData().npcs[i].triggers[j].conditions[m].triggerIndex = j; } - for(let m in getServerData().npcs[i].triggers[j].responses) { + for (let m in getServerData().npcs[i].triggers[j].responses) { getServerData().npcs[i].triggers[j].responses[m].index = m; getServerData().npcs[i].triggers[j].responses[m].triggerIndex = j; } @@ -272,12 +272,12 @@ function setNPCDataIndexes() { function spawnNPC(npcIndex) { let npcData = getNPCData(npcIndex); let ped = createGamePed(npcData.skin, npcData.position, npcData.rotation.z); - if(ped) { + if (ped) { getNPCData(npcIndex).ped = ped; setEntityData(ped, "vrr.dataIndex", npcIndex, false); - if(npcData.animationName != "") { + if (npcData.animationName != "") { let animationId = getAnimationFromParams(npcData.animationName); - if(animationId != false) { + if (animationId != false) { setEntityData(ped, "vrr.anim", animationId, true); } } @@ -289,7 +289,7 @@ function spawnNPC(npcIndex) { // =========================================================================== function spawnAllNPCs() { - for(let i in getServerData().npcs) { + for (let i in getServerData().npcs) { spawnNPC(i); } } @@ -297,9 +297,9 @@ function spawnAllNPCs() { // =========================================================================== function deleteNPCCommand(command, params, client) { - let closestNPC = getClosestNPC(getPlayerPosition(client)); + let closestNPC = getClosestNPC(getPlayerPosition(client), getPlayerDimension(client), getPlayerInterior(client)); - if(!getNPCData(closestNPC)) { + if (!getNPCData(closestNPC)) { messagePlayerError(client, getLocaleString(client, "InvalidNPC")); return false; } @@ -315,8 +315,8 @@ function deleteNPCCommand(command, params, client) { function deleteNPC(npcId) { quickDatabaseQuery(`DELETE FROM npc_main WHERE npc_id=${getNPCData(npcId).databaseId}`); - if(getNPCData(npcId)) { - if(getNPCData(npcId).ped != false) { + if (getNPCData(npcId)) { + if (getNPCData(npcId).ped != false) { deleteEntity(getNPCData(npcId).ped); } getServerData().npcs.splice(npcId, 1); @@ -328,27 +328,27 @@ function deleteNPC(npcId) { // =========================================================================== function setNPCAnimationCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } - let closestNPC = getClosestNPC(getPlayerPosition(client)); + let closestNPC = getClosestNPC(getPlayerPosition(client), getPlayerDimension(client), getPlayerInterior(client)); let animationId = getAnimationFromParams(getParam(params, " ", 1)); let animationPositionOffset = 1; - if(!getNPCData(closestNPC)) { + if (!getNPCData(closestNPC)) { messagePlayerError(client, getLocaleString(client, "InvalidNPC")); return false; } - if(!getAnimationData(animationId)) { + if (!getAnimationData(animationId)) { messagePlayerError(client, getLocaleString(client, "InvalidAnimation")); return false; } - if(areThereEnoughParams(params, 2, " ")) { - if(toInteger(animationPositionOffset) < 0 || toInteger(animationPositionOffset) > 3) { + if (areThereEnoughParams(params, 2, " ")) { + if (toInteger(animationPositionOffset) < 0 || toInteger(animationPositionOffset) > 3) { messagePlayerError(client, getLocaleString(client, "InvalidAnimationDistance")); return false; } @@ -365,15 +365,15 @@ function setNPCAnimationCommand(command, params, client) { // =========================================================================== function setNPCNameCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } - let closestNPC = getClosestNPC(getPlayerPosition(client)); + let closestNPC = getClosestNPC(getPlayerPosition(client), getPlayerDimension(client), getPlayerInterior(client)); let name = params; - if(!getNPCData(closestNPC)) { + if (!getNPCData(closestNPC)) { messagePlayerError(client, getLocaleString(client, "InvalidNPC")); return false; } @@ -389,9 +389,9 @@ function setNPCNameCommand(command, params, client) { // =========================================================================== function toggleNPCLookAtClosestPlayerCommand(command, params, client) { - let closestNPC = getClosestNPC(getPlayerPosition(client)); + let closestNPC = getClosestNPC(getPlayerPosition(client), getPlayerDimension(client), getPlayerInterior(client)); - if(!getNPCData(closestNPC)) { + if (!getNPCData(closestNPC)) { messagePlayerError(client, getLocaleString(client, "InvalidNPC")); return false; } @@ -406,14 +406,14 @@ function toggleNPCLookAtClosestPlayerCommand(command, params, client) { // =========================================================================== function getNPCInfoCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } let closestNPC = getClosestNPC(getPlayerPosition(client)); - if(!getNPCData(closestNPC)) { + if (!getNPCData(closestNPC)) { messagePlayerError(client, getLocaleString(client, "InvalidNPC")); return false; } @@ -422,7 +422,7 @@ function getNPCInfoCommand(command, params, client) { let ownerName = "Nobody"; let ownerType = "None"; - switch(npcData.ownerType) { + switch (npcData.ownerType) { case VRR_NPCOWNER_CLAN: ownerName = getClanData(getClanIdFromDatabaseId(npcData.ownerId)).name; ownerType = "clan"; @@ -464,22 +464,19 @@ function getNPCInfoCommand(command, params, client) { messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderNPCInfo"))); let chunkedList = splitArrayIntoChunks(stats, 6); - for(let i in chunkedList) { + for (let i in chunkedList) { messagePlayerInfo(client, chunkedList[i].join(", ")); } } // =========================================================================== -function getClosestNPC(position) { +function getClosestNPC(position, interior, dimension) { let npcs = getServerData().npcs; - let interior = getPlayerInterior(client); - let dimension = getPlayerDimension(client); - let closest = 0; - for(let i in npcs) { - if(getDistance(npcs[i].ped.position, position) < getDistance(npcs[closest].ped.position, position) && npcs[closest].interior == interior && npcs[closest].dimension == dimension) { + for (let i in npcs) { + if (getDistance(npcs[i].ped.position, position) < getDistance(npcs[closest].ped.position, position) && npcs[closest].interior == interior && npcs[closest].dimension == dimension) { closest = i; } } @@ -502,9 +499,9 @@ function createNPC(skinIndex, position, heading, interior, dimension) { let npcIndex = getServerData().npcs.push(tempNPCData); setNPCDataIndexes(); - spawnNPC(npcIndex-1); + spawnNPC(npcIndex - 1); - return npcIndex-1; + return npcIndex - 1; } // =========================================================================== \ No newline at end of file diff --git a/scripts/server/staff.js b/scripts/server/staff.js index ea12b450..6da241e7 100644 --- a/scripts/server/staff.js +++ b/scripts/server/staff.js @@ -24,20 +24,20 @@ function initStaffScript() { * */ function kickClientCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } let targetClient = getPlayerFromParams(params); - if(!targetClient) { + if (!targetClient) { messagePlayerError(client, getLocaleString(client, "InvalidPlayer")); return false; } // Prevent kicking admins with really high permissions - if(doesPlayerHaveStaffPermission(targetClient, getStaffFlagValue("ManageServer")) || doesPlayerHaveStaffPermission(targetClient, getStaffFlagValue("Developer"))) { - if(!doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageServer")) && !doesPlayerHaveStaffPermission(client, getStaffFlagValue("Developer"))) { + if (doesPlayerHaveStaffPermission(targetClient, getStaffFlagValue("ManageServer")) || doesPlayerHaveStaffPermission(targetClient, getStaffFlagValue("Developer"))) { + if (!doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageServer")) && !doesPlayerHaveStaffPermission(client, getStaffFlagValue("Developer"))) { messagePlayerError(client, "You cannot kick this person!"); return false; } @@ -45,7 +45,8 @@ function kickClientCommand(command, params, client) { //getPlayerData(targetClient).customDisconnectReason = reason; announceAdminAction(`PlayerKicked`, getPlayerName(targetClient)); - targetdisconnectPlayer(client); + getPlayerData(targetClient).customDisconnectReason = `Kicked - ${reason}`; + disconnectPlayer(targetClient); } // =========================================================================== @@ -60,7 +61,7 @@ function kickClientCommand(command, params, client) { * */ function setStaffTitleCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -69,14 +70,14 @@ function setStaffTitleCommand(command, params, client) { let targetClient = getPlayerFromParams(getParam(params, " ", 1)); let staffTitle = splitParams.slice(1).join(" "); - if(!targetClient) { + if (!targetClient) { messagePlayerError(client, getLocaleString(client, "InvalidPlayer")); return false; } // Prevent setting titles on staff with really high permissions - if(doesPlayerHaveStaffPermission(targetClient, getStaffFlagValue("ManageServer")) || doesPlayerHaveStaffPermission(targetClient, getStaffFlagValue("Developer"))) { - if(!doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageServer")) && !doesPlayerHaveStaffPermission(client, getStaffFlagValue("Developer"))) { + if (doesPlayerHaveStaffPermission(targetClient, getStaffFlagValue("ManageServer")) || doesPlayerHaveStaffPermission(targetClient, getStaffFlagValue("Developer"))) { + if (!doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageServer")) && !doesPlayerHaveStaffPermission(client, getStaffFlagValue("Developer"))) { messagePlayerError(client, "You cannot set this person's staff title!"); return false; } @@ -85,7 +86,6 @@ function setStaffTitleCommand(command, params, client) { getPlayerData(targetClient).accountData.staffTitle = staffTitle; messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} set {ALTCOLOUR}${getPlayerName(targetClient)}'s{MAINCOLOUR} staff title to ${staffTitle}`); messagePlayerAlert(targetClient, `${getPlayerName(client)} set your staff title to ${staffTitle}`); - //targetdisconnectPlayer(client); } // =========================================================================== @@ -100,20 +100,20 @@ function setStaffTitleCommand(command, params, client) { * */ function muteClientCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } let targetClient = getPlayerFromParams(params); - if(!targetClient) { + if (!targetClient) { messagePlayerError(client, getLocaleString(client, "InvalidPlayer")); return false; } // Prevent muting admins with really high permissions - if(doesPlayerHaveStaffPermission(targetClient, getStaffFlagValue("ManageServer")) || doesPlayerHaveStaffPermission(targetClient, getStaffFlagValue("Developer"))) { - if(!doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageServer")) && !doesPlayerHaveStaffPermission(client, getStaffFlagValue("Developer"))) { + if (doesPlayerHaveStaffPermission(targetClient, getStaffFlagValue("ManageServer")) || doesPlayerHaveStaffPermission(targetClient, getStaffFlagValue("Developer"))) { + if (!doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageServer")) && !doesPlayerHaveStaffPermission(client, getStaffFlagValue("Developer"))) { messagePlayerError(client, "You cannot mute this person!"); return false; } @@ -135,20 +135,20 @@ function muteClientCommand(command, params, client) { * */ function unMuteClientCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } let targetClient = getPlayerFromParams(params); - if(!targetClient) { + if (!targetClient) { messagePlayerError(client, getLocaleString(client, "InvalidPlayer")); return false; } // Prevent unmuting admins with really high permissions - if(doesPlayerHaveStaffPermission(targetClient, getStaffFlagValue("ManageServer")) || doesPlayerHaveStaffPermission(targetClient, getStaffFlagValue("Developer"))) { - if(!doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageServer")) && !doesPlayerHaveStaffPermission(client, getStaffFlagValue("Developer"))) { + if (doesPlayerHaveStaffPermission(targetClient, getStaffFlagValue("ManageServer")) || doesPlayerHaveStaffPermission(targetClient, getStaffFlagValue("Developer"))) { + if (!doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageServer")) && !doesPlayerHaveStaffPermission(client, getStaffFlagValue("Developer"))) { messagePlayerError(client, "You cannot unmute this person!"); return false; } @@ -170,20 +170,20 @@ function unMuteClientCommand(command, params, client) { * */ function freezeClientCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } let targetClient = getPlayerFromParams(params); - if(!targetClient) { + if (!targetClient) { messagePlayerError(client, getLocaleString(client, "InvalidPlayer")); return false; } // Prevent freeze admins with really high permissions - if(doesPlayerHaveStaffPermission(targetClient, getStaffFlagValue("ManageServer")) || doesPlayerHaveStaffPermission(targetClient, getStaffFlagValue("Developer"))) { - if(!doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageServer")) && !doesPlayerHaveStaffPermission(client, getStaffFlagValue("Developer"))) { + if (doesPlayerHaveStaffPermission(targetClient, getStaffFlagValue("ManageServer")) || doesPlayerHaveStaffPermission(targetClient, getStaffFlagValue("Developer"))) { + if (!doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageServer")) && !doesPlayerHaveStaffPermission(client, getStaffFlagValue("Developer"))) { messagePlayerError(client, "You cannot freeze this person!"); return false; } @@ -206,20 +206,20 @@ function freezeClientCommand(command, params, client) { * */ function unFreezeClientCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } let targetClient = getPlayerFromParams(params); - if(!targetClient) { + if (!targetClient) { messagePlayerError(client, getLocaleString(client, "InvalidPlayer")); return false; } // Prevent unfreezing admins with really high permissions - if(doesPlayerHaveStaffPermission(targetClient, getStaffFlagValue("ManageServer")) || doesPlayerHaveStaffPermission(targetClient, getStaffFlagValue("Developer"))) { - if(!doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageServer")) && !doesPlayerHaveStaffPermission(client, getStaffFlagValue("Developer"))) { + if (doesPlayerHaveStaffPermission(targetClient, getStaffFlagValue("ManageServer")) || doesPlayerHaveStaffPermission(targetClient, getStaffFlagValue("Developer"))) { + if (!doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageServer")) && !doesPlayerHaveStaffPermission(client, getStaffFlagValue("Developer"))) { messagePlayerError(client, "You cannot freeze this person!"); return false; } @@ -242,13 +242,13 @@ function unFreezeClientCommand(command, params, client) { * */ function gotoPlayerCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } let targetClient = getPlayerFromParams(params); - if(!targetClient) { + if (!targetClient) { messagePlayerError(client, getLocaleString(client, "InvalidPlayer")); return false; } @@ -283,13 +283,13 @@ function gotoPlayerCommand(command, params, client) { * */ function getPlayerGeoIPInformationCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } let targetClient = getPlayerFromParams(params); - if(!targetClient) { + if (!targetClient) { messagePlayerError(client, getLocaleString(client, "InvalidPlayer")); return false; } @@ -313,13 +313,13 @@ function getPlayerGeoIPInformationCommand(command, params, client) { * */ function getPlayerIPInformationCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } let targetClient = getPlayerFromParams(params); - if(!targetClient) { + if (!targetClient) { messagePlayerError(client, getLocaleString(client, "InvalidPlayer")); return false; } @@ -339,12 +339,12 @@ function getPlayerIPInformationCommand(command, params, client) { * */ function gotoVehicleCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } - if(typeof getServerData().vehicles[toInteger(params)] == "undefined") { + if (typeof getServerData().vehicles[toInteger(params)] == "undefined") { messagePlayerError(client, "That vehicle ID doesn't exist!"); } @@ -378,16 +378,16 @@ function gotoVehicleCommand(command, params, client) { * */ function getVehicleCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } - if(typeof getServerData().vehicles[toInteger(params)-1] == "undefined") { + if (typeof getServerData().vehicles[toInteger(params) - 1] == "undefined") { messagePlayerError(client, "That vehicle ID doesn't exist!"); } - let vehicle = getServerData().vehicles[toInteger(params)-1].vehicle; + let vehicle = getServerData().vehicles[toInteger(params) - 1].vehicle; setElementPosition(vehicle, getPosInFrontOfPos(getPlayerPosition(client), fixAngle(getPlayerHeading(client)), 5.0)); setElementInterior(vehicle, getPlayerInterior(client)); @@ -410,14 +410,14 @@ function getVehicleCommand(command, params, client) { function warpIntoVehicleCommand(command, params, client) { let vehicle = getClosestVehicle(getPlayerPosition(client)); - if(areParamsEmpty(params)) { - if(!getPlayerVehicle(client) && getDistance(getVehiclePosition(vehicle), getPlayerPosition(client)) > getGlobalConfig().vehicleLockDistance) { + if (areParamsEmpty(params)) { + if (!getPlayerVehicle(client) && getDistance(getVehiclePosition(vehicle), getPlayerPosition(client)) > getGlobalConfig().vehicleLockDistance) { messagePlayerError(client, getLocaleString(client, "MustBeInOrNearVehicle")); return false; } } else { let vehicleIndex = getParam(params, " ", 1); - if(typeof getServerData().vehicles[vehicleIndex] == "undefined") { + if (typeof getServerData().vehicles[vehicleIndex] == "undefined") { messagePlayerError(client, getLocaleString(client, "InvaliVehicle")); return false; } @@ -425,7 +425,7 @@ function warpIntoVehicleCommand(command, params, client) { vehicle = getServerData().vehicles[vehicleIndex].vehicle; } - if(getVehicleData(vehicle)) { + if (getVehicleData(vehicle)) { getPlayerData(client).enteringVehicle = vehicle; } @@ -447,14 +447,14 @@ function warpIntoVehicleCommand(command, params, client) { * */ function gotoBusinessCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } let businessId = getBusinessFromParams(params) - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } @@ -487,14 +487,14 @@ function gotoBusinessCommand(command, params, client) { * */ function gotoGameLocationCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } let gameLocationId = getGameLocationFromParams(params); - if(gameLocationId == false) { + if (gameLocationId == false) { messagePlayerError(client, "That game location doesn't exist!"); return false; } @@ -528,14 +528,14 @@ function gotoGameLocationCommand(command, params, client) { * */ function gotoHouseCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } let houseId = getHouseFromParams(params) - if(!getHouseData(houseId)) { + if (!getHouseData(houseId)) { messagePlayerError(client, getLocaleString(client, "InvalidHouse")); return false; } @@ -568,21 +568,21 @@ function gotoHouseCommand(command, params, client) { * */ function gotoJobLocationCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } let jobId = getJobFromParams(getParam(params, " ", 1)) || getClosestJobLocation(getPlayerPosition(client)).job; - if(!getJobData(jobId)) { + if (!getJobData(jobId)) { messagePlayerError(client, getLocaleString(client, "InvalidJob")); return false; } let jobLocationId = getParam(params, " ", 2) || 0; - if(typeof getJobData(jobId).locations[jobLocationId] == "undefined") { + if (typeof getJobData(jobId).locations[jobLocationId] == "undefined") { messagePlayerError(client, `That location ID does not exist!`); return false; } @@ -629,7 +629,7 @@ function gotoNewPlayerSpawnCommand(command, params, client) { * */ function gotoPositionCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -663,8 +663,8 @@ function gotoPositionCommand(command, params, client) { */ function teleportForwardCommand(command, params, client) { let distance = 1.0; - if(!areParamsEmpty(params)) { - if(!isNaN(params)) { + if (!areParamsEmpty(params)) { + if (!isNaN(params)) { distance = toFloat(params); } } @@ -687,8 +687,8 @@ function teleportForwardCommand(command, params, client) { */ function teleportBackwardCommand(command, params, client) { let distance = 1.0; - if(!areParamsEmpty(params)) { - if(!isNaN(params)) { + if (!areParamsEmpty(params)) { + if (!isNaN(params)) { distance = toFloat(params); } } @@ -711,8 +711,8 @@ function teleportBackwardCommand(command, params, client) { */ function teleportLeftCommand(command, params, client) { let distance = 1.0; - if(!areParamsEmpty(params)) { - if(!isNaN(params)) { + if (!areParamsEmpty(params)) { + if (!isNaN(params)) { distance = toFloat(params); } } @@ -735,8 +735,8 @@ function teleportLeftCommand(command, params, client) { */ function teleportUpCommand(command, params, client) { let distance = 1.0; - if(!areParamsEmpty(params)) { - if(!isNaN(params)) { + if (!areParamsEmpty(params)) { + if (!isNaN(params)) { distance = toFloat(params); } } @@ -759,8 +759,8 @@ function teleportUpCommand(command, params, client) { */ function teleportDownCommand(command, params, client) { let distance = 1.0; - if(!areParamsEmpty(params)) { - if(!isNaN(params)) { + if (!areParamsEmpty(params)) { + if (!isNaN(params)) { distance = toFloat(params); } } @@ -774,8 +774,8 @@ function teleportDownCommand(command, params, client) { function teleportRightCommand(command, params, client) { let distance = 1.0; - if(!areParamsEmpty(params)) { - if(!isNaN(params)) { + if (!areParamsEmpty(params)) { + if (!isNaN(params)) { distance = toFloat(params); } } @@ -797,18 +797,18 @@ function teleportRightCommand(command, params, client) { * */ function playerInteriorCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } let targetClient = getPlayerFromParams(getParam(params, " ", 1)); - if(!targetClient) { + if (!targetClient) { messagePlayerError(client, getLocaleString(client, "InvalidPlayer")); return false; } - if(getParamsCount(params, " ") == 1) { + if (getParamsCount(params, " ") == 1) { messagePlayerInfo(client, `${getPlayerName(targetClient)}'s interior is {ALTCOLOUR}${getPlayerInterior(targetClient)}`); return false; } @@ -830,18 +830,18 @@ function playerInteriorCommand(command, params, client) { * */ function playerVirtualWorldCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } let targetClient = getPlayerFromParams(getParam(params, " ", 1)); - if(!targetClient) { + if (!targetClient) { messagePlayerError(client, getLocaleString(client, "InvalidPlayer")); return false; } - if(getParamsCount(params, " ") == 1) { + if (getParamsCount(params, " ") == 1) { messagePlayerInfo(client, `{ALTCOLOUR}${getPlayerName(targetClient)}'s{MAINCOLOUR} virtual world is {ALTCOLOUR}${getPlayerDimension(targetClient)}`); return false; } @@ -863,13 +863,13 @@ function playerVirtualWorldCommand(command, params, client) { * */ function getPlayerCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } let targetClient = getPlayerFromParams(params); - if(!targetClient) { + if (!targetClient) { messagePlayerError(client, getLocaleString(client, "InvalidPlayer")); return false; } @@ -903,20 +903,20 @@ function getPlayerCommand(command, params, client) { * */ function returnPlayerCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } let targetClient = getPlayerFromParams(params); - if(!targetClient) { + if (!targetClient) { messagePlayerError(client, getLocaleString(client, "InvalidPlayer")); return false; } removePlayerFromVehicle(targetClient); - if(getPlayerData(targetClient).returnToPosition == null) { + if (getPlayerData(targetClient).returnToPosition == null) { messagePlayerError(client, "There is nowhere to return that player to!"); return false; } @@ -950,7 +950,7 @@ function returnPlayerCommand(command, params, client) { * */ function addPlayerStaffFlagCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -958,19 +958,19 @@ function addPlayerStaffFlagCommand(command, params, client) { let targetClient = getPlayerFromParams(getParam(params, " ", 1)); let flagName = getParam(params, " ", 2) || "None"; - if(!targetClient) { + if (!targetClient) { messagePlayerError(client, getLocaleString(client, "InvalidPlayer")); return false; } - if(getStaffFlagValue(flagName) == false) { + if (getStaffFlagValue(flagName) == false) { messagePlayerError(client, getLocaleString(client, "InvalidStaffFlag")); return false; } // Prevent setting flags on admins with really high permissions - if(doesPlayerHaveStaffPermission(targetClient, getStaffFlagValue("ManageServer")) || doesPlayerHaveStaffPermission(targetClient, getStaffFlagValue("Developer"))) { - if(!doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageServer")) && !doesPlayerHaveStaffPermission(client, getStaffFlagValue("Developer"))) { + if (doesPlayerHaveStaffPermission(targetClient, getStaffFlagValue("ManageServer")) || doesPlayerHaveStaffPermission(targetClient, getStaffFlagValue("Developer"))) { + if (!doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageServer")) && !doesPlayerHaveStaffPermission(client, getStaffFlagValue("Developer"))) { messagePlayerError(client, "You cannot give staff flags to this person!"); return false; } @@ -992,7 +992,7 @@ function addPlayerStaffFlagCommand(command, params, client) { * */ function removePlayerStaffFlagCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -1000,19 +1000,19 @@ function removePlayerStaffFlagCommand(command, params, client) { let targetClient = getPlayerFromParams(getParam(params, " ", 1)); let flagName = getParam(params, " ", 2) || "None"; - if(!targetClient) { + if (!targetClient) { messagePlayerError(client, getLocaleString(client, "InvalidPlayer")); return false; } - if(getStaffFlagValue(flagName) == false) { + if (getStaffFlagValue(flagName) == false) { messagePlayerError(client, "That staff flag doesn't exist!"); return false; } // Prevent setting flags on admins with really high permissions - if(doesPlayerHaveStaffPermission(targetClient, getStaffFlagValue("ManageServer")) || doesPlayerHaveStaffPermission(targetClient, getStaffFlagValue("Developer"))) { - if(!doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageServer")) && !doesPlayerHaveStaffPermission(client, getStaffFlagValue("Developer"))) { + if (doesPlayerHaveStaffPermission(targetClient, getStaffFlagValue("ManageServer")) || doesPlayerHaveStaffPermission(targetClient, getStaffFlagValue("Developer"))) { + if (!doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageServer")) && !doesPlayerHaveStaffPermission(client, getStaffFlagValue("Developer"))) { messagePlayerError(client, "You cannot take staff flags from this person!"); return false; } @@ -1034,21 +1034,21 @@ function removePlayerStaffFlagCommand(command, params, client) { * */ function removePlayerStaffFlagsCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } let targetClient = getPlayerFromParams(getParam(params, " ", 1)); - if(!targetClient) { + if (!targetClient) { messagePlayerError(client, getLocaleString(client, "InvalidPlayer")); return false; } // Prevent setting flags on admins with really high permissions - if(doesPlayerHaveStaffPermission(targetClient, getStaffFlagValue("ManageServer")) || doesPlayerHaveStaffPermission(targetClient, getStaffFlagValue("Developer"))) { - if(!doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageServer")) && !doesPlayerHaveStaffPermission(client, getStaffFlagValue("Developer"))) { + if (doesPlayerHaveStaffPermission(targetClient, getStaffFlagValue("ManageServer")) || doesPlayerHaveStaffPermission(targetClient, getStaffFlagValue("Developer"))) { + if (!doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageServer")) && !doesPlayerHaveStaffPermission(client, getStaffFlagValue("Developer"))) { messagePlayerError(client, "You cannot clear staff flags for this person!"); return false; } @@ -1070,42 +1070,42 @@ function removePlayerStaffFlagsCommand(command, params, client) { * */ function getPlayerStaffFlagsCommand(command, params, client) { - if(getCommand(command).requireLogin) { - if(!isPlayerLoggedIn(client)) { + if (getCommand(command).requireLogin) { + if (!isPlayerLoggedIn(client)) { messagePlayerError(client, "You must be logged in to use this command!"); return false; } } - if(!doesPlayerHaveStaffPermission(client, getCommandRequiredPermissions(command))) { + if (!doesPlayerHaveStaffPermission(client, getCommandRequiredPermissions(command))) { messagePlayerError(client, "You do not have permission to use this command!"); return false; } - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } let targetClient = getPlayerFromParams(getParam(params, " ", 1)); - if(!targetClient) { + if (!targetClient) { messagePlayerError(client, getLocaleString(client, "InvalidPlayer")); return false; } let tempStaffFlags = []; let serverBitFlagKeys = getServerBitFlagKeys(); - for(let i in serverBitFlagKeys) { + for (let i in serverBitFlagKeys) { let tempFlagValue = getStaffFlagValue(serverBitFlagKeys[i]); - if(doesPlayerHaveStaffPermission(targetClient, tempFlagValue)) { + if (doesPlayerHaveStaffPermission(targetClient, tempFlagValue)) { tempStaffFlags.push(serverBitFlagKeys[i]); } } let flagList = []; - for(let i in getServerBitFlagKeys().staffFlagKeys) { - if(doesPlayerHaveStaffPermission(targetClient, getStaffFlagValue(getServerBitFlagKeys().staffFlagKeys[i]))) { + for (let i in getServerBitFlagKeys().staffFlagKeys) { + if (doesPlayerHaveStaffPermission(targetClient, getStaffFlagValue(getServerBitFlagKeys().staffFlagKeys[i]))) { flagList.push(`{softGreen}${getServerBitFlagKeys().staffFlagKeys[i]}`); } else { flagList.push(`{softRed}${getServerBitFlagKeys().staffFlagKeys[i]}`); @@ -1116,7 +1116,7 @@ function getPlayerStaffFlagsCommand(command, params, client) { messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderPlayerStaffFlagsList", getPlayerData(targetClient).accountData.name))); - for(let i in chunkedList) { + for (let i in chunkedList) { messagePlayerInfo(client, chunkedList[i].join("{MAINCOLOUR}, ")); } } @@ -1133,7 +1133,7 @@ function getPlayerStaffFlagsCommand(command, params, client) { * */ function getStaffFlagsCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -1141,7 +1141,7 @@ function getStaffFlagsCommand(command, params, client) { let targetClient = getPlayerFromParams(getParam(params, " ", 1)); let flagName = getParam(params, " ", 2) || "None"; - if(!targetClient) { + if (!targetClient) { messagePlayerError(client, getLocaleString(client, "InvalidPlayer")); return false; } @@ -1149,7 +1149,7 @@ function getStaffFlagsCommand(command, params, client) { let chunkedList = splitArrayIntoChunks(getServerBitFlagKeys().staffFlagKeys, 8); messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderStaffFlagsList"))); - for(let i in chunkedList) { + for (let i in chunkedList) { messagePlayerInfo(client, chunkedList[i].join("{MAINCOLOUR}, ")); } } @@ -1166,7 +1166,7 @@ function getStaffFlagsCommand(command, params, client) { * */ function givePlayerMoneyCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -1174,7 +1174,7 @@ function givePlayerMoneyCommand(command, params, client) { let targetClient = getPlayerFromParams(getParam(params, " ", 1)); let amount = toInteger(getParam(params, " ", 2)); - if(!targetClient) { + if (!targetClient) { messagePlayerError(client, getLocaleString(client, "InvalidPlayer")); return false; } @@ -1198,7 +1198,7 @@ function givePlayerMoneyCommand(command, params, client) { * */ function setPlayerAccentCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -1206,18 +1206,18 @@ function setPlayerAccentCommand(command, params, client) { let targetClient = getPlayerFromParams(getParam(params, " ", 1)); let newAccent = getParam(params, " ", 2) || "None"; - if(!targetClient) { + if (!targetClient) { messagePlayerError(client, getLocaleString(client, "InvalidPlayer")); return false; } - if(toLowerCase(newAccent) == "None") { + if (toLowerCase(newAccent) == "None") { newAccent = ""; } setPlayerAccentText(client, newAccent); - if(newAccent == "") { + if (newAccent == "") { //messagePlayerSuccess(client, `You removed {ALTCOLOUR}${getCharacterFullName(targetClient)}'s {MAINCOLOUR}accent.`); messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} removed {ALTCOLOUR}${getCharacterFullName(targetClient)}'s{MAINCOLOUR} accent.`); messagePlayerAlert(client, `An admin removed your accent.`); @@ -1240,14 +1240,14 @@ function setPlayerAccentCommand(command, params, client) { * */ function forceCharacterNameChangeCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } let targetClient = getPlayerFromParams(getParam(params, " ", 1)); - if(!targetClient) { + if (!targetClient) { messagePlayerError(client, getLocaleString(client, "InvalidPlayer")); return false; } @@ -1270,7 +1270,7 @@ function forceCharacterNameChangeCommand(command, params, client) { * */ function setCharacterNameCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -1284,7 +1284,7 @@ function setCharacterNameCommand(command, params, client) { let firstName = getParam(params, " ", 2); let lastName = getParam(params, " ", 3); - if(!targetClient) { + if (!targetClient) { messagePlayerError(client, getLocaleString(client, "InvalidPlayer")); return false; } @@ -1314,7 +1314,7 @@ function setCharacterNameCommand(command, params, client) { * */ function setPlayerSkinCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -1328,12 +1328,12 @@ function setPlayerSkinCommand(command, params, client) { let targetClient = getPlayerFromParams(splitParams[0]); let skinIndex = getSkinModelIndexFromParams(splitParams.slice(1).join(" "), getGame()); - if(!targetClient) { + if (!targetClient) { messagePlayerError(client, getLocaleString(client, "InvalidPlayer")); return false; } - if(!skinIndex) { + if (!skinIndex) { messagePlayerError(client, getLocaleString(client, "InvalidSkin")); return false; } @@ -1353,8 +1353,8 @@ function setPlayerSkinCommand(command, params, client) { * @return {bool} Whether or not the command was successful * */ - function setPlayerStaffTitleCommand(command, params, client) { - if(areParamsEmpty(params)) { +function setPlayerStaffTitleCommand(command, params, client) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -1363,7 +1363,7 @@ function setPlayerSkinCommand(command, params, client) { let targetClient = getPlayerFromParams(splitParams[0]); let newTitle = splitParams.slice(1).join(" "); - if(!targetClient) { + if (!targetClient) { messagePlayerError(client, getLocaleString(client, "InvalidPlayer")); return false; } @@ -1385,7 +1385,7 @@ function setPlayerSkinCommand(command, params, client) { * */ function setPlayerHealthCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -1399,7 +1399,7 @@ function setPlayerHealthCommand(command, params, client) { let targetClient = getPlayerFromParams(getParam(params, " ", 1)); let health = getParam(params, " ", 2); - if(!targetClient) { + if (!targetClient) { messagePlayerError(client, getLocaleString(client, "InvalidPlayer")); return false; } @@ -1421,7 +1421,7 @@ function setPlayerHealthCommand(command, params, client) { * */ function setPlayerArmourCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -1429,7 +1429,7 @@ function setPlayerArmourCommand(command, params, client) { let targetClient = getPlayerFromParams(getParam(params, " ", 1)); let armour = getParam(params, " ", 2); - if(!targetClient) { + if (!targetClient) { messagePlayerError(client, getLocaleString(client, "InvalidPlayer")); return false; } @@ -1451,7 +1451,7 @@ function setPlayerArmourCommand(command, params, client) { * */ function setPlayerInfiniteRunCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -1459,12 +1459,12 @@ function setPlayerInfiniteRunCommand(command, params, client) { let targetClient = getPlayerFromParams(getParam(params, " ", 1)); let state = getParam(params, " ", 2) || 0; - if(!targetClient) { + if (!targetClient) { messagePlayerError(client, getLocaleString(client, "InvalidPlayer")); return false; } - if(isNaN(state)) { + if (isNaN(state)) { messagePlayerError(client, `The infinite run state must be a number!`); return false; } @@ -1487,7 +1487,7 @@ function setPlayerInfiniteRunCommand(command, params, client) { * */ function setPlayerWantedLevelCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -1495,7 +1495,7 @@ function setPlayerWantedLevelCommand(command, params, client) { let targetClient = getPlayerFromParams(getParam(params, " ", 1)); let wantedLevel = getParam(params, " ", 2); - if(!targetClient) { + if (!targetClient) { messagePlayerError(client, getLocaleString(client, "InvalidPlayer")); return false; } @@ -1517,14 +1517,14 @@ function setPlayerWantedLevelCommand(command, params, client) { * */ function getVehiclesOwnedByPlayerCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } let targetClient = getPlayerFromParams(params); - if(!targetClient) { + if (!targetClient) { messagePlayerError(client, getLocaleString(client, "InvalidPlayer")); return false; } @@ -1532,7 +1532,7 @@ function getVehiclesOwnedByPlayerCommand(command, params, client) { let vehicles = getAllVehiclesOwnedByPlayer(targetClient); messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderPlayerVehiclesList", getCharacterFullName(targetClient)))); - for(let i in vehicles) { + for (let i in vehicles) { messagePlayerNormal(client, `🚗 {vehiclePurple}[Vehicle Info] {MAINCOLOUR}ID: {ALTCOLOUR}${vehicles[i].index}, {MAINCOLOUR}DatabaseID: {ALTCOLOUR}${vehicles[i].databaseId}, {MAINCOLOUR}Type: {ALTCOLOUR}${getVehicleName(vehicles[i].vehicle)}[${vehicles[i].model}], {MAINCOLOUR}BuyPrice: {ALTCOLOUR}${vehicles[i].buyPrice}, {MAINCOLOUR}RentPrice: {ALTCOLOUR}${vehicles[i].rentPrice}, {MAINCOLOUR}Locked: {ALTCOLOUR}${getYesNoFromBool(vehicles[i].locked)}, {MAINCOLOUR}Engine: {ALTCOLOUR}${getYesNoFromBool(vehicles[i].engine)}`); } } @@ -1549,14 +1549,14 @@ function getVehiclesOwnedByPlayerCommand(command, params, client) { * */ function getBusinessesOwnedByPlayerCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } let targetClient = getPlayerFromParams(params); - if(!targetClient) { + if (!targetClient) { messagePlayerError(client, getLocaleString(client, "InvalidPlayer")); return false; } @@ -1564,7 +1564,7 @@ function getBusinessesOwnedByPlayerCommand(command, params, client) { let businesses = getAllBusinessesOwnedByPlayer(targetClient); messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderPlayerBusinessesList", getCharacterFullName(targetClient)))); - for(let i in businesses) { + for (let i in businesses) { let info = [ `Name: ${businesses[i].name}`, `Locked: ${businesses[i].locked}`, @@ -1586,14 +1586,14 @@ function getBusinessesOwnedByPlayerCommand(command, params, client) { * */ function getHousesOwnedByPlayerCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } let targetClient = getPlayerFromParams(params); - if(!targetClient) { + if (!targetClient) { messagePlayerError(client, getLocaleString(client, "InvalidPlayer")); return false; } @@ -1601,7 +1601,7 @@ function getHousesOwnedByPlayerCommand(command, params, client) { let houses = getAllHousesOwnedByPlayer(targetClient); messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderPlayerHousesList", getCharacterFullName(targetClient)))); - for(let i in houses) { + for (let i in houses) { messagePlayerNormal(client, `🏠 {houseGreen}[House Info] {MAINCOLOUR}Description: {ALTCOLOUR}${houses[i].description}, {MAINCOLOUR}Locked: {ALTCOLOUR}${getYesNoFromBool(intToBool(houses[i].locked))}, {MAINCOLOUR}ID: {ALTCOLOUR}${houses[i].index}/${houses[i].databaseId}`); } } @@ -1618,14 +1618,14 @@ function getHousesOwnedByPlayerCommand(command, params, client) { * */ function forceAccountPasswordResetCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } let targetClient = getPlayerFromParams(params); - if(!targetClient) { + if (!targetClient) { messagePlayerError(client, getLocaleString(client, "InvalidPlayer")); return false; } @@ -1643,19 +1643,19 @@ function forceAccountPasswordResetCommand(command, params, client) { * */ function toggleSyncForElementsSpawnedByPlayerCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } let targetClient = getPlayerFromParams(params); - if(!targetClient) { + if (!targetClient) { messagePlayerError(client, getLocaleString(client, "InvalidPlayer")); return false; } - if(!hasBitFlag(getPlayerData(client).accountData.flags.moderation, getModerationFlagValue("DontSyncClientElements"))) { + if (!hasBitFlag(getPlayerData(client).accountData.flags.moderation, getModerationFlagValue("DontSyncClientElements"))) { getPlayerData(client).accountData.flags.moderation = addBitFlag(getPlayerData(client).accountData.flags.moderation, getModerationFlagValue("DontSyncClientElements")); messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} turned {softGreen}ON{MAINCOLOUR} client element sync for {ALTCOLOUR}${getPlayerName(targetClient)}`); } else { @@ -1667,7 +1667,7 @@ function toggleSyncForElementsSpawnedByPlayerCommand(command, params, client) { // =========================================================================== function isPlayerWeaponBanned(client) { - if(hasBitFlag(getPlayerData(client).accountData.flags.moderation, getModerationFlagValue("WeaponBanned"))) { + if (hasBitFlag(getPlayerData(client).accountData.flags.moderation, getModerationFlagValue("WeaponBanned"))) { return true; } @@ -1677,7 +1677,7 @@ function isPlayerWeaponBanned(client) { // =========================================================================== function isPlayerJobBanned(client) { - if(hasBitFlag(getPlayerData(client).accountData.flags.moderation, getModerationFlagValue("JobBanned"))) { + if (hasBitFlag(getPlayerData(client).accountData.flags.moderation, getModerationFlagValue("JobBanned"))) { return true; } @@ -1688,14 +1688,14 @@ function isPlayerJobBanned(client) { function isPlayerPoliceBanned(client) { let jobId = getJobFromParams("Police"); - if(doesJobHaveWhiteListEnabled(jobId)) { - if(isPlayerOnJobWhiteList(client, jobId)) { + if (doesJobHaveWhiteListEnabled(jobId)) { + if (isPlayerOnJobWhiteList(client, jobId)) { return true; } } - if(doesJobHaveBlackListEnabled(jobId)) { - if(!isPlayerOnJobBlackList(client, jobId)) { + if (doesJobHaveBlackListEnabled(jobId)) { + if (!isPlayerOnJobBlackList(client, jobId)) { return true; } } @@ -1715,7 +1715,7 @@ function isPlayerPoliceBanned(client) { * */ function forceFightStyleCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -1738,7 +1738,7 @@ function forceFightStyleCommand(command, params, client) { // return false; //} - if(!fightStyleId) { + if (!fightStyleId) { messagePlayerError(client, `That fight style doesn't exist!`); messagePlayerError(client, `Fight styles: ${getGameConfig().fightStyles[getGame()].map(fs => fs[0]).join(", ")}`); return false; @@ -1762,8 +1762,8 @@ function forceFightStyleCommand(command, params, client) { * @return {bool} Whether or not the command was successful * */ - function getPlayerCurrentHouseCommand(command, params, client) { - if(areParamsEmpty(params)) { +function getPlayerCurrentHouseCommand(command, params, client) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -1772,7 +1772,7 @@ function forceFightStyleCommand(command, params, client) { let houseId = getPlayerHouse(targetClient); - if(!houseId) { + if (!houseId) { messagePlayerAlert(client, `${getPlayerName(targetClient)} isn't in or at a house!`); return false; } @@ -1793,8 +1793,8 @@ function forceFightStyleCommand(command, params, client) { * @return {bool} Whether or not the command was successful * */ - function getPlayerCurrentBusinessCommand(command, params, client) { - if(areParamsEmpty(params)) { +function getPlayerCurrentBusinessCommand(command, params, client) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -1803,7 +1803,7 @@ function forceFightStyleCommand(command, params, client) { let businessId = getPlayerBusiness(targetClient); - if(!businessId) { + if (!businessId) { messagePlayerAlert(client, `${getPlayerName(targetClient)} isn't in or at a house!`); return false; } diff --git a/scripts/server/startup.js b/scripts/server/startup.js index ef3e3a6b..2b14dbae 100644 --- a/scripts/server/startup.js +++ b/scripts/server/startup.js @@ -59,7 +59,7 @@ function initServerScripts() { // =========================================================================== function checkForHashingModule() { - if(typeof module.hashing == "undefined") { + if (typeof module.hashing == "undefined") { return false; } return true; @@ -68,7 +68,7 @@ function checkForHashingModule() { // =========================================================================== function checkForMySQLModule() { - if(typeof module.mysql == "undefined") { + if (typeof module.mysql == "undefined") { return false; } @@ -78,7 +78,7 @@ function checkForMySQLModule() { // =========================================================================== function checkForSMTPModule() { - if(typeof module.smtp == "undefined") { + if (typeof module.smtp == "undefined") { return false; } @@ -90,19 +90,19 @@ function checkForSMTPModule() { function checkForAllRequiredModules() { logToConsole(LOG_DEBUG, "[VRR.Startup]: Checking for required modules ..."); - if(!checkForHashingModule()) { + if (!checkForHashingModule()) { logToConsole(LOG_WARN, "[VRR.Startup]: Hashing module is not loaded!"); logToConsole(LOG_WARN, "[VRR.Startup]: This resource will now shutdown."); thisResource.stop(); } - if(!checkForMySQLModule()) { + if (!checkForMySQLModule()) { logToConsole(LOG_WARN, "[VRR.Startup]: MySQL module is not loaded!"); logToConsole(LOG_WARN, "[VRR.Startup]: This resource will now shutdown."); thisResource.stop(); } - if(!checkForSMTPModule()) { + if (!checkForSMTPModule()) { logToConsole(LOG_WARN, "[VRR.Startup]: SMTP Email module is not loaded!"); logToConsole(LOG_WARN, "[VRR.Startup]: Email features will NOT be available!"); } @@ -120,6 +120,8 @@ function loadServerDataFromDatabase() { getServerData().localeStrings = loadAllLocaleStrings(); getServerData().allowedSkins = getAllowedSkins(getGame()); + getServerData().itemTypes = loadItemTypesFromDatabase(); + // Translation Cache getServerData().cachedTranslations = new Array(getGlobalConfig().locale.locales.length); getServerData().cachedTranslationFrom = new Array(getGlobalConfig().locale.locales.length); @@ -127,8 +129,7 @@ function loadServerDataFromDatabase() { getServerData().cachedTranslations.fill(getServerData().cachedTranslationFrom); // Only load these if the server isn't a testing/dev server - if(!getServerConfig().devServer) { - getServerData().itemTypes = loadItemTypesFromDatabase(); + if (!getServerConfig().devServer) { getServerData().items = loadItemsFromDatabase(); getServerData().businesses = loadBusinessesFromDatabase(); getServerData().houses = loadHousesFromDatabase(); diff --git a/scripts/server/subaccount.js b/scripts/server/subaccount.js index 11a53772..8a6c4df9 100644 --- a/scripts/server/subaccount.js +++ b/scripts/server/subaccount.js @@ -16,12 +16,12 @@ function initSubAccountScript() { function loadSubAccountFromName(firstName, lastName) { let dbConnection = connectToDatabase(); - if(dbConnection) { + if (dbConnection) { firstName = escapeDatabaseString(dbConnection, firstName); lastName = escapeDatabaseString(dbConnection, lastName); let dbQueryString = `SELECT * FROM sacct_main INNER JOIN sacct_svr ON sacct_svr.sacct_svr_sacct=sacct_main.sacct_id AND sacct_svr.sacct_svr_server=${getServerId()} WHERE sacct_name_first = '${firstName}' AND sacct_name_last = '${lastName}' LIMIT 1;`; let dbQuery = queryDatabase(dbConnection, dbQueryString); - if(dbQuery) { + if (dbQuery) { let dbAssoc = fetchQueryAssoc(dbQuery); freeDatabaseQuery(dbQuery); return new SubAccountData(dbAssoc); @@ -36,10 +36,10 @@ function loadSubAccountFromName(firstName, lastName) { function loadSubAccountFromId(subAccountId) { let dbConnection = connectToDatabase(); - if(dbConnection) { + if (dbConnection) { let dbQueryString = `SELECT * FROM sacct_main INNER JOIN sacct_svr ON sacct_svr.sacct_svr_sacct=sacct_main.sacct_id AND sacct_svr.sacct_svr_server=${getServerId()} WHERE sacct_id = ${subAccountId} LIMIT 1;`; let dbQuery = queryDatabase(dbConnection, dbQueryString); - if(dbQuery) { + if (dbQuery) { let dbAssoc = fetchQueryAssoc(dbQuery); freeDatabaseQuery(dbQuery); return new SubAccountData(dbAssoc); @@ -55,31 +55,31 @@ function loadSubAccountFromId(subAccountId) { function loadSubAccountsFromAccount(accountId) { let tempSubAccounts = []; let dbAssoc = false; - if(accountId > 0) { + if (accountId > 0) { let dbConnection = connectToDatabase(); - if(dbConnection) { + if (dbConnection) { let dbQueryString = `SELECT * FROM sacct_main INNER JOIN sacct_svr ON sacct_svr.sacct_svr_sacct=sacct_main.sacct_id AND sacct_svr.sacct_svr_server=${getServerId()} WHERE sacct_acct = ${accountId} AND sacct_server = ${getServerId()}`; let dbQuery = queryDatabase(dbConnection, dbQueryString); - if(dbQuery) { - while(dbAssoc = fetchQueryAssoc(dbQuery)) { + if (dbQuery) { + while (dbAssoc = fetchQueryAssoc(dbQuery)) { let tempSubAccount = new SubAccountData(dbAssoc); // Make sure skin is valid - if(tempSubAccount.skin == -1) { + if (tempSubAccount.skin == -1) { tempSubAccount.skin = getServerConfig().newCharacter.skin; } // Check if clan and rank are still valid - if(tempSubAccount.clan != 0) { + if (tempSubAccount.clan != 0) { let clanId = getClanIdFromDatabaseId(tempSubAccount.clan); - if(!getClanData(clanId)) { + if (!getClanData(clanId)) { tempSubAccount.clan = 0; tempSubAccount.clanRank = 0; tempSubAccount.clanTitle = ""; tempSubAccount.clanFlags = 0; } else { let rankId = getClanRankIdFromDatabaseId(clanId, tempSubAccount.clanRank); - if(!getClanRankData(clanId, rankId)) { + if (!getClanRankData(clanId, rankId)) { tempSubAccount.clanRank = 0; } } @@ -101,7 +101,7 @@ function loadSubAccountsFromAccount(accountId) { function saveSubAccountToDatabase(subAccountData) { let dbConnection = connectToDatabase(); - if(dbConnection) { + if (dbConnection) { let safeClanTag = escapeDatabaseString(dbConnection, subAccountData.ClanTag); let safeClanTitle = escapeDatabaseString(dbConnection, subAccountData.clanTitle); let safeFirstName = escapeDatabaseString(dbConnection, subAccountData.firstName); @@ -171,7 +171,7 @@ function saveSubAccountToDatabase(subAccountData) { ["sacct_svr_hd_prop_rightwrist_model", subAccountData.bodyProps.rightWrist[0]], ["sacct_svr_hd_prop_rightwrist_texture", subAccountData.bodyProps.rightWrist[1]], ["sacct_svr_hd_prop_hip_model", subAccountData.bodyProps.hip[0]], - ["sacct_svr_hd_prop_hip_texture",subAccountData.bodyProps.hip[1]], + ["sacct_svr_hd_prop_hip_texture", subAccountData.bodyProps.hip[1]], ["sacct_svr_hd_prop_leftfoot_model", subAccountData.bodyProps.leftFoot[0]], ["sacct_svr_hd_prop_leftfoot_texture", subAccountData.bodyProps.leftFoot[1]], ["sacct_svr_hd_prop_rightfoot_model", subAccountData.bodyProps.rightFoot[0]], @@ -196,7 +196,7 @@ function createSubAccount(accountId, firstName, lastName) { let dbConnection = connectToDatabase(); let dbQuery = false; - if(dbConnection) { + if (dbConnection) { firstName = fixCharacterName(firstName); lastName = fixCharacterName(lastName); let safeFirstName = escapeDatabaseString(dbConnection, firstName); @@ -204,13 +204,13 @@ function createSubAccount(accountId, firstName, lastName) { dbQuery = queryDatabase(dbConnection, `INSERT INTO sacct_main (sacct_acct, sacct_name_first, sacct_name_last, sacct_pos_x, sacct_pos_y, sacct_pos_z, sacct_rot_z, sacct_cash, sacct_server, sacct_health, sacct_when_made, sacct_when_lastlogin) VALUES (${accountId}, '${safeFirstName}', '${safeLastName}', ${getServerConfig().newCharacter.spawnPosition.x}, ${getServerConfig().newCharacter.spawnPosition.y}, ${getServerConfig().newCharacter.spawnPosition.z}, ${getServerConfig().newCharacter.spawnHeading}, ${getServerConfig().newCharacter.money}, ${getServerId()}, 100, CURRENT_TIMESTAMP(), 0)`); //if(dbQuery) { - if(getDatabaseInsertId(dbConnection) > 0) { - let dbInsertId = getDatabaseInsertId(dbConnection); - createDefaultSubAccountServerData(dbInsertId, getServerConfig().newCharacter.skin); - let tempSubAccount = loadSubAccountFromId(dbInsertId); - return tempSubAccount; - } - //freeDatabaseQuery(dbQuery); + if (getDatabaseInsertId(dbConnection) > 0) { + let dbInsertId = getDatabaseInsertId(dbConnection); + createDefaultSubAccountServerData(dbInsertId, getServerConfig().newCharacter.skin); + let tempSubAccount = loadSubAccountFromId(dbInsertId); + return tempSubAccount; + } + //freeDatabaseQuery(dbQuery); //} disconnectFromDatabase(dbConnection); } @@ -223,20 +223,20 @@ function createSubAccount(accountId, firstName, lastName) { function showCharacterSelectToClient(client) { getPlayerData(client).switchingCharacter = true; - if(doesPlayerHaveAutoSelectLastCharacterEnabled(client)) { - if(getPlayerData(client).subAccounts.length > 0) { + if (doesPlayerHaveAutoSelectLastCharacterEnabled(client)) { + if (getPlayerData(client).subAccounts.length > 0) { logToConsole(LOG_DEBUG, `[VRR.SubAccount] ${getPlayerDisplayForConsole(client)} is being auto-spawned as character ID ${getPlayerLastUsedSubAccount(client)}`); selectCharacter(client, getPlayerLastUsedSubAccount(client)); return true; } } - if(doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) { + if (doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) { getPlayerData(client).currentSubAccount = 0; logToConsole(LOG_DEBUG, `[VRR.SubAccount] Setting ${getPlayerDisplayForConsole(client)}'s character to ID ${getPlayerData(client).currentSubAccount}`); let tempSubAccount = getPlayerData(client).subAccounts[0]; let clanName = (tempSubAccount.clan != 0) ? getClanData(getClanIdFromDatabaseId(tempSubAccount.clan)).name : "None"; - let lastPlayedText = (tempSubAccount.lastLogin != 0) ? `${msToTime(getCurrentUnixTimestamp()-tempSubAccount.lastLogin)} ago` : "Never"; + let lastPlayedText = (tempSubAccount.lastLogin != 0) ? `${msToTime(getCurrentUnixTimestamp() - tempSubAccount.lastLogin)} ago` : "Never"; showPlayerCharacterSelectGUI(client, tempSubAccount.firstName, tempSubAccount.lastName, tempSubAccount.cash, clanName, lastPlayedText, getGameConfig().skins[getGame()][tempSubAccount.skin][0]); //spawnPlayer(client, getServerConfig().characterSelectPedPosition, getServerConfig().characterSelectPedHeading, getPlayerCurrentSubAccount(client).skin, getServerConfig().characterSelectInterior, getServerConfig().characterSelectDimension); @@ -245,16 +245,12 @@ function showCharacterSelectToClient(client) { //}, 500); logToConsole(LOG_DEBUG, `[VRR.SubAccount] ${getPlayerDisplayForConsole(client)} is being shown the character select GUI`); } else { - //let emojiNumbers = ["➊", "➋", "➌", "➍", "➎", "➏", "➐", "➑", "➒"]; - //let emojiNumbers = ["①", "②", "③", "④", "⑤", "⑥", "⑦", "⑧", "⑨"]; - //let emojiNumbers = ["1️⃣", "2️⃣", "3️⃣", "4️⃣", "5️⃣", "6️⃣", "7️⃣", "8️⃣", "9️⃣"]; - messagePlayerNormal(client, `You have the following characters. Use /usechar to select one:`, getColourByName("teal")); - getPlayerData(client).subAccounts.forEach(function(subAccount, index) { - let tempSubAccount = getPlayerData(client).subAccounts[0]; - //let clanName = (tempSubAccount.clan != 0) ? getClanData(getClanIdFromDatabaseId(tempSubAccount.clan)).name : "None"; - let lastPlayedText = (tempSubAccount.lastLogin != 0) ? `${msToTime(getCurrentUnixTimestamp()-tempSubAccount.lastLogin)} ago` : "Never"; - messagePlayerNormal(client, `${index+1} • [#BBBBBB]${subAccount.firstName} ${subAccount.lastName} ($${tempSubAccount.cash}, ${lastPlayedText})`); - }); + let charactersList = getPlayerData(client).subAccounts.map((sacct, index) => `{teal}${index + 1}: {ALTCOLOUR}${sacct.firstName} ${sacct.lastName}`); + let chunkedList = splitArrayIntoChunks(charactersList, 5); + messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderCharactersListSelf"))); + for (let i in chunkedList) { + messagePlayerNormal(client, chunkedList[i].join("{MAINCOLOUR}, ")); + } logToConsole(LOG_DEBUG, `[VRR.SubAccount] ${getPlayerDisplayForConsole(client)} is being shown the character select/list message (GUI disabled)`); } } @@ -262,25 +258,25 @@ function showCharacterSelectToClient(client) { // =========================================================================== function checkNewCharacter(client, firstName, lastName) { - if(areParamsEmpty(firstName)) { + if (areParamsEmpty(firstName)) { showPlayerNewCharacterFailedGUI(client, "First name cannot be blank!"); return false; } firstName = firstName.trim(); - if(areParamsEmpty(lastName)) { + if (areParamsEmpty(lastName)) { showPlayerNewCharacterFailedGUI(client, "Last name cannot be blank!"); return false; } lastName = lastName.trim(); - if(doesNameContainInvalidCharacters(firstName) || doesNameContainInvalidCharacters(lastName)) { - logToConsole(LOG_INFO|LOG_WARN, `[VRR.Account] Subaccount ${firstName} ${lastName} could not be created (invalid characters in name)`); + if (doesNameContainInvalidCharacters(firstName) || doesNameContainInvalidCharacters(lastName)) { + logToConsole(LOG_INFO | LOG_WARN, `[VRR.Account] Subaccount ${firstName} ${lastName} could not be created (invalid characters in name)`); showPlayerNewCharacterFailedGUI(client, "Invalid characters in name!"); return false; } - if(getPlayerData(client).changingCharacterName) { + if (getPlayerData(client).changingCharacterName) { getPlayerCurrentSubAccount(client).firstName = fixCharacterName(firstName); getPlayerCurrentSubAccount(client).lastName = fixCharacterName(lastName); updateAllPlayerNameTags(client); @@ -289,8 +285,8 @@ function checkNewCharacter(client, firstName, lastName) { } let subAccountData = createSubAccount(getPlayerData(client).accountData.databaseId, firstName, lastName); - if(!subAccountData) { - if(doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) { + if (!subAccountData) { + if (doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) { showPlayerNewCharacterFailedGUI(client, "Your character could not be created!"); } else { messagePlayerError(client, "Your character could not be created!"); @@ -302,16 +298,15 @@ function checkNewCharacter(client, firstName, lastName) { getPlayerData(client).subAccounts = loadSubAccountsFromAccount(getPlayerData(client).accountData.databaseId); getPlayerData(client).currentSubAccount = 0; getPlayerData(client).creatingCharacter = false; - let tempSubAccount = getPlayerData(client).subAccounts[0]; showCharacterSelectToClient(client); } // =========================================================================== function checkPreviousCharacter(client) { - if(getPlayerData(client).subAccounts.length > 1) { - if(getPlayerData(client).currentSubAccount <= 0) { - getPlayerData(client).currentSubAccount = getPlayerData(client).subAccounts.length-1; + if (getPlayerData(client).subAccounts.length > 1) { + if (getPlayerData(client).currentSubAccount <= 0) { + getPlayerData(client).currentSubAccount = getPlayerData(client).subAccounts.length - 1; } else { getPlayerData(client).currentSubAccount--; } @@ -320,7 +315,7 @@ function checkPreviousCharacter(client) { let tempSubAccount = getPlayerData(client).subAccounts[subAccountId]; let clanName = (tempSubAccount.clan != 0) ? getClanData(getClanIdFromDatabaseId(tempSubAccount.clan)).name : "None"; - let lastPlayedText = (tempSubAccount.lastLogin != 0) ? `${msToTime(getCurrentUnixTimestamp()-tempSubAccount.lastLogin)} ago` : "Never"; + let lastPlayedText = (tempSubAccount.lastLogin != 0) ? `${msToTime(getCurrentUnixTimestamp() - tempSubAccount.lastLogin)} ago` : "Never"; showPlayerCharacterSelectGUI(client, tempSubAccount.firstName, tempSubAccount.lastName, tempSubAccount.cash, clanName, lastPlayedText, getGameConfig().skins[getGame()][tempSubAccount.skin][0]); logToConsole(LOG_DEBUG, `[VRR.SubAccount] Setting ${getPlayerDisplayForConsole(client)}'s character to ID ${getPlayerData(client).currentSubAccount}`); @@ -330,8 +325,8 @@ function checkPreviousCharacter(client) { // =========================================================================== function checkNextCharacter(client) { - if(getPlayerData(client).subAccounts.length > 1) { - if(getPlayerData(client).currentSubAccount >= getPlayerData(client).subAccounts.length-1) { + if (getPlayerData(client).subAccounts.length > 1) { + if (getPlayerData(client).currentSubAccount >= getPlayerData(client).subAccounts.length - 1) { getPlayerData(client).currentSubAccount = 0; } else { getPlayerData(client).currentSubAccount++; @@ -341,7 +336,7 @@ function checkNextCharacter(client) { let tempSubAccount = getPlayerData(client).subAccounts[subAccountId]; let clanName = (tempSubAccount.clan != 0) ? getClanData(getClanIdFromDatabaseId(tempSubAccount.clan)).name : "None"; - let lastPlayedText = (tempSubAccount.lastLogin != 0) ? `${msToTime(getCurrentUnixTimestamp()-tempSubAccount.lastLogin)} ago` : "Never"; + let lastPlayedText = (tempSubAccount.lastLogin != 0) ? `${msToTime(getCurrentUnixTimestamp() - tempSubAccount.lastLogin)} ago` : "Never"; showPlayerCharacterSelectGUI(client, tempSubAccount.firstName, tempSubAccount.lastName, tempSubAccount.cash, clanName, lastPlayedText, getGameConfig().skins[getGame()][tempSubAccount.skin][0]); logToConsole(LOG_DEBUG, `[VRR.SubAccount] Setting ${getPlayerDisplayForConsole(client)}'s character to ID ${getPlayerData(client).currentSubAccount}`); @@ -352,7 +347,7 @@ function checkNextCharacter(client) { function selectCharacter(client, characterId = -1) { logToConsole(LOG_DEBUG, `[VRR.SubAccount] ${getPlayerDisplayForConsole(client)} character select called (Character ID ${characterId})`); - if(characterId != -1) { + if (characterId != -1) { logToConsole(LOG_DEBUG, `[VRR.SubAccount] ${getPlayerDisplayForConsole(client)} provided character ID (${characterId}) to spawn with`); getPlayerData(client).currentSubAccount = characterId; } @@ -371,9 +366,9 @@ function selectCharacter(client, characterId = -1) { //setPlayerCameraLookAt(client, getPosBehindPos(spawnPosition, spawnHeading, 5), spawnPosition); getPlayerData(client).pedState = VRR_PEDSTATE_SPAWNING; - if(getGame() <= VRR_GAME_GTA_SA) { + if (getGame() <= VRR_GAME_GTA_SA) { spawnPlayer(client, spawnPosition, spawnHeading, getGameConfig().skins[getGame()][skin][0], spawnInterior, spawnDimension); - } else if(getGame() == VRR_GAME_GTA_IV) { + } else if (getGame() == VRR_GAME_GTA_IV) { spawnPlayer(client, spawnPosition, spawnHeading, getGameConfig().skins[getGame()][skin][0], spawnInterior, spawnDimension); //clearPlayerWeapons(client); //setPlayerSkin(client, skin); @@ -382,7 +377,7 @@ function selectCharacter(client, characterId = -1) { //setPlayerInterior(client, spawnInterior); //setPlayerDimension(client, spawnDimension); //restorePlayerCamera(client); - } else if(getGame() == VRR_GAME_MAFIA_ONE) { + } else if (getGame() == VRR_GAME_MAFIA_ONE) { //spawnPlayer(client, spawnPosition, spawnHeading, getGameConfig().skins[getGame()][skin][0]); logToConsole(LOG_DEBUG, `[VRR.SubAccount] Spawning ${getPlayerDisplayForConsole(client)} as ${getGameConfig().skins[getGame()][skin][1]} (${getGameConfig().skins[getGame()][skin][0]})`); spawnPlayer(client, getGameConfig().skins[getGame()][skin][0], spawnPosition, spawnHeading); @@ -392,7 +387,7 @@ function selectCharacter(client, characterId = -1) { logToConsole(LOG_DEBUG, `[VRR.SubAccount] Spawned ${getPlayerDisplayForConsole(client)} as character ID ${getPlayerData(client).currentSubAccount} with skin ${skin} (${spawnPosition.x}, ${spawnPosition.y}, ${spawnPosition.z})`); - setTimeout(function() { + setTimeout(function () { onPlayerSpawn(client); }, 500); @@ -405,12 +400,12 @@ function selectCharacter(client, characterId = -1) { function switchCharacterCommand(command, params, client) { logToConsole(LOG_DEBUG, `[VRR.SubAccount] ${getPlayerDisplayForConsole(client)} is requesting to switch characters (current character: ${getCharacterFullName(client)} [${getPlayerData(client).currentSubAccount}/${getPlayerCurrentSubAccount(client).databaseId}])`); - if(!isPlayerSpawned(client)) { + if (!isPlayerSpawned(client)) { logToConsole(LOG_WARN, `[VRR.SubAccount] ${getPlayerDisplayForConsole(client)} is not allowed to switch characters (not spawned)`); return false; } - if(isPlayerSwitchingCharacter(client)) { + if (isPlayerSwitchingCharacter(client)) { logToConsole(LOG_WARN, `[VRR.SubAccount] ${getPlayerDisplayForConsole(client)} is not allowed to switch characters (already in switch char mode)`); messagePlayerError(client, "You are already selecting/switching characters!"); return false; @@ -422,12 +417,12 @@ function switchCharacterCommand(command, params, client) { // =========================================================================== function newCharacterCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } -let firstName = getParam(params, " ", 1); + let firstName = getParam(params, " ", 1); let lastName = getParam(params, " ", 2); checkNewCharacter(client, firstName, lastName); @@ -436,19 +431,19 @@ let firstName = getParam(params, " ", 1); // =========================================================================== function useCharacterCommand(command, params, client) { - if(!getPlayerData(client).switchingCharacter) { + if (!getPlayerData(client).switchingCharacter) { messagePlayerError(client, "Use /switchchar to save this character and return to the characters screen first!"); return false; } - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } let characterId = toInteger(params) || 1; - selectCharacter(client, characterId-1); + selectCharacter(client, characterId - 1); } // =========================================================================== @@ -456,8 +451,8 @@ function useCharacterCommand(command, params, client) { function getPlayerLastUsedSubAccount(client) { let subAccounts = getPlayerData(client).subAccounts; let lastUsed = 0; - for(let i in subAccounts) { - if(subAccounts[i].lastLogin > subAccounts[lastUsed].lastLogin) { + for (let i in subAccounts) { + if (subAccounts[i].lastLogin > subAccounts[lastUsed].lastLogin) { lastUsed = i; } } @@ -496,16 +491,16 @@ function isPlayerCreatingCharacter(client) { * */ function getPlayerCurrentSubAccount(client) { - if(!getPlayerData(client)) { + if (!getPlayerData(client)) { return false; } let subAccountId = getPlayerData(client).currentSubAccount; - if(subAccountId == -1) { + if (subAccountId == -1) { return false; } - if(typeof getPlayerData(client).subAccounts[subAccountId] == "undefined") { + if (typeof getPlayerData(client).subAccounts[subAccountId] == "undefined") { return false; } @@ -522,21 +517,21 @@ function getClientSubAccountName(client) { // =========================================================================== function setFightStyleCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } let fightStyleId = getFightStyleFromParams(params); - if(!fightStyle) { + if (!fightStyle) { messagePlayerError(client, `That fight style doesn't exist!`); messagePlayerError(client, `Fight styles: ${getGameConfig().fightStyles[getGame()].map(fs => fs[0]).join(", ")}`); return false; } - if(!isPlayerAtGym(client)) { - if(!doesPlayerHaveStaffPermission(client, getStaffFlagValue("BasicModeration"))) { + if (!isPlayerAtGym(client)) { + if (!doesPlayerHaveStaffPermission(client, getStaffFlagValue("BasicModeration"))) { messagePlayerError(client, `You need to be at a gym!`); return false } @@ -551,8 +546,8 @@ function setFightStyleCommand(command, params, client) { // =========================================================================== function createDefaultSubAccountServerData(databaseId, thisServerSkin) { - for(let i = 1 ; i <= 5 ; i++) { - if(i == getServerId()) { + for (let i = 1; i <= 5; i++) { + if (i == getServerId()) { let dbQueryString = `INSERT INTO sacct_svr (sacct_svr_sacct, sacct_svr_server, sacct_svr_skin) VALUES (${databaseId}, ${i}, ${thisServerSkin})`; quickDatabaseQuery(dbQueryString); } else { @@ -582,5 +577,6 @@ function forcePlayerIntoSwitchCharacterScreen(client) { getPlayerData(client).switchingCharacter = true; showConnectCameraToPlayer(client); + showCharacterSelectToClient(client); } \ No newline at end of file diff --git a/scripts/server/timers.js b/scripts/server/timers.js index 484a9998..49d08e07 100644 --- a/scripts/server/timers.js +++ b/scripts/server/timers.js @@ -12,7 +12,7 @@ let serverTimers = {}; // =========================================================================== function saveServerDataToDatabase() { - if(getServerConfig().pauseSavingToDatabase) { + if (getServerConfig().pauseSavingToDatabase) { return false; } @@ -20,67 +20,67 @@ function saveServerDataToDatabase() { try { saveAllPlayersToDatabase(); - } catch(error) { + } catch (error) { logToConsole(LOG_ERROR, `Could not save players to database: ${error}`); } try { saveAllClansToDatabase(); - } catch(error) { + } catch (error) { logToConsole(LOG_ERROR, `Could not save clans to database: ${error}`); } try { saveAllHousesToDatabase(); - } catch(error) { + } catch (error) { logToConsole(LOG_ERROR, `Could not save houses to database: ${error}`); } try { saveAllBusinessesToDatabase(); - } catch(error) { + } catch (error) { logToConsole(LOG_ERROR, `Could not save businesses to database: ${error}`); } try { saveAllVehiclesToDatabase(); - } catch(error) { + } catch (error) { logToConsole(LOG_ERROR, `Could not save vehicles to database: ${error}`); } try { saveAllItemTypesToDatabase(); - } catch(error) { + } catch (error) { logToConsole(LOG_ERROR, `Could not save item types to database: ${error}`); } try { saveAllItemsToDatabase(); - } catch(error) { + } catch (error) { logToConsole(LOG_ERROR, `Could not save items to database: ${error}`); } try { saveAllJobsToDatabase(); - } catch(error) { + } catch (error) { logToConsole(LOG_ERROR, `Could not save jobs to database: ${error}`); } try { saveAllNPCsToDatabase(); - } catch(error) { + } catch (error) { logToConsole(LOG_ERROR, `Could not save NPCs to database: ${error}`); } try { saveAllGatesToDatabase(); - } catch(error) { + } catch (error) { logToConsole(LOG_ERROR, `Could not save gates to database: ${error}`); } try { saveServerConfigToDatabase(); - } catch(error) { + } catch (error) { logToConsole(LOG_ERROR, `Could not save server config to database: ${error}`); } @@ -91,10 +91,10 @@ function saveServerDataToDatabase() { function initTimers() { //if(!isDevelopmentServer()) { - serverTimers.updatePingsTimer = setInterval(updatePings, 5000); - serverTimers.oneMinuteTimer = setInterval(oneMinuteTimerFunction, 60000); - serverTimers.fifteenMinuteTimer = setInterval(tenMinuteTimerFunction, 600000); - serverTimers.thirtyMinuteTimer = setInterval(thirtyMinuteTimerFunction, 1800000); + serverTimers.updatePingsTimer = setInterval(updatePings, 5000); + serverTimers.oneMinuteTimer = setInterval(oneMinuteTimerFunction, 60000); + serverTimers.fifteenMinuteTimer = setInterval(tenMinuteTimerFunction, 600000); + serverTimers.thirtyMinuteTimer = setInterval(thirtyMinuteTimerFunction, 1800000); //} } @@ -132,12 +132,12 @@ function thirtyMinuteTimerFunction() { function checkVehicleRenting() { let renting = getServerData().rentingVehicleCache; - for(let i in renting) { - if(isClientInitialized(renting[i])) { - if(getPlayerData(renting[i]) != false) { - if(isPlayerLoggedIn(renting[i] && isPlayerSpawned(renting[i]))) { - if(getPlayerData(renting[i]).rentingVehicle != false) { - if(getPlayerCurrentSubAccount(renting[i]).cash < getServerData().vehicles[getPlayerData(renting[i]).rentingVehicle].rentPrice) { + for (let i in renting) { + if (isClientInitialized(renting[i])) { + if (getPlayerData(renting[i]) != false) { + if (isPlayerLoggedIn(renting[i] && isPlayerSpawned(renting[i]))) { + if (getPlayerData(renting[i]).rentingVehicle != false) { + if (getPlayerCurrentSubAccount(renting[i]).cash < getServerData().vehicles[getPlayerData(renting[i]).rentingVehicle].rentPrice) { messagePlayerAlert(renting[i], `You do not have enough money to continue renting this vehicle!`); stopRentingVehicle(renting[i]); } else { @@ -174,11 +174,11 @@ function checkVehicleRenting() { function updatePings() { let clients = getClients(); - for(let i in clients) { - if(isClientInitialized(clients[i])) { - if(!clients[i].console) { + for (let i in clients) { + if (isClientInitialized(clients[i])) { + if (!clients[i].console) { updatePlayerPing(clients[i]); - if(isPlayerSpawned(clients[i])) { + if (isPlayerSpawned(clients[i])) { updatePlayerCash(clients[i]); } } @@ -190,16 +190,16 @@ function updatePings() { function checkServerGameTime() { //if(!getServerConfig().useRealTime) { - if(getServerConfig().minute >= 59) { - getServerConfig().minute = 0; - if(getServerConfig().hour >= 23) { - getServerConfig().hour = 0; - } else { - getServerConfig().hour = getServerConfig().hour + 1; - } + if (getServerConfig().minute >= 59) { + getServerConfig().minute = 0; + if (getServerConfig().hour >= 23) { + getServerConfig().hour = 0; } else { - getServerConfig().minute = getServerConfig().minute + 1; + getServerConfig().hour = getServerConfig().hour + 1; } + } else { + getServerConfig().minute = getServerConfig().minute + 1; + } //} else { // let dateTime = getCurrentTimeStampWithTimeZone(getServerConfig().realTimeZone); // getServerConfig().hour = dateTime.getHours(); @@ -213,9 +213,9 @@ function checkServerGameTime() { function checkPayDays() { let clients = getClients(); - for(let i in clients) { - if(isClientInitialized(clients[i])) { - if(isPlayerLoggedIn(clients[i]) && isPlayerSpawned(clients[i])) { + for (let i in clients) { + if (isClientInitialized(clients[i])) { + if (isPlayerLoggedIn(clients[i]) && isPlayerSpawned(clients[i])) { getPlayerData(clients[i]).payDayStart = sdl.ticks; playerPayDay(clients[i]); @@ -227,8 +227,8 @@ function checkPayDays() { } } - for(let i in getServerData().businesses) { - if(getBusinessData(i).ownerType != VRR_BIZOWNER_NONE && getBusinessData(i).ownerType != VRR_BIZOWNER_PUBLIC && getBusinessData(i).ownerType != VRR_BIZOWNER_FACTION) { + for (let i in getServerData().businesses) { + if (getBusinessData(i).ownerType != VRR_BIZOWNER_NONE && getBusinessData(i).ownerType != VRR_BIZOWNER_PUBLIC && getBusinessData(i).ownerType != VRR_BIZOWNER_FACTION) { getBusinessData(i).till += 1000; } } @@ -237,14 +237,14 @@ function checkPayDays() { // =========================================================================== function showRandomTipToAllPlayers() { - let tipId = getRandom(0, randomTips.length-1); - let clients = getClients(); - for(let i in clients) { - if(isClientInitialized(clients[i])) { - if(isPlayerLoggedIn(clients[i]) && isPlayerSpawned(clients[i])) { - if(!doesPlayerHaveRandomTipsDisabled(clients[i])) { - messagePlayerTimedRandomTip(null, randomTips[tipId]); + for (let i in clients) { + if (isClientInitialized(clients[i])) { + if (isPlayerLoggedIn(clients[i]) && isPlayerSpawned(clients[i])) { + if (!doesPlayerHaveRandomTipsDisabled(clients[i])) { + let localeId = getPlayerLocaleId(clients[i]); + let tipId = getRandom(0, getServerData().localeStrings[localeId]["RandomTips"].length - 1); + messagePlayerTip(clients[i], getGroupedLocaleString(clients[i], "RandomTips", tipId)); } } } @@ -255,11 +255,11 @@ function showRandomTipToAllPlayers() { function checkInactiveVehicleRespawns() { let vehicles = getElementsByType(ELEMENT_VEHICLE); - for(let i in vehicles) { - if(getVehicleData(vehicles[i] != false)) { - if(isVehicleUnoccupied(vehicles[i])) { - if(getVehicleData(vehicles[i]).lastActiveTime != false) { - if(getCurrentUnixTimestamp() - getVehicleData(vehicles[i]).lastActiveTime >= getGlobalConfig().vehicleInactiveRespawnDelay) { + for (let i in vehicles) { + if (getVehicleData(vehicles[i] != false)) { + if (isVehicleUnoccupied(vehicles[i])) { + if (getVehicleData(vehicles[i]).lastActiveTime != false) { + if (getCurrentUnixTimestamp() - getVehicleData(vehicles[i]).lastActiveTime >= getGlobalConfig().vehicleInactiveRespawnDelay) { respawnVehicle(vehicles[i]); getVehicleData(vehicles[i]).lastActiveTime = false; } diff --git a/scripts/server/utilities.js b/scripts/server/utilities.js index a89a7821..275680a7 100644 --- a/scripts/server/utilities.js +++ b/scripts/server/utilities.js @@ -12,13 +12,13 @@ // =========================================================================== function getPositionArea(position) { - if(typeof position == "Vec3") { + if (typeof position == "Vec3") { position = vec3ToVec2(position); } let gameAreas = getGameAreas(getGame()); - for(let i in gameAreas) { - if(isPositionInArea(position, gameAreas[i][1])) { + for (let i in gameAreas) { + if (isPositionInArea(position, gameAreas[i][1])) { return i; } } @@ -30,7 +30,7 @@ function getPositionArea(position) { function getAreaName(position) { let areaId = getPositionArea(position); - if(!areaId) { + if (!areaId) { return false; } @@ -50,8 +50,8 @@ function getGameAreas(gameId) { * @return {ClientData} The player/client's data (class instancee) */ function getPlayerData(client) { - if(client != null) { - if(isClientInitialized(client)) { + if (client != null) { + if (isClientInitialized(client)) { return getServerData().clients[getPlayerId(client)]; } } @@ -61,7 +61,7 @@ function getPlayerData(client) { // =========================================================================== function initAllClients() { - getClients().forEach(function(client) { + getClients().forEach(function (client) { initClient(client); }); } @@ -72,17 +72,17 @@ function updateServerRules() { logToConsole(LOG_DEBUG, `[VRR.Utilities]: Updating all server rules ...`); logToConsole(LOG_DEBUG, `[VRR.Utilities]: Time support: ${isTimeSupported()}`); - if(isTimeSupported()) { - if(getServerConfig() != false) { + if (isTimeSupported()) { + if (getServerConfig() != false) { let value = makeReadableTime(getServerConfig().hour, getServerConfig().minute); logToConsole(LOG_DEBUG, `[VRR.Utilities]: Setting server rule "Time" as ${value}`); server.setRule("Time", value); } } - if(isWeatherSupported()) { - if(getServerConfig() != false) { - if(typeof getGameConfig().weatherNames[getGame()] != "undefined") { + if (isWeatherSupported()) { + if (getServerConfig() != false) { + if (typeof getGameConfig().weatherNames[getGame()] != "undefined") { let value = getGameConfig().weatherNames[getGame()][getServerConfig().weather]; logToConsole(LOG_DEBUG, `[VRR.Utilities]: Setting server rule "Weather" as ${value}`); server.setRule("Weather", value); @@ -90,8 +90,8 @@ function updateServerRules() { } } - if(isSnowSupported()) { - if(getServerConfig() != false) { + if (isSnowSupported()) { + if (getServerConfig() != false) { let value = getYesNoFromBool(getServerConfig().fallingSnow); logToConsole(LOG_DEBUG, `[VRR.Utilities]: Setting server rule "Snowing" as ${value}`); server.setRule("Snowing", value); @@ -103,14 +103,14 @@ function updateServerRules() { // =========================================================================== function getWeatherFromParams(params) { - if(isNaN(params)) { - for(let i in getGameConfig().weatherNames[getGame()]) { - if(toLowerCase(getGameConfig().weatherNames[getGame()][i]).indexOf(toLowerCase(params)) != -1) { + if (isNaN(params)) { + for (let i in getGameConfig().weatherNames[getGame()]) { + if (toLowerCase(getGameConfig().weatherNames[getGame()][i]).indexOf(toLowerCase(params)) != -1) { return i; } } } else { - if(typeof getGameConfig().weatherNames[getGame()][params] != "undefined") { + if (typeof getGameConfig().weatherNames[getGame()][params] != "undefined") { return toInteger(params); } } @@ -121,14 +121,14 @@ function getWeatherFromParams(params) { // =========================================================================== function getFightStyleFromParams(params) { - if(isNaN(params)) { - for(let i in getGameConfig().fightStyles[getGame()]) { - if(toLowerCase(getGameConfig().fightStyles[getGame()][i][0]).indexOf(toLowerCase(params)) != -1) { + if (isNaN(params)) { + for (let i in getGameConfig().fightStyles[getGame()]) { + if (toLowerCase(getGameConfig().fightStyles[getGame()][i][0]).indexOf(toLowerCase(params)) != -1) { return i; } } } else { - if(typeof getGameConfig().fightStyles[getGame()][params] != "undefined") { + if (typeof getGameConfig().fightStyles[getGame()][params] != "undefined") { return toInteger(params); } } @@ -139,12 +139,12 @@ function getFightStyleFromParams(params) { // =========================================================================== function getClosestHospital(position) { - if(typeof getGameConfig().hospitals[getGame()] == "undefined") { - return {position: getServerConfig().newCharacter.spawnPosition}; + if (typeof getGameConfig().hospitals[getGame()] == "undefined") { + return { position: getServerConfig().newCharacter.spawnPosition }; } else { let closest = 0; - for(let i in getGameConfig().hospitals[getGame()]) { - if(getDistance(getGameConfig().hospitals[getGame()][i].position, position) < getDistance(getGameConfig().hospitals[getGame()][closest].position, position)) { + for (let i in getGameConfig().hospitals[getGame()]) { + if (getDistance(getGameConfig().hospitals[getGame()][i].position, position) < getDistance(getGameConfig().hospitals[getGame()][closest].position, position)) { closest = i; } } @@ -156,12 +156,12 @@ function getClosestHospital(position) { // =========================================================================== function getClosestPoliceStation(position) { - if(typeof getGameConfig().policeStations[getGame()] == "undefined") { - return {position: getServerConfig().newCharacter.spawnPosition}; + if (typeof getGameConfig().policeStations[getGame()] == "undefined") { + return { position: getServerConfig().newCharacter.spawnPosition }; } else { let closest = 0; - for(let i in getGameConfig().policeStations[getGame()]) { - if(getDistance(getGameConfig().policeStations[getGame()][i].position, position) < getDistance(getGameConfig().policeStations[getGame()][closest].position, position)) { + for (let i in getGameConfig().policeStations[getGame()]) { + if (getDistance(getGameConfig().policeStations[getGame()][i].position, position) < getDistance(getGameConfig().policeStations[getGame()][closest].position, position)) { closest = i; } } @@ -173,7 +173,7 @@ function getClosestPoliceStation(position) { // =========================================================================== function getPlayerDisplayForConsole(client) { - if(isNull(client)) { + if (isNull(client)) { return "(Unknown client)"; } return `${getPlayerName(client)}[${getPlayerId(client)}]`; @@ -182,7 +182,7 @@ function getPlayerDisplayForConsole(client) { // =========================================================================== function getPlayerNameForNameTag(client) { - if(isPlayerSpawned(client)) { + if (isPlayerSpawned(client)) { return `${getPlayerCurrentSubAccount(client).firstName} ${getPlayerCurrentSubAccount(client).lastName}`; } return getPlayerName(client); @@ -191,7 +191,7 @@ function getPlayerNameForNameTag(client) { // =========================================================================== function isPlayerSpawned(client) { - if(!getPlayerData(client)) { + if (!getPlayerData(client)) { return false; } return getPlayerData(client).spawned; @@ -206,8 +206,8 @@ function getPlayerIsland(client) { // =========================================================================== function isAtPayAndSpray(position) { - for(let i in getGameConfig().payAndSprays[getGame()]) { - if(getDistance(position, getGameConfig().payAndSprays[getGame()][i]) <= getGlobalConfig().payAndSprayDistance) { + for (let i in getGameConfig().payAndSprays[getGame()]) { + if (getDistance(position, getGameConfig().payAndSprays[getGame()][i]) <= getGlobalConfig().payAndSprayDistance) { return true; } } @@ -220,15 +220,15 @@ function isAtPayAndSpray(position) { function resetClientStuff(client) { logToConsole(LOG_DEBUG, `[VRR.Utilities] Resetting client data for ${getPlayerDisplayForConsole(client)}`); - if(!getPlayerData(client)) { + if (!getPlayerData(client)) { return false; } - if(isPlayerOnJobRoute(client)) { + if (isPlayerOnJobRoute(client)) { stopJobRoute(client, false, false); } - if(getPlayerData(client).rentingVehicle) { + if (getPlayerData(client).rentingVehicle) { stopRentingVehicle(client); } @@ -241,9 +241,9 @@ function resetClientStuff(client) { function getPlayerFromCharacterId(subAccountId) { let clients = getClients(); - for(let i in clients) { - for(let j in getPlayerData(clients[i]).subAccounts) { - if(getPlayerData(clients[i]).subAccounts[j].databaseId == subAccountId) { + for (let i in clients) { + for (let j in getPlayerData(clients[i]).subAccounts) { + if (getPlayerData(clients[i]).subAccounts[j].databaseId == subAccountId) { return clients[i]; } } @@ -256,11 +256,11 @@ function getPlayerFromCharacterId(subAccountId) { function checkPlayerPedStates() { let clients = getClients(); - for(let i in clients) { - if(getPlayerData(clients[i])) { - if(getPlayerData(clients[i]).pedState) { - if(isPlayerInAnyVehicle(clients[i])) { - if(getPlayerData(clients[i]).pedState == VRR_PEDSTATE_EXITINGVEHICLE) { + for (let i in clients) { + if (getPlayerData(clients[i])) { + if (getPlayerData(clients[i]).pedState) { + if (isPlayerInAnyVehicle(clients[i])) { + if (getPlayerData(clients[i]).pedState == VRR_PEDSTATE_EXITINGVEHICLE) { getPlayerData(clients[i]).pedState == VRR_PEDSTATE_READY; } } @@ -272,11 +272,11 @@ function checkPlayerPedStates() { // =========================================================================== function showConnectCameraToPlayer(client) { - if(isFadeCameraSupported()) { + if (isFadeCameraSupported()) { fadeCamera(client, true, 1); } - if(isCustomCameraSupported()) { + if (isCustomCameraSupported()) { //setPlayerInterior(client, 0); //setPlayerDimension(client, 0); setPlayerCameraLookAt(client, getServerConfig().connectCameraPosition, getServerConfig().connectCameraLookAt); @@ -295,9 +295,9 @@ function showCharacterSelectCameraToPlayer(client) { function getClosestPlayer(position, exemptPlayer) { let clients = getClients(); let closest = 0; - for(let i in clients) { - if(exemptClient != clients[i]) { - if(getDistance(getPlayerPosition(clients[i]), position) < getDistance(getPlayerPosition(clients[closest]), position)) { + for (let i in clients) { + if (exemptClient != clients[i]) { + if (getDistance(getPlayerPosition(clients[i]), position) < getDistance(getPlayerPosition(clients[closest]), position)) { closest = i; } } @@ -315,20 +315,20 @@ function isPlayerMuted(client) { 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) { + if (isNaN(params)) { + for (let i in clients) { + if (!clients[i].console) { + if (toLowerCase(clients[i].name).indexOf(toLowerCase(params)) != -1) { return clients[i]; } - if(toLowerCase(getCharacterFullName(clients[i])).indexOf(toLowerCase(params)) != -1) { + if (toLowerCase(getCharacterFullName(clients[i])).indexOf(toLowerCase(params)) != -1) { return clients[i]; } } } } else { - if(typeof clients[toInteger(params)] != "undefined") { + if (typeof clients[toInteger(params)] != "undefined") { return clients[toInteger(params)]; } } @@ -339,7 +339,7 @@ function getPlayerFromParams(params) { // =========================================================================== function updateConnectionLogOnQuit(client, quitReasonId) { - if(getPlayerData(client) != false) { + if (getPlayerData(client) != false) { quickDatabaseQuery(`UPDATE conn_main SET conn_when_disconnect=NOW(), conn_how_disconnect=${quitReasonId} WHERE conn_id = ${getPlayerData(client).sessionId}`); } } @@ -353,12 +353,12 @@ function updateConnectionLogOnAuth(client, authId) { // =========================================================================== function updateConnectionLogOnClientInfoReceive(client, clientVersion, screenWidth, screenHeight) { - if(getPlayerData(client) != false) { + if (getPlayerData(client) != false) { getPlayerData(client).clientVersion = clientVersion; } let dbConnection = connectToDatabase(); - if(dbConnection) { + if (dbConnection) { let safeClientVersion = escapeDatabaseString(dbConnection, clientVersion); let safeScreenWidth = escapeDatabaseString(dbConnection, toString(screenWidth)); let safeScreenHeight = escapeDatabaseString(dbConnection, toString(screenHeight)); @@ -377,8 +377,8 @@ function generateRandomPhoneNumber() { function doesNameContainInvalidCharacters(name) { let disallowedCharacters = getGlobalConfig().subAccountNameAllowedCharacters; name = toLowerCase(name); - for(let i = 0; i < name.length; i++) { - if(disallowedCharacters.toLowerCase().indexOf(name.charAt(i)) == -1) { + for (let i = 0; i < name.length; i++) { + if (disallowedCharacters.toLowerCase().indexOf(name.charAt(i)) == -1) { return true; } } @@ -394,36 +394,12 @@ function getClientFromSyncerId(syncerId) { // =========================================================================== -function triggerWebHook(messageString, serverId = getServerId(), type = VRR_DISCORD_WEBHOOK_LOG) { - if(!getGlobalConfig().discord.webhook.enabled) { - return false; - } - - let tempURL = getGlobalConfig().discord.webhook.webhookBaseURL; - tempURL = tempURL.replace("{0}", encodeURI(messageString)); - tempURL = tempURL.replace("{1}", serverId); - tempURL = tempURL.replace("{2}", type); - tempURL = tempURL.replace("{3}", getGlobalConfig().discord.webhook.pass); - - httpGet( - tempURL, - "", - function(data) { - - }, - function(data) { - } - ); -} - -// =========================================================================== - function clearTemporaryVehicles() { let vehicles = getElementsByType(ELEMENT_VEHICLE); - for(let i in vehicles) { - if(!getVehicleData(vehicles[i])) { + for (let i in vehicles) { + if (!getVehicleData(vehicles[i])) { let occupants = vehicles[i].getOccupants(); - for(let j in occupants) { + for (let j in occupants) { destroyGameElement(occupants[j]); } destroyGameElement(vehicles[i]); @@ -435,11 +411,11 @@ function clearTemporaryVehicles() { function clearTemporaryPeds() { let peds = getElementsByType(ELEMENT_PED); - for(let i in peds) { - if(peds[i].owner == -1) { - if(!peds[i].isType(ELEMENT_PLAYER)) { - if(peds[i].vehicle == null) { - if(!getNPCData(peds[i])) { + for (let i in peds) { + if (peds[i].owner == -1) { + if (!peds[i].isType(ELEMENT_PLAYER)) { + if (peds[i].vehicle == null) { + if (!getNPCData(peds[i])) { destroyElement(peds[i]); } } @@ -452,6 +428,7 @@ function clearTemporaryPeds() { function kickAllClients() { getClients().forEach((client) => { + getPlayerData(client).customDisconnectReason = `Kicked - All clients are being disconnected`; disconnectPlayer(client); }) } @@ -459,7 +436,7 @@ function kickAllClients() { // =========================================================================== function updateTimeRule() { - if(isTimeSupported()) { + if (isTimeSupported()) { server.setRule("Time", makeReadableTime(game.time.hour, game.time.minute)); } } @@ -473,7 +450,7 @@ function isClientInitialized(client) { // =========================================================================== function getPedForNetworkEvent(ped) { - if(getGame() == VRR_GAME_GTA_IV) { + if (getGame() == VRR_GAME_GTA_IV) { return ped; } else { return ped.id; @@ -485,10 +462,10 @@ function getPedForNetworkEvent(ped) { // Get how many times a player connected in the last month by name function getPlayerConnectionsInLastMonthByName(name) { let dbConnection = connectToDatabase(); - if(dbConnection) { + if (dbConnection) { let safeName = escapeDatabaseString(dbConnection, name); let result = quickDatabaseQuery(`SELECT COUNT(*) AS count FROM conn_main WHERE conn_when_connect >= NOW() - INTERVAL 1 MONTH AND conn_name = '${safeName}'`); - if(result) { + if (result) { return result[0].count; } } @@ -500,7 +477,7 @@ function getPlayerConnectionsInLastMonthByName(name) { function addPrefixNumberFill(number, amount) { let numberString = toString(number); - while(numberString.length < amount) { + while (numberString.length < amount) { numberString = toString(`0${numberString}`); } return toString(numberString); diff --git a/scripts/server/vehicle.js b/scripts/server/vehicle.js index 2b232073..da43e51f 100644 --- a/scripts/server/vehicle.js +++ b/scripts/server/vehicle.js @@ -20,11 +20,11 @@ function loadVehiclesFromDatabase() { let dbConnection = connectToDatabase(); let tempVehicles = []; let dbAssoc; - if(dbConnection) { + if (dbConnection) { let dbQueryString = `SELECT * FROM veh_main WHERE veh_server = ${getServerId()} AND veh_deleted = 0`; let dbQuery = queryDatabase(dbConnection, dbQueryString); - if(dbQuery) { - while(dbAssoc = fetchQueryAssoc(dbQuery)) { + if (dbQuery) { + while (dbAssoc = fetchQueryAssoc(dbQuery)) { let tempVehicleData = new VehicleData(dbAssoc); tempVehicles.push(tempVehicleData); } @@ -40,14 +40,14 @@ function loadVehiclesFromDatabase() { // =========================================================================== function saveAllVehiclesToDatabase() { - if(getServerConfig().devServer) { + if (getServerConfig().devServer) { return false; } logToConsole(LOG_INFO, "[VRR.Vehicle]: Saving all server vehicles to database ..."); let vehicles = getServerData().vehicles; - for(let i in vehicles) { - if(vehicles[i].needsSaved) { + for (let i in vehicles) { + if (vehicles[i].needsSaved) { saveVehicleToDatabase(i); } } @@ -59,29 +59,29 @@ function saveAllVehiclesToDatabase() { // =========================================================================== function saveVehicleToDatabase(vehicleDataId) { - if(getVehicleData(vehicleDataId) == null) { + if (getVehicleData(vehicleDataId) == null) { // Invalid vehicle data return false; } let tempVehicleData = getServerData().vehicles[vehicleDataId]; - if(tempVehicleData.databaseId == -1) { + if (tempVehicleData.databaseId == -1) { // Temp vehicle, no need to save return false; } - if(!tempVehicleData.needsSaved) { + if (!tempVehicleData.needsSaved) { // Vehicle hasn't changed. No need to save. return false; } logToConsole(LOG_VERBOSE, `[VRR.Vehicle]: Saving vehicle ${tempVehicleData.databaseId} to database ...`); let dbConnection = connectToDatabase(); - if(dbConnection) { - if(tempVehicleData.vehicle != false) { - if(!tempVehicleData.spawnLocked) { - if(areServerElementsSupported()) { + if (dbConnection) { + if (tempVehicleData.vehicle != false) { + if (!tempVehicleData.spawnLocked) { + if (areServerElementsSupported()) { tempVehicleData.spawnPosition = tempVehicleData.vehicle.position; tempVehicleData.spawnRotation = tempVehicleData.vehicle.heading; } else { @@ -112,19 +112,19 @@ function saveVehicleToDatabase(vehicleDataId) { ["veh_col2_isrgb", boolToInt(tempVehicleData.colour2IsRGBA)], ["veh_col3_isrgb", boolToInt(tempVehicleData.colour3IsRGBA)], ["veh_col4_isrgb", boolToInt(tempVehicleData.colour4IsRGBA)], - ["veh_extra1", tempVehicleData.extras[0]], - ["veh_extra2", tempVehicleData.extras[1]], - ["veh_extra3", tempVehicleData.extras[2]], - ["veh_extra4", tempVehicleData.extras[3]], - ["veh_extra5", tempVehicleData.extras[4]], - ["veh_extra6", tempVehicleData.extras[5]], - ["veh_extra7", tempVehicleData.extras[6]], - ["veh_extra8", tempVehicleData.extras[7]], - ["veh_extra9", tempVehicleData.extras[8]], - ["veh_extra10", tempVehicleData.extras[9]], - ["veh_extra11", tempVehicleData.extras[10]], - ["veh_extra12", tempVehicleData.extras[11]], - ["veh_extra13", tempVehicleData.extras[12]], + //["veh_extra1", tempVehicleData.extras[0]], + //["veh_extra2", tempVehicleData.extras[1]], + //["veh_extra3", tempVehicleData.extras[2]], + //["veh_extra4", tempVehicleData.extras[3]], + //["veh_extra5", tempVehicleData.extras[4]], + //["veh_extra6", tempVehicleData.extras[5]], + //["veh_extra7", tempVehicleData.extras[6]], + //["veh_extra8", tempVehicleData.extras[7]], + //["veh_extra9", tempVehicleData.extras[8]], + //["veh_extra10", tempVehicleData.extras[9]], + //["veh_extra11", tempVehicleData.extras[10]], + //["veh_extra12", tempVehicleData.extras[11]], + //["veh_extra13", tempVehicleData.extras[12]], ["veh_engine", intToBool(tempVehicleData.engine)], ["veh_lights", intToBool(tempVehicleData.lights)], ["veh_health", toInteger(tempVehicleData.health)], @@ -137,7 +137,7 @@ function saveVehicleToDatabase(vehicleDataId) { ]; let dbQuery = null; - if(tempVehicleData.databaseId == 0) { + if (tempVehicleData.databaseId == 0) { let queryString = createDatabaseInsertQuery("veh_main", data); dbQuery = queryDatabase(dbConnection, queryString); getServerData().vehicles[vehicleDataId].databaseId = getDatabaseInsertId(dbConnection); @@ -160,7 +160,7 @@ function saveVehicleToDatabase(vehicleDataId) { // =========================================================================== function spawnAllVehicles() { - for(let i in getServerData().vehicles) { + for (let i in getServerData().vehicles) { let vehicle = spawnVehicle(getServerData().vehicles[i]); getServerData().vehicles[i].vehicle = vehicle; setEntityData(vehicle, "vrr.dataSlot", i, false); @@ -175,10 +175,10 @@ function spawnAllVehicles() { * @return {VehicleData} The vehicles's data (class instance) */ function getVehicleData(vehicle) { - if(getGame() != VRR_GAME_GTA_IV) { - if(isVehicleObject(vehicle)) { + if (getGame() != VRR_GAME_GTA_IV) { + if (isVehicleObject(vehicle)) { let dataIndex = getEntityData(vehicle, "vrr.dataSlot"); - if(typeof getServerData().vehicles[dataIndex] != "undefined") { + if (typeof getServerData().vehicles[dataIndex] != "undefined") { return getServerData().vehicles[dataIndex]; } } @@ -192,20 +192,20 @@ function getVehicleData(vehicle) { // =========================================================================== function createVehicleCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } let modelIndex = getVehicleModelIndexFromParams(params); - if(!modelIndex) { + if (!modelIndex) { messagePlayerError(client, "That vehicle type is invalid!"); return false; } let heading = getPlayerHeading(client); - if(getGame() == VRR_GAME_MAFIA_ONE) { + if (getGame() == VRR_GAME_MAFIA_ONE) { heading = degToRad(getPlayerHeading(client)); } @@ -218,14 +218,14 @@ function createVehicleCommand(command, params, client) { // =========================================================================== function createTemporaryVehicleCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } let modelIndex = getVehicleModelIndexFromParams(params); - if(!modelIndex) { + if (!modelIndex) { messagePlayerError(client, "That vehicle type is invalid!"); return false; } @@ -241,34 +241,34 @@ function createTemporaryVehicleCommand(command, params, client) { function getNearbyVehiclesCommand(command, params, client) { let distance = 10.0; - if(!areParamsEmpty(params)) { + if (!areParamsEmpty(params)) { distance = getParam(params, " ", 1); } - if(isNaN(distance)) { + if (isNaN(distance)) { messagePlayerError(client, "The distance must be a number!"); return false; } distance = toFloat(distance); - if(distance <= 0) { + if (distance <= 0) { messagePlayerError(client, "The distance must be more than 0!"); return false; } let nearbyVehicles = getVehiclesInRange(getPlayerPosition(client), distance); - if(nearbyVehicles.length == 0) { + if (nearbyVehicles.length == 0) { messagePlayerAlert(client, getLocaleString(client, "NoVehiclesWithinRange", distance)); return false; } - let vehiclesList = nearbyVehicles.map(function(x) { return `{ALTCOLOUR}${getVehicleData(x).index}: {MAINCOLOUR}${getVehicleName(x)} {darkGrey}(${getDistance(getPlayerPosition(client), getVehiclePosition(x))} ${getLocaleString(client, "Meters")} ${getGroupedLocaleString(client, "CardinalDirections")[getCardinalDirection(getPlayerPosition(client), getVehiclePosition(x))]}})`; }); + let vehiclesList = nearbyVehicles.map(function (x) { return `{ALTCOLOUR}${getVehicleData(x).index}: {MAINCOLOUR}${getVehicleName(x)} {darkGrey}(${getDistance(getPlayerPosition(client), getVehiclePosition(x))} ${getLocaleString(client, "Meters")} ${getGroupedLocaleString(client, "CardinalDirections")[getCardinalDirection(getPlayerPosition(client), getVehiclePosition(x))]}})`; }); let chunkedList = splitArrayIntoChunks(vehiclesList, 4); messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderVehiclesInRangeList"))); - for(let i in chunkedList) { + for (let i in chunkedList) { messagePlayerInfo(client, chunkedList[i].join(", ")); } } @@ -279,17 +279,17 @@ function vehicleTrunkCommand(command, params, client) { let vehicle = getClosestVehicle(getPlayerPosition(client)); let behindPosition = getPosBehindPos(getVehiclePosition(vehicle), getVehicleHeading(vehicle), getGlobalConfig().vehicleTrunkDistance); - if(!getPlayerVehicle(client) && getDistance(behindPosition, getPlayerPosition(client)) > getGlobalConfig().vehicleTrunkDistance) { + if (!getPlayerVehicle(client) && getDistance(behindPosition, getPlayerPosition(client)) > getGlobalConfig().vehicleTrunkDistance) { messagePlayerError(client, getLocaleString(client, "MustBeInOrNearVehicle")); return false; } - if(!getVehicleData(vehicle)) { + if (!getVehicleData(vehicle)) { messagePlayerError(client, getLocaleString(client, "RandomVehicleCommandsDisabled")); return false; } - if(!doesPlayerHaveVehicleKeys(client, vehicle)) { + if (!doesPlayerHaveVehicleKeys(client, vehicle)) { messagePlayerError(client, getLocaleString(client, "DontHaveVehicleKey")); return false; } @@ -304,19 +304,19 @@ function vehicleTrunkCommand(command, params, client) { // =========================================================================== function vehicleLightsCommand(command, params, client) { - if(!getPlayerVehicle(client)) { + if (!getPlayerVehicle(client)) { messagePlayerError(client, getLocaleString(client, "MustBeInAVehicle")); return false; } let vehicle = getPlayerVehicle(client); - if(!getVehicleData(vehicle)) { + if (!getVehicleData(vehicle)) { messagePlayerError(client, getLocaleString(client, "RandomVehicleCommandsDisabled")); return false; } - if(getPlayerVehicleSeat(client) > 1) { + if (getPlayerVehicleSeat(client) > 1) { messagePlayerError(client, getLocaleString(client, "MustBeInVehicleFrontSeat")); return false; } @@ -331,14 +331,14 @@ function vehicleLightsCommand(command, params, client) { // =========================================================================== function deleteVehicleCommand(command, params, client) { - if(!getPlayerVehicle(client)) { + if (!getPlayerVehicle(client)) { messagePlayerError(client, getLocaleString(client, "MustBeInAVehicle")); return false; } let vehicle = getPlayerVehicle(client); - if(!getVehicleData(vehicle)) { + if (!getVehicleData(vehicle)) { messagePlayerError(client, getLocaleString(client, "RandomVehicleCommandsDisabled")); return false; } @@ -346,7 +346,7 @@ function deleteVehicleCommand(command, params, client) { let dataIndex = getEntityData(vehicle, "vrr.dataSlot"); let vehicleName = getVehicleName(vehicle); - quickDatabaseQuery(`DELETE FROM veh_main WHERE veh_id = ${getVehicleData(vehicle).databaseId}`); + quickDatabaseQuery(`UPDATE veh_main SET veh_deleted = 1 WHERE veh_id = ${getVehicleData(vehicle).databaseId}`); getServerData().vehicles.splice(dataIndex, 1); destroyElement(vehicle); @@ -357,24 +357,24 @@ function deleteVehicleCommand(command, params, client) { // =========================================================================== function vehicleEngineCommand(command, params, client) { - if(!getPlayerVehicle(client)) { + if (!getPlayerVehicle(client)) { messagePlayerError(client, getLocaleString(client, "MustBeInAVehicle")); return false; } - if(getPlayerVehicleSeat(client) > 0) { + if (getPlayerVehicleSeat(client) > 0) { messagePlayerError(client, getLocaleString(client, "MustBeInVehicleDriverSeat")); return false; } let vehicle = getPlayerVehicle(client); - if(!doesPlayerHaveVehicleKeys(client, vehicle)) { + if (!doesPlayerHaveVehicleKeys(client, vehicle)) { messagePlayerError(client, getLocaleString(client, "DontHaveVehicleKey")); return false; } - if(!getVehicleData(vehicle)) { + if (!getVehicleData(vehicle)) { messagePlayerError(client, getLocaleString(client, "RandomVehicleCommandsDisabled")); return false; } @@ -391,24 +391,24 @@ function vehicleEngineCommand(command, params, client) { // =========================================================================== function vehicleSirenCommand(command, params, client) { - if(!getPlayerVehicle(client)) { + if (!getPlayerVehicle(client)) { messagePlayerError(client, getLocaleString(client, "MustBeInAVehicle")); return false; } let vehicle = getPlayerVehicle(client); - if(!getVehicleData(vehicle)) { + if (!getVehicleData(vehicle)) { messagePlayerError(client, getLocaleString(client, "RandomVehicleCommandsDisabled")); return false; } - if(getPlayerVehicleSeat(client) > 1) { + if (getPlayerVehicleSeat(client) > 1) { messagePlayerError(client, getLocaleString(client, "MustBeInVehicleFrontSeat")); return false; } - if(!doesPlayerHaveVehicleKeys(client, vehicle)) { + if (!doesPlayerHaveVehicleKeys(client, vehicle)) { messagePlayerError(client, getLocaleString(client, "DontHaveVehicleKey")); return false; } @@ -424,19 +424,19 @@ function vehicleSirenCommand(command, params, client) { // =========================================================================== function vehicleAdminColourCommand(command, params, client) { - if(areParamsEmpty(params) && areThereEnoughParams(params, 2)) { + if (areParamsEmpty(params) && areThereEnoughParams(params, 2)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } - if(!getPlayerVehicle(client)) { + if (!getPlayerVehicle(client)) { messagePlayerError(client, getLocaleString(client, "MustBeInAVehicle")); return false; } let vehicle = getPlayerVehicle(client); - if(!getVehicleData(vehicle)) { + if (!getVehicleData(vehicle)) { messagePlayerError(client, getLocaleString(client, "RandomVehicleCommandsDisabled")); return false; } @@ -459,7 +459,7 @@ function vehicleAdminColourCommand(command, params, client) { // =========================================================================== function vehicleAdminRepairCommand(command, params, client) { - if(!isPlayerInAnyVehicle(client)) { + if (!isPlayerInAnyVehicle(client)) { logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)} could not repair their vehicle. Reason: Not in a vehicle.`); messagePlayerError(client, getLocaleString(client, "MustBeInAVehicle")); return false; @@ -467,7 +467,7 @@ function vehicleAdminRepairCommand(command, params, client) { let vehicle = getPlayerVehicle(client); - if(!getVehicleData(vehicle)) { + if (!getVehicleData(vehicle)) { logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)} could not repair their ${getVehicleName(vehicle)} vehicle. Not a server vehicle.`); messagePlayerError(client, getLocaleString(client, "RandomVehicleCommandsDisabled")); return false; @@ -483,20 +483,20 @@ function vehicleAdminRepairCommand(command, params, client) { // =========================================================================== function vehicleAdminLiveryCommand(command, params, client) { - if(!isPlayerInAnyVehicle(client)) { + if (!isPlayerInAnyVehicle(client)) { messagePlayerError(client, getLocaleString(client, "MustBeInAVehicle")); return false; } let vehicle = getPlayerVehicle(client); - if(!getVehicleData(vehicle)) { + if (!getVehicleData(vehicle)) { messagePlayerError(client, getLocaleString(client, "RandomVehicleCommandsDisabled")); return false; } - if(getPlayerCurrentSubAccount(client).cash < getGlobalConfig().repairVehicleCost) { - messagePlayerError(client, `You don't have enough money to change the vehicle's livery (need $${makeLargeNumberReadable(getGlobalConfig().resprayVehicleCost-getPlayerCurrentSubAccount(client).cash)} more!)`); + if (getPlayerCurrentSubAccount(client).cash < getGlobalConfig().repairVehicleCost) { + messagePlayerError(client, `You don't have enough money to change the vehicle's livery (need $${makeLargeNumberReadable(getGlobalConfig().resprayVehicleCost - getPlayerCurrentSubAccount(client).cash)} more!)`); return false; } @@ -516,24 +516,24 @@ function vehicleAdminLiveryCommand(command, params, client) { // =========================================================================== function buyVehicleCommand(command, params, client) { - if(!isPlayerInAnyVehicle(client)) { + if (!isPlayerInAnyVehicle(client)) { messagePlayerError(client, getLocaleString(client, "MustBeInAVehicle")); return false; } let vehicle = getPlayerVehicle(client); - if(!getVehicleData(vehicle)) { + if (!getVehicleData(vehicle)) { messagePlayerError(client, getLocaleString(client, "RandomVehicleCommandsDisabled")); return false; } - if(getVehicleData(vehicle).buyPrice <= 0) { + if (getVehicleData(vehicle).buyPrice <= 0) { messagePlayerError(client, getLocaleString(client, "VehicleNotForSale")); return false; } - if(getPlayerCurrentSubAccount(client).cash < getVehicleData(vehicle).buyPrice) { + if (getPlayerCurrentSubAccount(client).cash < getVehicleData(vehicle).buyPrice) { messagePlayerError(client, getLocaleString(client, "VehiclePurchaseNotEnoughMoney")); return false; } @@ -553,31 +553,31 @@ function buyVehicleCommand(command, params, client) { // =========================================================================== function rentVehicleCommand(command, params, client) { - if(!isPlayerInAnyVehicle(client)) { + if (!isPlayerInAnyVehicle(client)) { messagePlayerError(client, getLocaleString(client, "MustBeInAVehicle")); return false; } let vehicle = getPlayerVehicle(client); - if(!getVehicleData(vehicle)) { + if (!getVehicleData(vehicle)) { messagePlayerError(client, getLocaleString(client, "RandomVehicleCommandsDisabled")); return false; } - if(getVehicleData(vehicle).rentPrice <= 0) { + if (getVehicleData(vehicle).rentPrice <= 0) { messagePlayerError(client, getLocaleString(client, "VehicleNotForRent")); return false; } - if(getPlayerData(client).rentingVehicle) { + if (getPlayerData(client).rentingVehicle) { messagePlayerAlert(client, `You are no longer renting the ${getVehicleName(vehicle)}`); stopRentingVehicle(client); return false; } - if(getVehicleData(vehicle).rentedBy != false) { - if(getVehicleData(vehicle).rentedBy != client) { + if (getVehicleData(vehicle).rentedBy != false) { + if (getVehicleData(vehicle).rentedBy != client) { messagePlayerAlert(client, `Someone else is already renting this vehicle!`); return false; } else { @@ -586,8 +586,8 @@ function rentVehicleCommand(command, params, client) { } } - if(getVehicleData(vehicle).rentPrice > getPlayerCurrentSubAccount(client).cash) { - messagePlayerError(client, getLocaleString(client, "NotEnoughCashNeedAmountMore", getVehicleData(vehicle).rentPrice-getPlayerCurrentSubAccount(client).cash)); + if (getVehicleData(vehicle).rentPrice > getPlayerCurrentSubAccount(client).cash) { + messagePlayerError(client, getLocaleString(client, "NotEnoughCashNeedAmountMore", getVehicleData(vehicle).rentPrice - getPlayerCurrentSubAccount(client).cash)); return false; } @@ -600,8 +600,8 @@ function rentVehicleCommand(command, params, client) { meActionToNearbyPlayers(client, `rents the ${getVehicleName(vehicle)} and receives a set of vehicle keys!`); messagePlayerAlert(client, `You will be charged $${makeLargeNumberReadable(getVehicleData(vehicle).rentPrice)} per minute to use this vehicle. To stop renting this vehicle, use /vehrent again.`); - if(!getVehicleData(vehicle).engine) { - if(!doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForCommand(client, "engine")) { + if (!getVehicleData(vehicle).engine) { + if (!doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForCommand(client, "engine")) { messagePlayerTip(client, `The ${getVehicleName(vehicle)}'s engine is off. Press {ALTCOLOUR}${toUpperCase(getKeyNameFromId(getPlayerKeyBindForCommand(client, "engine").key))} {MAINCOLOUR}to start it.`); } else { messagePlayerAlert(client, `The ${getVehicleName(vehicle)}'s engine is off. Use /engine to start it`); @@ -618,7 +618,7 @@ function enterVehicleAsPassengerCommand(command, params, client) { // =========================================================================== function stopRentingVehicleCommand(command, params, client) { - if(!getPlayerData(client).rentingVehicle) { + if (!getPlayerData(client).rentingVehicle) { messagePlayerError(client, "You aren't renting a vehicle!"); return false; } @@ -635,43 +635,43 @@ function stopRentingVehicleCommand(command, params, client) { function doesPlayerHaveVehicleKeys(client, vehicle) { let vehicleData = getVehicleData(vehicle); - if(doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageVehicles"))) { + if (doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageVehicles"))) { return true; } - if(vehicleData.ownerType == VRR_VEHOWNER_PUBLIC) { + if (vehicleData.ownerType == VRR_VEHOWNER_PUBLIC) { return true; } - if(vehicleData.ownerType == VRR_VEHOWNER_PLAYER) { - if(vehicleData.ownerId == getPlayerCurrentSubAccount(client).databaseId) { + if (vehicleData.ownerType == VRR_VEHOWNER_PLAYER) { + if (vehicleData.ownerId == getPlayerCurrentSubAccount(client).databaseId) { return true; } } - if(vehicleData.ownerType == VRR_VEHOWNER_CLAN) { - if(vehicleData.ownerId == getPlayerCurrentSubAccount(client).clan) { - if(vehicleData.clanRank <= getPlayerCurrentSubAccount(client).clanRank) { + if (vehicleData.ownerType == VRR_VEHOWNER_CLAN) { + if (vehicleData.ownerId == getPlayerCurrentSubAccount(client).clan) { + if (vehicleData.clanRank <= getPlayerCurrentSubAccount(client).clanRank) { return true; } } } - if(vehicleData.ownerType == VRR_VEHOWNER_FACTION) { - if(vehicleData.ownerId == getPlayerCurrentSubAccount(client).faction) { - if(vehicleData.factionRank <= getPlayerCurrentSubAccount(client).factionRank) { + if (vehicleData.ownerType == VRR_VEHOWNER_FACTION) { + if (vehicleData.ownerId == getPlayerCurrentSubAccount(client).faction) { + if (vehicleData.factionRank <= getPlayerCurrentSubAccount(client).factionRank) { return true; } } } - if(vehicleData.ownerType == VRR_VEHOWNER_JOB) { - if(vehicleData.ownerId == getPlayerCurrentSubAccount(client).job) { + if (vehicleData.ownerType == VRR_VEHOWNER_JOB) { + if (vehicleData.ownerId == getPlayerCurrentSubAccount(client).job) { return true; } } - if(vehicleData.rentedBy == client) { + if (vehicleData.rentedBy == client) { return true; } @@ -683,19 +683,19 @@ function doesPlayerHaveVehicleKeys(client, vehicle) { function doesClientOwnVehicle(client, vehicle) { let vehicleData = getVehicleData(vehicle); - if(doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageVehicles"))) { + if (doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageVehicles"))) { return true; } - if(vehicleData.ownerType == VRR_VEHOWNER_PLAYER) { - if(vehicleData.ownerId == getPlayerData(client).accountData.databaseId) { + if (vehicleData.ownerType == VRR_VEHOWNER_PLAYER) { + if (vehicleData.ownerId == getPlayerData(client).accountData.databaseId) { return true; } } - if(vehicleData.ownerType == VRR_VEHOWNER_CLAN) { - if(vehicleData.ownerId == getPlayerCurrentSubAccount(client).clan) { - if(doesPlayerHaveClanPermission(client, "ManageVehicles") || doesPlayerHaveClanPermission(client, "owner")) { + if (vehicleData.ownerType == VRR_VEHOWNER_CLAN) { + if (vehicleData.ownerId == getPlayerCurrentSubAccount(client).clan) { + if (doesPlayerHaveClanPermission(client, "ManageVehicles") || doesPlayerHaveClanPermission(client, "owner")) { return true; } } @@ -707,14 +707,14 @@ function doesClientOwnVehicle(client, vehicle) { // =========================================================================== function setVehicleJobCommand(command, params, client) { - if(!isPlayerInAnyVehicle(client)) { + if (!isPlayerInAnyVehicle(client)) { messagePlayerError(client, "You need to be in a vehicle!"); return false; } let vehicle = getPlayerVehicle(client); - if(!getVehicleData(vehicle)) { + if (!getVehicleData(vehicle)) { messagePlayerError(client, getLocaleString(client, "RandomVehicleCommandsDisabled")); return false; } @@ -722,7 +722,7 @@ function setVehicleJobCommand(command, params, client) { let closestJobLocation = getClosestJobLocation(getVehiclePosition(vehicle)); let jobId = closestJobLocation.job; - if(!areParamsEmpty(params)) { + if (!areParamsEmpty(params)) { jobId = getJobFromParams(params); } @@ -743,12 +743,12 @@ function setVehicleJobCommand(command, params, client) { // =========================================================================== function setVehicleRankCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } - if(!isPlayerInAnyVehicle(client)) { + if (!isPlayerInAnyVehicle(client)) { messagePlayerError(client, "You need to be in a vehicle!"); return false; } @@ -756,20 +756,20 @@ function setVehicleRankCommand(command, params, client) { let vehicle = getPlayerVehicle(client); let rankId = params; - if(!getVehicleData(vehicle)) { + if (!getVehicleData(vehicle)) { messagePlayerError(client, getLocaleString(client, "RandomVehicleCommandsDisabled")); return false; } - if(getVehicleData(vehicle).ownerType == VRR_VEHOWNER_CLAN) { + if (getVehicleData(vehicle).ownerType == VRR_VEHOWNER_CLAN) { rankId = getClanRankFromParams(getVehicleData(vehicle).ownerId, params); - if(!getClanRankData(getVehicleData(vehicle).ownerId, rankId)) { + if (!getClanRankData(getVehicleData(vehicle).ownerId, rankId)) { messagePlayerError(client, getLocaleString(client, "ClanRankInvalid")); return false; } getVehicleData(vehicle).rank = getClanRankData(getVehicleData(vehicle).ownerId, rankId).databaseId; messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} set their {vehiclePurple}${getVehicleName(vehicle)}{MAINCOLOUR} rank to {ALTCOLOUR}${getClanRankData(getVehicleData(vehicle).ownerId, rankId).name}{MAINCOLOUR} of the {clanOrange}${getClanData(getVehicleData(vehicle).ownerId).name}{MAINCOLOUR} clan!`); - } else if(getVehicleData(vehicle).ownerType == VRR_VEHOWNER_JOB) { + } else if (getVehicleData(vehicle).ownerType == VRR_VEHOWNER_JOB) { getVehicleData(vehicle).rank = rankId; messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} set their {vehiclePurple}${getVehicleName(vehicle)}{MAINCOLOUR} rank to {ALTCOLOUR}${rankId}{MAINCOLOUR} of the {jobYellow}${getJobData(getJobIdFromDatabaseId(getVehicleData(vehicle).ownerId)).name}{MAINCOLOUR} job!`); } @@ -780,7 +780,7 @@ function setVehicleRankCommand(command, params, client) { // =========================================================================== function setVehicleClanCommand(command, params, client) { - if(!isPlayerInAnyVehicle(client)) { + if (!isPlayerInAnyVehicle(client)) { messagePlayerError(client, "You need to be in a vehicle!"); return false; } @@ -788,22 +788,22 @@ function setVehicleClanCommand(command, params, client) { let vehicle = getPlayerVehicle(client); let clanId = getPlayerClan(client); - if(!getVehicleData(vehicle)) { + if (!getVehicleData(vehicle)) { messagePlayerError(client, getLocaleString(client, "RandomVehicleCommandsDisabled")); return false; } - if(!getClanData(clanId)) { + if (!getClanData(clanId)) { messagePlayerError(client, "That clan is invalid or doesn't exist!"); return false; } - if(getVehicleData(vehicle).ownerType != VRR_VEHOWNER_PLAYER) { + if (getVehicleData(vehicle).ownerType != VRR_VEHOWNER_PLAYER) { messagePlayerError(client, getLocaleString(client, "MustOwnVehicle")); return false; } - if(getVehicleData(vehicle).ownerId != getPlayerCurrentSubAccount(client).databaseId) { + if (getVehicleData(vehicle).ownerId != getPlayerCurrentSubAccount(client).databaseId) { messagePlayerError(client, getLocaleString(client, "MustOwnVehicle")); return false; } @@ -817,7 +817,7 @@ function setVehicleClanCommand(command, params, client) { // =========================================================================== function setVehicleToBusinessCommand(command, params, client) { - if(!isPlayerInAnyVehicle(client)) { + if (!isPlayerInAnyVehicle(client)) { messagePlayerError(client, "You need to be in a vehicle!"); return false; } @@ -825,12 +825,12 @@ function setVehicleToBusinessCommand(command, params, client) { let vehicle = getPlayerVehicle(client); let businessId = getPlayerBusiness(client); - if(!getVehicleData(vehicle)) { + if (!getVehicleData(vehicle)) { messagePlayerError(client, getLocaleString(client, "RandomVehicleCommandsDisabled")); return false; } - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); return false; } @@ -846,7 +846,7 @@ function setVehicleToBusinessCommand(command, params, client) { // =========================================================================== function setVehicleOwnerCommand(command, params, client) { - if(!isPlayerInAnyVehicle(client)) { + if (!isPlayerInAnyVehicle(client)) { messagePlayerError(client, "You need to be in a vehicle!"); return false; } @@ -854,12 +854,12 @@ function setVehicleOwnerCommand(command, params, client) { let vehicle = getPlayerVehicle(client); let targetClient = getPlayerFromParams(params); - if(!getVehicleData(vehicle)) { + if (!getVehicleData(vehicle)) { messagePlayerError(client, getLocaleString(client, "RandomVehicleCommandsDisabled")); return false; } - if(!targetClient) { + if (!targetClient) { messagePlayerError(client, "That player is invalid or isn't connected!"); return false; } @@ -875,14 +875,14 @@ function setVehicleOwnerCommand(command, params, client) { // =========================================================================== function setVehiclePublicCommand(command, params, client) { - if(!isPlayerInAnyVehicle(client)) { + if (!isPlayerInAnyVehicle(client)) { messagePlayerError(client, "You need to be in a vehicle!"); return false; } let vehicle = getPlayerVehicle(client); - if(!getVehicleData(vehicle)) { + if (!getVehicleData(vehicle)) { messagePlayerError(client, getLocaleString(client, "RandomVehicleCommandsDisabled")); return false; } @@ -898,20 +898,20 @@ function setVehiclePublicCommand(command, params, client) { // =========================================================================== function setVehicleRentPriceCommand(command, params, client) { - if(!isPlayerInAnyVehicle(client)) { + if (!isPlayerInAnyVehicle(client)) { messagePlayerError(client, "You need to be in a vehicle!"); return false; } let vehicle = getPlayerVehicle(client); - if(!getVehicleData(vehicle)) { + if (!getVehicleData(vehicle)) { messagePlayerError(client, getLocaleString(client, "RandomVehicleCommandsDisabled")); return false; } - if(!doesClientOwnVehicle(client, vehicle)) { - if(!doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageVehicles"))) { + if (!doesClientOwnVehicle(client, vehicle)) { + if (!doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageVehicles"))) { messagePlayerError(client, "You can't set the rent price for this vehicle!"); } } @@ -927,20 +927,20 @@ function setVehicleRentPriceCommand(command, params, client) { // =========================================================================== function setVehicleBuyPriceCommand(command, params, client) { - if(!isPlayerInAnyVehicle(client)) { + if (!isPlayerInAnyVehicle(client)) { messagePlayerError(client, "You need to be in a vehicle!"); return false; } let vehicle = getPlayerVehicle(client); - if(!getVehicleData(vehicle)) { + if (!getVehicleData(vehicle)) { messagePlayerError(client, getLocaleString(client, "RandomVehicleCommandsDisabled")); return false; } - if(!doesClientOwnVehicle(client, vehicle)) { - if(!doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageVehicles"))) { + if (!doesClientOwnVehicle(client, vehicle)) { + if (!doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageVehicles"))) { messagePlayerError(client, "You can't set the buy price for this vehicle!"); } } @@ -956,7 +956,7 @@ function setVehicleBuyPriceCommand(command, params, client) { // =========================================================================== function removeVehicleOwnerCommand(command, params, client) { - if(!isPlayerInAnyVehicle(client)) { + if (!isPlayerInAnyVehicle(client)) { messagePlayerError(client, "You need to be in a vehicle!"); return false; } @@ -964,12 +964,12 @@ function removeVehicleOwnerCommand(command, params, client) { let vehicle = getPlayerVehicle(client); let targetClient = getPlayerFromParams(params); - if(!getVehicleData(vehicle)) { + if (!getVehicleData(vehicle)) { messagePlayerError(client, getLocaleString(client, "RandomVehicleCommandsDisabled")); return false; } - if(!targetClient) { + if (!targetClient) { messagePlayerError(client, "That player is invalid or isn't connected!"); return false; } @@ -986,14 +986,14 @@ function removeVehicleOwnerCommand(command, params, client) { // =========================================================================== function getVehicleInfoCommand(command, params, client) { - if(!isPlayerInAnyVehicle(client)) { + if (!isPlayerInAnyVehicle(client)) { messagePlayerError(client, "You need to be in a vehicle!"); return false; } let vehicle = getPlayerVehicle(client); - if(!getVehicleData(vehicle)) { + if (!getVehicleData(vehicle)) { messagePlayerError(client, getLocaleString(client, "RandomVehicleCommandsDisabled")); return false; } @@ -1002,7 +1002,7 @@ function getVehicleInfoCommand(command, params, client) { let ownerName = "Nobody"; let ownerType = "None"; - switch(vehicleData.ownerType) { + switch (vehicleData.ownerType) { case VRR_VEHOWNER_CLAN: ownerName = getClanData(getClanIdFromDatabaseId(vehicleData.ownerId)).name; ownerType = "clan"; @@ -1053,7 +1053,7 @@ function getVehicleInfoCommand(command, params, client) { messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderVehicleInfo"))); let chunkedList = splitArrayIntoChunks(stats, 6); - for(let i in chunkedList) { + for (let i in chunkedList) { messagePlayerInfo(client, chunkedList[i].join(", ")); } @@ -1070,7 +1070,7 @@ function getLastVehicleInfoCommand(command, params, client) { let vehicle = getPlayerLastVehicle(client); - if(!getVehicleData(vehicle)) { + if (!getVehicleData(vehicle)) { messagePlayerError(client, getLocaleString(client, "RandomVehicleCommandsDisabled")); return false; } @@ -1079,7 +1079,7 @@ function getLastVehicleInfoCommand(command, params, client) { let ownerName = "Nobody"; let ownerType = "None"; - switch(vehicleData.ownerType) { + switch (vehicleData.ownerType) { case VRR_VEHOWNER_CLAN: ownerName = getClanData(vehicleData.ownerId).name; ownerType = "clan"; @@ -1118,7 +1118,7 @@ function getLastVehicleInfoCommand(command, params, client) { // =========================================================================== function toggleVehicleSpawnLockCommand(command, params, client) { - if(!isPlayerInAnyVehicle(client)) { + if (!isPlayerInAnyVehicle(client)) { messagePlayerError(client, "You need to be in a vehicle!"); return false; } @@ -1126,7 +1126,7 @@ function toggleVehicleSpawnLockCommand(command, params, client) { let vehicle = getPlayerVehicle(client); getVehicleData(vehicle).spawnLocked = !getVehicleData(vehicle).spawnLocked; - if(getVehicleData(vehicle).spawnLocked) { + if (getVehicleData(vehicle).spawnLocked) { getVehicleData(vehicle).spawnPosition = getVehiclePosition(vehicle); getVehicleData(vehicle).spawnRotation = getVehicleHeading(vehicle); } @@ -1139,8 +1139,8 @@ function toggleVehicleSpawnLockCommand(command, params, client) { // =========================================================================== function reloadAllVehiclesCommand(command, params, client) { - for(let i in getServerData().vehicles) { - if(getServerData().vehicles[i].vehicle) { + for (let i in getServerData().vehicles) { + if (getServerData().vehicles[i].vehicle) { deleteGameElement(getServerData().vehicles[i].vehicle); } } @@ -1157,7 +1157,7 @@ function reloadAllVehiclesCommand(command, params, client) { // =========================================================================== function respawnVehicleCommand(command, params, client) { - if(isPlayerInAnyVehicle(client)) { + if (isPlayerInAnyVehicle(client)) { removeAllOccupantsFromVehicle(getPlayerVehicle(client)); respawnVehicle(getPlayerVehicle(client)); } @@ -1171,12 +1171,12 @@ function respawnVehicleCommand(command, params, client) { // =========================================================================== function respawnAllVehiclesCommand(command, params, client) { - for(let i in getServerData().vehicles) { + for (let i in getServerData().vehicles) { respawnVehicle(getServerData().vehicles[i].vehicle); } let randomVehicles = getElementsByType(ELEMENT_VEHICLE).filter(v => getVehicleData(v) == false); - for(let i in randomVehicles) { + for (let i in randomVehicles) { destroyElement(randomVehicles[i]); } @@ -1188,15 +1188,15 @@ function respawnAllVehiclesCommand(command, params, client) { // =========================================================================== function respawnEmptyVehiclesCommand(command, params, client) { - for(let i in getServerData().vehicles) { - if(!isVehicleUnoccupied(getServerData().vehicles[i].vehicle)) { + for (let i in getServerData().vehicles) { + if (!isVehicleUnoccupied(getServerData().vehicles[i].vehicle)) { respawnVehicle(getServerData().vehicles[i].vehicle); } } let clientVehicles = getElementsByType(ELEMENT_VEHICLE).filter(v => getVehicleData(v) == false); - for(let i in clientVehicles) { - if(!isVehicleUnoccupied(clientVehicles[i])) { + for (let i in clientVehicles) { + if (!isVehicleUnoccupied(clientVehicles[i])) { destroyElement(clientVehicles[i]); } } @@ -1207,8 +1207,8 @@ function respawnEmptyVehiclesCommand(command, params, client) { // =========================================================================== function respawnJobVehiclesCommand(command, params, client) { - for(let i in getServerData().vehicles) { - if(getServerData().vehicles[i].ownerType == VRR_VEHOWNER_JOB) { + for (let i in getServerData().vehicles) { + if (getServerData().vehicles[i].ownerType == VRR_VEHOWNER_JOB) { respawnVehicle(getServerData().vehicles[i].vehicle); } } @@ -1219,8 +1219,8 @@ function respawnJobVehiclesCommand(command, params, client) { // =========================================================================== function respawnClanVehiclesCommand(command, params, client) { - for(let i in getServerData().vehicles) { - if(getServerData().vehicles[i].ownerType == VRR_VEHOWNER_CLAN) { + for (let i in getServerData().vehicles) { + if (getServerData().vehicles[i].ownerType == VRR_VEHOWNER_CLAN) { respawnVehicle(getServerData().vehicles[i].vehicle); } } @@ -1231,8 +1231,8 @@ function respawnClanVehiclesCommand(command, params, client) { // =========================================================================== function respawnPlayerVehiclesCommand(command, params, client) { - for(let i in getServerData().vehicles) { - if(getServerData().vehicles[i].ownerType == VRR_VEHOWNER_PLAYER) { + for (let i in getServerData().vehicles) { + if (getServerData().vehicles[i].ownerType == VRR_VEHOWNER_PLAYER) { respawnVehicle(getServerData().vehicles[i].vehicle); } } @@ -1243,8 +1243,8 @@ function respawnPlayerVehiclesCommand(command, params, client) { // =========================================================================== function respawnPublicVehiclesCommand(command, params, client) { - for(let i in getServerData().vehicles) { - if(getServerData().vehicles[i].ownerType == VRR_VEHOWNER_PUBLIC) { + for (let i in getServerData().vehicles) { + if (getServerData().vehicles[i].ownerType == VRR_VEHOWNER_PUBLIC) { respawnVehicle(getServerData().vehicles[i].vehicle); } } @@ -1255,8 +1255,8 @@ function respawnPublicVehiclesCommand(command, params, client) { // =========================================================================== function respawnBusinessVehiclesCommand(command, params, client) { - for(let i in getServerData().vehicles) { - if(getServerData().vehicles[i].ownerType == VRR_VEHOWNER_BIZ) { + for (let i in getServerData().vehicles) { + if (getServerData().vehicles[i].ownerType == VRR_VEHOWNER_BIZ) { respawnVehicle(getServerData().vehicles[i].vehicle); } } @@ -1278,13 +1278,13 @@ function stopRentingVehicle(client) { function respawnVehicle(vehicle) { let vehicles = getServerData().vehicles; - for(let i in vehicles) { - if(vehicle == vehicles[i].vehicle) { - if(vehicles[i].spawnLocked == true) { + for (let i in vehicles) { + if (vehicle == vehicles[i].vehicle) { + if (vehicles[i].spawnLocked == true) { vehicles[i].engine = false; } - if(vehicles[i].ownerType == VRR_VEHOWNER_JOB) { + if (vehicles[i].ownerType == VRR_VEHOWNER_JOB) { vehicles[i].locked = true; } @@ -1308,7 +1308,7 @@ function spawnVehicle(vehicleData) { setVehicleHeading(vehicle, vehicleData.spawnRotation); setElementTransient(vehicle, false); - if(!vehicle) { + if (!vehicle) { return false; } @@ -1317,8 +1317,8 @@ function spawnVehicle(vehicleData) { vehicleData.vehicle = vehicle; - if(isGameFeatureSupported("vehicleColours")) { - if(vehicleData.colour1IsRGBA && vehicleData.colour2IsRGBA) { + if (isGameFeatureSupported("vehicleColours")) { + if (vehicleData.colour1IsRGBA && vehicleData.colour2IsRGBA) { vehicle.setRGBColours(vehicleData.colour1RGBA, vehicleData.colour2RGBA); let colour1 = rgbaArrayFromToColour(vehicleData.colour1RGBA); let colour2 = rgbaArrayFromToColour(vehicleData.colour2RGBA); @@ -1330,14 +1330,14 @@ function spawnVehicle(vehicleData) { } } - if(vehicleData.spawnLocked == true) { + if (vehicleData.spawnLocked == true) { setVehicleEngine(vehicle, false); logToConsole(LOG_VERBOSE, `[VRR.Vehicle]: Setting vehicle ${vehicle.id}'s engine to OFF`); } else { - setVehicleEngine(vehicle, intToBool(vehicleData.engine));logToConsole(LOG_VERBOSE, `[VRR.Vehicle]: Setting vehicle ${vehicle.id}'s engine to ${toUpperCase(getOnOffFromBool(getVehicleEngine(vehicle)))}`); + setVehicleEngine(vehicle, intToBool(vehicleData.engine)); logToConsole(LOG_VERBOSE, `[VRR.Vehicle]: Setting vehicle ${vehicle.id}'s engine to ${toUpperCase(getOnOffFromBool(getVehicleEngine(vehicle)))}`); } - if(typeof vehicle.locked != "undefined") { + if (typeof vehicle.locked != "undefined") { setVehicleLocked(vehicle, intToBool(vehicleData.locked)); logToConsole(LOG_VERBOSE, `[VRR.Vehicle]: Setting vehicle ${vehicle.id}'s lock state to ${toUpperCase(getOnOffFromBool(getVehicleLocked(vehicle)))}`); } @@ -1358,8 +1358,8 @@ function spawnVehicle(vehicleData) { // =========================================================================== function isVehicleAtPayAndSpray(vehicle) { - for(let i in getServerData().payAndSprays[getGame()]) { - if(getDistance(getVehiclePosition(vehicle), getServerData().payAndSprays[getGame()][i].position) <= getGlobalConfig().payAndSprayDistance) { + for (let i in getServerData().payAndSprays[getGame()]) { + if (getDistance(getVehiclePosition(vehicle), getServerData().payAndSprays[getGame()][i].position) <= getGlobalConfig().payAndSprayDistance) { return true; } } @@ -1369,7 +1369,7 @@ function isVehicleAtPayAndSpray(vehicle) { // =========================================================================== function getVehicleOwnerTypeText(ownerType) { - switch(ownerType) { + switch (ownerType) { case VRR_VEHOWNER_CLAN: return "clan"; @@ -1393,7 +1393,7 @@ function getVehicleOwnerTypeText(ownerType) { // =========================================================================== function isVehicleOwnedByJob(vehicle, jobId) { - if(getVehicleData(vehicle).ownerType == VRR_VEHOWNER_JOB) { + if (getVehicleData(vehicle).ownerType == VRR_VEHOWNER_JOB) { return (getVehicleData(vehicle).ownerId == jobId); } return false; @@ -1402,8 +1402,8 @@ function isVehicleOwnedByJob(vehicle, jobId) { // =========================================================================== async function getPlayerNewVehicle(client) { - while(true) { - if(isPlayerInAnyVehicle(client)) { + while (true) { + if (isPlayerInAnyVehicle(client)) { return getPlayerVehicle(client); } await null; @@ -1414,7 +1414,7 @@ async function getPlayerNewVehicle(client) { function createNewDealershipVehicle(modelIndex, spawnPosition, spawnRotation, price, dealershipId, interior = 0, dimension = 0) { let vehicle = createGameVehicle(modelIndex, spawnPosition, spawnRotation); - if(!vehicle) { + if (!vehicle) { return false; } setVehicleHeading(vehicle, spawnRotation); @@ -1434,7 +1434,7 @@ function createNewDealershipVehicle(modelIndex, spawnPosition, spawnRotation, pr tempVehicleData.dimension = dimension; let slot = getServerData().vehicles.push(tempVehicleData); - setEntityData(vehicle, "vrr.dataSlot", slot-1, false); + setEntityData(vehicle, "vrr.dataSlot", slot - 1, false); } // =========================================================================== @@ -1451,7 +1451,7 @@ function createTemporaryVehicle(modelIndex, position, heading, interior = 0, dim tempVehicleData.databaseId = -1; tempVehicleData.interior = interior; tempVehicleData.dimension = dimension; - if(!isGameFeatureSupported("vehicleColours")) { + if (!isGameFeatureSupported("vehicleColours")) { tempVehicleData.colour1 = 0; tempVehicleData.colour2 = 0; tempVehicleData.colour3 = 0; @@ -1459,7 +1459,7 @@ function createTemporaryVehicle(modelIndex, position, heading, interior = 0, dim } let slot = getServerData().vehicles.push(tempVehicleData); - setEntityData(vehicle, "vrr.dataSlot", slot-1, false); + setEntityData(vehicle, "vrr.dataSlot", slot - 1, false); return vehicle; } @@ -1477,7 +1477,7 @@ function createPermanentVehicle(modelIndex, position, heading, interior = 0, dim tempVehicleData.model = modelIndex; tempVehicleData.interior = interior; tempVehicleData.dimension = dimension; - if(!isGameFeatureSupported("vehicleColours")) { + if (!isGameFeatureSupported("vehicleColours")) { tempVehicleData.colour1 = 0; tempVehicleData.colour2 = 0; tempVehicleData.colour3 = 0; @@ -1486,8 +1486,8 @@ function createPermanentVehicle(modelIndex, position, heading, interior = 0, dim let slot = getServerData().vehicles.push(tempVehicleData); - if(areServerElementsSupported()) { - setEntityData(vehicle, "vrr.dataSlot", slot-1, false); + if (areServerElementsSupported()) { + setEntityData(vehicle, "vrr.dataSlot", slot - 1, false); } @@ -1497,12 +1497,12 @@ function createPermanentVehicle(modelIndex, position, heading, interior = 0, dim // =========================================================================== function processVehiclePurchasing() { - if(!getGlobalConfig().useServerSideVehiclePurchaseCheck) { + if (!getGlobalConfig().useServerSideVehiclePurchaseCheck) { return false; } let purchasingVehicles = getServerData().purchasingVehicleCache; - for(let i in purchasingVehicles) { + for (let i in purchasingVehicles) { checkVehiclePurchasing(purchasingVehicles[i]); } @@ -1512,28 +1512,28 @@ function processVehiclePurchasing() { // =========================================================================== function checkVehiclePurchasing(client) { - if(!isPlayerLoggedIn(client)) { + if (!isPlayerLoggedIn(client)) { setPlayerBuyingVehicleState(client, VRR_VEHBUYSTATE_NONE, null, null); return false; } - if(!isPlayerSpawned(client)) { + if (!isPlayerSpawned(client)) { setPlayerBuyingVehicleState(client, VRR_VEHBUYSTATE_NONE, null, null); return false; } - if(!getPlayerData(client)) { + if (!getPlayerData(client)) { setPlayerBuyingVehicleState(client, VRR_VEHBUYSTATE_NONE, null, null); return false; } - if(!getPlayerData(client).buyingVehicle) { + if (!getPlayerData(client).buyingVehicle) { setPlayerBuyingVehicleState(client, VRR_VEHBUYSTATE_NONE, null, null); return false; } - if(!isPlayerInAnyVehicle(client)) { - if(getPlayerData(client).buyingVehicle != false) { + if (!isPlayerInAnyVehicle(client)) { + if (getPlayerData(client).buyingVehicle != false) { getServerData().purchasingVehicleCache.splice(getServerData().purchasingVehicleCache.indexOf(client), 1); messagePlayerError(client, getLocaleString(client, "DealershipPurchaseExitedVehicle")); respawnVehicle(getPlayerData(client).buyingVehicle); @@ -1543,8 +1543,8 @@ function checkVehiclePurchasing(client) { return false; } - if(getDistance(getVehiclePosition(getPlayerData(client).buyingVehicle), getVehicleData(getPlayerData(client).buyingVehicle).spawnPosition) > getGlobalConfig().buyVehicleDriveAwayDistance) { - if(getPlayerCurrentSubAccount(client).cash < getVehicleData(getPlayerData(client).buyingVehicle).buyPrice) { + if (getDistance(getVehiclePosition(getPlayerData(client).buyingVehicle), getVehicleData(getPlayerData(client).buyingVehicle).spawnPosition) > getGlobalConfig().buyVehicleDriveAwayDistance) { + if (getPlayerCurrentSubAccount(client).cash < getVehicleData(getPlayerData(client).buyingVehicle).buyPrice) { getServerData().purchasingVehicleCache.splice(getServerData().purchasingVehicleCache.indexOf(client), 1); messagePlayerError(client, getLocaleString(client, "VehiclePurchaseNotEnoughMoney")); respawnVehicle(getPlayerData(client).buyingVehicle); @@ -1572,14 +1572,14 @@ function checkVehiclePurchasing(client) { // =========================================================================== function processVehicleBurning() { - if(!getGlobalConfig().useServerSideVehicleBurnCheck) { + if (!getGlobalConfig().useServerSideVehicleBurnCheck) { return false; } let vehicles = getElementsByType(ELEMENT_VEHICLE); - for(let i in vehicles) { - if(vehicles[i].syncer == null) { - if(vehicles[i].health <= 250) { + for (let i in vehicles) { + if (vehicles[i].syncer == null) { + if (vehicles[i].health <= 250) { vehicles[i].health = 250; } } @@ -1589,11 +1589,11 @@ function processVehicleBurning() { // =========================================================================== function cacheAllVehicleItems() { - for(let i in getServerData().vehicles) { - for(let j in getServerData().items) { - if(getItemData(j).ownerType == VRR_ITEM_OWNER_VEHTRUNK && getItemData(j).ownerId == getServerData().vehicles[i].databaseId) { + for (let i in getServerData().vehicles) { + for (let j in getServerData().items) { + if (getItemData(j).ownerType == VRR_ITEM_OWNER_VEHTRUNK && getItemData(j).ownerId == getServerData().vehicles[i].databaseId) { getServerData().vehicles[i].trunkItemCache.push(j); - } else if(getItemData(j).ownerType == VRR_ITEM_OWNER_VEHDASH && getItemData(j).ownerId == getServerData().vehicles[i].databaseId) { + } else if (getItemData(j).ownerType == VRR_ITEM_OWNER_VEHDASH && getItemData(j).ownerId == getServerData().vehicles[i].databaseId) { getServerData().vehicles[i].dashItemCache.push(j); } } @@ -1603,7 +1603,7 @@ function cacheAllVehicleItems() { // =========================================================================== function resetVehiclePosition(vehicle) { - if(!getVehicleData(vehicle).spawnLocked) { + if (!getVehicleData(vehicle).spawnLocked) { getVehicleData(vehicle).spawnPosition = getVehiclePosition(vehicle); getVehicleData(vehicle).spawnHeading = getVehiclePosition(vehicle); } @@ -1612,7 +1612,7 @@ function resetVehiclePosition(vehicle) { // =========================================================================== function setAllVehicleIndexes() { - for(let i in getServerData().vehicles) { + for (let i in getServerData().vehicles) { getServerData().vehicles[i].index = i; } } @@ -1620,16 +1620,16 @@ function setAllVehicleIndexes() { // =========================================================================== function doesVehicleHaveMegaphone(vehicle) { - if(getVehicleData(vehicle).ownerType == VRR_VEHOWNER_JOB) { - if(getJobType(getJobIdFromDatabaseId(getVehicleData(vehicle).ownerId)) == VRR_JOB_POLICE) { + if (getVehicleData(vehicle).ownerType == VRR_VEHOWNER_JOB) { + if (getJobType(getJobIdFromDatabaseId(getVehicleData(vehicle).ownerId)) == VRR_JOB_POLICE) { return true; } - if(getJobType(getJobIdFromDatabaseId(getVehicleData(vehicle).ownerId)) == VRR_JOB_FIRE) { + if (getJobType(getJobIdFromDatabaseId(getVehicleData(vehicle).ownerId)) == VRR_JOB_FIRE) { return true; } - if(getJobType(getJobIdFromDatabaseId(getVehicleData(vehicle).ownerId)) == VRR_JOB_MEDICAL) { + if (getJobType(getJobIdFromDatabaseId(getVehicleData(vehicle).ownerId)) == VRR_JOB_MEDICAL) { return true; } } @@ -1641,8 +1641,8 @@ function doesVehicleHaveMegaphone(vehicle) { function getVehicleFromDatabaseId(databaseId) { let vehicles = getServerData().vehicles; - for(let i in vehicles) { - if(vehicles[i].databaseId == databaseId) { + for (let i in vehicles) { + if (vehicles[i].databaseId == databaseId) { return vehicles[i].vehicle; } } @@ -1651,8 +1651,8 @@ function getVehicleFromDatabaseId(databaseId) { // =========================================================================== function isVehicleUnoccupied(vehicle) { - for(let i = 0 ; i <= 8 ; i++) { - if(vehicle.getOccupant(i) != null) { + for (let i = 0; i <= 8; i++) { + if (vehicle.getOccupant(i) != null) { return true; } } @@ -1677,8 +1677,8 @@ function getVehicleTrunkPosition(vehicle) { // =========================================================================== function removeAllOccupantsFromVehicle(vehicle) { - for(let i = 0 ; i <= 16 ; i++) { - if(vehicle.getOccupant(i) != null) { + for (let i = 0; i <= 16; i++) { + if (vehicle.getOccupant(i) != null) { removePlayerFromVehicle(vehicle.getOccupant(i)); } } @@ -1687,7 +1687,7 @@ function removeAllOccupantsFromVehicle(vehicle) { // =========================================================================== function getVehicleColourInfoString(colour, isRGBA) { - if(isRGBA) { + if (isRGBA) { let arrayColour = rgbaArrayFromToColour(colour); return `RGBA [${arrayColour[0]}, ${arrayColour[1]}, ${arrayColour[2]}, ${arrayColour[3]}]`; } else { diff --git a/scripts/shared/gamedata.js b/scripts/shared/gamedata.js index fee7e5ca..c987c6b3 100644 --- a/scripts/shared/gamedata.js +++ b/scripts/shared/gamedata.js @@ -119,6 +119,16 @@ let supportedFeatures = { [VRR_GAME_MAFIA_TWO]: false, [VRR_GAME_MAFIA_THREE]: false }, + attachedBlips: { + [VRR_GAME_GTA_III]: true, + [VRR_GAME_GTA_VC]: true, + [VRR_GAME_GTA_SA]: true, + [VRR_GAME_GTA_IV]: false, + [VRR_GAME_GTA_IV_EFLC]: false, + [VRR_GAME_MAFIA_ONE]: false, + [VRR_GAME_MAFIA_TWO]: false, + [VRR_GAME_MAFIA_THREE]: false + }, fightStyles: { [VRR_GAME_GTA_III]: false, [VRR_GAME_GTA_VC]: false, @@ -159,6 +169,16 @@ let supportedFeatures = { [VRR_GAME_MAFIA_ONE]: false, [VRR_GAME_MAFIA_TWO]: false, [VRR_GAME_MAFIA_THREE]: false + }, + interior: { + [VRR_GAME_GTA_III]: false, + [VRR_GAME_GTA_VC]: true, + [VRR_GAME_GTA_SA]: true, + [VRR_GAME_GTA_IV]: false, + [VRR_GAME_GTA_IV_EFLC]: false, + [VRR_GAME_MAFIA_ONE]: false, + [VRR_GAME_MAFIA_TWO]: false, + [VRR_GAME_MAFIA_THREE]: false } }; @@ -570,1264 +590,1264 @@ let gameData = { }, skins: { [VRR_GAME_GTA_III]: [ - [0 , "Claude" , false], - [1 , "Police Officer" , false], - [2 , "SWAT Officer" , false], - [3 , "FBI Agent" , false], - [4 , "Army Soldier" , false], - [5 , "Paramedic" , false], - [6 , "Firefighter" , false], - [7 , "Wise Guy" , true ], - [8 , "Taxi Driver" , false], - [9 , "Pimp" , true ], - [10 , "Mafia Member 1" , true ], - [11 , "Mafia Member 2" , true ], - [12 , "Triad Member 1" , true ], - [13 , "Triad Member 2" , true ], - [14 , "Diablo Member 1" , true ], - [15 , "Diablo Member 2" , true ], - [16 , "Yakuza Member 1" , true ], - [17 , "Yakuza Member 2" , true ], - [18 , "Yardie Member 1" , true ], - [19 , "Yardie Member 2" , true ], - [20 , "Cartel Soldier 1" , true ], - [21 , "Cartel Soldier 2" , true ], - [22 , "Red Jacks Thug" , true ], - [23 , "Purple Nines Thug" , true ], - [24 , "Street Criminal 1" , true ], - [25 , "Street Criminal 2" , true ], - [30 , "Male Client" , true ], - [31 , "Random Guy" , true ], - [32 , "Vacationist" , true ], - [33 , "DJ" , true ], - [34 , "Young Woman" , true ], - [35 , "Young Woman" , true ], - [36 , "Business Woman" , true ], - [37 , "Elder Woman 1" , true ], - [38 , "Elder Woman 2" , true ], - [39 , "Prostitute 1" , true ], - [40 , "Prostitute 2" , true ], - [41 , "Random Guy" , true ], - [42 , "Diseased Man" , true ], - [43 , "Deseased Woman" , true ], - [44 , "Young Woman" , true ], - [45 , "Old Man 1" , true ], - [46 , "Random Guy" , true ], - [47 , "Old Woman 1" , true ], - [48 , "Old Woman 2" , true ], - [49 , "Old Man 2" , true ], - [50 , "Random Guy" , true ], - [51 , "Old Woman 3" , true ], - [52 , "Young Woman" , true ], - [53 , "Docks Worker 1" , true ], - [54 , "Docks Worker 2" , true ], - [55 , "Male Street Bum" , true ], - [56 , "Female Street Bum" , true ], - [57 , "Delivery Guy 1" , true ], - [58 , "Delivery Guy 2" , true ], - [59 , "Business Man" , true ], - [60 , "Marty Chonks" , true ], - [61 , "CIA Agent" , true ], - [62 , "Female Client" , true ], - [63 , "Young Woman" , true ], - [64 , "Business Woman" , true ], - [65 , "Business Man" , true ], - [66 , "Female Client" , true ], - [67 , "Male Steward" , true ], - [68 , "Female Steward" , true ], - [69 , "Male Cocks Fan 1" , true ], - [70 , "Male Cocks Fan 2" , true ], - [71 , "Female Cocks Fan" , true ], - [72 , "Male Paramedics Assistant" , true ], - [73 , "Female Paramedics Assistant", true ], - [74 , "Construction Worker 1" , true ], - [75 , "Construction Worker 2" , true ], - [76 , "Zip Customer" , true ], - [77 , "Party Woman 1" , true ], - [78 , "Party Woman 2" , true ], - [80 , "Female College Student" , true ], - [81 , "Old Man" , true ], - [82 , "Female Jogger" , true ], - [83 , "Asuka Kasen" , true ], - [84 , "Spank Suicide Bomber" , true ], - [85 , "Salvatore's Butler" , true ], - [86 , "Catalina" , true ], - [87 , "Lee Chong" , true ], - [88 , "Colombian Cartel Member 1" , true ], - [89 , "Colombian Cartel Member 2" , true ], - [90 , "Colombian Cartel Member 3" , true ], - [91 , "Colombian Cartel Member 4" , true ], - [92 , "Police Officer" , false], - [93 , "Curly Bob" , true ], - [94 , "Phil Cassidy" , true ], - [95 , "Detective" , true ], - [96 , "8-Ball 1" , true ], - [97 , "8-Ball 2" , true ], - [98 , "Salvatore Leone" , true ], - [99 , "Mafia Member" , true ], - [100, "Joey Leone 1" , true ], - [101, "Joey Leone 2" , true ], - [102, "Bar Owner" , true ], - [103, "Kenji Kasen" , true ], - [104, "Mike Forelli" , true ], - [105, "Donald Love 1" , true ], - [106, "Donald Love 2" , true ], - [107, "Luigi Goterelli" , true ], - [108, "Maria Latore" , true ], - [109, "Mickey Hamfists" , true ], - [110, "Miguel" , true ], - [111, "Misty" , true ], - [112, "Old Oriental Gentleman 1" , true ], - [113, "Old Oriental Gentleman 2" , true ], - [114, "Old Oriental Gentleman 3" , true ], - [115, "Ray Machowski" , true ], - [116, "Mafia Member" , true ], - [117, "Ammunation Clerk" , true ], - [118, "Tanner" , true ], - [119, "Toni Cipriani" , true ], - [120, "Darkel" , true ], - [121, "Chuff Security Officer" , false], - [122, "Claude Speed (Prison)" , false], - [123, "Busker 1" , false], - [124, "Busker 2" , false], - [125, "Busker 3" , false], - [125, "Busker 4" , false], + [0, "Claude", false], + [1, "Police Officer", false], + [2, "SWAT Officer", false], + [3, "FBI Agent", false], + [4, "Army Soldier", false], + [5, "Paramedic", false], + [6, "Firefighter", false], + [7, "Wise Guy", true], + [8, "Taxi Driver", false], + [9, "Pimp", true], + [10, "Mafia Member 1", true], + [11, "Mafia Member 2", true], + [12, "Triad Member 1", true], + [13, "Triad Member 2", true], + [14, "Diablo Member 1", true], + [15, "Diablo Member 2", true], + [16, "Yakuza Member 1", true], + [17, "Yakuza Member 2", true], + [18, "Yardie Member 1", true], + [19, "Yardie Member 2", true], + [20, "Cartel Soldier 1", true], + [21, "Cartel Soldier 2", true], + [22, "Red Jacks Thug", true], + [23, "Purple Nines Thug", true], + [24, "Street Criminal 1", true], + [25, "Street Criminal 2", true], + [30, "Male Client", true], + [31, "Random Guy", true], + [32, "Vacationist", true], + [33, "DJ", true], + [34, "Young Woman", true], + [35, "Young Woman", true], + [36, "Business Woman", true], + [37, "Elder Woman 1", true], + [38, "Elder Woman 2", true], + [39, "Prostitute 1", true], + [40, "Prostitute 2", true], + [41, "Random Guy", true], + [42, "Diseased Man", true], + [43, "Deseased Woman", true], + [44, "Young Woman", true], + [45, "Old Man 1", true], + [46, "Random Guy", true], + [47, "Old Woman 1", true], + [48, "Old Woman 2", true], + [49, "Old Man 2", true], + [50, "Random Guy", true], + [51, "Old Woman 3", true], + [52, "Young Woman", true], + [53, "Docks Worker 1", true], + [54, "Docks Worker 2", true], + [55, "Male Street Bum", true], + [56, "Female Street Bum", true], + [57, "Delivery Guy 1", true], + [58, "Delivery Guy 2", true], + [59, "Business Man", true], + [60, "Marty Chonks", true], + [61, "CIA Agent", true], + [62, "Female Client", true], + [63, "Young Woman", true], + [64, "Business Woman", true], + [65, "Business Man", true], + [66, "Female Client", true], + [67, "Male Steward", true], + [68, "Female Steward", true], + [69, "Male Cocks Fan 1", true], + [70, "Male Cocks Fan 2", true], + [71, "Female Cocks Fan", true], + [72, "Male Paramedics Assistant", true], + [73, "Female Paramedics Assistant", true], + [74, "Construction Worker 1", true], + [75, "Construction Worker 2", true], + [76, "Zip Customer", true], + [77, "Party Woman 1", true], + [78, "Party Woman 2", true], + [80, "Female College Student", true], + [81, "Old Man", true], + [82, "Female Jogger", true], + [83, "Asuka Kasen", true], + [84, "Spank Suicide Bomber", true], + [85, "Salvatore's Butler", true], + [86, "Catalina", true], + [87, "Lee Chong", true], + [88, "Colombian Cartel Member 1", true], + [89, "Colombian Cartel Member 2", true], + [90, "Colombian Cartel Member 3", true], + [91, "Colombian Cartel Member 4", true], + [92, "Police Officer", false], + [93, "Curly Bob", true], + [94, "Phil Cassidy", true], + [95, "Detective", true], + [96, "8-Ball 1", true], + [97, "8-Ball 2", true], + [98, "Salvatore Leone", true], + [99, "Mafia Member", true], + [100, "Joey Leone 1", true], + [101, "Joey Leone 2", true], + [102, "Bar Owner", true], + [103, "Kenji Kasen", true], + [104, "Mike Forelli", true], + [105, "Donald Love 1", true], + [106, "Donald Love 2", true], + [107, "Luigi Goterelli", true], + [108, "Maria Latore", true], + [109, "Mickey Hamfists", true], + [110, "Miguel", true], + [111, "Misty", true], + [112, "Old Oriental Gentleman 1", true], + [113, "Old Oriental Gentleman 2", true], + [114, "Old Oriental Gentleman 3", true], + [115, "Ray Machowski", true], + [116, "Mafia Member", true], + [117, "Ammunation Clerk", true], + [118, "Tanner", true], + [119, "Toni Cipriani", true], + [120, "Darkel", true], + [121, "Chuff Security Officer", false], + [122, "Claude Speed (Prison)", false], + [123, "Busker 1", false], + [124, "Busker 2", false], + [125, "Busker 3", false], + [125, "Busker 4", false], ], [VRR_GAME_GTA_VC]: [ - [0 , "Tommy Vercetti" , false], - [1 , "Police Officer" , false], - [2 , "SWAT Officer" , false], - [3 , "FBI Agent" , false], - [4 , "Army Soldier" , false], - [5 , "Paramedic" , false], - [6 , "Fireman" , false], - [7 , "Golfer" , true ], - [9 , "Random Lady 1" , true], - [10 , "Bum 1" , true], - [11 , "Greaser" , true], - [12 , "Random Guy 1" , true], - [13 , "Random Guy 2" , true], - [14 , "Random Lady" , true], - [15 , "Random Guy 3" , true], - [16 , "Random Guy 4" , true], - [17 , "Beach Lady 1" , true], - [18 , "Fat Beach Lady" , true ], - [19 , "Beach Guy 1" , true ], - [20 , "Fat Beach Guy" , true ], - [21 , "Random Lady 2" , true ], - [22 , "Random Lady 3" , true ], - [23 , "Random Lady 4" , true ], - [24 , "Prostitute 1" , true ], - [25 , "Bum 2" , true ], - [26 , "Bum 3" , true ], - [27 , "Random Guy" , true ], - [28 , "Taxi Driver 1" , true ], - [29 , "Haitian" , true ], - [30 , "Criminal" , true ], - [31 , "Random Lady 5" , true ], - [32 , "Random Lady 6" , true ], - [33 , "Random Guy 5" , true ], - [34 , "Random Guy 6" , true ], - [35 , "Random Lady 7" , true ], - [36 , "Random Lady 8" , true ], - [37 , "Random Guy 7" , true ], - [38 , "Beach Lady 2" , true ], - [39 , "Beach Guy 2" , true ], - [40 , "Beach Lady 3" , true ], - [41 , "Beach Guy 3" , true ], - [42 , "Random Guy 8" , true ], - [43 , "Prostitute 2" , true ], - [44 , "Bum 4" , true ], - [45 , "Bum 5" , true ], - [46 , "Random Guy 9" , true ], - [47 , "Random Guy 9" , true ], - [48 , "Punk 1" , true ], - [49 , "Prostitute 3" , true ], - [50 , "Random Old Lady" , true ], - [51 , "Punk 2" , true ], - [52 , "Random Guy 10" , true ], - [53 , "Random Lady 9" , true ], - [54 , "Random Lady 10" , true ], - [55 , "Random Guy 11" , true ], - [56 , "Random Guy 12" , true ], - [57 , "Beach Lady" , true ], - [58 , "Beach Guy 13" , true ], - [59 , "Beach Lady" , true ], - [60 , "Beach Guy 14" , true ], - [61 , "Construction Worker" , true ], - [62 , "Golfer 1" , true ], - [63 , "Golfer 2" , true ], - [64 , "Golfer 3" , true ], - [65 , "Beach Lady 4" , true ], - [66 , "Beach Guy 4" , true ], - [67 , "Random Lady 11" , true ], - [68 , "Random Guy 15" , true ], - [69 , "Random Guy 16" , true ], - [70 , "Prostitute 4" , true ], - [71 , "Bum Lady" , true ], - [72 , "Random Guy 17" , true ], - [73 , "Random Guy 18" , true ], - [74 , "Taxi Driver 2" , true ], - [75 , "Random Woman" , true ], - [76 , "Skater Guy 1" , true ], - [77 , "Beach Lady 5" , true ], - [78 , "Skater Guy 2" , true ], - [79 , "Young Woman Shopper" , true ], - [80 , "Old Women Shopper" , true ], - [81 , "Tourist 1" , true ], - [82 , "Tourist 2" , true ], - [83 , "Cuban 1" , true ], - [84 , "Cuban 2" , true ], - [85 , "Haitian 1" , true ], - [86 , "Haitian 2" , true ], - [87 , "Shark 1" , true ], - [88 , "Shark 2" , true ], - [89 , "Diaz Guy 1" , true ], - [90 , "Diaz Guy 2" , true ], - [91 , "Security Guard 1" , false], - [92 , "Security Guard 2" , false], - [93 , "Biker 1" , true ], - [94 , "Biker 2" , true ], - [95 , "Vercetti Guy 1" , true ], - [96 , "Vercetti Guy 2" , true ], - [97 , "Undercover Cop 1" , false], - [98 , "Undercover Cop 2" , false], - [99 , "Undercover Cop 3" , false], - [100, "Undercover Cop 4" , false], - [101, "Undercover Cop 5" , false], - [102, "Undercover Cop 6" , false], - [103, "Random Guy" , true ], - [104, "Bodyguard" , true ], - [105, "Prostitute 1" , true ], - [106, "Prostitute 2" , false], - [107, "Ricardo Diaz" , true ], - [108, "Love Fist Guy" , true ], - [109, "Ken Rosenburg" , true ], - [110, "Candy Suxx" , true ], - [111, "Hilary" , true ], - [112, "Love Fist" , true ], - [113, "Phil" , true ], - [114, "Rockstar Guy" , true ], - [115, "Sonny" , true ], - [116, "Lance" , true ], - [117, "Mercedes" , true ], - [118, "Love Fist" , true ], - [119, "Alex Scrub" , true ], - [120, "Officer Lance Vance" , false], - [121, "Lance Vance" , true ], - [122, "Cortez" , true ], - [123, "SWAT 2" , false], - [124, "Columbian" , true ], - [125, "Hilary" , true ], - [126, "Mercedes" , true ], - [127, "Cam 1" , true ], - [128, "Cam 2" , true ], - [129, "Phil 1" , true ], - [130, "Phil 2" , true ], - [131, "Bodyguard" , true ], - [132, "Pizza Worker" , true ], - [133, "Taxi Driver 3" , true ], - [134, "Taxi Driver 4" , true ], - [135, "Sailor 1" , true ], - [136, "Sailor 2" , true ], - [137, "Sailor 3" , true ], - [138, "Chef" , true ], - [139, "Criminal" , true ], + [0, "Tommy Vercetti", false], + [1, "Police Officer", false], + [2, "SWAT Officer", false], + [3, "FBI Agent", false], + [4, "Army Soldier", false], + [5, "Paramedic", false], + [6, "Fireman", false], + [7, "Golfer", true], + [9, "Random Lady 1", true], + [10, "Bum 1", true], + [11, "Greaser", true], + [12, "Random Guy 1", true], + [13, "Random Guy 2", true], + [14, "Random Lady", true], + [15, "Random Guy 3", true], + [16, "Random Guy 4", true], + [17, "Beach Lady 1", true], + [18, "Fat Beach Lady", true], + [19, "Beach Guy 1", true], + [20, "Fat Beach Guy", true], + [21, "Random Lady 2", true], + [22, "Random Lady 3", true], + [23, "Random Lady 4", true], + [24, "Prostitute 1", true], + [25, "Bum 2", true], + [26, "Bum 3", true], + [27, "Random Guy", true], + [28, "Taxi Driver 1", true], + [29, "Haitian", true], + [30, "Criminal", true], + [31, "Random Lady 5", true], + [32, "Random Lady 6", true], + [33, "Random Guy 5", true], + [34, "Random Guy 6", true], + [35, "Random Lady 7", true], + [36, "Random Lady 8", true], + [37, "Random Guy 7", true], + [38, "Beach Lady 2", true], + [39, "Beach Guy 2", true], + [40, "Beach Lady 3", true], + [41, "Beach Guy 3", true], + [42, "Random Guy 8", true], + [43, "Prostitute 2", true], + [44, "Bum 4", true], + [45, "Bum 5", true], + [46, "Random Guy 9", true], + [47, "Random Guy 9", true], + [48, "Punk 1", true], + [49, "Prostitute 3", true], + [50, "Random Old Lady", true], + [51, "Punk 2", true], + [52, "Random Guy 10", true], + [53, "Random Lady 9", true], + [54, "Random Lady 10", true], + [55, "Random Guy 11", true], + [56, "Random Guy 12", true], + [57, "Beach Lady", true], + [58, "Beach Guy 13", true], + [59, "Beach Lady", true], + [60, "Beach Guy 14", true], + [61, "Construction Worker", true], + [62, "Golfer 1", true], + [63, "Golfer 2", true], + [64, "Golfer 3", true], + [65, "Beach Lady 4", true], + [66, "Beach Guy 4", true], + [67, "Random Lady 11", true], + [68, "Random Guy 15", true], + [69, "Random Guy 16", true], + [70, "Prostitute 4", true], + [71, "Bum Lady", true], + [72, "Random Guy 17", true], + [73, "Random Guy 18", true], + [74, "Taxi Driver 2", true], + [75, "Random Woman", true], + [76, "Skater Guy 1", true], + [77, "Beach Lady 5", true], + [78, "Skater Guy 2", true], + [79, "Young Woman Shopper", true], + [80, "Old Women Shopper", true], + [81, "Tourist 1", true], + [82, "Tourist 2", true], + [83, "Cuban 1", true], + [84, "Cuban 2", true], + [85, "Haitian 1", true], + [86, "Haitian 2", true], + [87, "Shark 1", true], + [88, "Shark 2", true], + [89, "Diaz Guy 1", true], + [90, "Diaz Guy 2", true], + [91, "Security Guard 1", false], + [92, "Security Guard 2", false], + [93, "Biker 1", true], + [94, "Biker 2", true], + [95, "Vercetti Guy 1", true], + [96, "Vercetti Guy 2", true], + [97, "Undercover Cop 1", false], + [98, "Undercover Cop 2", false], + [99, "Undercover Cop 3", false], + [100, "Undercover Cop 4", false], + [101, "Undercover Cop 5", false], + [102, "Undercover Cop 6", false], + [103, "Random Guy", true], + [104, "Bodyguard", true], + [105, "Prostitute 1", true], + [106, "Prostitute 2", false], + [107, "Ricardo Diaz", true], + [108, "Love Fist Guy", true], + [109, "Ken Rosenburg", true], + [110, "Candy Suxx", true], + [111, "Hilary", true], + [112, "Love Fist", true], + [113, "Phil", true], + [114, "Rockstar Guy", true], + [115, "Sonny", true], + [116, "Lance", true], + [117, "Mercedes", true], + [118, "Love Fist", true], + [119, "Alex Scrub", true], + [120, "Officer Lance Vance", false], + [121, "Lance Vance", true], + [122, "Cortez", true], + [123, "SWAT 2", false], + [124, "Columbian", true], + [125, "Hilary", true], + [126, "Mercedes", true], + [127, "Cam 1", true], + [128, "Cam 2", true], + [129, "Phil 1", true], + [130, "Phil 2", true], + [131, "Bodyguard", true], + [132, "Pizza Worker", true], + [133, "Taxi Driver 3", true], + [134, "Taxi Driver 4", true], + [135, "Sailor 1", true], + [136, "Sailor 2", true], + [137, "Sailor 3", true], + [138, "Chef", true], + [139, "Criminal", true], //[140, "French Guy" , true ], //[141, "Worker" , true ], - [142, "Haitian" , true ], - [143, "Waitress" , true ], - [144, "Forelli Member 1" , true ], - [145, "Forelli Member 2" , true ], - [146, "Forelli Member 3" , true ], - [147, "Columbian" , true ], - [148, "Random Guy 19" , true ], - [149, "Beach Guy" , true ], - [150, "Random Guy 20" , true ], - [151, "Random Guy 21" , true ], - [152, "Random Guy 22" , true ], - [153, "Drag Queen" , true ], - [154, "Diaz Traitor" , true ], - [155, "Random Guy 23" , true ], - [156, "Random Guy 24" , true ], - [157, "Stripper 1" , true ], - [158, "Stripper 2" , true ], - [159, "Stripper 3" , true ], - [160, "Store Clerk" , true ], - [161, "Tommy Vercetti" , true ], - [162, "Tommy Vercetti (Business Suit)" , true ], - [163, "Tommy Vercetti (SpandEx Overalls)" , true ], - [164, "Tommy Vercetti (Golfer)" , true ], - [165, "Tommy Vercetti (Cuban)" , true ], - [166, "Tommy Vercetti (Cop)" , false], - [167, "Tommy Vercetti (Robbery Suit)" , true ], - [168, "Tommy Vercetti (T-Shirt and Jeans)", true ], - [169, "Tommy Vercetti (Striped Suit)" , true ], - [170, "Tommy Vercetti (Black Tracksuit)" , true ], - [171, "Tommy Vercetti (Red Tracksuit)" , true ], - [172, "Club Bouncer 1" , true ], - [173, "Club Bouncer 2" , true ], - [174, "Stripclub Dancer 1" , true ], - [175, "Random Guy 25" , true ], - [176, "Stripclub Dancer 2" , true ], - [177, "Stripclub Dancer 3" , true ], - [178, "Stripclub Dancer 4" , true ], - [179, "Gang Member 1" , true ], - [180, "Tommy Vercetti (Endgame T-Shirt)" , true ], - [181, "Forelli Thug 1" , true ], - [182, "Forelli Thug 2" , true ], - [183, "Random Lady 12" , true ], - [184, "Gang Member 2" , true ], - [185, "Party Waitress" , true ], - [186, "Kent Paul" , true ], - [187, "Big Head Taxi Driver" , false ], + [142, "Haitian", true], + [143, "Waitress", true], + [144, "Forelli Member 1", true], + [145, "Forelli Member 2", true], + [146, "Forelli Member 3", true], + [147, "Columbian", true], + [148, "Random Guy 19", true], + [149, "Beach Guy", true], + [150, "Random Guy 20", true], + [151, "Random Guy 21", true], + [152, "Random Guy 22", true], + [153, "Drag Queen", true], + [154, "Diaz Traitor", true], + [155, "Random Guy 23", true], + [156, "Random Guy 24", true], + [157, "Stripper 1", true], + [158, "Stripper 2", true], + [159, "Stripper 3", true], + [160, "Store Clerk", true], + [161, "Tommy Vercetti", true], + [162, "Tommy Vercetti (Business Suit)", true], + [163, "Tommy Vercetti (SpandEx Overalls)", true], + [164, "Tommy Vercetti (Golfer)", true], + [165, "Tommy Vercetti (Cuban)", true], + [166, "Tommy Vercetti (Cop)", false], + [167, "Tommy Vercetti (Robbery Suit)", true], + [168, "Tommy Vercetti (T-Shirt and Jeans)", true], + [169, "Tommy Vercetti (Striped Suit)", true], + [170, "Tommy Vercetti (Black Tracksuit)", true], + [171, "Tommy Vercetti (Red Tracksuit)", true], + [172, "Club Bouncer 1", true], + [173, "Club Bouncer 2", true], + [174, "Stripclub Dancer 1", true], + [175, "Random Guy 25", true], + [176, "Stripclub Dancer 2", true], + [177, "Stripclub Dancer 3", true], + [178, "Stripclub Dancer 4", true], + [179, "Gang Member 1", true], + [180, "Tommy Vercetti (Endgame T-Shirt)", true], + [181, "Forelli Thug 1", true], + [182, "Forelli Thug 2", true], + [183, "Random Lady 12", true], + [184, "Gang Member 2", true], + [185, "Party Waitress", true], + [186, "Kent Paul", true], + [187, "Big Head Taxi Driver", false], ], [VRR_GAME_GTA_SA]: [ - [0 , "Carl 'CJ' Johnson" , false], - [1 , "The Truth" , true], - [2 , "Maccer" , true], - [6 , "Taxi Driver/Train Driver" , true], - [9 , "Normal Ped" , true], - [10 , "Old Woman" , true], - [11 , "Casino Croupier" , false], - [12 , "Rich Woman" , true], - [13 , "Street Girl" , true], - [14 , "Normal Ped" , true], - [15 , "Mr.Whittaker (RS Haul Owner)" , true], - [16 , "Airport Ground Worker" , true], - [17 , "Businessman" , true], - [18 , "Beach Visitor" , true], - [19 , "DJ" , true], - [20 , "Rich Guy (Madd Doggs Manager)" , true], - [21 , "Normal Ped" , true], - [22 , "Normal Ped" , true], - [23 , "Bmxer" , true], - [24 , "Madd Dogg Bodyguard" , true], - [25 , "Madd Dogg Bodyguard" , true], - [26 , "Backpacker" , true], - [27 , "Construction Worker" , true], - [28 , "Drug Dealer" , true], - [29 , "Drug Dealer" , true], - [30 , "Drug Dealer" , true], - [31 , "Farm-Town Inhabitant" , true], - [32 , "Farm-Town Inhabitant" , true], - [33 , "Farm-Town Inhabitant" , true], - [34 , "Farm-Town Inhabitant" , true], - [35 , "Gardener" , true], - [36 , "Golfer" , true], - [37 , "Golfer" , true], - [38 , "Normal Ped" , true], - [39 , "Normal Ped" , true], - [40 , "Normal Ped" , true], - [41 , "Normal Ped" , true], - [43 , "Normal Ped" , true], - [44 , "Normal Ped" , true], - [45 , "Beach Visitor" , true], - [46 , "Normal Ped" , true], - [47 , "Normal Ped" , true], - [48 , "Normal Ped" , true], - [49 , "Snakehead (Da Nang)" , true], - [50 , "Mechanic" , true], - [51 , "Mountain Biker" , true], - [52 , "Mountain Biker" , true], - [53 , "Unknown" , true], - [54 , "Normal Ped" , true], - [55 , "Normal Ped" , true], - [56 , "Normal Ped" , true], - [57 , "Oriental Ped" , true], - [58 , "Oriental Ped" , true], - [59 , "Normal Ped" , true], - [60 , "Normal Ped" , true], - [61 , "Pilot" , false], - [62 , "Colonel Fuhrberger" , true], - [63 , "Prostitute" , true], - [64 , "Prostitute" , true], - [66 , "Pool Player" , true], - [67 , "Pool Player" , true], - [68 , "Priest/Preacher" , true], - [69 , "Normal Ped" , true], - [70 , "Scientist" , true], - [71 , "Security Guard" , false], - [72 , "Hippy" , true], - [73 , "Hippy" , true], - [75 , "Prostitute" , true], - [76 , "Stewardess" , true], - [77 , "Homeless" , true], - [78 , "Homeless" , true], - [79 , "Homeless" , true], - [80 , "Boxer" , true], - [81 , "Boxer" , true], - [82 , "Black Elvis" , true], - [83 , "White Elvis" , true], - [84 , "Blue Elvis" , true], - [85 , "Prostitute" , true], - [87 , "Stripper" , true], - [88 , "Normal Ped" , true], - [89 , "Normal Ped" , true], - [90 , "Jogger" , true], - [91 , "Rich Woman" , true], - [92 , "Rollerskater" , true], - [93 , "Normal Ped" , true], - [94 , "Normal Ped" , true], - [95 , "Normal Ped" , true], - [96 , "Jogger" , true], - [97 , "Lifeguard" , true], - [98 , "Normal Ped" , true], - [99 , "Rollerskater" , true], - [100, "Biker" , true], - [101, "Normal Ped" , true], - [102, "Ballas Gang Member" , true], - [103, "Ballas Gang Member" , true], - [104, "Ballas Gang Member" , true], - [105, "Grove Street Families Gang Member" , true], - [106, "Grove Street Families Gang Member" , true], - [107, "Grove Street Families Gang Member" , true], - [108, "Los Santos Vagos Gang Member" , true], - [109, "Los Santos Vagos Gang Member" , true], - [110, "Los Santos Vagos Gang Member" , true], - [111, "Russian Mafioso" , true], - [112, "Russian Mafioso" , true], - [113, "Russian Mafioso" , true], - [114, "Varios Los Aztecas Gang Member" , true], - [115, "Varios Los Aztecas Gang Member" , true], - [116, "Varios Los Aztecas Gang Member" , true], - [117, "Triad" , true], - [118, "Triad" , true], - [120, "Triad Boss" , true], - [121, "Da Nang Boy" , true], - [122, "Da Nang Boy" , true], - [123, "Da Nang Boy" , true], - [124, "Italian Mafioso" , true], - [125, "Italian Mafioso" , true], - [126, "Italian Mafioso" , true], - [127, "Italian Mafioso" , true], - [128, "Farm Inhabitant" , true], - [129, "Farm Inhabitant" , true], - [130, "Farm Inhabitant" , true], - [131, "Farm Inhabitant" , true], - [132, "Farm Inhabitant" , true], - [133, "Farm Inhabitant" , true], - [134, "Homeless" , true], - [135, "Homeless" , true], - [136, "Normal Ped" , true], - [137, "Homeless" , true], - [138, "Beach Visitor" , true], - [139, "Beach Visitor" , true], - [140, "Beach Visitor" , true], - [141, "Businesswoman" , true], - [142, "Taxi Driver" , true], - [143, "Crack Maker" , true], - [144, "Crack Maker" , true], - [145, "Crack Maker" , true], - [146, "Crack Maker" , true], - [147, "Businessman" , true], - [148, "Businesswoman" , true], - [150, "Businesswoman" , true], - [151, "Normal Ped" , true], - [152, "Prostitute" , true], - [153, "Construction Worker" , true], - [154, "Beach Visitor" , true], - [155, "Well Stacked Pizza Worker" , true], - [156, "Barber" , true], - [157, "Hillbilly" , true], - [158, "Farmer" , true], - [159, "Hillbilly" , true], - [160, "Hillbilly" , true], - [161, "Farmer" , true], - [162, "Hillbilly" , true], - [163, "Black Bouncer" , true], - [164, "White Bouncer" , true], - [165, "White MIB Agent" , false], - [166, "Black MIB Agent" , false], - [167, "Cluckin Bell Worker" , true], - [168, "Hotdog/Chilli Dog Vendor" , true], - [169, "Normal Ped" , true], - [170, "Normal Ped" , true], - [171, "Blackjack Dealer" , true], - [172, "Casino Croupier" , true], - [173, "San Fierro Rifa" , true], - [174, "San Fierro Rifa" , true], - [175, "San Fierro Rifa" , true], - [176, "Barber" , true], - [177, "Barber" , true], - [178, "Whore" , true], - [179, "Ammunation Salesman" , true], - [180, "Tattoo Artist" , true], - [181, "Punk" , true], - [182, "Cab Driver" , true], - [183, "Normal Ped" , true], - [184, "Normal Ped" , true], - [185, "Normal Ped" , true], - [186, "Normal Ped" , true], - [187, "Businessman" , true], - [188, "Normal Ped" , true], - [189, "Valet" , true], - [190, "Barbara Schternvart" , true], - [191, "Helena Wankstein" , true], - [192, "Michelle Cannes" , true], - [193, "Katie Zhan" , true], - [194, "Millie Perkins" , true], - [195, "Denise Robinson" , true], - [196, "Farm-Town Inhabitant" , true], - [197, "Hillbilly" , true], - [198, "Farm-Town Inhabitant" , true], - [199, "Farm-Town Inhabitant" , true], - [200, "Hillbilly" , true], - [201, "Farmer" , true], - [202, "Farmer" , true], - [203, "Karate Teacher" , true], - [204, "Karate Teacher" , true], - [205, "Burger Shot Cashier" , true], - [206, "Cab Driver" , true], - [207, "Prostitute" , true], - [209, "Oriental Noodle Stand Vendor" , true], + [0, "Carl 'CJ' Johnson", false], + [1, "The Truth", true], + [2, "Maccer", true], + [6, "Taxi Driver/Train Driver", true], + [9, "Normal Ped", true], + [10, "Old Woman", true], + [11, "Casino Croupier", false], + [12, "Rich Woman", true], + [13, "Street Girl", true], + [14, "Normal Ped", true], + [15, "Mr.Whittaker (RS Haul Owner)", true], + [16, "Airport Ground Worker", true], + [17, "Businessman", true], + [18, "Beach Visitor", true], + [19, "DJ", true], + [20, "Rich Guy (Madd Doggs Manager)", true], + [21, "Normal Ped", true], + [22, "Normal Ped", true], + [23, "Bmxer", true], + [24, "Madd Dogg Bodyguard", true], + [25, "Madd Dogg Bodyguard", true], + [26, "Backpacker", true], + [27, "Construction Worker", true], + [28, "Drug Dealer", true], + [29, "Drug Dealer", true], + [30, "Drug Dealer", true], + [31, "Farm-Town Inhabitant", true], + [32, "Farm-Town Inhabitant", true], + [33, "Farm-Town Inhabitant", true], + [34, "Farm-Town Inhabitant", true], + [35, "Gardener", true], + [36, "Golfer", true], + [37, "Golfer", true], + [38, "Normal Ped", true], + [39, "Normal Ped", true], + [40, "Normal Ped", true], + [41, "Normal Ped", true], + [43, "Normal Ped", true], + [44, "Normal Ped", true], + [45, "Beach Visitor", true], + [46, "Normal Ped", true], + [47, "Normal Ped", true], + [48, "Normal Ped", true], + [49, "Snakehead (Da Nang)", true], + [50, "Mechanic", true], + [51, "Mountain Biker", true], + [52, "Mountain Biker", true], + [53, "Unknown", true], + [54, "Normal Ped", true], + [55, "Normal Ped", true], + [56, "Normal Ped", true], + [57, "Oriental Ped", true], + [58, "Oriental Ped", true], + [59, "Normal Ped", true], + [60, "Normal Ped", true], + [61, "Pilot", false], + [62, "Colonel Fuhrberger", true], + [63, "Prostitute", true], + [64, "Prostitute", true], + [66, "Pool Player", true], + [67, "Pool Player", true], + [68, "Priest/Preacher", true], + [69, "Normal Ped", true], + [70, "Scientist", true], + [71, "Security Guard", false], + [72, "Hippy", true], + [73, "Hippy", true], + [75, "Prostitute", true], + [76, "Stewardess", true], + [77, "Homeless", true], + [78, "Homeless", true], + [79, "Homeless", true], + [80, "Boxer", true], + [81, "Boxer", true], + [82, "Black Elvis", true], + [83, "White Elvis", true], + [84, "Blue Elvis", true], + [85, "Prostitute", true], + [87, "Stripper", true], + [88, "Normal Ped", true], + [89, "Normal Ped", true], + [90, "Jogger", true], + [91, "Rich Woman", true], + [92, "Rollerskater", true], + [93, "Normal Ped", true], + [94, "Normal Ped", true], + [95, "Normal Ped", true], + [96, "Jogger", true], + [97, "Lifeguard", true], + [98, "Normal Ped", true], + [99, "Rollerskater", true], + [100, "Biker", true], + [101, "Normal Ped", true], + [102, "Ballas Gang Member", true], + [103, "Ballas Gang Member", true], + [104, "Ballas Gang Member", true], + [105, "Grove Street Families Gang Member", true], + [106, "Grove Street Families Gang Member", true], + [107, "Grove Street Families Gang Member", true], + [108, "Los Santos Vagos Gang Member", true], + [109, "Los Santos Vagos Gang Member", true], + [110, "Los Santos Vagos Gang Member", true], + [111, "Russian Mafioso", true], + [112, "Russian Mafioso", true], + [113, "Russian Mafioso", true], + [114, "Varios Los Aztecas Gang Member", true], + [115, "Varios Los Aztecas Gang Member", true], + [116, "Varios Los Aztecas Gang Member", true], + [117, "Triad", true], + [118, "Triad", true], + [120, "Triad Boss", true], + [121, "Da Nang Boy", true], + [122, "Da Nang Boy", true], + [123, "Da Nang Boy", true], + [124, "Italian Mafioso", true], + [125, "Italian Mafioso", true], + [126, "Italian Mafioso", true], + [127, "Italian Mafioso", true], + [128, "Farm Inhabitant", true], + [129, "Farm Inhabitant", true], + [130, "Farm Inhabitant", true], + [131, "Farm Inhabitant", true], + [132, "Farm Inhabitant", true], + [133, "Farm Inhabitant", true], + [134, "Homeless", true], + [135, "Homeless", true], + [136, "Normal Ped", true], + [137, "Homeless", true], + [138, "Beach Visitor", true], + [139, "Beach Visitor", true], + [140, "Beach Visitor", true], + [141, "Businesswoman", true], + [142, "Taxi Driver", true], + [143, "Crack Maker", true], + [144, "Crack Maker", true], + [145, "Crack Maker", true], + [146, "Crack Maker", true], + [147, "Businessman", true], + [148, "Businesswoman", true], + [150, "Businesswoman", true], + [151, "Normal Ped", true], + [152, "Prostitute", true], + [153, "Construction Worker", true], + [154, "Beach Visitor", true], + [155, "Well Stacked Pizza Worker", true], + [156, "Barber", true], + [157, "Hillbilly", true], + [158, "Farmer", true], + [159, "Hillbilly", true], + [160, "Hillbilly", true], + [161, "Farmer", true], + [162, "Hillbilly", true], + [163, "Black Bouncer", true], + [164, "White Bouncer", true], + [165, "White MIB Agent", false], + [166, "Black MIB Agent", false], + [167, "Cluckin Bell Worker", true], + [168, "Hotdog/Chilli Dog Vendor", true], + [169, "Normal Ped", true], + [170, "Normal Ped", true], + [171, "Blackjack Dealer", true], + [172, "Casino Croupier", true], + [173, "San Fierro Rifa", true], + [174, "San Fierro Rifa", true], + [175, "San Fierro Rifa", true], + [176, "Barber", true], + [177, "Barber", true], + [178, "Whore", true], + [179, "Ammunation Salesman", true], + [180, "Tattoo Artist", true], + [181, "Punk", true], + [182, "Cab Driver", true], + [183, "Normal Ped", true], + [184, "Normal Ped", true], + [185, "Normal Ped", true], + [186, "Normal Ped", true], + [187, "Businessman", true], + [188, "Normal Ped", true], + [189, "Valet", true], + [190, "Barbara Schternvart", true], + [191, "Helena Wankstein", true], + [192, "Michelle Cannes", true], + [193, "Katie Zhan", true], + [194, "Millie Perkins", true], + [195, "Denise Robinson", true], + [196, "Farm-Town Inhabitant", true], + [197, "Hillbilly", true], + [198, "Farm-Town Inhabitant", true], + [199, "Farm-Town Inhabitant", true], + [200, "Hillbilly", true], + [201, "Farmer", true], + [202, "Farmer", true], + [203, "Karate Teacher", true], + [204, "Karate Teacher", true], + [205, "Burger Shot Cashier", true], + [206, "Cab Driver", true], + [207, "Prostitute", true], + [209, "Oriental Noodle Stand Vendor", true], [210, "Oriental Boating School Instructor", true], - [211, "Clothes Shop Staff" , true], - [212, "Homeless" , true], - [213, "Weird Old Man" , true], - [214, "Waitress (Maria Latore)" , true], - [215, "Normal Ped" , true], - [216, "Normal Ped" , true], - [217, "Clothes Shop Staff" , true], - [218, "Normal Ped" , true], - [219, "Rich Woman" , true], - [220, "Cab Driver" , true], - [221, "Normal Ped" , true], - [222, "Normal Ped" , true], - [223, "Normal Ped" , true], - [224, "Normal Ped" , true], - [225, "Normal Ped" , true], - [226, "Normal Ped" , true], - [227, "Oriental Businessman" , true], - [228, "Oriental Ped" , true], - [229, "Oriental Ped" , true], - [230, "Homeless" , true], - [231, "Normal Ped" , true], - [232, "Normal Ped" , true], - [233, "Normal Ped" , true], - [234, "Cab Driver" , true], - [235, "Normal Ped" , true], - [236, "Normal Ped" , true], - [237, "Prostitute" , true], - [238, "Prostitute" , true], - [239, "Homeless" , true], - [240, "The D.A" , true], - [241, "Afro-American" , true], - [242, "Mexican" , true], - [243, "Prostitute" , true], - [244, "Stripper" , true], - [245, "Prostitute" , true], - [246, "Stripper" , true], - [247, "Biker" , true], - [248, "Biker" , true], - [249, "Pimp" , true], - [250, "Normal Ped" , true], - [251, "Lifeguard" , true], - [252, "Naked Valet" , true], - [253, "Bus Driver" , false], - [254, "Biker Drug Dealer" , true], - [255, "Chauffeur (Limo Driver)" , true], - [256, "Stripper" , true], - [257, "Stripper" , true], - [258, "Heckler" , true], - [259, "Heckler" , true], - [260, "Construction Worker" , true], - [261, "Cab Driver" , true], - [262, "Cab Driver" , true], - [263, "Normal Ped" , true], - [264, "Clown (Ice-Cream Van Driver)" , true], - [265, "Officer Frank Tenpenny" , false], - [266, "Officer Eddie Pulaski" , false], - [267, "Officer Jimmy Hernandez" , false], - [268, "Dwaine/Dwayne" , true], - [269, "Melvin Big Smoke Harris (Mission)" , true], - [270, "Sean Sweet Johnson" , true], - [271, "Lance Ryder Wilson" , true], - [272, "Mafia Boss" , true], - [274, "Paramedic" , false], - [275, "Paramedic" , false], - [276, "Paramedic" , false], - [277, "Firefighter" , false], - [278, "Firefighter" , false], - [279, "Firefighter" , false], - [280, "Los Santos Police Officer" , false], - [281, "San Fierro Police Officer" , false], - [282, "Las Venturas Police Officer" , false], - [283, "County Sheriff" , false], - [284, "Motorbike Cop" , false], - [285, "S.W.A.T." , false], - [286, "Federal Agent" , false], - [287, "Army Soldier" , false], - [288, "Desert Sheriff" , false], - [290, "Ken Rosenberg" , true], - [291, "Kent Paul" , true], - [292, "Cesar Vialpando" , true], - [293, "Jeffery Og Loc Martin/Cross" , true], - [294, "Wu Zi Mu (Woozie)" , true], - [295, "Michael Toreno" , true], - [296, "Jizzy B." , true], - [297, "Madd Dogg" , true], - [298, "Catalina" , true], - [299, "Claude Speed" , true], - [300, "Lance Ryder Wilson" , true], - [301, "Lance Ryder Wilson (robbery mask)" , true], - [302, "Emmet" , true], - [303, "Unknown" , false], - [304, "Denise" , true], - [305, "Jethro" , true], - [306, "Zero" , true], - [307, "T-Bone Mendez" , true], - [308, "Forelli" , true], - [309, "Mechanic" , true], - [310, "Barry Big Bear Thorne (Skinny)" , true], - [311, "Melvin Big Smoke Harris (Vest)" , true], - [312, "Army Guy" , true], - [313, "Barry Big Bear Thorne (Fat)" , true], + [211, "Clothes Shop Staff", true], + [212, "Homeless", true], + [213, "Weird Old Man", true], + [214, "Waitress (Maria Latore)", true], + [215, "Normal Ped", true], + [216, "Normal Ped", true], + [217, "Clothes Shop Staff", true], + [218, "Normal Ped", true], + [219, "Rich Woman", true], + [220, "Cab Driver", true], + [221, "Normal Ped", true], + [222, "Normal Ped", true], + [223, "Normal Ped", true], + [224, "Normal Ped", true], + [225, "Normal Ped", true], + [226, "Normal Ped", true], + [227, "Oriental Businessman", true], + [228, "Oriental Ped", true], + [229, "Oriental Ped", true], + [230, "Homeless", true], + [231, "Normal Ped", true], + [232, "Normal Ped", true], + [233, "Normal Ped", true], + [234, "Cab Driver", true], + [235, "Normal Ped", true], + [236, "Normal Ped", true], + [237, "Prostitute", true], + [238, "Prostitute", true], + [239, "Homeless", true], + [240, "The D.A", true], + [241, "Afro-American", true], + [242, "Mexican", true], + [243, "Prostitute", true], + [244, "Stripper", true], + [245, "Prostitute", true], + [246, "Stripper", true], + [247, "Biker", true], + [248, "Biker", true], + [249, "Pimp", true], + [250, "Normal Ped", true], + [251, "Lifeguard", true], + [252, "Naked Valet", true], + [253, "Bus Driver", false], + [254, "Biker Drug Dealer", true], + [255, "Chauffeur (Limo Driver)", true], + [256, "Stripper", true], + [257, "Stripper", true], + [258, "Heckler", true], + [259, "Heckler", true], + [260, "Construction Worker", true], + [261, "Cab Driver", true], + [262, "Cab Driver", true], + [263, "Normal Ped", true], + [264, "Clown (Ice-Cream Van Driver)", true], + [265, "Officer Frank Tenpenny", false], + [266, "Officer Eddie Pulaski", false], + [267, "Officer Jimmy Hernandez", false], + [268, "Dwaine/Dwayne", true], + [269, "Melvin Big Smoke Harris (Mission)", true], + [270, "Sean Sweet Johnson", true], + [271, "Lance Ryder Wilson", true], + [272, "Mafia Boss", true], + [274, "Paramedic", false], + [275, "Paramedic", false], + [276, "Paramedic", false], + [277, "Firefighter", false], + [278, "Firefighter", false], + [279, "Firefighter", false], + [280, "Los Santos Police Officer", false], + [281, "San Fierro Police Officer", false], + [282, "Las Venturas Police Officer", false], + [283, "County Sheriff", false], + [284, "Motorbike Cop", false], + [285, "S.W.A.T.", false], + [286, "Federal Agent", false], + [287, "Army Soldier", false], + [288, "Desert Sheriff", false], + [290, "Ken Rosenberg", true], + [291, "Kent Paul", true], + [292, "Cesar Vialpando", true], + [293, "Jeffery Og Loc Martin/Cross", true], + [294, "Wu Zi Mu (Woozie)", true], + [295, "Michael Toreno", true], + [296, "Jizzy B.", true], + [297, "Madd Dogg", true], + [298, "Catalina", true], + [299, "Claude Speed", true], + [300, "Lance Ryder Wilson", true], + [301, "Lance Ryder Wilson (robbery mask)", true], + [302, "Emmet", true], + [303, "Unknown", false], + [304, "Denise", true], + [305, "Jethro", true], + [306, "Zero", true], + [307, "T-Bone Mendez", true], + [308, "Forelli", true], + [309, "Mechanic", true], + [310, "Barry Big Bear Thorne (Skinny)", true], + [311, "Melvin Big Smoke Harris (Vest)", true], + [312, "Army Guy", true], + [313, "Barry Big Bear Thorne (Fat)", true], ], [VRR_GAME_GTA_IV]: [ - [-2020305438,"Male Multiplayer" , false], - [-641875910 ,"Female Multiplayer" , false], - [-1370810922,"MODEL_SUPERLOD" , false], - [ 1853617247,"Anna" , true], - [-1646893330,"Anthony" , true], - [ 1495769888,"Badman" , true], - [ 1500493064,"Bernie Crane" , true], - [ 1731510984,"Bledar" , true], - [ 422305098 ,"Brian" , true], - [-1729980128,"Brucie" , true], - [ 237511807 ,"Bulgarin" , true], - [ 88667657 ,"Charise" , true], - [-1328445565,"Charlie Undercover" , false], - [ 1343144208,"Clarence" , true], - [ 1468450703,"Dardan" , true], - [ 386513184 ,"Darko" , true], - [ 1169442297,"Derric" , true], - [ 237497537 ,"Dmitri" , true], - [-617264103 ,"Dwayne" , true], - [-1600585231,"Eddie" , true], - [ 57218969 ,"Faustin" , true], - [ 1710545037,"Francis" , true], - [ 1424670436,"French Tom" , true], - [ 2129490787,"Gordon" , true], - [-357652594 ,"Gracie" , true], - [ 980768434 ,"Hossan" , true], - [-835225126 ,"Ilyena" , true], - [-479595866 ,"Issac" , true], - [ 1166762483,"Ivan" , true], - [ 364686627 ,"Jay" , true], - [ 170756246 ,"Jason" , true], - [ 390357829 ,"Jeff" , true], - [-366421228 ,"Jimmy" , true], - [-911507684 ,"Johnny Klebitz" , true], - [-773750838 ,"Kate" , true], - [ 995576506 ,"Kenny" , true], - [ 1487004273,"Lil Jacob" , true], - [-1275031987,"Lil Jacob 2," , true], - [-681942840 ,"Luca" , true], - [-492470690 ,"Luis" , true], - [-1040287406,"Mallorie" , true], - [-322700377 ,"Mam" , true], - [ 1445589009,"Manny" , true], - [ 411185872 ,"Marnie" , true], - [-807339118 ,"Mel" , true], - [ 735211577 ,"Michael" , true], - [-1080659212,"Michelle" , true], - [-636669566 ,"Mickey" , true], - [ 1690783035,"Packie" , true], - [-165448092 ,"Pathos" , true], - [-1947682830,"Petrovic" , true], - [-1826458934,"Phil Bell" , true], - [ 1794146792,"Playboy X" , true], - [ 954215094 ,"Ray Boccino" , true], - [-587324132 ,"Ricky" , true], - [-1992728631,"Roman" , true], - [ 558221221 ,"Roman 2," , true], - [-17823883 ,"Sarah" , true], - [ 1384833284,"Tuna" , true], - [-1014976873,"Vinny Spaz" , true], - [ 896408642 ,"Vlad" , true], - [-301223260 ,"Black Street Thug 1," , true], - [-1143910864,"Black Street Thug 2," , true], - [ 869501081 ,"Black Street OG 1," , true], - [ 632613980 ,"Black Street OG 1," , true], - [-503930010 ,"Albanian Thug 1," , true], - [-235584669 ,"Albanian Thug 2," , true], - [ 207714363 ,"Albanian Thug 3," , true], - [ 514268366 ,"Albanian Thug 4," , true], - [ 43005364 ,"Biker 1," , true], - [ 1346668127,"Biker 2," , true], - [-1677255197,"Biker 3," , true], - [-1461281345,"Biker 4," , true], - [ 1574850459,"Biker 5," , true], - [-1953289472,"Biker 6," , true], - [ 280474699 ,"Irish Man 1," , true], - [-19263344 ,"Irish Man 2," , true], - [ 1844702918,"Irish Man 3," , true], - [ 1609755055,"Jamaican OG 1," , true], - [-330497431 ,"Jamaican OG 2," , true], - [ 1117105909,"Jamaican OG 3," , true], - [-1500397869,"Jamaican Thug 1," , true], - [-881358690 ,"Jamaican Thug 2," , true], - [ 1540383669,"Asian Man 1," , true], - [ 764249904 ,"Asian Man 2," , true], - [ 492147228 ,"Hispanic Man 1," , true], - [-1926041127,"Hispanic Man 2," , true], - [ 1168388225,"Hispanic Man 3," , true], - [-1746774780,"Hispanic Man 4," , true], - [-302362397 ,"Fat Italian Mafia Boss" , true], - [-1616890832,"Italian Mafia Boss" , true], - [ 64730935 ,"Italian Mafia Associate" , true], - [ 510389335 ,"Fat Italian Mafia Associate" , true], - [-1836006237,"Russian Thug 1," , true], - [-2088164056,"Russian Thug 2," , true], - [ 1976502708,"Russian Thug 3," , true], - [ 1543404628,"Russian Thug 4," , true], - [ 1865532596,"Russian Thug 5," , true], - [ 431692232 ,"Russian Thug 6," , true], - [ 1724587620,"Russian Thug 7," , true], - [-1180674815,"Russian Thug 8," , true], - [ 871281791 ,"Triad Boss 1," , true], - [ 683712035 ,"Triad Boss 2," , true], - [-1084007777,"Triad Member 3," , true], - [-164935626 ,"Triad Member 4," , true], - [-751071255 ,"Female Maid" , true], - [-109247258 ,"Female Binco Worker" , false], - [ 1366257926,"Female Bank Teller" , true], - [ 346338575 ,"Female Doctor" , true], - [ 1350216795,"Female Gym Worker" , true], - [ 924926104 ,"Female Burger Shot Worker" , false], - [-346378101 ,"Female Cluckin Bell Worker" , false], - [-2104311883,"Female Rockstar Cafe Worker" , false], - [ 212900845 ,"Female TW@ Cafe Worker" , false], - [-290070895 ,"Female Well Stacked Pizza Worker", false], - [ 552542187 ,"Hooker" , true], - [ 996267216 ,"Hooker 2," , true], - [-1193778389,"Nurse" , true], - [ 1113677074,"Stripper 1," , true], - [ 1353709999,"Stripper 2," , true], - [ 24233425 ,"Waitress" , true], - [-1761003415,"Alcoholic Man" , true], - [ 1075583233,"Armoured Truck Driver" , false], - [ 134077503 ,"Bus Driver" , false], - [ 757349871 ,"Generic Asian Man" , true], - [-1827421800,"Black Crackhead" , true], - [ 219393781 ,"Doctor (Scrubs)" , true], - [-1186940778,"Doctor" , true], - [ 375732086 ,"Doctor (Blood Covered Coat)" , true], - [ 2105015949,"Cook" , true], - [-200234085 ,"Italian Mob Enforcer" , true], - [ 800131009 ,"Factory Worker" , true], - [-999506922 ,"FIB Agent" , false], - [-1993909080,"Fat Delivery Driver" , true], - [ 610888851 ,"Fire Chief" , false], - [ 486302863 ,"Mercenary Soldier" , false], - [-778316080 ,"Helicopter Pilot" , false], - [ 624314380 ,"Hotel Doorman" , true], - [-1784833142,"Korean Cook" , true], - [-1852976689,"Lawyer 1," , true], - [-1134712978,"Lawyer 2," , true], - [ 379171768 ,"Loony Black Man" , true], - [-1945168882,"Pilot" , false], - [ 807236245 ,"Generic Man" , true], - [-284362863 ,"Postal Worker" , true], - [-1188246269,"Saxophone Player" , true], - [-1870989171,"Security Guard" , false], - [ 420915580 ,"Stadium Food Vendor" , true], - [ 1878085135,"Stadium Food Cook" , true], - [ 142730876 ,"Street Food Vendor" , true], - [-690681764 ,"Street Sweeper Driver" , true], - [ 8772846 ,"Taxi Driver" , true], - [ 1186270890,"Telephone Company Worker" , true], - [-379234846 ,"Tennis Player" , true], - [ 1159759556,"Train Conductor" , false], - [-142386662 ,"Homeless Black Man" , true], - [-46564867 ,"Trucker" , true], - [-1284047560,"Janitor" , true], - [ 22944263 ,"Hotel Doorman 2," , true], - [ 1178487645,"Mob Boss" , true], - [-1464712858,"Airport Worker" , false], - [-2139064254,"Bartender" , true], - [-1780698891,"Biker Bouncer" , true], - [-409283472 ,"High End Club Bouncer" , true], - [-799229885 ,"Bowling Alley Worker" , true], - [-434183225 ,"Bowling Alley Worker 2," , true], - [ 768442188 ,"Chinese Food Vendor" , true], - [ 676448572 ,"Club Security" , true], - [-722019798 ,"Construction Worker" , true], - [-1015957728,"Construction Worker 2," , true], - [-714220780 ,"Construction Worker 3," , true], - [-183203150 ,"Police Officer" , false], - [-1518937979,"Traffic Officer" , false], - [-370395528 ,"Fat Police Officer" , false], - [-1371133859,"Courier" , true], - [-573788283 ,"Cowboy 1," , true], - [-1283406538,"Drug Dealer 1," , true], - [ 1448755353,"Drug Dealer 2," , true], - [ 989485 ,"Male Burger Shot Worker" , true], - [-1011530423,"Male Cluckin Bell Worker" , true], - [ 1979561477,"Male Rockstar Cafe Worker" , true], - [-786449781 ,"Male TW@ Cafe Worker" , true], - [ 206941425 ,"Male Well Stacked Pizza Worker" , true], - [-610224615 ,"Firefighter" , false], - [ 1136499716,"Garbage Collector" , false], - [ 897868981 ,"Goon" , true], - [-1902758612,"Male Gym Worker" , true], - [-356904519 ,"Mechanic 2," , true], - [-1056268969,"Male Modo Worker" , true], - [ 1201610759,"Helicopter Pilot" , false], - [-151000142 ,"Perseus" , true], - [ 501136335 ,"Generic Male 1," , true], - [ 186619473 ,"Generic Male 2," , true], - [-111611196 ,"Generic Male 3," , true], - [-1175077216,"Paramedic" , false], - [-1676937780,"Prisoner" , false], - [ 215190023 ,"Prisoner 2," , false], - [ 1552970117,"Roman's Taxi Service Driver" , true], - [-1481923910,"Male Runner" , true], - [ 357919731 ,"Male Shop Assistant 1," , true], - [-89302119 ,"State Trooper" , false], - [-1004762946,"SWAT" , false], - [-64233032 ,"Sword Swallower" , true], - [-1292254815,"Thief" , true], - [ 271284208 ,"Valet" , true], - [-186113957 ,"Vendor" , true], - [-2015686009,"French Tom" , true], - [ 1977784957,"Jim Fitz" , true], - [-203833294 ,"East European Woman" , true], - [ 189853472 ,"East European Woman 2," , true], - [-349043578 ,"Woman" , true], - [-114937692 ,"Jersey Woman" , true], - [-1697333660,"Oriental Woman" , true], - [ 100706569 ,"Rich Woman" , true], - [ 155063868 ,"Business Woman 1," , true], - [ 394310337 ,"Business Woman 2," , true], - [ 1375728805,"Chinatown Woman" , true], - [-284229525 ,"Business Woman 3," , true], - [ 677687516 ,"East European Woman 3," , true], - [-1188238883,"Fat Black Woman" , true], - [-2075220936,"Jersey Woman 1," , true], - [-1356924456,"Jersey Woman 2," , true], - [ 812112483 ,"Fat Hispanic Woman 1," , true], - [-129242580 ,"Fat Hispanic Woman 2," , true], - [ 852423121 ,"White Manhattan Woman" , true], - [ 76551508 ,"Black Manhattan Woman" , true], - [-2118501976,"Old Asian Woman" , true], - [ 1616769823,"Old Rich Woman" , true], - [ 453889158 ,"Business Woman 4," , true], - [ 824245375 ,"Asian Woman in Dress" , true], - [-1362442041,"Fat Black Bronx Woman" , true], - [-1788328884,"Random White Woman" , true], - [-1523915823,"Random Hispanic Woman" , true], - [-949987237 ,"Random Eastern European Woman" , true], - [-1926577323,"Random Black Woman" , true], - [ 168065679 ,"Black Harlem Woman 1," , true], - [ 441464 ,"Fat Jersey Woman 1," , true], - [ 54114008 ,"Fat Hispanic Woman 3," , true], - [-292713088 ,"Hispanic Woman 1," , true], - [ 1743814728,"Hispanic Woman 2," , true], - [ 1670568326,"Manhattan Woman 1," , true], - [ 1354281938,"Manhattan Woman 2," , true], - [ 1056837725,"Manhattan Woman 1," , true], - [-1193633577,"Asian Woman 1," , true], - [ 713691120 ,"Black Woman 2," , true], - [-1780385799,"Rich White Woman 1," , true], - [-952185135 ,"Asian Woman" , true], - [ 1586287288,"Female Shopper 1," , true], - [ 1848013291,"Female Shopper 2," , true], - [-1702036227,"Female Shopper 3," , true], - [ 1182843182,"Female Socialite 1," , true], - [-900623157 ,"Street Woman 1," , true], - [ 286007875 ,"Street Woman 2," , true], - [ 1473654742,"Street Woman 3," , true], - [-1850743775,"Street Woman 4," , true], - [ 1290755317,"Street Woman 5," , true], - [ 1872110126,"Street Woman 6," , true], - [ 1754440500,"Tourist Woman 1," , true], - [ 761763258 ,"MODEL_F_Y_VILLBO_01," , true], - [-636579119 ,"Business Man 1," , true], - [-1754526315,"Business Man 2," , true], - [-1516474414,"Street Criminal 1," , true], - [-1821258883,"Street Criminal 2," , true], - [ 1952671026,"Obese Mafia Thug" , true], - [-1991603022,"Gay Man 1," , true], - [-1080673049,"Homeless Bum 1," , true], - [ 495499562 ,"Loony White Man 1," , true], - [-1984134881,"MODEL_M_M_MIDTOWN_01," , true], - [ 1063816580,"Business Man 2," , true], - [ 208763854 ,"Eastern European Man 1," , true], - [-1020237172,"Fat Black Man 2," , true], - [ 1782277836,"MODEL_M_M_PINDUS_02," , true], - [-1402442039,"Fat Italian Man 1," , true], - [-1628417063,"Italian Man 2," , true], - [ 1158569407,"Hispanic Man 1," , true], - [ 1969438324,"Hispanic Man 2," , true], - [ 1621955848,"Hispanic Man 3," , true], - [-657489059 ,"Tourist Man 1," , true], - [-1307068958,"Black Business Man 1," , true], - [ 734334931 ,"Asian Man 3," , true], - [ 1865082075,"MODEL_M_M_PRICH_01," , true], - [-432593815 ,"MODEL_M_O_EASTEURO_01," , true], - [-1639359785,"Hasidic Jewish Man 1," , true], - [ 1656087115,"Old Man 1," , true], - [ 2034185905,"MODEL_M_O_PEASTEURO_02," , true], - [ 1316404726,"MODEL_M_O_PHARBRON_01," , true], - [ 980990533 ,"MODEL_M_O_PJERSEY_01," , true], - [-1298691925,"MODEL_M_O_STREET_01," , true], - [ 243672348 ,"Old Business Man" , true], - [ 2085884255,"MODEL_M_Y_BOHO_01," , true], - [ 221246143 ,"MODEL_M_Y_BOHOGUY_01," , true], - [ 52357603 ,"MODEL_M_Y_BRONX_01," , true], - [ 1530937394,"Black Business Man 2," , true], - [ 690281432 ,"Black Business Man 3," , true], - [-1149743642,"Asian Man 4," , true], - [-314369597 ,"Chopshop Mechanic 1," , true], - [-552829610 ,"Chopshop Mechanic 2," , true], - [-1097188138,"MODEL_M_Y_DODGY_01," , true], - [-1775659292,"MODEL_M_Y_DORK_02," , true], - [ 1207402441,"MODEL_M_Y_DOWNTOWN_01," , true], - [ 1500619449,"MODEL_M_Y_DOWNTOWN_02," , true], - [ 594261682 ,"MODEL_M_Y_DOWNTOWN_03," , true], - [-747824291 ,"MODEL_M_Y_GAYYOUNG" , true], - [-677160979 ,"MODEL_M_Y_GENSTREET_11," , true], - [-1678614360,"MODEL_M_Y_GENSTREET_16," , true], - [ 989044076 ,"MODEL_M_Y_GENSTREET_20," , true], - [ 1180218190,"MODEL_M_Y_GENSTREET_34," , true], - [-1420592428,"MODEL_M_Y_HARDMAN_01," , true], - [-1222963415,"MODEL_M_Y_HARLEM_01," , true], - [-1746153269,"MODEL_M_Y_HARLEM_02," , true], - [ 2104499156,"MODEL_M_Y_HARLEM_04," , true], - [-1874580889,"Hasidic Jewish Man 2," , true], - [-1055386282,"MODEL_M_Y_LEASTSIDE_01," , true], - [ 575808580 ,"MODEL_M_Y_PBRONX_01," , true], - [-71980543 ,"MODEL_M_Y_PCOOL_01," , true], - [-195159218 ,"MODEL_M_Y_PCOOL_02," , true], - [ 697247370 ,"MODEL_M_Y_PEASTEURO_01," , true], - [ 670406267 ,"MODEL_M_Y_PHARBRON_01," , true], - [ 26615298 ,"MODEL_M_Y_PHARLEM_01," , true], - [ 1542927558,"MODEL_M_Y_PJERSEY_01," , true], - [-1806886352,"MODEL_M_Y_PLATIN_01," , true], - [-1022920796,"MODEL_M_Y_PLATIN_02," , true], - [-1326394505,"MODEL_M_Y_PLATIN_03," , true], - [ 607901190 ,"MODEL_M_Y_PMANHAT_01," , true], - [ 1968470106,"MODEL_M_Y_PMANHAT_02," , true], - [-344136289 ,"MODEL_M_Y_PORIENT_01," , true], - [ 560413584 ,"MODEL_M_Y_PQUEENS_01," , true], - [ 1352017873,"MODEL_M_Y_PRICH_01," , true], - [ 223726252 ,"MODEL_M_Y_PVILLBO_01," , true], - [-1252681043,"MODEL_M_Y_PVILLBO_02," , true], - [-1562020391,"MODEL_M_Y_PVILLBO_03," , true], - [ 1223224881,"MODEL_M_Y_QUEENSBRIDGE" , true], - [-1220737489,"MODEL_M_Y_SHADY_02," , true], - [ 1755322862,"MODEL_M_Y_SKATEBIKE_01," , true], - [ 386690478 ,"MODEL_M_Y_SOHO_01," , true], - [ 62496225 ,"MODEL_M_Y_STREET_01," , true], - [ 523785438 ,"MODEL_M_Y_STREET_03," , true], - [ 813889395 ,"MODEL_M_Y_STREET_04," , true], - [-1552214124,"MODEL_M_Y_STREETBLK_02," , true], - [-650575089 ,"MODEL_M_Y_STREETBLK_03," , true], - [-740078918 ,"Street Punk 1," , true], - [-1927496394,"Street Punk 2," , true], - [ 1374242512,"Street Punk 3," , true], - [-1139941790,"Tough Guy" , true], - [ 809067472 ,"Male Tourist" , true] + [-2020305438, "Male Multiplayer", false], + [-641875910, "Female Multiplayer", false], + [-1370810922, "MODEL_SUPERLOD", false], + [1853617247, "Anna", true], + [-1646893330, "Anthony", true], + [1495769888, "Badman", true], + [1500493064, "Bernie Crane", true], + [1731510984, "Bledar", true], + [422305098, "Brian", true], + [-1729980128, "Brucie", true], + [237511807, "Bulgarin", true], + [88667657, "Charise", true], + [-1328445565, "Charlie Undercover", false], + [1343144208, "Clarence", true], + [1468450703, "Dardan", true], + [386513184, "Darko", true], + [1169442297, "Derric", true], + [237497537, "Dmitri", true], + [-617264103, "Dwayne", true], + [-1600585231, "Eddie", true], + [57218969, "Faustin", true], + [1710545037, "Francis", true], + [1424670436, "French Tom", true], + [2129490787, "Gordon", true], + [-357652594, "Gracie", true], + [980768434, "Hossan", true], + [-835225126, "Ilyena", true], + [-479595866, "Issac", true], + [1166762483, "Ivan", true], + [364686627, "Jay", true], + [170756246, "Jason", true], + [390357829, "Jeff", true], + [-366421228, "Jimmy", true], + [-911507684, "Johnny Klebitz", true], + [-773750838, "Kate", true], + [995576506, "Kenny", true], + [1487004273, "Lil Jacob", true], + [-1275031987, "Lil Jacob 2,", true], + [-681942840, "Luca", true], + [-492470690, "Luis", true], + [-1040287406, "Mallorie", true], + [-322700377, "Mam", true], + [1445589009, "Manny", true], + [411185872, "Marnie", true], + [-807339118, "Mel", true], + [735211577, "Michael", true], + [-1080659212, "Michelle", true], + [-636669566, "Mickey", true], + [1690783035, "Packie", true], + [-165448092, "Pathos", true], + [-1947682830, "Petrovic", true], + [-1826458934, "Phil Bell", true], + [1794146792, "Playboy X", true], + [954215094, "Ray Boccino", true], + [-587324132, "Ricky", true], + [-1992728631, "Roman", true], + [558221221, "Roman 2,", true], + [-17823883, "Sarah", true], + [1384833284, "Tuna", true], + [-1014976873, "Vinny Spaz", true], + [896408642, "Vlad", true], + [-301223260, "Black Street Thug 1,", true], + [-1143910864, "Black Street Thug 2,", true], + [869501081, "Black Street OG 1,", true], + [632613980, "Black Street OG 1,", true], + [-503930010, "Albanian Thug 1,", true], + [-235584669, "Albanian Thug 2,", true], + [207714363, "Albanian Thug 3,", true], + [514268366, "Albanian Thug 4,", true], + [43005364, "Biker 1,", true], + [1346668127, "Biker 2,", true], + [-1677255197, "Biker 3,", true], + [-1461281345, "Biker 4,", true], + [1574850459, "Biker 5,", true], + [-1953289472, "Biker 6,", true], + [280474699, "Irish Man 1,", true], + [-19263344, "Irish Man 2,", true], + [1844702918, "Irish Man 3,", true], + [1609755055, "Jamaican OG 1,", true], + [-330497431, "Jamaican OG 2,", true], + [1117105909, "Jamaican OG 3,", true], + [-1500397869, "Jamaican Thug 1,", true], + [-881358690, "Jamaican Thug 2,", true], + [1540383669, "Asian Man 1,", true], + [764249904, "Asian Man 2,", true], + [492147228, "Hispanic Man 1,", true], + [-1926041127, "Hispanic Man 2,", true], + [1168388225, "Hispanic Man 3,", true], + [-1746774780, "Hispanic Man 4,", true], + [-302362397, "Fat Italian Mafia Boss", true], + [-1616890832, "Italian Mafia Boss", true], + [64730935, "Italian Mafia Associate", true], + [510389335, "Fat Italian Mafia Associate", true], + [-1836006237, "Russian Thug 1,", true], + [-2088164056, "Russian Thug 2,", true], + [1976502708, "Russian Thug 3,", true], + [1543404628, "Russian Thug 4,", true], + [1865532596, "Russian Thug 5,", true], + [431692232, "Russian Thug 6,", true], + [1724587620, "Russian Thug 7,", true], + [-1180674815, "Russian Thug 8,", true], + [871281791, "Triad Boss 1,", true], + [683712035, "Triad Boss 2,", true], + [-1084007777, "Triad Member 3,", true], + [-164935626, "Triad Member 4,", true], + [-751071255, "Female Maid", true], + [-109247258, "Female Binco Worker", false], + [1366257926, "Female Bank Teller", true], + [346338575, "Female Doctor", true], + [1350216795, "Female Gym Worker", true], + [924926104, "Female Burger Shot Worker", false], + [-346378101, "Female Cluckin Bell Worker", false], + [-2104311883, "Female Rockstar Cafe Worker", false], + [212900845, "Female TW@ Cafe Worker", false], + [-290070895, "Female Well Stacked Pizza Worker", false], + [552542187, "Hooker", true], + [996267216, "Hooker 2,", true], + [-1193778389, "Nurse", true], + [1113677074, "Stripper 1,", true], + [1353709999, "Stripper 2,", true], + [24233425, "Waitress", true], + [-1761003415, "Alcoholic Man", true], + [1075583233, "Armoured Truck Driver", false], + [134077503, "Bus Driver", false], + [757349871, "Generic Asian Man", true], + [-1827421800, "Black Crackhead", true], + [219393781, "Doctor (Scrubs)", true], + [-1186940778, "Doctor", true], + [375732086, "Doctor (Blood Covered Coat)", true], + [2105015949, "Cook", true], + [-200234085, "Italian Mob Enforcer", true], + [800131009, "Factory Worker", true], + [-999506922, "FIB Agent", false], + [-1993909080, "Fat Delivery Driver", true], + [610888851, "Fire Chief", false], + [486302863, "Mercenary Soldier", false], + [-778316080, "Helicopter Pilot", false], + [624314380, "Hotel Doorman", true], + [-1784833142, "Korean Cook", true], + [-1852976689, "Lawyer 1,", true], + [-1134712978, "Lawyer 2,", true], + [379171768, "Loony Black Man", true], + [-1945168882, "Pilot", false], + [807236245, "Generic Man", true], + [-284362863, "Postal Worker", true], + [-1188246269, "Saxophone Player", true], + [-1870989171, "Security Guard", false], + [420915580, "Stadium Food Vendor", true], + [1878085135, "Stadium Food Cook", true], + [142730876, "Street Food Vendor", true], + [-690681764, "Street Sweeper Driver", true], + [8772846, "Taxi Driver", true], + [1186270890, "Telephone Company Worker", true], + [-379234846, "Tennis Player", true], + [1159759556, "Train Conductor", false], + [-142386662, "Homeless Black Man", true], + [-46564867, "Trucker", true], + [-1284047560, "Janitor", true], + [22944263, "Hotel Doorman 2,", true], + [1178487645, "Mob Boss", true], + [-1464712858, "Airport Worker", false], + [-2139064254, "Bartender", true], + [-1780698891, "Biker Bouncer", true], + [-409283472, "High End Club Bouncer", true], + [-799229885, "Bowling Alley Worker", true], + [-434183225, "Bowling Alley Worker 2,", true], + [768442188, "Chinese Food Vendor", true], + [676448572, "Club Security", true], + [-722019798, "Construction Worker", true], + [-1015957728, "Construction Worker 2,", true], + [-714220780, "Construction Worker 3,", true], + [-183203150, "Police Officer", false], + [-1518937979, "Traffic Officer", false], + [-370395528, "Fat Police Officer", false], + [-1371133859, "Courier", true], + [-573788283, "Cowboy 1,", true], + [-1283406538, "Drug Dealer 1,", true], + [1448755353, "Drug Dealer 2,", true], + [989485, "Male Burger Shot Worker", true], + [-1011530423, "Male Cluckin Bell Worker", true], + [1979561477, "Male Rockstar Cafe Worker", true], + [-786449781, "Male TW@ Cafe Worker", true], + [206941425, "Male Well Stacked Pizza Worker", true], + [-610224615, "Firefighter", false], + [1136499716, "Garbage Collector", false], + [897868981, "Goon", true], + [-1902758612, "Male Gym Worker", true], + [-356904519, "Mechanic 2,", true], + [-1056268969, "Male Modo Worker", true], + [1201610759, "Helicopter Pilot", false], + [-151000142, "Perseus", true], + [501136335, "Generic Male 1,", true], + [186619473, "Generic Male 2,", true], + [-111611196, "Generic Male 3,", true], + [-1175077216, "Paramedic", false], + [-1676937780, "Prisoner", false], + [215190023, "Prisoner 2,", false], + [1552970117, "Roman's Taxi Service Driver", true], + [-1481923910, "Male Runner", true], + [357919731, "Male Shop Assistant 1,", true], + [-89302119, "State Trooper", false], + [-1004762946, "SWAT", false], + [-64233032, "Sword Swallower", true], + [-1292254815, "Thief", true], + [271284208, "Valet", true], + [-186113957, "Vendor", true], + [-2015686009, "French Tom", true], + [1977784957, "Jim Fitz", true], + [-203833294, "East European Woman", true], + [189853472, "East European Woman 2,", true], + [-349043578, "Woman", true], + [-114937692, "Jersey Woman", true], + [-1697333660, "Oriental Woman", true], + [100706569, "Rich Woman", true], + [155063868, "Business Woman 1,", true], + [394310337, "Business Woman 2,", true], + [1375728805, "Chinatown Woman", true], + [-284229525, "Business Woman 3,", true], + [677687516, "East European Woman 3,", true], + [-1188238883, "Fat Black Woman", true], + [-2075220936, "Jersey Woman 1,", true], + [-1356924456, "Jersey Woman 2,", true], + [812112483, "Fat Hispanic Woman 1,", true], + [-129242580, "Fat Hispanic Woman 2,", true], + [852423121, "White Manhattan Woman", true], + [76551508, "Black Manhattan Woman", true], + [-2118501976, "Old Asian Woman", true], + [1616769823, "Old Rich Woman", true], + [453889158, "Business Woman 4,", true], + [824245375, "Asian Woman in Dress", true], + [-1362442041, "Fat Black Bronx Woman", true], + [-1788328884, "Random White Woman", true], + [-1523915823, "Random Hispanic Woman", true], + [-949987237, "Random Eastern European Woman", true], + [-1926577323, "Random Black Woman", true], + [168065679, "Black Harlem Woman 1,", true], + [441464, "Fat Jersey Woman 1,", true], + [54114008, "Fat Hispanic Woman 3,", true], + [-292713088, "Hispanic Woman 1,", true], + [1743814728, "Hispanic Woman 2,", true], + [1670568326, "Manhattan Woman 1,", true], + [1354281938, "Manhattan Woman 2,", true], + [1056837725, "Manhattan Woman 1,", true], + [-1193633577, "Asian Woman 1,", true], + [713691120, "Black Woman 2,", true], + [-1780385799, "Rich White Woman 1,", true], + [-952185135, "Asian Woman", true], + [1586287288, "Female Shopper 1,", true], + [1848013291, "Female Shopper 2,", true], + [-1702036227, "Female Shopper 3,", true], + [1182843182, "Female Socialite 1,", true], + [-900623157, "Street Woman 1,", true], + [286007875, "Street Woman 2,", true], + [1473654742, "Street Woman 3,", true], + [-1850743775, "Street Woman 4,", true], + [1290755317, "Street Woman 5,", true], + [1872110126, "Street Woman 6,", true], + [1754440500, "Tourist Woman 1,", true], + [761763258, "MODEL_F_Y_VILLBO_01,", true], + [-636579119, "Business Man 1,", true], + [-1754526315, "Business Man 2,", true], + [-1516474414, "Street Criminal 1,", true], + [-1821258883, "Street Criminal 2,", true], + [1952671026, "Obese Mafia Thug", true], + [-1991603022, "Gay Man 1,", true], + [-1080673049, "Homeless Bum 1,", true], + [495499562, "Loony White Man 1,", true], + [-1984134881, "MODEL_M_M_MIDTOWN_01,", true], + [1063816580, "Business Man 2,", true], + [208763854, "Eastern European Man 1,", true], + [-1020237172, "Fat Black Man 2,", true], + [1782277836, "MODEL_M_M_PINDUS_02,", true], + [-1402442039, "Fat Italian Man 1,", true], + [-1628417063, "Italian Man 2,", true], + [1158569407, "Hispanic Man 1,", true], + [1969438324, "Hispanic Man 2,", true], + [1621955848, "Hispanic Man 3,", true], + [-657489059, "Tourist Man 1,", true], + [-1307068958, "Black Business Man 1,", true], + [734334931, "Asian Man 3,", true], + [1865082075, "MODEL_M_M_PRICH_01,", true], + [-432593815, "MODEL_M_O_EASTEURO_01,", true], + [-1639359785, "Hasidic Jewish Man 1,", true], + [1656087115, "Old Man 1,", true], + [2034185905, "MODEL_M_O_PEASTEURO_02,", true], + [1316404726, "MODEL_M_O_PHARBRON_01,", true], + [980990533, "MODEL_M_O_PJERSEY_01,", true], + [-1298691925, "MODEL_M_O_STREET_01,", true], + [243672348, "Old Business Man", true], + [2085884255, "MODEL_M_Y_BOHO_01,", true], + [221246143, "MODEL_M_Y_BOHOGUY_01,", true], + [52357603, "MODEL_M_Y_BRONX_01,", true], + [1530937394, "Black Business Man 2,", true], + [690281432, "Black Business Man 3,", true], + [-1149743642, "Asian Man 4,", true], + [-314369597, "Chopshop Mechanic 1,", true], + [-552829610, "Chopshop Mechanic 2,", true], + [-1097188138, "MODEL_M_Y_DODGY_01,", true], + [-1775659292, "MODEL_M_Y_DORK_02,", true], + [1207402441, "MODEL_M_Y_DOWNTOWN_01,", true], + [1500619449, "MODEL_M_Y_DOWNTOWN_02,", true], + [594261682, "MODEL_M_Y_DOWNTOWN_03,", true], + [-747824291, "MODEL_M_Y_GAYYOUNG", true], + [-677160979, "MODEL_M_Y_GENSTREET_11,", true], + [-1678614360, "MODEL_M_Y_GENSTREET_16,", true], + [989044076, "MODEL_M_Y_GENSTREET_20,", true], + [1180218190, "MODEL_M_Y_GENSTREET_34,", true], + [-1420592428, "MODEL_M_Y_HARDMAN_01,", true], + [-1222963415, "MODEL_M_Y_HARLEM_01,", true], + [-1746153269, "MODEL_M_Y_HARLEM_02,", true], + [2104499156, "MODEL_M_Y_HARLEM_04,", true], + [-1874580889, "Hasidic Jewish Man 2,", true], + [-1055386282, "MODEL_M_Y_LEASTSIDE_01,", true], + [575808580, "MODEL_M_Y_PBRONX_01,", true], + [-71980543, "MODEL_M_Y_PCOOL_01,", true], + [-195159218, "MODEL_M_Y_PCOOL_02,", true], + [697247370, "MODEL_M_Y_PEASTEURO_01,", true], + [670406267, "MODEL_M_Y_PHARBRON_01,", true], + [26615298, "MODEL_M_Y_PHARLEM_01,", true], + [1542927558, "MODEL_M_Y_PJERSEY_01,", true], + [-1806886352, "MODEL_M_Y_PLATIN_01,", true], + [-1022920796, "MODEL_M_Y_PLATIN_02,", true], + [-1326394505, "MODEL_M_Y_PLATIN_03,", true], + [607901190, "MODEL_M_Y_PMANHAT_01,", true], + [1968470106, "MODEL_M_Y_PMANHAT_02,", true], + [-344136289, "MODEL_M_Y_PORIENT_01,", true], + [560413584, "MODEL_M_Y_PQUEENS_01,", true], + [1352017873, "MODEL_M_Y_PRICH_01,", true], + [223726252, "MODEL_M_Y_PVILLBO_01,", true], + [-1252681043, "MODEL_M_Y_PVILLBO_02,", true], + [-1562020391, "MODEL_M_Y_PVILLBO_03,", true], + [1223224881, "MODEL_M_Y_QUEENSBRIDGE", true], + [-1220737489, "MODEL_M_Y_SHADY_02,", true], + [1755322862, "MODEL_M_Y_SKATEBIKE_01,", true], + [386690478, "MODEL_M_Y_SOHO_01,", true], + [62496225, "MODEL_M_Y_STREET_01,", true], + [523785438, "MODEL_M_Y_STREET_03,", true], + [813889395, "MODEL_M_Y_STREET_04,", true], + [-1552214124, "MODEL_M_Y_STREETBLK_02,", true], + [-650575089, "MODEL_M_Y_STREETBLK_03,", true], + [-740078918, "Street Punk 1,", true], + [-1927496394, "Street Punk 2,", true], + [1374242512, "Street Punk 3,", true], + [-1139941790, "Tough Guy", true], + [809067472, "Male Tourist", true] ], [VRR_GAME_MAFIA_ONE]: [ - ["Tommy.i3d" , "Tommy Angelo" , true ], - ["TommyBOXER.i3d" , "Tommy Angelo" , true ], - ["TommyCOAT.i3d" , "Tommy Angelo" , false], - ["TommyCOATHAT.i3d" , "Tommy Angelo" , true ], - ["TommyDELNIK.i3d" , "Tommy Angelo" , true ], - ["TommyDELNIKHIGH.i3d" , "Tommy Angelo" , true ], - ["TommyFREERIDER.i3d" , "Tommy Angelo" , true ], - ["TommyGUN.i3d" , "Tommy Angelo" , true ], - ["TommyHAT.i3d" , "Tommy Angelo" , true ], - ["TommyHIGH.i3d" , "Tommy Angelo" , true ], - ["TommyHIGHBLOOD.i3d" , "Tommy Angelo" , false], - ["TommyHighCOATHAT.i3d" , "Tommy Angelo" , true ], - ["TommyHighHAT.i3d" , "Tommy Angelo" , true ], - ["TommyNAHAC.i3d" , "Tommy Angelo (Naked)" , false], - ["TommyOLD.i3d" , "Tommy Angelo (Old)" , true ], - ["TommyOLDBLOOD.i3d" , "Tommy Angelo (Old)" , false], - ["TommyPYTEL.i3d" , "Tommy Angelo (With Bag)" , true ], - ["TommyRACER.i3d" , "Tommy Angelo (Racer)" , true ], - ["TommyRACER2.i3d" , "Tommy Angelo (Racer)" , true ], - ["TommyRUKAV.i3d" , "Tommy Angelo (Suit)" , true ], - ["TommySAILOR.i3d" , "Tommy Angelo (Sailor)" , true ], - ["TommyTAXIDRIVER.i3d" , "Tommy Angelo (Taxi Driver)" , true ], - ["TommyTAXIdriverHIGH.i3d" , "Tommy Angelo (Taxi Driver)" , true ], - ["AsisPZ1.i3d" , "Generic Man" , true ], - ["Barman01.i3d" , "Bartender" , true ], - ["Bclerk01.i3d" , "Generic Man" , true ], - ["Bclerk02.i3d" , "Generic Man" , true ], - ["Bguard01.i3d" , "Bodyguard" , true ], - ["Bguard01M.i3d" , "Bodyguard" , true ], - ["Bguard02.i3d" , "Bodyguard" , true ], - ["Bguard03.i3d" , "Bodyguard" , true ], - ["Bguard03M.i3d" , "Bodyguard" , true ], - ["Biff.i3d" , "Biff" , true ], - ["BigDig.i3d" , "Generic Man" , true ], - ["BnkO01.i3d" , "Security Guard" , false], - ["BnkO02.i3d" , "Security Guard" , false], - ["BnkO03.i3d" , "Security Guard" , false], - ["BobAut01.i3d" , "Generic Man" , true ], - ["Bookmaker01.i3d" , "Generic Man" , true ], - ["Bookmaker02.i3d" , "Generic Man" , true ], - ["Boxer01.i3d" , "Boxer" , true ], - ["Boxer02.i3d" , "Boxer" , true ], - ["Boxer03.i3d" , "Boxer" , true ], - ["Boxer04.i3d" , "Boxer04" , false], - ["Carlo.i3d" , "Carlo" , true ], - ["China1.i3d" , "China1" , false], - ["Chulig1.i3d" , "Generic Man" , true ], - ["Chulig1b.i3d" , "Generic Man" , true ], - ["David.i3d" , "David" , true ], - ["Delnik01.i3d" , "Generic Man" , true ], - ["Delnik02.i3d" , "Generic Man" , true ], - ["Delnik03.i3d" , "Generic Man" , true ], - ["Detektiv01.i3d" , "Detective" , false], - ["Detektiv02.i3d" , "Detective" , false], - ["Detektiv03.i3d" , "Detective" , false], - ["Enemy01+.i3d" , "Generic Man" , true ], - ["Enemy01.i3d" , "Generic Man" , true ], - ["Enemy02+.i3d" , "Generic Man" , true ], - ["Enemy02.i3d" , "Generic Man" , true ], - ["Enemy03+.i3d" , "Generic Man" , true ], - ["Enemy03.i3d" , "Generic Man" , true ], - ["Enemy04.i3d" , "Generic Man" , true ], - ["Enemy04BLOOD.i3d" , "Generic Man" , false], - ["Enemy04K.i3d" , "Generic Man" , true ], - ["Enemy05.i3d" , "Generic Man" , true ], - ["Enemy06+.i3d" , "Generic Man" , true ], - ["Enemy06.i3d" , "Generic Man" , true ], - ["Enemy07+.i3d" , "Generic Man" , true ], - ["Enemy07.i3d" , "Generic Man" , true ], - ["Enemy08+.i3d" , "Generic Man" , true ], - ["Enemy08.i3d" , "Generic Man" , true ], - ["Enemy08K.i3d" , "Generic Man" , true ], - ["Enemy09+.i3d" , "Generic Man" , true ], - ["Enemy09.i3d" , "Generic Man" , true ], - ["Enemy09K.i3d" , "Generic Man" , true ], - ["Enemy10+.i3d" , "Generic Man" , true ], - ["Enemy10.i3d" , "Generic Man" , true ], - ["Enemy10K.i3d" , "Generic Man" , true ], - ["Enemy11K.i3d" , "Generic Man" , true ], - ["Enemy12.i3d" , "Generic Man" , true ], - ["Enemy12K.i3d" , "Generic Man" , true ], - ["Enemy13C.i3d" , "Generic Man" , true ], - ["Enemy91.i3d" , "Generic Man" , true ], - ["Enemy92.i3d" , "Generic Man" , true ], - ["FMVENemy11K.i3d" , "Gangster" , true ], - ["FREEgang01.i3d" , "Gangster" , true ], - ["FREEgang02.i3d" , "Gangster" , true ], - ["FrankHIGH.i3d" , "Frank" , true ], - ["Friend1.i3d" , "Generic Man" , true ], - ["Friend2.i3d" , "Generic Man" , true ], - ["Gangster01.i3d" , "Generic Man" , true ], - ["Gangster02.i3d" , "Generic Man" , true ], - ["Gangster03.i3d" , "Generic Man" , true ], - ["Gangster04.i3d" , "Generic Man" , true ], - ["Gangster05.i3d" , "Generic Man" , true ], - ["GodzMan1.i3d" , "Generic Man" , true ], - ["Guard01.i3d" , "Bodyguard" , true ], - ["Guard02.i3d" , "Bodyguard" , true ], - ["Hasic01.i3d" , "Firefighter" , true ], - ["HighCivil.i3d" , "Generic Man" , true ], - ["HighCivilBLOOD.i3d" , "Generic Man" , false], - ["Homeless01.i3d" , "Generic Man" , true ], - ["Hoolig01.i3d" , "Generic Man" , true ], - ["Hoolig02.i3d" , "Generic Man" , true ], - ["Hoolig03.i3d" , "Generic Man" , true ], - ["Hoolig04.i3d" , "Generic Man" , true ], - ["Hoolig05.i3d" , "Generic Man" , true ], - ["Hoolig06.i3d" , "Generic Man" , true ], - ["I04Delnik01+.i3d" , "I04Delnik01+" , false], - ["I04Delnik01.i3d" , "Generic Man" , true ], - ["Joe.i3d" , "Joe" , true ], - ["Kasar.i3d" , "Generic Man" , true ], - ["Knez.i3d" , "Preacher" , true ], - ["LifeG01.i3d" , "Sailor" , false], - ["Lucas.i3d" , "Lucas" , true ], - ["Luigi.i3d" , "Luigi" , true ], - ["Malticka1.i3d" , "Generic Man" , true ], - ["MorelloHIGH.i3d" , "Morello" , true ], - ["MorelloLOW.i3d" , "Morello" , true ], - ["NormanHIGH.i3d" , "Norman" , true ], - ["Organizator01.i3d" , "Generic Man" , true ], - ["Paulie.i3d" , "Paulie" , true ], - ["PaulieCOATHAT.i3d" , "Paulie" , true ], - ["PaulieCTHIGH.i3d" , "Paulie" , true ], - ["PaulieCorpse.i3d" , "Paulie" , false], - ["PaulieHIGH.i3d" , "Paulie" , true ], - ["Pepe.i3d" , "Pepe" , true ], - ["PoliceMan01.i3d" , "Police Officer" , false], - ["PoliceMan02.i3d" , "Police Officer" , false], - ["Politik.i3d" , "Generic Man" , true ], - ["PortGuard01.i3d" , "Port Guard" , false], - ["PortGuard02.i3d" , "Port Guard" , false], - ["ProdZ1.i3d" , "Generic Man" , true ], - ["Prokur.i3d" , "Prosecutor" , true ], - ["Radni01.i3d" , "Worker" , true ], - ["Radni02.i3d" , "Worker" , true ], - ["Ralph.i3d" , "Ralph" , true ], - ["RalphHIGH.i3d" , "Ralph" , true ], - ["ReditelB.i3d" , "Director" , true ], - ["ReditelH.i3d" , "Director" , true ], - ["RidicNakladaku.i3d" , "Truck Driver" , false], - ["SalMan01K.i3d" , "Gangster" , true ], - ["SalMan02K.i3d" , "Gangster" , true ], - ["SalMan03.i3d" , "Gangster" , true ], - ["SalMan03K.i3d" , "Gangster" , true ], - ["SalMan04.i3d" , "Gangster" , true ], - ["SalMan05.i3d" , "Gangster" , true ], - ["SalMan05K.i3d" , "Salieri" , true ], - ["Salieri2.i3d" , "Salieri" , true ], - ["SalieriHIGH.i3d" , "Salieri" , true ], - ["SalieriHIGH2.i3d" , "Salieri" , true ], - ["SalieriLOW.i3d" , "Salieri" , true ], - ["Sam.i3d" , "Sam" , true ], - ["SamCOATHAT.i3d" , "Sam" , true ], - ["SamHIGH.i3d" , "Sam" , true ], - ["SamHIGHblood1.i3d" , "SamHIGHblood1" , false], - ["SamHIGHblood2.i3d" , "SamHIGHblood2" , false], - ["SamHIGHblood3.i3d" , "SamHIGHblood3" , false], - ["SamHIGHblood4.i3d" , "SamHIGHblood4" , false], - ["Samblood1.i3d" , "Samblood1" , false], - ["Sergio.i3d" , "Sergio" , true ], - ["SergioBLOOD.i3d" , "SergioBLOOD" , false], - ["SynRad1.i3d" , "Generic Man" , true ], - ["SynRad1BLOOD.i3d" , "SynRad1BLOOD" , false], - ["SynRad1DEAD.i3d" , "SynRad1DEAD" , false], - ["Tony.i3d" , "Tony" , true ], - ["VincenzoHIGH.i3d" , "Vincenzo" , true ], - ["VincenzoLOW.i3d" , "Vincenzo" , true ], - ["Vrabec.i3d" , "Generic Man" , true ], - ["Vratny1.i3d" , "Generic Man" , true ], - ["Vypravci.i3d" , "Train Conductor" , false], - ["Vypravci2.i3d" , "Train Conductor" , false], - ["WillG1.i3d" , "Generic Man" , true ], - ["WillG2.i3d" , "Generic Man" , true ], - ["WillMan01.i3d" , "Generic Man" , true ], - ["WillMan02.i3d" , "Generic Man" , true ], - ["Zavod1.i3d" , "Racer" , true ], - ["Zavod2.i3d" , "Racer" , true ], - ["Zavod3.i3d" , "Racer" , true ], - ["ZavodFMV1.i3d" , "Racer" , true ], - ["ZavodFMV2.i3d" , "Racer" , true ], - ["civil02.i3d" , "Generic Man" , true ], - ["civil03.i3d" , "Generic Man" , true ], - ["civil04.i3d" , "Generic Man" , true ], - ["civil05.i3d" , "Generic Man" , true ], - ["civil06.i3d" , "Generic Man" , true ], - ["civil11.i3d" , "Generic Man" , true ], - ["civil11M.i3d" , "Generic Man" , true ], - ["civil12.i3d" , "Generic Man" , true ], - ["civil13.i3d" , "Generic Man" , true ], - ["civil14.i3d" , "Generic Man" , true ], - ["civil15.i3d" , "Generic Man" , true ], - ["civil16.i3d" , "Generic Man" , true ], - ["civil16M.i3d" , "Generic Man" , true ], - ["civil17.i3d" , "Generic Man" , true ], - ["civil18.i3d" , "Generic Man" , true ], - ["civil19.i3d" , "Generic Man" , true ], - ["civil19M.i3d" , "Generic Man" , true ], - ["civil21.i3d" , "Generic Man" , true ], - ["civil21N.i3d" , "Generic Man" , true ], - ["civil22.i3d" , "Generic Man" , true ], - ["civil31.i3d" , "Generic Man" , true ], - ["civil32.i3d" , "Generic Man" , true ], - ["civil33.i3d" , "Generic Man" , true ], - ["civil34.i3d" , "Generic Man" , true ], - ["civil35.i3d" , "Generic Man" , true ], - ["civil36.i3d" , "Generic Man" , true ], - ["civil36M.i3d" , "Generic Man" , true ], - ["civil37.i3d" , "Generic Man" , true ], - ["civil38.i3d" , "Generic Man" , true ], - ["civil39.i3d" , "Generic Man" , true ], - ["civil40.i3d" , "Generic Man" , true ], - ["civil41.i3d" , "Generic Man" , true ], - ["civil42.i3d" , "Generic Man" , true ], - ["civil42M.i3d" , "Generic Man" , true ], - ["civil43.i3d" , "Generic Man" , true ], - ["civil44.i3d" , "Generic Man" , true ], - ["civil51.i3d" , "Generic Man" , true ], - ["civil51M.i3d" , "Generic Man" , true ], - ["civil52.i3d" , "Generic Man" , true ], - ["civil53.i3d" , "Generic Man" , true ], - ["civil54.i3d" , "Generic Man" , true ], - ["civil54M.i3d" , "Generic Man" , true ], - ["civil55.i3d" , "Generic Man" , true ], - ["civil55M.i3d" , "Generic Man" , true ], - ["civil56.i3d" , "Generic Man" , true ], - ["civil56M.i3d" , "Generic Man" , true ], - ["civil57.i3d" , "Generic Man" , true ], - ["civil57M.i3d" , "Generic Man" , true ], - ["civil60.i3d" , "Generic Man" , true ], - ["civil61.i3d" , "Generic Man" , true ], - ["civil62.i3d" , "Generic Man" , true ], - ["civil63.i3d" , "Generic Man" , true ], - ["civil70.i3d" , "Generic Man" , true ], - ["civil70M.i3d" , "Generic Man" , true ], - ["civil71.i3d" , "Generic Man" , true ], - ["civil72.i3d" , "Generic Man" , true ], - ["frank.i3d" , "frank" , true ], - ["ohorelec01.i3d" , "Dead Guy" , false], - ["pianist1.i3d" , "Pianist" , true ], - ["pol01.i3d" , "Police Officer" , false], - ["pol02.i3d" , "Police Officer" , false], - ["pol03.i3d" , "Police Officer" , false], - ["pol11.i3d" , "Police Officer" , false], - ["pol12.i3d" , "Police Officer" , false], - ["pol13.i3d" , "Police Officer" , false], - ["polim62.i3d" , "Police Officer" , false], - ["pumpar01.i3d" , "Fuel Pumper" , true ], - ["recep.i3d" , "recep" , true ], - ["sailor01.i3d" , "Sailor" , false], - ["sailor01M.i3d" , "Sailor" , false], - ["sailor02.i3d" , "Sailor" , false], - ["sailor02M.i3d" , "Sailor" , false], - ["sailor03.i3d" , "Sailor" , false], - ["waiter01.i3d" , "Waiter" , true ], - ["waiter01M.i3d" , "Waiter" , true ], - ["waiter02.i3d" , "Waiter" , true ], - ["waiter02M.i3d" , "Waiter" , true ], - ["waiter03.i3d" , "Waiter" , true ], - ["Alice1.i3d" , "Alice" , true ], - ["Berta.i3d" , "Berta" , true ], - ["Bitch01.i3d" , "Generic Woman" , true ], - ["Bitch02.i3d" , "Generic Woman" , true ], - ["Bitch02Mask.i3d" , "Generic Woman" , true ], - ["Bitch03M.i3d" , "Generic Woman" , true ], - ["CarlZen1.i3d" , "CarlZen1" , true ], - ["Czena01.i3d" , "Generic Woman" , true ], - ["Czena02.i3d" , "Generic Woman" , true ], - ["Czena03.i3d" , "Generic Woman" , true ], - ["Czena04.i3d" , "Generic Woman" , true ], - ["Czena05.i3d" , "Generic Woman" , true ], - ["Czena06.i3d" , "Generic Woman" , true ], - ["Czena07.i3d" , "Generic Woman" , true ], - ["Czena07M.i3d" , "Generic Woman" , true ], - ["Czena08.i3d" , "Generic Woman" , true ], - ["Czena09.i3d" , "Generic Woman" , true ], - ["Czena09M.i3d" , "Generic Woman" , true ], - ["Czena10.i3d" , "Generic Woman" , true ], - ["Czena10M.i3d" , "Generic Woman" , true ], - ["Czena11.i3d" , "Generic Woman" , true ], - ["Czena11M.i3d" , "Generic Woman" , true ], - ["Czena12.i3d" , "Generic Woman" , true ], - ["Czena13.i3d" , "Generic Woman" , true ], - ["FMVCzena03.i3d" , "Generic Woman" , true ], - ["FMVCzena04.i3d" , "Generic Woman" , true ], - ["March1.i3d" , "Generic Woman" , true ], - ["Michelle.i3d" , "Michelle Naked" , false], - ["MichelleLOW.i3d" , "Michelle" , true ], - ["Milenka1.i3d" , "Milenka" , true ], - ["Sarah1.i3d" , "Sarah Naked" , false], - ["Sarah1Obl.i3d" , "Sarah" , true ], - ["Sarah2.i3d" , "Sarah" , true ], - ["Sarah2HIGH.i3d" , "Sarah" , true ], - ["Sarah2HIGHnaha.i3d" , "Sarah Naked" , false], - ["Sarah2LOW.i3d" , "Sarah" , true ], - ["Serv01.i3d" , "Maid" , true ], + ["Tommy.i3d", "Tommy Angelo", true], + ["TommyBOXER.i3d", "Tommy Angelo", true], + ["TommyCOAT.i3d", "Tommy Angelo", false], + ["TommyCOATHAT.i3d", "Tommy Angelo", true], + ["TommyDELNIK.i3d", "Tommy Angelo", true], + ["TommyDELNIKHIGH.i3d", "Tommy Angelo", true], + ["TommyFREERIDER.i3d", "Tommy Angelo", true], + ["TommyGUN.i3d", "Tommy Angelo", true], + ["TommyHAT.i3d", "Tommy Angelo", true], + ["TommyHIGH.i3d", "Tommy Angelo", true], + ["TommyHIGHBLOOD.i3d", "Tommy Angelo", false], + ["TommyHighCOATHAT.i3d", "Tommy Angelo", true], + ["TommyHighHAT.i3d", "Tommy Angelo", true], + ["TommyNAHAC.i3d", "Tommy Angelo (Naked)", false], + ["TommyOLD.i3d", "Tommy Angelo (Old)", true], + ["TommyOLDBLOOD.i3d", "Tommy Angelo (Old)", false], + ["TommyPYTEL.i3d", "Tommy Angelo (With Bag)", true], + ["TommyRACER.i3d", "Tommy Angelo (Racer)", true], + ["TommyRACER2.i3d", "Tommy Angelo (Racer)", true], + ["TommyRUKAV.i3d", "Tommy Angelo (Suit)", true], + ["TommySAILOR.i3d", "Tommy Angelo (Sailor)", true], + ["TommyTAXIDRIVER.i3d", "Tommy Angelo (Taxi Driver)", true], + ["TommyTAXIdriverHIGH.i3d", "Tommy Angelo (Taxi Driver)", true], + ["AsisPZ1.i3d", "Generic Man", true], + ["Barman01.i3d", "Bartender", true], + ["Bclerk01.i3d", "Generic Man", true], + ["Bclerk02.i3d", "Generic Man", true], + ["Bguard01.i3d", "Bodyguard", true], + ["Bguard01M.i3d", "Bodyguard", true], + ["Bguard02.i3d", "Bodyguard", true], + ["Bguard03.i3d", "Bodyguard", true], + ["Bguard03M.i3d", "Bodyguard", true], + ["Biff.i3d", "Biff", true], + ["BigDig.i3d", "Generic Man", true], + ["BnkO01.i3d", "Security Guard", false], + ["BnkO02.i3d", "Security Guard", false], + ["BnkO03.i3d", "Security Guard", false], + ["BobAut01.i3d", "Generic Man", true], + ["Bookmaker01.i3d", "Generic Man", true], + ["Bookmaker02.i3d", "Generic Man", true], + ["Boxer01.i3d", "Boxer", true], + ["Boxer02.i3d", "Boxer", true], + ["Boxer03.i3d", "Boxer", true], + ["Boxer04.i3d", "Boxer04", false], + ["Carlo.i3d", "Carlo", true], + ["China1.i3d", "China1", false], + ["Chulig1.i3d", "Generic Man", true], + ["Chulig1b.i3d", "Generic Man", true], + ["David.i3d", "David", true], + ["Delnik01.i3d", "Generic Man", true], + ["Delnik02.i3d", "Generic Man", true], + ["Delnik03.i3d", "Generic Man", true], + ["Detektiv01.i3d", "Detective", false], + ["Detektiv02.i3d", "Detective", false], + ["Detektiv03.i3d", "Detective", false], + ["Enemy01+.i3d", "Generic Man", true], + ["Enemy01.i3d", "Generic Man", true], + ["Enemy02+.i3d", "Generic Man", true], + ["Enemy02.i3d", "Generic Man", true], + ["Enemy03+.i3d", "Generic Man", true], + ["Enemy03.i3d", "Generic Man", true], + ["Enemy04.i3d", "Generic Man", true], + ["Enemy04BLOOD.i3d", "Generic Man", false], + ["Enemy04K.i3d", "Generic Man", true], + ["Enemy05.i3d", "Generic Man", true], + ["Enemy06+.i3d", "Generic Man", true], + ["Enemy06.i3d", "Generic Man", true], + ["Enemy07+.i3d", "Generic Man", true], + ["Enemy07.i3d", "Generic Man", true], + ["Enemy08+.i3d", "Generic Man", true], + ["Enemy08.i3d", "Generic Man", true], + ["Enemy08K.i3d", "Generic Man", true], + ["Enemy09+.i3d", "Generic Man", true], + ["Enemy09.i3d", "Generic Man", true], + ["Enemy09K.i3d", "Generic Man", true], + ["Enemy10+.i3d", "Generic Man", true], + ["Enemy10.i3d", "Generic Man", true], + ["Enemy10K.i3d", "Generic Man", true], + ["Enemy11K.i3d", "Generic Man", true], + ["Enemy12.i3d", "Generic Man", true], + ["Enemy12K.i3d", "Generic Man", true], + ["Enemy13C.i3d", "Generic Man", true], + ["Enemy91.i3d", "Generic Man", true], + ["Enemy92.i3d", "Generic Man", true], + ["FMVENemy11K.i3d", "Gangster", true], + ["FREEgang01.i3d", "Gangster", true], + ["FREEgang02.i3d", "Gangster", true], + ["FrankHIGH.i3d", "Frank", true], + ["Friend1.i3d", "Generic Man", true], + ["Friend2.i3d", "Generic Man", true], + ["Gangster01.i3d", "Generic Man", true], + ["Gangster02.i3d", "Generic Man", true], + ["Gangster03.i3d", "Generic Man", true], + ["Gangster04.i3d", "Generic Man", true], + ["Gangster05.i3d", "Generic Man", true], + ["GodzMan1.i3d", "Generic Man", true], + ["Guard01.i3d", "Bodyguard", true], + ["Guard02.i3d", "Bodyguard", true], + ["Hasic01.i3d", "Firefighter", true], + ["HighCivil.i3d", "Generic Man", true], + ["HighCivilBLOOD.i3d", "Generic Man", false], + ["Homeless01.i3d", "Generic Man", true], + ["Hoolig01.i3d", "Generic Man", true], + ["Hoolig02.i3d", "Generic Man", true], + ["Hoolig03.i3d", "Generic Man", true], + ["Hoolig04.i3d", "Generic Man", true], + ["Hoolig05.i3d", "Generic Man", true], + ["Hoolig06.i3d", "Generic Man", true], + ["I04Delnik01+.i3d", "I04Delnik01+", false], + ["I04Delnik01.i3d", "Generic Man", true], + ["Joe.i3d", "Joe", true], + ["Kasar.i3d", "Generic Man", true], + ["Knez.i3d", "Preacher", true], + ["LifeG01.i3d", "Sailor", false], + ["Lucas.i3d", "Lucas", true], + ["Luigi.i3d", "Luigi", true], + ["Malticka1.i3d", "Generic Man", true], + ["MorelloHIGH.i3d", "Morello", true], + ["MorelloLOW.i3d", "Morello", true], + ["NormanHIGH.i3d", "Norman", true], + ["Organizator01.i3d", "Generic Man", true], + ["Paulie.i3d", "Paulie", true], + ["PaulieCOATHAT.i3d", "Paulie", true], + ["PaulieCTHIGH.i3d", "Paulie", true], + ["PaulieCorpse.i3d", "Paulie", false], + ["PaulieHIGH.i3d", "Paulie", true], + ["Pepe.i3d", "Pepe", true], + ["PoliceMan01.i3d", "Police Officer", false], + ["PoliceMan02.i3d", "Police Officer", false], + ["Politik.i3d", "Generic Man", true], + ["PortGuard01.i3d", "Port Guard", false], + ["PortGuard02.i3d", "Port Guard", false], + ["ProdZ1.i3d", "Generic Man", true], + ["Prokur.i3d", "Prosecutor", true], + ["Radni01.i3d", "Worker", true], + ["Radni02.i3d", "Worker", true], + ["Ralph.i3d", "Ralph", true], + ["RalphHIGH.i3d", "Ralph", true], + ["ReditelB.i3d", "Director", true], + ["ReditelH.i3d", "Director", true], + ["RidicNakladaku.i3d", "Truck Driver", false], + ["SalMan01K.i3d", "Gangster", true], + ["SalMan02K.i3d", "Gangster", true], + ["SalMan03.i3d", "Gangster", true], + ["SalMan03K.i3d", "Gangster", true], + ["SalMan04.i3d", "Gangster", true], + ["SalMan05.i3d", "Gangster", true], + ["SalMan05K.i3d", "Salieri", true], + ["Salieri2.i3d", "Salieri", true], + ["SalieriHIGH.i3d", "Salieri", true], + ["SalieriHIGH2.i3d", "Salieri", true], + ["SalieriLOW.i3d", "Salieri", true], + ["Sam.i3d", "Sam", true], + ["SamCOATHAT.i3d", "Sam", true], + ["SamHIGH.i3d", "Sam", true], + ["SamHIGHblood1.i3d", "SamHIGHblood1", false], + ["SamHIGHblood2.i3d", "SamHIGHblood2", false], + ["SamHIGHblood3.i3d", "SamHIGHblood3", false], + ["SamHIGHblood4.i3d", "SamHIGHblood4", false], + ["Samblood1.i3d", "Samblood1", false], + ["Sergio.i3d", "Sergio", true], + ["SergioBLOOD.i3d", "SergioBLOOD", false], + ["SynRad1.i3d", "Generic Man", true], + ["SynRad1BLOOD.i3d", "SynRad1BLOOD", false], + ["SynRad1DEAD.i3d", "SynRad1DEAD", false], + ["Tony.i3d", "Tony", true], + ["VincenzoHIGH.i3d", "Vincenzo", true], + ["VincenzoLOW.i3d", "Vincenzo", true], + ["Vrabec.i3d", "Generic Man", true], + ["Vratny1.i3d", "Generic Man", true], + ["Vypravci.i3d", "Train Conductor", false], + ["Vypravci2.i3d", "Train Conductor", false], + ["WillG1.i3d", "Generic Man", true], + ["WillG2.i3d", "Generic Man", true], + ["WillMan01.i3d", "Generic Man", true], + ["WillMan02.i3d", "Generic Man", true], + ["Zavod1.i3d", "Racer", true], + ["Zavod2.i3d", "Racer", true], + ["Zavod3.i3d", "Racer", true], + ["ZavodFMV1.i3d", "Racer", true], + ["ZavodFMV2.i3d", "Racer", true], + ["civil02.i3d", "Generic Man", true], + ["civil03.i3d", "Generic Man", true], + ["civil04.i3d", "Generic Man", true], + ["civil05.i3d", "Generic Man", true], + ["civil06.i3d", "Generic Man", true], + ["civil11.i3d", "Generic Man", true], + ["civil11M.i3d", "Generic Man", true], + ["civil12.i3d", "Generic Man", true], + ["civil13.i3d", "Generic Man", true], + ["civil14.i3d", "Generic Man", true], + ["civil15.i3d", "Generic Man", true], + ["civil16.i3d", "Generic Man", true], + ["civil16M.i3d", "Generic Man", true], + ["civil17.i3d", "Generic Man", true], + ["civil18.i3d", "Generic Man", true], + ["civil19.i3d", "Generic Man", true], + ["civil19M.i3d", "Generic Man", true], + ["civil21.i3d", "Generic Man", true], + ["civil21N.i3d", "Generic Man", true], + ["civil22.i3d", "Generic Man", true], + ["civil31.i3d", "Generic Man", true], + ["civil32.i3d", "Generic Man", true], + ["civil33.i3d", "Generic Man", true], + ["civil34.i3d", "Generic Man", true], + ["civil35.i3d", "Generic Man", true], + ["civil36.i3d", "Generic Man", true], + ["civil36M.i3d", "Generic Man", true], + ["civil37.i3d", "Generic Man", true], + ["civil38.i3d", "Generic Man", true], + ["civil39.i3d", "Generic Man", true], + ["civil40.i3d", "Generic Man", true], + ["civil41.i3d", "Generic Man", true], + ["civil42.i3d", "Generic Man", true], + ["civil42M.i3d", "Generic Man", true], + ["civil43.i3d", "Generic Man", true], + ["civil44.i3d", "Generic Man", true], + ["civil51.i3d", "Generic Man", true], + ["civil51M.i3d", "Generic Man", true], + ["civil52.i3d", "Generic Man", true], + ["civil53.i3d", "Generic Man", true], + ["civil54.i3d", "Generic Man", true], + ["civil54M.i3d", "Generic Man", true], + ["civil55.i3d", "Generic Man", true], + ["civil55M.i3d", "Generic Man", true], + ["civil56.i3d", "Generic Man", true], + ["civil56M.i3d", "Generic Man", true], + ["civil57.i3d", "Generic Man", true], + ["civil57M.i3d", "Generic Man", true], + ["civil60.i3d", "Generic Man", true], + ["civil61.i3d", "Generic Man", true], + ["civil62.i3d", "Generic Man", true], + ["civil63.i3d", "Generic Man", true], + ["civil70.i3d", "Generic Man", true], + ["civil70M.i3d", "Generic Man", true], + ["civil71.i3d", "Generic Man", true], + ["civil72.i3d", "Generic Man", true], + ["frank.i3d", "frank", true], + ["ohorelec01.i3d", "Dead Guy", false], + ["pianist1.i3d", "Pianist", true], + ["pol01.i3d", "Police Officer", false], + ["pol02.i3d", "Police Officer", false], + ["pol03.i3d", "Police Officer", false], + ["pol11.i3d", "Police Officer", false], + ["pol12.i3d", "Police Officer", false], + ["pol13.i3d", "Police Officer", false], + ["polim62.i3d", "Police Officer", false], + ["pumpar01.i3d", "Fuel Pumper", true], + ["recep.i3d", "recep", true], + ["sailor01.i3d", "Sailor", false], + ["sailor01M.i3d", "Sailor", false], + ["sailor02.i3d", "Sailor", false], + ["sailor02M.i3d", "Sailor", false], + ["sailor03.i3d", "Sailor", false], + ["waiter01.i3d", "Waiter", true], + ["waiter01M.i3d", "Waiter", true], + ["waiter02.i3d", "Waiter", true], + ["waiter02M.i3d", "Waiter", true], + ["waiter03.i3d", "Waiter", true], + ["Alice1.i3d", "Alice", true], + ["Berta.i3d", "Berta", true], + ["Bitch01.i3d", "Generic Woman", true], + ["Bitch02.i3d", "Generic Woman", true], + ["Bitch02Mask.i3d", "Generic Woman", true], + ["Bitch03M.i3d", "Generic Woman", true], + ["CarlZen1.i3d", "CarlZen1", true], + ["Czena01.i3d", "Generic Woman", true], + ["Czena02.i3d", "Generic Woman", true], + ["Czena03.i3d", "Generic Woman", true], + ["Czena04.i3d", "Generic Woman", true], + ["Czena05.i3d", "Generic Woman", true], + ["Czena06.i3d", "Generic Woman", true], + ["Czena07.i3d", "Generic Woman", true], + ["Czena07M.i3d", "Generic Woman", true], + ["Czena08.i3d", "Generic Woman", true], + ["Czena09.i3d", "Generic Woman", true], + ["Czena09M.i3d", "Generic Woman", true], + ["Czena10.i3d", "Generic Woman", true], + ["Czena10M.i3d", "Generic Woman", true], + ["Czena11.i3d", "Generic Woman", true], + ["Czena11M.i3d", "Generic Woman", true], + ["Czena12.i3d", "Generic Woman", true], + ["Czena13.i3d", "Generic Woman", true], + ["FMVCzena03.i3d", "Generic Woman", true], + ["FMVCzena04.i3d", "Generic Woman", true], + ["March1.i3d", "Generic Woman", true], + ["Michelle.i3d", "Michelle Naked", false], + ["MichelleLOW.i3d", "Michelle", true], + ["Milenka1.i3d", "Milenka", true], + ["Sarah1.i3d", "Sarah Naked", false], + ["Sarah1Obl.i3d", "Sarah", true], + ["Sarah2.i3d", "Sarah", true], + ["Sarah2HIGH.i3d", "Sarah", true], + ["Sarah2HIGHnaha.i3d", "Sarah Naked", false], + ["Sarah2LOW.i3d", "Sarah", true], + ["Serv01.i3d", "Maid", true], ], [VRR_GAME_GTA_V]: [ ["a_c_boar", 0xCE5FF074, false], @@ -2745,500 +2765,500 @@ let gameData = { [236, "VCPD Cheetah"], ], [VRR_GAME_GTA_SA]: [ // GTA San Andreas - [400, "Landstalker" ], - [401, "Bravura" ], - [402, "Buffalo" ], - [403, "Linerunner" ], - [404, "Pereniel" ], - [405, "Sentinel" ], - [406, "Dumper" ], - [407, "Firetruck" ], - [408, "Trashmaster" ], - [409, "Stretch" ], - [410, "Manana" ], - [411, "Infernus" ], - [412, "Voodoo" ], - [413, "Pony" ], - [414, "Mule" ], - [415, "Cheetah" ], - [416, "Ambulance" ], - [417, "Leviathan" ], - [418, "Moonbeam" ], - [419, "Esperanto" ], - [420, "Taxi" ], - [421, "Washington" ], - [422, "Bobcat" ], - [423, "Mr Whoopee" ], - [424, "BF Injection" ], - [425, "Hunter" ], - [426, "Premier" ], - [427, "Enforcer" ], - [428, "Securicar" ], - [429, "Banshee" ], - [430, "Predator" ], - [431, "Bus" ], - [432, "Rhino" ], - [433, "Barracks" ], - [434, "Hotknife" ], - [435, "Box Trailer" ], - [436, "Previon" ], - [437, "Coach" ], - [438, "Cabbie" ], - [439, "Stallion" ], - [440, "Rumpo" ], - [441, "RC Bandit" ], - [442, "Romero" ], - [443, "Packer" ], - [444, "Monster" ], - [445, "Admiral" ], - [446, "Squalo" ], - [447, "Seasparrow" ], - [448, "Pizzaboy" ], - [449, "Tram" ], - [450, "Grain Trailer" ], - [451, "Turismo" ], - [452, "Speeder" ], - [453, "Reefer" ], - [454, "Tropic" ], - [455, "Flatbed" ], - [456, "Yankee" ], - [457, "Caddy" ], - [458, "Solair" ], - [459, "Berkley's RC Van" ], - [460, "Skimmer" ], - [461, "PCJ-600" ], - [462, "Faggio" ], - [463, "Freeway" ], - [464, "RC Baron" ], - [465, "RC Raider" ], - [466, "Glendale" ], - [467, "Oceanic" ], - [468, "Sanchez" ], - [469, "Sparrow" ], - [470, "Patriot" ], - [471, "Quad" ], - [472, "Coastguard" ], - [473, "Dinghy" ], - [474, "Hermes" ], - [475, "Sabre" ], - [476, "Rustler" ], - [477, "ZR-350" ], - [478, "Walton" ], - [479, "Regina" ], - [480, "Comet" ], - [481, "BMX" ], - [482, "Burrito" ], - [483, "Camper" ], - [484, "Marquis" ], - [485, "Baggage" ], - [486, "Dozer" ], - [487, "Maverick" ], - [488, "News Maverick" ], - [489, "Rancher" ], - [490, "FBI Rancher" ], - [491, "Virgo" ], - [492, "Greenwood" ], - [493, "Jetmax" ], - [494, "Hotring-Racer A" ], - [495, "Sandking" ], - [496, "Blista" ], - [497, "Police Maverick" ], - [498, "Boxville" ], - [499, "Benson" ], - [500, "Mesa" ], - [501, "RC Goblin" ], - [502, "Hotring-Racer B" ], - [503, "Hotring-Racer C" ], - [504, "Bloodring-Banger" ], - [505, "Rancher" ], - [506, "Super-GT" ], - [507, "Elegant" ], - [508, "Journey" ], - [509, "Bike" ], - [510, "Mountain Bike" ], - [511, "Beagle" ], - [512, "Cropduster" ], - [513, "Stunt" ], - [514, "Tanker" ], - [515, "RoadTrain" ], - [516, "Nebula" ], - [517, "Majestic" ], - [518, "Buccaneer" ], - [519, "Shamal" ], - [520, "Hydra" ], - [521, "FCR-900" ], - [522, "NRG-500" ], - [523, "HPV1000" ], - [524, "Cement Truck" ], - [525, "Tow Truck" ], - [526, "Fortune" ], - [527, "Cadrona" ], - [528, "FBI Truck" ], - [529, "Willard" ], - [530, "Forklift" ], - [531, "Tractor" ], - [532, "Combine" ], - [533, "Feltzer" ], - [534, "Remington" ], - [535, "Slamvan" ], - [536, "Blade" ], - [537, "Freight" ], - [538, "Streak" ], - [539, "Vortex" ], - [540, "Vincent" ], - [541, "Bullet" ], - [542, "Clover" ], - [543, "Sadler" ], - [544, "Firetruck" ], - [545, "Hustler" ], - [546, "Intruder" ], - [547, "Primo" ], - [548, "Cargobob" ], - [549, "Tampa" ], - [550, "Sunrise" ], - [551, "Merit" ], - [552, "Utility" ], - [553, "Nevada" ], - [554, "Yosemite" ], - [555, "Windsor" ], - [556, "Monster Truck A" ], - [557, "Monster Truck B" ], - [558, "Uranus" ], - [559, "Jester" ], - [560, "Sultan" ], - [561, "Stratum" ], - [562, "Elegy" ], - [563, "Raindance" ], - [564, "RC Tiger" ], - [565, "Flash" ], - [566, "Tahoma" ], - [567, "Savanna" ], - [568, "Bandito" ], - [569, "Freight" ], - [570, "Trailer" ], - [571, "Kart" ], - [572, "Mower" ], - [573, "Duneride" ], - [574, "Sweeper" ], - [575, "Broadway" ], - [576, "Tornado" ], - [577, "AT-400" ], - [578, "DFT-30" ], - [579, "Huntley" ], - [580, "Stafford" ], - [581, "BF-400" ], - [582, "Newsvan" ], - [583, "Tug" ], - [584, "Tanker Trailer" ], - [585, "Emperor" ], - [586, "Wayfarer" ], - [587, "Euros" ], - [588, "Hotdog" ], - [589, "Club" ], - [590, "Freight Boxcar" ], + [400, "Landstalker"], + [401, "Bravura"], + [402, "Buffalo"], + [403, "Linerunner"], + [404, "Pereniel"], + [405, "Sentinel"], + [406, "Dumper"], + [407, "Firetruck"], + [408, "Trashmaster"], + [409, "Stretch"], + [410, "Manana"], + [411, "Infernus"], + [412, "Voodoo"], + [413, "Pony"], + [414, "Mule"], + [415, "Cheetah"], + [416, "Ambulance"], + [417, "Leviathan"], + [418, "Moonbeam"], + [419, "Esperanto"], + [420, "Taxi"], + [421, "Washington"], + [422, "Bobcat"], + [423, "Mr Whoopee"], + [424, "BF Injection"], + [425, "Hunter"], + [426, "Premier"], + [427, "Enforcer"], + [428, "Securicar"], + [429, "Banshee"], + [430, "Predator"], + [431, "Bus"], + [432, "Rhino"], + [433, "Barracks"], + [434, "Hotknife"], + [435, "Box Trailer"], + [436, "Previon"], + [437, "Coach"], + [438, "Cabbie"], + [439, "Stallion"], + [440, "Rumpo"], + [441, "RC Bandit"], + [442, "Romero"], + [443, "Packer"], + [444, "Monster"], + [445, "Admiral"], + [446, "Squalo"], + [447, "Seasparrow"], + [448, "Pizzaboy"], + [449, "Tram"], + [450, "Grain Trailer"], + [451, "Turismo"], + [452, "Speeder"], + [453, "Reefer"], + [454, "Tropic"], + [455, "Flatbed"], + [456, "Yankee"], + [457, "Caddy"], + [458, "Solair"], + [459, "Berkley's RC Van"], + [460, "Skimmer"], + [461, "PCJ-600"], + [462, "Faggio"], + [463, "Freeway"], + [464, "RC Baron"], + [465, "RC Raider"], + [466, "Glendale"], + [467, "Oceanic"], + [468, "Sanchez"], + [469, "Sparrow"], + [470, "Patriot"], + [471, "Quad"], + [472, "Coastguard"], + [473, "Dinghy"], + [474, "Hermes"], + [475, "Sabre"], + [476, "Rustler"], + [477, "ZR-350"], + [478, "Walton"], + [479, "Regina"], + [480, "Comet"], + [481, "BMX"], + [482, "Burrito"], + [483, "Camper"], + [484, "Marquis"], + [485, "Baggage"], + [486, "Dozer"], + [487, "Maverick"], + [488, "News Maverick"], + [489, "Rancher"], + [490, "FBI Rancher"], + [491, "Virgo"], + [492, "Greenwood"], + [493, "Jetmax"], + [494, "Hotring-Racer A"], + [495, "Sandking"], + [496, "Blista"], + [497, "Police Maverick"], + [498, "Boxville"], + [499, "Benson"], + [500, "Mesa"], + [501, "RC Goblin"], + [502, "Hotring-Racer B"], + [503, "Hotring-Racer C"], + [504, "Bloodring-Banger"], + [505, "Rancher"], + [506, "Super-GT"], + [507, "Elegant"], + [508, "Journey"], + [509, "Bike"], + [510, "Mountain Bike"], + [511, "Beagle"], + [512, "Cropduster"], + [513, "Stunt"], + [514, "Tanker"], + [515, "RoadTrain"], + [516, "Nebula"], + [517, "Majestic"], + [518, "Buccaneer"], + [519, "Shamal"], + [520, "Hydra"], + [521, "FCR-900"], + [522, "NRG-500"], + [523, "HPV1000"], + [524, "Cement Truck"], + [525, "Tow Truck"], + [526, "Fortune"], + [527, "Cadrona"], + [528, "FBI Truck"], + [529, "Willard"], + [530, "Forklift"], + [531, "Tractor"], + [532, "Combine"], + [533, "Feltzer"], + [534, "Remington"], + [535, "Slamvan"], + [536, "Blade"], + [537, "Freight"], + [538, "Streak"], + [539, "Vortex"], + [540, "Vincent"], + [541, "Bullet"], + [542, "Clover"], + [543, "Sadler"], + [544, "Firetruck"], + [545, "Hustler"], + [546, "Intruder"], + [547, "Primo"], + [548, "Cargobob"], + [549, "Tampa"], + [550, "Sunrise"], + [551, "Merit"], + [552, "Utility"], + [553, "Nevada"], + [554, "Yosemite"], + [555, "Windsor"], + [556, "Monster Truck A"], + [557, "Monster Truck B"], + [558, "Uranus"], + [559, "Jester"], + [560, "Sultan"], + [561, "Stratum"], + [562, "Elegy"], + [563, "Raindance"], + [564, "RC Tiger"], + [565, "Flash"], + [566, "Tahoma"], + [567, "Savanna"], + [568, "Bandito"], + [569, "Freight"], + [570, "Trailer"], + [571, "Kart"], + [572, "Mower"], + [573, "Duneride"], + [574, "Sweeper"], + [575, "Broadway"], + [576, "Tornado"], + [577, "AT-400"], + [578, "DFT-30"], + [579, "Huntley"], + [580, "Stafford"], + [581, "BF-400"], + [582, "Newsvan"], + [583, "Tug"], + [584, "Tanker Trailer"], + [585, "Emperor"], + [586, "Wayfarer"], + [587, "Euros"], + [588, "Hotdog"], + [589, "Club"], + [590, "Freight Boxcar"], [591, "Short Box Trailer"], - [592, "Andromada" ], - [593, "Dodo" ], - [594, "RC Cam" ], - [595, "Launch" ], + [592, "Andromada"], + [593, "Dodo"], + [594, "RC Cam"], + [595, "Launch"], [596, "Police Car (LSPD)"], [597, "Police Car (SFPD)"], [598, "Police Car (LVPD)"], - [599, "Police Ranger" ], - [600, "Picador" ], - [601, "S.W.A.T. Van" ], - [602, "Alpha" ], - [603, "Phoenix" ], - [604, "Broken Glendale" ], - [605, "Broken Sadler" ], - [606, "Luggage Trailer" ], - [607, "Luggage Trailer" ], - [608, "Stair Trailer" ], - [609, "Boxville" ], - [610, "Farm Plow" ], - [611, "Utility Trailer" ], + [599, "Police Ranger"], + [600, "Picador"], + [601, "S.W.A.T. Van"], + [602, "Alpha"], + [603, "Phoenix"], + [604, "Broken Glendale"], + [605, "Broken Sadler"], + [606, "Luggage Trailer"], + [607, "Luggage Trailer"], + [608, "Stair Trailer"], + [609, "Boxville"], + [610, "Farm Plow"], + [611, "Utility Trailer"], ], [VRR_GAME_GTA_IV]: [ // GTA IV - [ 1264341792, "Admiral" ], - [ 1560980623, "Airtug" ], - [ 1171614426, "Ambulance" ], - [-1041692462, "Banshee" ], - [ 2053223216, "Benson" ], - [ 850991848 , "Biff" ], - [-344943009 , "Blista" ], - [ 1075851868, "Bobcat" ], - [-1987130134, "Boxville" ], - [-682211828 , "Buccaneer" ], - [-1346687836, "Burrito" ], - [-907477130 , "Burrito 2" ], - [-713569950 , "Bus" ], - [ 1884962369, "Cabby" ], - [ 2006918058, "Cavalcade" ], - [-67282078 , "Chavos" ], - [-2030171296, "Cognoscenti" ], - [ 1063483177, "Comet" ], - [ 108773431 , "Coquette" ], - [ 162883121 , "DF8" ], - [-1130810103, "Dillettante" ], - [ 723973206 , "Dukes" ], - [-1971955454, "E109" ], - [-685276541 , "Emperor" ], - [-1883002148, "Rusty Emperor" ], - [-276900515 , "Esperanto" ], - [-2119578145, "Faction" ], - [ 1127131465, "FIB Car" ], - [-1097828879, "Feltzer" ], - [ 974744810 , "Feroci" ], - [ 1026055242, "Airport Feroci" ], - [ 1938952078, "Firetruck" ], - [ 1353720154, "Flatbed" ], - [ 627033353 , "Fortune" ], - [ 1491375716, "Forklift" ], - [ 2016857647, "Futo" ], - [ 675415136 , "FXT" ], - [ 884422927 , "Habanero" ], - [-341892653 , "Hakumai" ], - [ 486987393 , "Huntley" ], - [ 418536135 , "Infernus" ], - [-1289722222, "Ingot" ], - [ 886934177 , "Intruder" ], - [ 1269098716, "Landstalker" ], - [-37030056 , "Lokus" ], - [-2124201592, "Manana" ], - [ 1304597482, "Marbella" ], - [-1260881538, "Merit" ], - [-310465116 , "Minivan" ], - [ 525509695 , "Moonbeam" ], - [ 583100975 , "Mr. Tasty" ], - [ 904750859 , "Mule" ], - [ 148777611 , "Noose Patrol Car" ], - [ 1911513875, "Noose Stockade" ], - [ 1348744438, "Oracle" ], - [ 569305213 , "Packer" ], - [-808457413 , "Patriot" ], - [-2077743597, "Perennial" ], + [1264341792, "Admiral"], + [1560980623, "Airtug"], + [1171614426, "Ambulance"], + [-1041692462, "Banshee"], + [2053223216, "Benson"], + [850991848, "Biff"], + [-344943009, "Blista"], + [1075851868, "Bobcat"], + [-1987130134, "Boxville"], + [-682211828, "Buccaneer"], + [-1346687836, "Burrito"], + [-907477130, "Burrito 2"], + [-713569950, "Bus"], + [1884962369, "Cabby"], + [2006918058, "Cavalcade"], + [-67282078, "Chavos"], + [-2030171296, "Cognoscenti"], + [1063483177, "Comet"], + [108773431, "Coquette"], + [162883121, "DF8"], + [-1130810103, "Dillettante"], + [723973206, "Dukes"], + [-1971955454, "E109"], + [-685276541, "Emperor"], + [-1883002148, "Rusty Emperor"], + [-276900515, "Esperanto"], + [-2119578145, "Faction"], + [1127131465, "FIB Car"], + [-1097828879, "Feltzer"], + [974744810, "Feroci"], + [1026055242, "Airport Feroci"], + [1938952078, "Firetruck"], + [1353720154, "Flatbed"], + [627033353, "Fortune"], + [1491375716, "Forklift"], + [2016857647, "Futo"], + [675415136, "FXT"], + [884422927, "Habanero"], + [-341892653, "Hakumai"], + [486987393, "Huntley"], + [418536135, "Infernus"], + [-1289722222, "Ingot"], + [886934177, "Intruder"], + [1269098716, "Landstalker"], + [-37030056, "Lokus"], + [-2124201592, "Manana"], + [1304597482, "Marbella"], + [-1260881538, "Merit"], + [-310465116, "Minivan"], + [525509695, "Moonbeam"], + [583100975, "Mr. Tasty"], + [904750859, "Mule"], + [148777611, "Noose Patrol Car"], + [1911513875, "Noose Stockade"], + [1348744438, "Oracle"], + [569305213, "Packer"], + [-808457413, "Patriot"], + [-2077743597, "Perennial"], [-1590284256, "Airport Perennial"], - [ 1830407356, "Peyote" ], - [-2137348917, "Phantom" ], - [ 131140572 , "Pinnacle" ], - [ 1376298265, "PMP-600" ], - [ 2046537925, "Police Cruiser" ], - [-1627000575, "Police Patrol" ], - [-350085182 , "Police Patriot" ], - [-119658072 , "Pony" ], - [-1883869285, "Premier" ], - [-1962071130, "Presidente" ], - [-1150599089, "Primo" ], - [-1900572838, "Police Stockade" ], - [ 1390084576, "Rancher" ], - [ 83136452 , "Rebla" ], - [-845979911 , "Reply" ], - [ 627094268 , "Romero" ], - [-1932515764, "Roman's Taxi" ], - [-227741703 , "Ruiner" ], - [-449022887 , "Sabre" ], - [ 1264386590, "Sabre 2" ], - [-1685021548, "Sabre GT" ], - [-322343873 , "Schafter" ], - [ 1349725314, "Sentinel" ], - [ 1344573448, "Solair" ], - [-810318068 , "Speedo" ], - [ 1923400478, "Stallion" ], - [ 1677715180, "Steed" ], - [ 1747439474, "Stockade" ], - [ 1723137093, "Stratum" ], - [-1961627517, "Stretch" ], - [ 970598228 , "Sultan" ], - [-295689028 , "Sultan RS" ], - [ 1821991593, "Super GT" ], - [-956048545 , "Taxi" ], - [ 1208856469, "Taxi 2" ], - [ 1917016601, "Trashmaster" ], - [-1896659641, "Turismo" ], - [ 1534326199, "Uranus" ], - [-825837129 , "Vigero" ], - [-1758379524, "Vigero 2" ], - [-583281407 , "Vincent" ], - [-498054846 , "Virgo" ], - [ 2006667053, "Voodoo" ], - [ 1777363799, "Washington" ], - [ 1937616578, "Willard" ], - [-1099960214, "Yankee" ], - [-1830458836, "Bobber" ], - [-1842748181, "Faggio" ], - [ 584879743 , "Hellfury" ], - [ 1203311498, "NRG-900" ], - [-909201658 , "PCJ-600" ], - [ 788045382 , "Sanchez" ], - [-570033273 , "Zombie" ], - [ 837858166 , "Annihilator" ], - [-1660661558, "Maverick" ], - [ 353883353 , "Police Maverick" ], - [ 2027357303, "Tour Maverick" ], - [ 1033245328, "Dinghy" ], - [ 861409633 , "Jetmax" ], - [-1043459709, "Marquis" ], - [-488123221 , "Predator" ], - [ 1759673526, "Reefer" ], - [ 400514754 , "Squalo" ], - [ 1064455782, "Tuga" ], - [ 290013743 , "Tropic" ], - [-960289747 , "Cablecar" ], - [ 800869680 , "Subway" ], - [-1953988645, "El Train" ], + [1830407356, "Peyote"], + [-2137348917, "Phantom"], + [131140572, "Pinnacle"], + [1376298265, "PMP-600"], + [2046537925, "Police Cruiser"], + [-1627000575, "Police Patrol"], + [-350085182, "Police Patriot"], + [-119658072, "Pony"], + [-1883869285, "Premier"], + [-1962071130, "Presidente"], + [-1150599089, "Primo"], + [-1900572838, "Police Stockade"], + [1390084576, "Rancher"], + [83136452, "Rebla"], + [-845979911, "Reply"], + [627094268, "Romero"], + [-1932515764, "Roman's Taxi"], + [-227741703, "Ruiner"], + [-449022887, "Sabre"], + [1264386590, "Sabre 2"], + [-1685021548, "Sabre GT"], + [-322343873, "Schafter"], + [1349725314, "Sentinel"], + [1344573448, "Solair"], + [-810318068, "Speedo"], + [1923400478, "Stallion"], + [1677715180, "Steed"], + [1747439474, "Stockade"], + [1723137093, "Stratum"], + [-1961627517, "Stretch"], + [970598228, "Sultan"], + [-295689028, "Sultan RS"], + [1821991593, "Super GT"], + [-956048545, "Taxi"], + [1208856469, "Taxi 2"], + [1917016601, "Trashmaster"], + [-1896659641, "Turismo"], + [1534326199, "Uranus"], + [-825837129, "Vigero"], + [-1758379524, "Vigero 2"], + [-583281407, "Vincent"], + [-498054846, "Virgo"], + [2006667053, "Voodoo"], + [1777363799, "Washington"], + [1937616578, "Willard"], + [-1099960214, "Yankee"], + [-1830458836, "Bobber"], + [-1842748181, "Faggio"], + [584879743, "Hellfury"], + [1203311498, "NRG-900"], + [-909201658, "PCJ-600"], + [788045382, "Sanchez"], + [-570033273, "Zombie"], + [837858166, "Annihilator"], + [-1660661558, "Maverick"], + [353883353, "Police Maverick"], + [2027357303, "Tour Maverick"], + [1033245328, "Dinghy"], + [861409633, "Jetmax"], + [-1043459709, "Marquis"], + [-488123221, "Predator"], + [1759673526, "Reefer"], + [400514754, "Squalo"], + [1064455782, "Tuga"], + [290013743, "Tropic"], + [-960289747, "Cablecar"], + [800869680, "Subway"], + [-1953988645, "El Train"], ], [VRR_GAME_MAFIA_ONE]: [ // Mafia 1 - ["fordtTud00.i3d" , "Blue Bolt Ace Tudor" ], - ["fordtTud01.i3d" , "Dark Blue Bolt Ace Tudor" ], - ["fordtTud02.i3d" , "Brown Bolt Ace Tudor" ], - ["fordtTud03.i3d" , "Green Bolt Ace Tudor" ], - ["fordtTud04.i3d" , "Red Bolt Ace Tudor" ], - ["fordtto00.i3d" , "Blue Bolt Ace Touring" ], - ["fordtto01.i3d" , "Dark Blue Bolt Ace Touring" ], - ["fordtto02.i3d" , "Brown Bolt Ace Touring" ], - ["fordtto03.i3d" , "Green Bolt Ace Touring" ], - ["fordtto04.i3d" , "Red Bolt Ace Touring" ], - ["fordtru00.i3d" , "Blue Bolt Ace Runabout" ], - ["fordtru01.i3d" , "Dark Blue Bolt Ace Runabout" ], - ["fordtru02.i3d" , "Brown Bolt Ace Runabout" ], - ["fordtru03.i3d" , "Green Bolt Ace Runabout" ], - ["fordtru04.i3d" , "Red Bolt Ace Runabout" ], - ["fordtpi00.i3d" , "Blue Bolt Ace Pickup" ], - ["fordtpi01.i3d" , "Dark Blue Bolt Ace Pickup" ], - ["fordtpi02.i3d" , "Brown Bolt Ace Pickup" ], - ["fordtpi03.i3d" , "Green Bolt Ace Pickup" ], - ["fordtpi04.i3d" , "Red Bolt Ace Pickup" ], - ["fordtFor00.i3d" , "Blue Bolt Ace Fordor" ], - ["fordtFor01.i3d" , "Dark Blue Bolt Ace Fordor" ], - ["fordtFor02.i3d" , "Brown Bolt Ace Fordor" ], - ["fordtFor03.i3d" , "Green Bolt Ace Fordor" ], - ["fordtFor04.i3d" , "Red Bolt Ace Fordor" ], - ["fordtco00.i3d" , "Blue Bolt Ace Coupe" ], - ["fordtco01.i3d" , "Dark Blue Bolt Ace Coupe" ], - ["fordtco02.i3d" , "Brown Bolt Ace Coupe" ], - ["fordtco03.i3d" , "Green Bolt Ace Coupe" ], - ["fordtco04.i3d" , "Red Bolt Ace Coupe" ], - ["forAtu00.i3d" , "Brown Bolt Model B Tudor" ], - ["ForAtu01.i3d" , "Red Bolt Model B Tudor" ], - ["ForAtu02.i3d" , "Green Bolt Model B Tudor" ], - ["ForAtu03.i3d" , "Dark Blue Bolt Model B Tudor" ], - ["ForAro00.i3d" , "Brown Bolt Model B Roadster" ], - ["ForAro01.i3d" , "Red Bolt Model B Roadster" ], - ["ForAro02.i3d" , "Green Bolt Model B Roadster" ], - ["ForAro03.i3d" , "Dark Blue Bolt Model B Roadster" ], - ["ForApic00.i3d" , "Brown Bolt Model B Pickup" ], - ["ForApic01.i3d" , "Red Bolt Model B Pickup" ], - ["ForApic02.i3d" , "Green Bolt Model B Pickup" ], - ["ForApic03.i3d" , "Dark Blue Bolt Model B Pickup" ], - ["ForAfo00.i3d" , "Brown Bolt Model B Fordor" ], - ["ForAfo01.i3d" , "Red Bolt Model B Fordor" ], - ["ForAfo02.i3d" , "Green Bolt Model B Fordor" ], - ["ForAfo03.i3d" , "Dark Blue Bolt Model B Fordor" ], - ["ForAde00.i3d" , "Brown Bolt Model B Delivery" ], - ["ForAde01.i3d" , "Red Bolt Model B Delivery" ], - ["ForAde02.i3d" , "Green Bolt Model B Delivery" ], - ["ForAde03.i3d" , "Dark Blue Bolt Model B Delivery" ], - ["ForAcou00.i3d" , "Brown Bolt Model B Coupe" ], - ["ForAcou01.i3d" , "Red Bolt Model B Coupe" ], - ["ForAcou02.i3d" , "Green Bolt Model B Coupe" ], - ["ForAcou03.i3d" , "Dark Blue Bolt Model B Coupe" ], - ["ForAtu00.i3d" , "Brown Bolt Model B Tudor" ], - ["ForAtu01.i3d" , "Red Bolt Model B Tudor" ], - ["ForAtu02.i3d" , "Green Bolt Model B Tudor" ], - ["ForAtu03.i3d" , "Dark Blue Bolt Model B Tudor" ], - ["forVco00.i3d" , "Green Bolt V8 Coupe" ], - ["forVco01.i3d" , "Red Bolt V8 Coupe" ], - ["forVco02.i3d" , "Blue Bolt V8 Coupe" ], - ["forVco03.i3d" , "Grey Bolt V8 Coupe" ], - ["forVfor00.i3d" , "Green Bolt V8 Forder" ], - ["forVfor01.i3d" , "Red Bolt V8 Forder" ], - ["forVfor02.i3d" , "Blue Bolt V8 Forder" ], - ["forVfor03.i3d" , "Grey Bolt V8 Forder" ], - ["forVro00.i3d" , "Green Bolt V8 Roadster" ], - ["forVro01.i3d" , "Red Bolt V8 Roadster" ], - ["forVro02.i3d" , "Blue Bolt V8 Roadster" ], - ["forVro03.i3d" , "Grey Bolt V8 Roadster" ], - ["forVto00.i3d" , "Green Bolt V8 Touring" ], - ["forVto01.i3d" , "Red Bolt V8 Touring" ], - ["forVto02.i3d" , "Blue Bolt V8 Touring" ], - ["forVto03.i3d" , "Grey Bolt V8 Touring" ], - ["forVtud00.i3d" , "Green Bolt V8 Tudor" ], - ["forVtud01.i3d" , "Red Bolt V8 Tudor" ], - ["forVtud02.i3d" , "Blue Bolt V8 Tudor" ], - ["forVtud03.i3d" , "Grey Bolt V8 Tudor" ], - ["miller00.i3d" , "Brubaker" ], - ["speedster00.i3d" , "Silver Bruno Speedster 851" ], - ["speedster01.i3d" , "Red Bruno Speedster 851" ], - ["speedster02.i3d" , "Green Bruno Speedster 851" ], - ["alfa00.i3d" , "Caesar 8C 2300 Racing" ], - ["alfa8C00.i3d" , "Red Caesar 8C Mostro" ], - ["alfa8C01.i3d" , "Black Caesar 8C Mostro" ], - ["merced500K00.i3d" , "White Celeste Marque 500" ], - ["merced500K01.i3d" , "Brown Celeste Marque 500" ], - ["bugatti00.i3d" , "Blue Corrozella C-Otto" ], - ["bugatti01.i3d" , "Green Corrozella C-Otto" ], - ["pontFor00.i3d" , "Blue Crusader Chromium Forder" ], - ["pontFor01.i3d" , "Violet Crusader Chromium Forder" ], - ["pontTud00.i3d" , "Green Crusader Chromium Forder" ], - ["pontTud01.i3d" , "Dark Blue Crusader Chromium Forder"], - ["blackha00.i3d" , "Blue Falconer" ], - ["blackha01.i3d" , "Red Falconer" ], - ["black00.i3d" , "Gangster Falconer" ], - ["taxi00.i3d" , "Falconer Yellowcar" ], - ["hudcou00.i3d" , "Umber Guardian Terraplane Coupe" ], - ["hudcou01.i3d" , "Beige Guardian Terraplane Coupe" ], - ["hudcou02.i3d" , "Black Guardian Terraplane Coupe" ], - ["hudfor00.i3d" , "Umber Guardian Terraplane Fordor" ], - ["hudfor01.i3d" , "Beige Guardian Terraplane Fordor" ], - ["hudfor02.i3d" , "Black Guardian Terraplane Fordor" ], - ["hudtu00.i3d" , "Umber Guardian Terraplane Tudor" ], - ["hudtu01.i3d" , "Beige Guardian Terraplane Tudor" ], - ["hudtu02.i3d" , "Black Guardian Terraplane Tudor" ], - ["cad_ford00.i3d" , "Lassister Fordor" ], - ["cad_phaeton00", "Lassister Phaeton" ], - ["cad_road00.i3d" , "Lassister Roadster" ], - ["hartmann00.i3d" , "Lassister Appolyon" ], - ["hearseCa00.i3d" , "Lassister Charon" ], - ["polCad00.i3d" , "Lassister Police" ], - ["chemaFor00.i3d" , "Green Shubert Extra Six Fordor" ], - ["chemaFor01.i3d" , "White Shubert Extra Six Fordor" ], - ["chemaFor02.i3d" , "Blue Shubert Extra Six Fordor" ], - ["polimFor00.i3d" , "Shubert Extra Six Fordor Police" ], - ["chematud00.i3d" , "Green Shubert Extra Six Tudor" ], - ["chematud01.i3d" , "White Shubert Extra Six Tudor" ], - ["chematud02.i3d" , "Blue Shubert Extra Six Tudor" ], - ["polimTud00.i3d" , "Shubert Extra Six Tudor Police" ], - ["chev00.i3d" , "Red Shubert Six" ], - ["chev01.i3d" , "White Shubert Six" ], - ["chev02.i3d" , "Black Shubert Six" ], - ["poli00.i3d" , "Shubert Six Police" ], - ["arrow00.i3d" , "Silver Fletcher" ], - ["cordca00.i3d" , "Orange Thor 810 Cabriolet" ], - ["cordca01.i3d" , "Black Thor 810 Cabriolet" ], - ["cordph00.i3d" , "Orange Thor 810 Phaeton" ], - ["cordph01.i3d" , "Black Thor 810 Phaeton" ], - ["cordse00.i3d" , "Orange Thor 810 Sedan" ], - ["cordse01.i3d" , "Black Thor 810 Sedan" ], - ["deuseJco00.i3d" , "Trautenberg Model J" ], - ["duesenberg00.i3d" , "Trautenberg Racer 4WD" ], - ["airflFor00.i3d" , "Yellow Ulver Airstream Fordor" ], - ["airflFor01.i3d" , "Green Ulver Airstream Fordor" ], - ["airfltud00.i3d" , "Yellow Ulver Airstream Tudor" ], - ["airfltud01.i3d" , "Green Ulver Airstream Tudor" ], - ["buiCou00.i3d" , "Blue Wright Coupe" ], - ["buiCou01.i3d" , "Red Wright Coupe" ], - ["buiCou02.i3d" , "Green Wright Coupe" ], - ["buigang00.i3d" , "Gangster Wright Coupe" ], - ["buikFor00.i3d" , "Blue Wright Fordor" ], - ["buikFor01.i3d" , "Red Wright Fordor" ], - ["buikFor02.i3d" , "Green Wright Fordor" ], - ["Ambulance00.i3d" , "Bolt Ambulance" ], - ["fire00.i3d" , "Bolt Firetruck" ], - ["hearseA00.i3d" , "Bolt Hearse" ], - ["truckA00.i3d" , "Bolt Truck Flatbed" ], - ["truckB00.i3d" , "Bolt Truck Covered" ], - ["TruckBxx00.i3d" , "Bolt Truck(Atlantic Import)" ], - ["truckBx00.i3d" , "Bolt Truck" ], + ["fordtTud00.i3d", "Blue Bolt Ace Tudor"], + ["fordtTud01.i3d", "Dark Blue Bolt Ace Tudor"], + ["fordtTud02.i3d", "Brown Bolt Ace Tudor"], + ["fordtTud03.i3d", "Green Bolt Ace Tudor"], + ["fordtTud04.i3d", "Red Bolt Ace Tudor"], + ["fordtto00.i3d", "Blue Bolt Ace Touring"], + ["fordtto01.i3d", "Dark Blue Bolt Ace Touring"], + ["fordtto02.i3d", "Brown Bolt Ace Touring"], + ["fordtto03.i3d", "Green Bolt Ace Touring"], + ["fordtto04.i3d", "Red Bolt Ace Touring"], + ["fordtru00.i3d", "Blue Bolt Ace Runabout"], + ["fordtru01.i3d", "Dark Blue Bolt Ace Runabout"], + ["fordtru02.i3d", "Brown Bolt Ace Runabout"], + ["fordtru03.i3d", "Green Bolt Ace Runabout"], + ["fordtru04.i3d", "Red Bolt Ace Runabout"], + ["fordtpi00.i3d", "Blue Bolt Ace Pickup"], + ["fordtpi01.i3d", "Dark Blue Bolt Ace Pickup"], + ["fordtpi02.i3d", "Brown Bolt Ace Pickup"], + ["fordtpi03.i3d", "Green Bolt Ace Pickup"], + ["fordtpi04.i3d", "Red Bolt Ace Pickup"], + ["fordtFor00.i3d", "Blue Bolt Ace Fordor"], + ["fordtFor01.i3d", "Dark Blue Bolt Ace Fordor"], + ["fordtFor02.i3d", "Brown Bolt Ace Fordor"], + ["fordtFor03.i3d", "Green Bolt Ace Fordor"], + ["fordtFor04.i3d", "Red Bolt Ace Fordor"], + ["fordtco00.i3d", "Blue Bolt Ace Coupe"], + ["fordtco01.i3d", "Dark Blue Bolt Ace Coupe"], + ["fordtco02.i3d", "Brown Bolt Ace Coupe"], + ["fordtco03.i3d", "Green Bolt Ace Coupe"], + ["fordtco04.i3d", "Red Bolt Ace Coupe"], + ["forAtu00.i3d", "Brown Bolt Model B Tudor"], + ["ForAtu01.i3d", "Red Bolt Model B Tudor"], + ["ForAtu02.i3d", "Green Bolt Model B Tudor"], + ["ForAtu03.i3d", "Dark Blue Bolt Model B Tudor"], + ["ForAro00.i3d", "Brown Bolt Model B Roadster"], + ["ForAro01.i3d", "Red Bolt Model B Roadster"], + ["ForAro02.i3d", "Green Bolt Model B Roadster"], + ["ForAro03.i3d", "Dark Blue Bolt Model B Roadster"], + ["ForApic00.i3d", "Brown Bolt Model B Pickup"], + ["ForApic01.i3d", "Red Bolt Model B Pickup"], + ["ForApic02.i3d", "Green Bolt Model B Pickup"], + ["ForApic03.i3d", "Dark Blue Bolt Model B Pickup"], + ["ForAfo00.i3d", "Brown Bolt Model B Fordor"], + ["ForAfo01.i3d", "Red Bolt Model B Fordor"], + ["ForAfo02.i3d", "Green Bolt Model B Fordor"], + ["ForAfo03.i3d", "Dark Blue Bolt Model B Fordor"], + ["ForAde00.i3d", "Brown Bolt Model B Delivery"], + ["ForAde01.i3d", "Red Bolt Model B Delivery"], + ["ForAde02.i3d", "Green Bolt Model B Delivery"], + ["ForAde03.i3d", "Dark Blue Bolt Model B Delivery"], + ["ForAcou00.i3d", "Brown Bolt Model B Coupe"], + ["ForAcou01.i3d", "Red Bolt Model B Coupe"], + ["ForAcou02.i3d", "Green Bolt Model B Coupe"], + ["ForAcou03.i3d", "Dark Blue Bolt Model B Coupe"], + ["ForAtu00.i3d", "Brown Bolt Model B Tudor"], + ["ForAtu01.i3d", "Red Bolt Model B Tudor"], + ["ForAtu02.i3d", "Green Bolt Model B Tudor"], + ["ForAtu03.i3d", "Dark Blue Bolt Model B Tudor"], + ["forVco00.i3d", "Green Bolt V8 Coupe"], + ["forVco01.i3d", "Red Bolt V8 Coupe"], + ["forVco02.i3d", "Blue Bolt V8 Coupe"], + ["forVco03.i3d", "Grey Bolt V8 Coupe"], + ["forVfor00.i3d", "Green Bolt V8 Forder"], + ["forVfor01.i3d", "Red Bolt V8 Forder"], + ["forVfor02.i3d", "Blue Bolt V8 Forder"], + ["forVfor03.i3d", "Grey Bolt V8 Forder"], + ["forVro00.i3d", "Green Bolt V8 Roadster"], + ["forVro01.i3d", "Red Bolt V8 Roadster"], + ["forVro02.i3d", "Blue Bolt V8 Roadster"], + ["forVro03.i3d", "Grey Bolt V8 Roadster"], + ["forVto00.i3d", "Green Bolt V8 Touring"], + ["forVto01.i3d", "Red Bolt V8 Touring"], + ["forVto02.i3d", "Blue Bolt V8 Touring"], + ["forVto03.i3d", "Grey Bolt V8 Touring"], + ["forVtud00.i3d", "Green Bolt V8 Tudor"], + ["forVtud01.i3d", "Red Bolt V8 Tudor"], + ["forVtud02.i3d", "Blue Bolt V8 Tudor"], + ["forVtud03.i3d", "Grey Bolt V8 Tudor"], + ["miller00.i3d", "Brubaker"], + ["speedster00.i3d", "Silver Bruno Speedster 851"], + ["speedster01.i3d", "Red Bruno Speedster 851"], + ["speedster02.i3d", "Green Bruno Speedster 851"], + ["alfa00.i3d", "Caesar 8C 2300 Racing"], + ["alfa8C00.i3d", "Red Caesar 8C Mostro"], + ["alfa8C01.i3d", "Black Caesar 8C Mostro"], + ["merced500K00.i3d", "White Celeste Marque 500"], + ["merced500K01.i3d", "Brown Celeste Marque 500"], + ["bugatti00.i3d", "Blue Corrozella C-Otto"], + ["bugatti01.i3d", "Green Corrozella C-Otto"], + ["pontFor00.i3d", "Blue Crusader Chromium Forder"], + ["pontFor01.i3d", "Violet Crusader Chromium Forder"], + ["pontTud00.i3d", "Green Crusader Chromium Forder"], + ["pontTud01.i3d", "Dark Blue Crusader Chromium Forder"], + ["blackha00.i3d", "Blue Falconer"], + ["blackha01.i3d", "Red Falconer"], + ["black00.i3d", "Gangster Falconer"], + ["taxi00.i3d", "Falconer Yellowcar"], + ["hudcou00.i3d", "Umber Guardian Terraplane Coupe"], + ["hudcou01.i3d", "Beige Guardian Terraplane Coupe"], + ["hudcou02.i3d", "Black Guardian Terraplane Coupe"], + ["hudfor00.i3d", "Umber Guardian Terraplane Fordor"], + ["hudfor01.i3d", "Beige Guardian Terraplane Fordor"], + ["hudfor02.i3d", "Black Guardian Terraplane Fordor"], + ["hudtu00.i3d", "Umber Guardian Terraplane Tudor"], + ["hudtu01.i3d", "Beige Guardian Terraplane Tudor"], + ["hudtu02.i3d", "Black Guardian Terraplane Tudor"], + ["cad_ford00.i3d", "Lassister Fordor"], + ["cad_phaeton00", "Lassister Phaeton"], + ["cad_road00.i3d", "Lassister Roadster"], + ["hartmann00.i3d", "Lassister Appolyon"], + ["hearseCa00.i3d", "Lassister Charon"], + ["polCad00.i3d", "Lassister Police"], + ["chemaFor00.i3d", "Green Shubert Extra Six Fordor"], + ["chemaFor01.i3d", "White Shubert Extra Six Fordor"], + ["chemaFor02.i3d", "Blue Shubert Extra Six Fordor"], + ["polimFor00.i3d", "Shubert Extra Six Fordor Police"], + ["chematud00.i3d", "Green Shubert Extra Six Tudor"], + ["chematud01.i3d", "White Shubert Extra Six Tudor"], + ["chematud02.i3d", "Blue Shubert Extra Six Tudor"], + ["polimTud00.i3d", "Shubert Extra Six Tudor Police"], + ["chev00.i3d", "Red Shubert Six"], + ["chev01.i3d", "White Shubert Six"], + ["chev02.i3d", "Black Shubert Six"], + ["poli00.i3d", "Shubert Six Police"], + ["arrow00.i3d", "Silver Fletcher"], + ["cordca00.i3d", "Orange Thor 810 Cabriolet"], + ["cordca01.i3d", "Black Thor 810 Cabriolet"], + ["cordph00.i3d", "Orange Thor 810 Phaeton"], + ["cordph01.i3d", "Black Thor 810 Phaeton"], + ["cordse00.i3d", "Orange Thor 810 Sedan"], + ["cordse01.i3d", "Black Thor 810 Sedan"], + ["deuseJco00.i3d", "Trautenberg Model J"], + ["duesenberg00.i3d", "Trautenberg Racer 4WD"], + ["airflFor00.i3d", "Yellow Ulver Airstream Fordor"], + ["airflFor01.i3d", "Green Ulver Airstream Fordor"], + ["airfltud00.i3d", "Yellow Ulver Airstream Tudor"], + ["airfltud01.i3d", "Green Ulver Airstream Tudor"], + ["buiCou00.i3d", "Blue Wright Coupe"], + ["buiCou01.i3d", "Red Wright Coupe"], + ["buiCou02.i3d", "Green Wright Coupe"], + ["buigang00.i3d", "Gangster Wright Coupe"], + ["buikFor00.i3d", "Blue Wright Fordor"], + ["buikFor01.i3d", "Red Wright Fordor"], + ["buikFor02.i3d", "Green Wright Fordor"], + ["Ambulance00.i3d", "Bolt Ambulance"], + ["fire00.i3d", "Bolt Firetruck"], + ["hearseA00.i3d", "Bolt Hearse"], + ["truckA00.i3d", "Bolt Truck Flatbed"], + ["truckB00.i3d", "Bolt Truck Covered"], + ["TruckBxx00.i3d", "Bolt Truck(Atlantic Import)"], + ["truckBx00.i3d", "Bolt Truck"], ], [VRR_GAME_GTA_V]: [ ["adder", 3078201489], @@ -3998,6 +4018,20 @@ let gameData = { [170, "Grenade"], [182, "RemoteDetonator"], [1319, "GenericPackageWhite"], + [1343, "WoodenBox"], + [1339, "CardboardBox"], + [1336, "RustyBarrel"], + [1348, "TrashDumpster"], + [1338, "WoodenPallet"], + [1360, "TrafficCone"], + [1310, "WashingMachine"], + [1347, "TrashBin"], + [1396, "MailBox"], + [1359, "OrangeRoundRoadBarrier"], + [1398, "ParkBench"], + [1344, "RedBarrel"], + [1349, "StraightRoadBarrier"] + [1337, "YellowBarrel"], ], [VRR_GAME_GTA_VC]: [ // GTA VC [259, "BrassKnuckles"], @@ -4284,25 +4318,26 @@ let gameData = { // Hospitals ["All Saints General Hospital", [1182.67, -1323.81, 13.579], 1.543, null], - ["County General Hospital", [2034.7567,-1403.1083,17.2931], 0.0, null], + ["County General Hospital", [2034.7567, -1403.1083, 17.2931], 0.0, null], + ["San Fierro Medical Center", [-2654.14, 635.36, 14.45], 3.0, null], // Strip Clubs - ["Pig Pen Strip Club", [2420.906982,-1222.321777,25.348423], 0.0, null], + ["Pig Pen Strip Club", [2420.906982, -1222.321777, 25.348423], 0.0, null], // Night/Dance Clubs ["Club Tableau", [551.877502, -1506.095581, 14.550004], 1.0, null], ["Club Alhambra", [1832.55, -1681.91, 13.510], -1.561, null], // Bars - ["Ten Green Bottles Bar", [2305.922363,-1646.797241,14.461124], 1.0, null], + ["Ten Green Bottles Bar", [2305.922363, -1646.797241, 14.461124], 1.0, null], // Restaurants and Food - ["Market Donut Shop", [1040.932006,-1336.229492,13.550251], 1.0, null], - ["Idlewood Pizza Stack", [2099.827636,-1806.375610,13.554687], 0.0, null], - ["Temple Burger Shot", [1212.020019,-924.311462,42.930198], 1.0, null], + ["Market Donut Shop", [1040.932006, -1336.229492, 13.550251], 1.0, null], + ["Idlewood Pizza Stack", [2099.827636, -1806.375610, 13.554687], 0.0, null], + ["Temple Burger Shot", [1212.020019, -924.311462, 42.930198], 1.0, null], // Clothes Shops - ["Ganton Binco", [2244.837402,-1664.232299,15.476562], 1.0, null], + ["Ganton Binco", [2244.837402, -1664.232299, 15.476562], 1.0, null], ["Los Santos Victim ", [456.31, -1501.53, 31.041], -1.378, null], ["Los Santos Didier Sachs", [449.68, -1479.94, 30.639], -1.149, null], ["ProLaps Los Santos", [502.37, -1355.58, 16.133], 2.659, null], @@ -4310,18 +4345,18 @@ let gameData = { ["Marina Burger Shot", [816.55, -1617.00, 13.859], 1.396, null], // Airports - ["Los Santos International Airport Gate", [1958.201049,-2182.789794,13.546875], 1.0, null], + ["Los Santos International Airport Gate", [1958.201049, -2182.789794, 13.546875], 1.0, null], ["Los Santos International Airport Runway", [2054.12, -2493.84, 13.547], 1.569, null], - ["Los Santos Stadium", [2694.261474,-1703.194335,11.506717], 1.0, null], + ["Los Santos Stadium", [2694.261474, -1703.194335, 11.506717], 1.0, null], // Sex Shops - ["El Corona Sex Shop", [1944.994873,-2116.641113,13.550632], 1.0, null], - ["Temple Sex Shop", [1090.181884,-927.265869,43.182197], 1.0, null], - ["Market Sex Shop", [1090.181884,-927.265869,43.182197], 1.0, null] + ["El Corona Sex Shop", [1944.994873, -2116.641113, 13.550632], 1.0, null], + ["Temple Sex Shop", [1090.181884, -927.265869, 43.182197], 1.0, null], + ["Market Sex Shop", [1090.181884, -927.265869, 43.182197], 1.0, null] // Misc/Other - ["Grotti Dealership", [540.6011,-1291.2489,17.2422], 0.0, null], - ["Santa Maria Beach", [302.994567,-1900.099121,1.938840], 0.0, null], + ["Grotti Dealership", [540.6011, -1291.2489, 17.2422], 0.0, null], + ["Santa Maria Beach", [302.994567, -1900.099121, 1.938840], 0.0, null], ["Glen Park Bridge", [1968.33, -1195.10, 25.70], 0.0, null], ["Los Santos Skate Park", [1865.96, -1380.53, 13.50], 0.0, null], ["Los Santos Garbage Dump", [2194.91, -1977.58, 13.55], 0.0, null], @@ -4605,124 +4640,124 @@ let gameData = { // [name, groupId, animId, animType, deltaTime, null, null, null, null, moveType], [VRR_GAME_GTA_III]: [ // GTA III - new AnimationData("talk", {groupId: 0, animId: 11}), - new AnimationData("chat", {groupId: 0, animId: 11}), - new AnimationData("hailtaxi", {groupId: 0, animId: 12}), - new AnimationData("wave", {groupId: 0, animId: 12}), + new AnimationData("talk", { groupId: 0, animId: 11 }), + new AnimationData("chat", { groupId: 0, animId: 11 }), + new AnimationData("hailtaxi", { groupId: 0, animId: 12 }), + new AnimationData("wave", { groupId: 0, animId: 12 }), - new AnimationData("headscratch", {groupId: 0, animId: 157}), - new AnimationData("lookaround1", {groupId: 0, animId: 158}), - new AnimationData("lookaround2", {groupId: 0, animId: 7}), - new AnimationData("plant", {groupId: 0, animId: 162}), - new AnimationData("cower", {groupId: 0, animId: 163}), - new AnimationData("aimdown", {groupId: 0, animId: 160}), - new AnimationData("aimcrouch", {groupId: 0, animId: 165}), - new AnimationData("throw", {groupId: 0, animId: 166}), - new AnimationData("handsup", {groupId: 0, animId: 167, animType: VRR_ANIMTYPE_SURRENDER}), - new AnimationData("sit", {groupId: 0, animId: 111}), - new AnimationData("sitleft", {groupId: 0, animId: 111, moveType: VRR_ANIMMOVE_LEFT}), - new AnimationData("sitback", {groupId: 0, animId: 111, moveType: VRR_ANIMMOVE_BACK}), - new AnimationData("sitright", {groupId: 0, animId: 111, moveType: VRR_ANIMMOVE_RIGHT}), - new AnimationData("sitforward", {groupId: 0, animId: 111, moveType: VRR_ANIMMOVE_FORWARD}), - new AnimationData("sitarmright", {groupId: 0, animId: 120, moveType: VRR_ANIMMOVE_BACK}), - new AnimationData("tazed", {groupId: 0, animId: 13, animType: VRR_ANIMTYPE_FORCED}), - new AnimationData("walk", {groupId: 0, animId: 0}), - new AnimationData("jog", {groupId: 0, animId: 1}), - new AnimationData("tired", {groupId: 0, animId: 9}), - new AnimationData("trip", {groupId: 0, animId: 27}), - new AnimationData("punch", {groupId: 0, animId: 45}), - new AnimationData("groundkick", {groupId: 0, animId: 46}), - new AnimationData("bathit1", {groupId: 0, animId: 47}), - new AnimationData("batgroundhit", {groupId: 0, animId: 48}), - new AnimationData("shootpistol", {groupId: 0, animId: 49}), - new AnimationData("toss", {groupId: 0, animId: 54}), - new AnimationData("pressbutton", {groupId: 0, animId: 56}), - new AnimationData("fightidle", {groupId: 0, animId: 66}), - new AnimationData("roundhouse", {groupId: 0, animId: 75}), - new AnimationData("highkick", {groupId: 0, animId: 71}), - new AnimationData("phonetalk", {groupId: 0, animId: 172}), - new AnimationData("handcuffed", {groupId: 0, animId: 8, animType: VRR_ANIMTYPE_FORCED}), - ], + new AnimationData("headscratch", { groupId: 0, animId: 157 }), + new AnimationData("lookaround1", { groupId: 0, animId: 158 }), + new AnimationData("lookaround2", { groupId: 0, animId: 7 }), + new AnimationData("plant", { groupId: 0, animId: 162 }), + new AnimationData("cower", { groupId: 0, animId: 163 }), + new AnimationData("aimdown", { groupId: 0, animId: 160 }), + new AnimationData("aimcrouch", { groupId: 0, animId: 165 }), + new AnimationData("throw", { groupId: 0, animId: 166 }), + new AnimationData("handsup", { groupId: 0, animId: 167, animType: VRR_ANIMTYPE_SURRENDER }), + new AnimationData("sit", { groupId: 0, animId: 111 }), + new AnimationData("sitleft", { groupId: 0, animId: 111, moveType: VRR_ANIMMOVE_LEFT }), + new AnimationData("sitback", { groupId: 0, animId: 111, moveType: VRR_ANIMMOVE_BACK }), + new AnimationData("sitright", { groupId: 0, animId: 111, moveType: VRR_ANIMMOVE_RIGHT }), + new AnimationData("sitforward", { groupId: 0, animId: 111, moveType: VRR_ANIMMOVE_FORWARD }), + new AnimationData("sitarmright", { groupId: 0, animId: 120, moveType: VRR_ANIMMOVE_BACK }), + new AnimationData("tazed", { groupId: 0, animId: 13, animType: VRR_ANIMTYPE_FORCED }), + new AnimationData("walk", { groupId: 0, animId: 0 }), + new AnimationData("jog", { groupId: 0, animId: 1 }), + new AnimationData("tired", { groupId: 0, animId: 9 }), + new AnimationData("trip", { groupId: 0, animId: 27 }), + new AnimationData("punch", { groupId: 0, animId: 45 }), + new AnimationData("groundkick", { groupId: 0, animId: 46 }), + new AnimationData("bathit1", { groupId: 0, animId: 47 }), + new AnimationData("batgroundhit", { groupId: 0, animId: 48 }), + new AnimationData("shootpistol", { groupId: 0, animId: 49 }), + new AnimationData("toss", { groupId: 0, animId: 54 }), + new AnimationData("pressbutton", { groupId: 0, animId: 56 }), + new AnimationData("fightidle", { groupId: 0, animId: 66 }), + new AnimationData("roundhouse", { groupId: 0, animId: 75 }), + new AnimationData("highkick", { groupId: 0, animId: 71 }), + new AnimationData("phonetalk", { groupId: 0, animId: 172 }), + new AnimationData("handcuffed", { groupId: 0, animId: 8, animType: VRR_ANIMTYPE_FORCED }), + ], [VRR_GAME_GTA_VC]: [ // GTA VC - new AnimationData("talk", {groupId: 0, animId: 11}), - new AnimationData("chat", {groupId: 0, animId: 11}), - new AnimationData("hailtaxi", {groupId: 0, animId: 12}), - new AnimationData("handsup", {groupId: 0, animId: 161, animType: VRR_ANIMTYPE_SURRENDER}), - new AnimationData("flipoff", {groupId: 0, animId: 163}), - new AnimationData("phoneout", {groupId: 0, animId: 164}), - new AnimationData("phonein", {groupId: 0, animId: 165}), - new AnimationData("phonetalk", {groupId: 0, animId: 166}), - new AnimationData("sit", {groupId: 0, animId: 169, animSpeed: 1.0}), - new AnimationData("atm", {groupId: 0, animId: 171}), - new AnimationData("cpr", {groupId: 24, animId: 214}), - new AnimationData("idle1", {groupId: 26, animId: 215}), - new AnimationData("idle2", {groupId: 26, animId: 216}), - new AnimationData("idle3", {groupId: 26, animId: 217}), - new AnimationData("idle4", {groupId: 26, animId: 218}), - new AnimationData("dance1", {groupId: 28, animId: 226}), - new AnimationData("dance2", {groupId: 28, animId: 227}), - new AnimationData("dance3", {groupId: 28, animId: 228}), - new AnimationData("dance4", {groupId: 28, animId: 229}), - new AnimationData("dance5", {groupId: 28, animId: 230}), - new AnimationData("dance6", {groupId: 28, animId: 231}), - new AnimationData("dance7", {groupId: 28, animId: 232}), - new AnimationData("pressbutton", {groupId: 0, animId: 62}), - new AnimationData("sitright", {groupId: 0, animId: 169, moveType: VRR_ANIMMOVE_RIGHT}), - new AnimationData("sitleft", {groupId: 0, animId: 169, moveType: VRR_ANIMMOVE_LEFT}), - new AnimationData("sitforward", {groupId: 0, animId: 169, moveType: VRR_ANIMMOVE_FORWARD}), - new AnimationData("sitback", {groupId: 0, animId: 169, moveType: VRR_ANIMMOVE_BACK}), - new AnimationData("tazed", {groupId: 0, animId: 13, animType: VRR_ANIMTYPE_FORCED}), - new AnimationData("fightidle1", {groupId: 0, animId: 45}), - new AnimationData("highkick1", {groupId: 0, animId: 50}), - new AnimationData("kneekick", {groupId: 0, animId: 51}), - new AnimationData("leftpunch", {groupId: 0, animId: 52}), - new AnimationData("rightpunch", {groupId: 0, animId: 53}), - new AnimationData("roundhouse", {groupId: 0, animId: 54}), - new AnimationData("highkick2", {groupId: 0, animId: 55}), - new AnimationData("hitandblock", {groupId: 0, animId: 56}), - new AnimationData("frontpunch", {groupId: 0, animId: 57}), - new AnimationData("elbowleft", {groupId: 0, animId: 58}), - new AnimationData("elbowright", {groupId: 0, animId: 59}), - new AnimationData("rearkick", {groupId: 0, animId: 61}), - new AnimationData("groundkick", {groupId: 0, animId: 65}), - new AnimationData("toss", {groupId: 0, animId: 66}), - new AnimationData("sithigh", {groupId: 0, animId: 104}), - new AnimationData("rollforward", {groupId: 0, animId: 147}), - new AnimationData("aimdown", {groupId: 0, animId: 155}), - new AnimationData("aimcrouch1", {groupId: 0, animId: 157}), - new AnimationData("aimcrouch2", {groupId: 0, animId: 160}), - new AnimationData("pose", {groupId: 0, animId: 172}), - new AnimationData("holdrifle", {groupId: 0, animId: 10}), - new AnimationData("tired", {groupId: 0, animId: 9}), - new AnimationData("handcuffed", {groupId: 0, animId: 9, animType: VRR_ANIMTYPE_FORCED}), - new AnimationData("walk", {groupId: 0, animId: 0}), - new AnimationData("jog", {groupId: 0, animId: 1}), - new AnimationData("headscratch", {groupId: 0, animId: 152}), - new AnimationData("lookaround", {groupId: 0, animId: 153}), + new AnimationData("talk", { groupId: 0, animId: 11 }), + new AnimationData("chat", { groupId: 0, animId: 11 }), + new AnimationData("hailtaxi", { groupId: 0, animId: 12 }), + new AnimationData("handsup", { groupId: 0, animId: 161, animType: VRR_ANIMTYPE_SURRENDER }), + new AnimationData("flipoff", { groupId: 0, animId: 163 }), + new AnimationData("phoneout", { groupId: 0, animId: 164 }), + new AnimationData("phonein", { groupId: 0, animId: 165 }), + new AnimationData("phonetalk", { groupId: 0, animId: 166 }), + new AnimationData("sit", { groupId: 0, animId: 169, animSpeed: 1.0 }), + new AnimationData("atm", { groupId: 0, animId: 171 }), + new AnimationData("cpr", { groupId: 24, animId: 214 }), + new AnimationData("idle1", { groupId: 26, animId: 215 }), + new AnimationData("idle2", { groupId: 26, animId: 216 }), + new AnimationData("idle3", { groupId: 26, animId: 217 }), + new AnimationData("idle4", { groupId: 26, animId: 218 }), + new AnimationData("dance1", { groupId: 28, animId: 226 }), + new AnimationData("dance2", { groupId: 28, animId: 227 }), + new AnimationData("dance3", { groupId: 28, animId: 228 }), + new AnimationData("dance4", { groupId: 28, animId: 229 }), + new AnimationData("dance5", { groupId: 28, animId: 230 }), + new AnimationData("dance6", { groupId: 28, animId: 231 }), + new AnimationData("dance7", { groupId: 28, animId: 232 }), + new AnimationData("pressbutton", { groupId: 0, animId: 62 }), + new AnimationData("sitright", { groupId: 0, animId: 169, moveType: VRR_ANIMMOVE_RIGHT }), + new AnimationData("sitleft", { groupId: 0, animId: 169, moveType: VRR_ANIMMOVE_LEFT }), + new AnimationData("sitforward", { groupId: 0, animId: 169, moveType: VRR_ANIMMOVE_FORWARD }), + new AnimationData("sitback", { groupId: 0, animId: 169, moveType: VRR_ANIMMOVE_BACK }), + new AnimationData("tazed", { groupId: 0, animId: 13, animType: VRR_ANIMTYPE_FORCED }), + new AnimationData("fightidle1", { groupId: 0, animId: 45 }), + new AnimationData("highkick1", { groupId: 0, animId: 50 }), + new AnimationData("kneekick", { groupId: 0, animId: 51 }), + new AnimationData("leftpunch", { groupId: 0, animId: 52 }), + new AnimationData("rightpunch", { groupId: 0, animId: 53 }), + new AnimationData("roundhouse", { groupId: 0, animId: 54 }), + new AnimationData("highkick2", { groupId: 0, animId: 55 }), + new AnimationData("hitandblock", { groupId: 0, animId: 56 }), + new AnimationData("frontpunch", { groupId: 0, animId: 57 }), + new AnimationData("elbowleft", { groupId: 0, animId: 58 }), + new AnimationData("elbowright", { groupId: 0, animId: 59 }), + new AnimationData("rearkick", { groupId: 0, animId: 61 }), + new AnimationData("groundkick", { groupId: 0, animId: 65 }), + new AnimationData("toss", { groupId: 0, animId: 66 }), + new AnimationData("sithigh", { groupId: 0, animId: 104 }), + new AnimationData("rollforward", { groupId: 0, animId: 147 }), + new AnimationData("aimdown", { groupId: 0, animId: 155 }), + new AnimationData("aimcrouch1", { groupId: 0, animId: 157 }), + new AnimationData("aimcrouch2", { groupId: 0, animId: 160 }), + new AnimationData("pose", { groupId: 0, animId: 172 }), + new AnimationData("holdrifle", { groupId: 0, animId: 10 }), + new AnimationData("tired", { groupId: 0, animId: 9 }), + new AnimationData("handcuffed", { groupId: 0, animId: 9, animType: VRR_ANIMTYPE_FORCED }), + new AnimationData("walk", { groupId: 0, animId: 0 }), + new AnimationData("jog", { groupId: 0, animId: 1 }), + new AnimationData("headscratch", { groupId: 0, animId: 152 }), + new AnimationData("lookaround", { groupId: 0, animId: 153 }), ], [VRR_GAME_GTA_SA]: [ // GTA SA - new AnimationData("knockback", {groupId: 0, animId: 105}), - new AnimationData("idle1", {groupId: 0, animId: 135}), - new AnimationData("cower", {groupId: 0, animId: 141}), - new AnimationData("handsup", {groupId: 0, animId: 142}), - new AnimationData("fucku", {groupId: 0, animId: 144}), - new AnimationData("phoneout", {groupId: 0, animId: 145}), - new AnimationData("phonein", {groupId: 0, animId: 146}), - new AnimationData("phonetalk", {groupId: 0, animId: 146}), - new AnimationData("sit1", {groupId: 0, animId: 150}), - new AnimationData("atm", {groupId: 0, animId: 151}), - new AnimationData("mindtrick", {groupId: 0, animId: 153}), - new AnimationData("look2", {groupId: 0, animId: 165}), - new AnimationData("gestureno", {groupId: 0, animId: 166}), - new AnimationData("gestureyes", {groupId: 0, animId: 167}), - new AnimationData("wave2", {groupId: 0, animId: 168}), - new AnimationData("snort", {groupId: 0, animId: 169}), - new AnimationData("sitright", {groupId: 0, animId: 150, moveType: VRR_ANIMMOVE_RIGHT}), - new AnimationData("sitleft", {groupId: 0, animId: 150, moveType: VRR_ANIMMOVE_LEFT}), - new AnimationData("sitforward", {groupId: 0, animId: 150, moveType: VRR_ANIMMOVE_FORWARD}), - new AnimationData("sitback", {groupId: 0, animId: 150, moveType: VRR_ANIMMOVE_BACK}), - new AnimationData("tazed", {groupId: 0, animId: 15, moveType: VRR_ANIMTYPE_FORCED}), + new AnimationData("knockback", { groupId: 0, animId: 105 }), + new AnimationData("idle1", { groupId: 0, animId: 135 }), + new AnimationData("cower", { groupId: 0, animId: 141 }), + new AnimationData("handsup", { groupId: 0, animId: 142 }), + new AnimationData("fucku", { groupId: 0, animId: 144 }), + new AnimationData("phoneout", { groupId: 0, animId: 145 }), + new AnimationData("phonein", { groupId: 0, animId: 146 }), + new AnimationData("phonetalk", { groupId: 0, animId: 146 }), + new AnimationData("sit1", { groupId: 0, animId: 150 }), + new AnimationData("atm", { groupId: 0, animId: 151 }), + new AnimationData("mindtrick", { groupId: 0, animId: 153 }), + new AnimationData("look2", { groupId: 0, animId: 165 }), + new AnimationData("gestureno", { groupId: 0, animId: 166 }), + new AnimationData("gestureyes", { groupId: 0, animId: 167 }), + new AnimationData("wave2", { groupId: 0, animId: 168 }), + new AnimationData("snort", { groupId: 0, animId: 169 }), + new AnimationData("sitright", { groupId: 0, animId: 150, moveType: VRR_ANIMMOVE_RIGHT }), + new AnimationData("sitleft", { groupId: 0, animId: 150, moveType: VRR_ANIMMOVE_LEFT }), + new AnimationData("sitforward", { groupId: 0, animId: 150, moveType: VRR_ANIMMOVE_FORWARD }), + new AnimationData("sitback", { groupId: 0, animId: 150, moveType: VRR_ANIMMOVE_BACK }), + new AnimationData("tazed", { groupId: 0, animId: 15, moveType: VRR_ANIMTYPE_FORCED }), /* ["talk", "PED", "IDLE_CHAT", VRR_ANIMTYPE_NORMAL, 0.0, null, null, null, null], @@ -4751,13 +4786,15 @@ let gameData = { */ ], [VRR_GAME_GTA_IV]: [ // GTA IV - new AnimationData("dance1", {groupId: "DAN_LOOP_A", animId: "DANCING", animSpeed: 16.0, infiniteLoop: true, infiniteLoopNoMovement: false, dontReturnToStartCoords: true, freezeLastFrame: false}), + new AnimationData("dance1", { groupId: "DAN_LOOP_A", animId: "DANCING", animSpeed: 16.0, infiniteLoop: true, infiniteLoopNoMovement: false, dontReturnToStartCoords: true, freezeLastFrame: false }), ], }, meleeWeapons: { [VRR_GAME_GTA_III]: [1], [VRR_GAME_GTA_VC]: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [VRR_GAME_GTA_SA]: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], + [VRR_GAME_GTA_IV]: [1, 2, 3], + [VRR_GAME_GTA_IV_EFLC]: [1, 2, 3], }, blipSprites: { [VRR_GAME_GTA_III]: { // GTA III @@ -5709,6 +5746,13 @@ let gameData = { } }, interiors: { + [VRR_GAME_GTA_III]: { + Apartment1: [toVector3(891.87, -308.28, 8.72), 0, false, -1], + JailCell: [toVector3(328.40, -1093.31, 25.98), 0, false, -1], + Church: [toVector3(13.87, -1122.43, 26.12), 0, false, -1], + Mansion: [toVector3(1461.00, -173.87, 55.78), 0, false, -1], + Garage: [toVector3(-420.69, 289.86, 62.96), 0, false, -1], + }, [VRR_GAME_GTA_VC]: { // GTA VC Mall: [toVector3(379.62, 1007.00, 19.22), 4, false, -1], MalibuClub: [toVector3(489.83, -76.49, 11.48), 17, false, -1], @@ -5768,22 +5812,22 @@ let gameData = { House6: [toVector3(328.49, 1480.59, 1084.45), 15, false, -1], House7: [toVector3(385.80, 1471.77, 1080.21), 15, false, -1], Atrium: [toVector3(1726.18, -1641.00, 20.23), 18, false, -1], - CrackPalace: [toVector3(2,567.52, -1294.59, 1063.25), 2, false, -1], + CrackPalace: [toVector3(2, 567.52, -1294.59, 1063.25), 2, false, -1], BloodbowlStadium: [toVector3(-1394.20, 987.62, 1023.96), 15, false, -1], BurningDesireHouse: [toVector3(2338.32, -1180.61, 1027.98), 5, false, -1], FurhbergerHouse: [toVector3(2807.63, -1170.15, 1025.57), 8, false, -1], DillimoreGas: [toVector3(664.19, -570.73, 16.34), 0, false, -1], DonutShop: [toVector3(377.19, -192.90, 1000.64), 17, false, -1], Airport: [toVector3(-1830.81, 16.83, 1061.14), 14, false, -1], - JeffersonMotel: [toVector3(2220.26, -1,148.01, 1025.80), 15, false, -1], - KickstartStadium: [toVector3(-1410.72, 1,591.16, 1052.53), 14, false, -1], + JeffersonMotel: [toVector3(2220.26, -1, 148.01, 1025.80), 15, false, -1], + KickstartStadium: [toVector3(-1410.72, 1, 591.16, 1052.53), 14, false, -1], LibertyCity: [toVector3(-750.80, 491.00, 1371.70), 1, false, -1], LSXBaggageReclaim: [toVector3(-1870.80, 59.81, 1056.25), 14, false, -1], JizzyClub: [toVector3(-2637.69, 1404.24, 906.46), 3, false, -1], RCBattlefield: [toVector3(-1079.99, 1061.58, 1343.04), 10, false, -1], RyderHouse: [toVector3(2451.77, -1699.80, 1013.51), 2, false, -1], SFGarage: [toVector3(-2042.42, 178.59, 28.84), 1, false, -1], - SweetHouse: [toVector3(2535.83, -1,674.32, 1015.50), 1, false, -1], + SweetHouse: [toVector3(2535.83, -1, 674.32, 1015.50), 1, false, -1], KatieHouse: [toVector3(267.22, 304.71, 999.14), 2, false, -1], HelenaHouse: [toVector3(292.44, 308.77, 999.14), 3, false, -1], WelcomePump: [toVector3(681.66, -453.32, -25.61), 1, false, -1], @@ -5809,24 +5853,24 @@ let gameData = { BincoStore: [toVector3(207.54, -109.00, 1005.13), 15, false, -1], Wardrobe: [toVector3(255.71, -41.13, 1002.02), 14, false, -1], CityHall: [toVector3(389.538, 173.652, 1008.38), 3, false, -1], - GantonGym: [toVector3(772.11,-3.89,1000.72), 5, false, -1], + GantonGym: [toVector3(772.11, -3.89, 1000.72), 5, false, -1], KungFuGym: [toVector3(774.21, -48.92, 1000.58), 6, false, -1], LVGym: [toVector3(773.57, -77.09, 1000.65), 7, false, -1], InsuranceCompany: [toVector3(-2029.76, -119.624, 1035.17), 1, false, -1], - StripClub1: [toVector3(1204.80,-11.58,1000.92), 2, false, -1], + StripClub1: [toVector3(1204.80, -11.58, 1000.92), 2, false, -1], StripClub1Private: [toVector3(1204.80, 13.89, 1000.92), 2, false, -1], - NightClub: [toVector3(493.39,-22.72,1000.67), 17, false, -1], + NightClub: [toVector3(493.39, -22.72, 1000.67), 17, false, -1], Warehouse1: [toVector3(1412.63, -1.78, 1000.92), 1, false, -1], Warehouse2: [toVector3(1302.51, -1.78, 1001.02), 18, false, -1], Warehouse3: [toVector3(76.63, -301.15, 1.57), 0, false, -1], Warehouse4: [toVector3(1059.89, 2081.68, 10.82), 0, false, -1], BikeSchool: [toVector3(1494.32, 1304.94, 1093.28), 3, false, -1], - Bar1: [toVector3(501.98,-69.15,998.75), 11, false, -1], + Bar1: [toVector3(501.98, -69.15, 998.75), 11, false, -1], Diner1: [toVector3(459.58, -88.60, 999.55), 4, false, -1], //Diner2: [toVector3(454.97, -110.10, 1000.07), 4, false, -1], //Diner3: [toVector3(435.27, -80.95, 999.55), 5, false, -1], SmallPoliceStation: [toVector3(322.19, 302.49, 999.14), 5, false, -1], - Cinema: [toVector3(2179.95,-1009.75,1021.68), 0, true, -1], + Cinema: [toVector3(2179.95, -1009.75, 1021.68), 0, true, -1], Courthouse: [toVector3(1219.51, -1792.69, 2431.34), 0, true, -1], }, @@ -6108,16 +6152,28 @@ let gameData = { ], [VRR_GAME_GTA_VC]: [ // GTA VC { - position: toVector3(493.14, 709.31, 11.80), - heading: 1.5, + position: toVector3(-883.56, -469.39, 13.11), + heading: -1.5, blip: false, - name: "Unknown", + name: "Little Havana Hospital", }, { - position: toVector3(-826.06, 1144.41, 12.41), - heading: 1.5, + position: toVector3(-135.38, -980.33, 10.46), + heading: -1.5, blip: false, - name: "Unknown", + name: "Ocean Beach Hospital", + }, + { + position: toVector3(-822.60, 1150.78, 12.41), + heading: 0.0, + blip: false, + name: "Downtown Hospital", + }, + { + position: toVector3(493.86, 700.72, 12.10), + heading: 1.02, + blip: false, + name: "Vice Point Hospital", }, ], [VRR_GAME_GTA_SA]: [ // GTA SA @@ -6451,14 +6507,14 @@ let gameData = { [VRR_GAME_GTA_SA]: [ // GTA San Andreas toVector3(403.8266, -2088.7598, 7.8359), toVector3(398.7553, -2088.7490, 7.8359), - toVector3(396.2197,-2088.6692,7.8359), - toVector3(391.1094,-2088.7976,7.8359), - toVector3(383.4157,-2088.7849,7.8359), - toVector3(374.9598,-2088.7979,7.8359), - toVector3(369.8107,-2088.7927,7.8359), - toVector3(367.3637,-2088.7925,7.8359), - toVector3(362.2244,-2088.7981,7.8359), - toVector3(354.5382,-2088.7979,7.8359), + toVector3(396.2197, -2088.6692, 7.8359), + toVector3(391.1094, -2088.7976, 7.8359), + toVector3(383.4157, -2088.7849, 7.8359), + toVector3(374.9598, -2088.7979, 7.8359), + toVector3(369.8107, -2088.7927, 7.8359), + toVector3(367.3637, -2088.7925, 7.8359), + toVector3(362.2244, -2088.7981, 7.8359), + toVector3(354.5382, -2088.7979, 7.8359), ], }, fishingCollectables: { diff --git a/scripts/shared/utilities.js b/scripts/shared/utilities.js index e9bb19a3..c0b95c01 100644 --- a/scripts/shared/utilities.js +++ b/scripts/shared/utilities.js @@ -7,6 +7,10 @@ // TYPE: Shared (JavaScript) // =========================================================================== +let emojiNumbers = ["➊", "➋", "➌", "➍", "➎", "➏", "➐", "➑", "➒"]; +//let emojiNumbers = ["①", "②", "③", "④", "⑤", "⑥", "⑦", "⑧", "⑨"]; +//let emojiNumbers = ["1️⃣", "2️⃣", "3️⃣", "4️⃣", "5️⃣", "6️⃣", "7️⃣", "8️⃣", "9️⃣"]; + let bindableKeys = { 8: "backspace", 9: "tab", @@ -1093,13 +1097,13 @@ let serverEmoji = [ [":water_buffalo:", "🐃"], [":neutral_face:", "😐"], [":clock1230:", "🕧"], - [":P", "😛" ], - [":)", "🙂" ], - [":D", "😃" ], - [":o", "😮" ], - [":O", "😮" ], - [":(", "☹️" ], - [":|", "😐" ], + [":P", "😛"], + [":)", "🙂"], + [":D", "😃"], + [":o", "😮"], + [":O", "😮"], + [":(", "☹️"], + [":|", "😐"], ]; // =========================================================================== @@ -1139,8 +1143,8 @@ function getKeyIdFromParams(params) { // return sdlName; //} - for(let i in bindableKeys) { - if(toLowerCase(bindableKeys[i]) == toLowerCase(tempParams)) { + for (let i in bindableKeys) { + if (toLowerCase(bindableKeys[i]) == toLowerCase(tempParams)) { return i; } } @@ -1325,11 +1329,11 @@ function toLowerCase(val) { // =========================================================================== function isNull(val) { - if(val == null) { + if (val == null) { return true; } - if(typeof val === "undefined") { + if (typeof val === "undefined") { return true; } @@ -1339,8 +1343,8 @@ function isNull(val) { // =========================================================================== function getEntityData(entity, dataName) { - if(entity != null) { - if(entity.getData != null) { + if (entity != null) { + if (entity.getData != null) { return entity.getData(dataName); } } @@ -1350,7 +1354,7 @@ function getEntityData(entity, dataName) { // =========================================================================== function getDistance(vec1, vec2) { - if(isNull(vec1) || isNull(vec2)) { + if (isNull(vec1) || isNull(vec2)) { return false; } return vec1.distance(vec2); @@ -1361,11 +1365,11 @@ function getDistance(vec1, vec2) { function logToConsole(tempLogLevel, text) { text = removeColoursInMessage(text); - if(hasBitFlag(logLevel|LOG_WARN|LOG_ERROR, tempLogLevel)) { - if(tempLogLevel & LOG_ERROR) { + if (hasBitFlag(logLevel | LOG_WARN | LOG_ERROR, tempLogLevel)) { + if (tempLogLevel & LOG_ERROR) { consoleError(text); return true; - } else if(tempLogLevel & LOG_WARN) { + } else if (tempLogLevel & LOG_WARN) { consoleWarn(text); return true; } else { @@ -1380,7 +1384,7 @@ function logToConsole(tempLogLevel, text) { function Enum(constantsList) { let tempTable = {}; - for(let i in constantsList) { + for (let i in constantsList) { tempTable[constantsList[i]] = i; } return tempTable; @@ -1401,7 +1405,7 @@ function isServerScript() { // =========================================================================== function getPercentage(num, per) { - return (num/100)*per; + return (num / 100) * per; } // =========================================================================== @@ -1498,8 +1502,8 @@ function getAllowedSkins(gameId = getGame()) { function getAllowedSkinIndexFromSkin(skin) { let allowedSkins = getAllowedSkins(); - for(let i in allowedSkins) { - if(allowedSkins[i][0] == skin) { + for (let i in allowedSkins) { + if (allowedSkins[i][0] == skin) { return i; } } @@ -1511,8 +1515,8 @@ function getAllowedSkinIndexFromSkin(skin) { function getSkinIndexFromModel(model, gameId = getGame()) { let skins = getGameConfig().skins[gameId]; - for(let i in skins) { - if(toLowerCase(skins[i][0]).indexOf(toLowerCase(model)) != -1) { + for (let i in skins) { + if (toLowerCase(skins[i][0]).indexOf(toLowerCase(model)) != -1) { return i; } } @@ -1524,8 +1528,8 @@ function getSkinIndexFromModel(model, gameId = getGame()) { function getSkinIndexFromName(name, gameId = getGame()) { let skins = getGameConfig().skins[gameId]; - for(let i in skins) { - if(toLowerCase(skins[i][1]).indexOf(toLowerCase(name)) != -1) { + for (let i in skins) { + if (toLowerCase(skins[i][1]).indexOf(toLowerCase(name)) != -1) { return i; } } @@ -1537,8 +1541,8 @@ function getSkinIndexFromName(name, gameId = getGame()) { function getObjectModelIndexFromModel(model, gameId = getGame()) { let objects = getGameConfig().objects[gameId]; - for(let i in objects) { - if(toLowerCase(objects[i][0]).indexOf(toLowerCase(model)) != -1) { + for (let i in objects) { + if (toLowerCase(objects[i][0]).indexOf(toLowerCase(model)) != -1) { return i; } } @@ -1558,11 +1562,11 @@ function getVehicleModelIndexFromParams(params, gameId = getGame()) { let fromName = getVehicleModelIndexFromName(params, gameId); let fromModel = getVehicleModelIndexFromModel(params, gameId); - if(fromModel && !fromName) { + if (fromModel && !fromName) { return fromModel; } - if(!fromModel && fromName) { + if (!fromModel && fromName) { return fromName; } @@ -1573,8 +1577,8 @@ function getVehicleModelIndexFromParams(params, gameId = getGame()) { function getVehicleModelIndexFromName(name, gameId = getGame()) { let vehicles = getGameConfig().vehicles[gameId]; - for(let i in vehicles) { - if(toLowerCase(vehicles[i][1]).indexOf(toLowerCase(name)) != -1) { + for (let i in vehicles) { + if (toLowerCase(vehicles[i][1]).indexOf(toLowerCase(name)) != -1) { return i; } } @@ -1586,13 +1590,13 @@ function getVehicleModelIndexFromName(name, gameId = getGame()) { function getVehicleModelIndexFromModel(model, gameId = getGame()) { let vehicles = getGameConfig().vehicles[gameId]; - for(let i in vehicles) { - if(isNaN(model)) { - if(toLowerCase(vehicles[i][0]).indexOf(toLowerCase(model)) != -1) { + for (let i in vehicles) { + if (isNaN(model)) { + if (toLowerCase(vehicles[i][0]).indexOf(toLowerCase(model)) != -1) { return i; } } else { - if(vehicles[i][0] == toInteger(model)) { + if (vehicles[i][0] == toInteger(model)) { return i; } } @@ -1605,8 +1609,8 @@ function getVehicleModelIndexFromModel(model, gameId = getGame()) { function getVehicleModelFromName(name, gameId = getGame()) { let vehicles = getGameConfig().vehicles[gameId]; - for(let i in vehicles) { - if(toLowerCase(vehicles[i][1]).indexOf(toLowerCase(name)) != -1) { + for (let i in vehicles) { + if (toLowerCase(vehicles[i][1]).indexOf(toLowerCase(name)) != -1) { return vehicles[i][0]; } } @@ -1618,13 +1622,13 @@ function getVehicleModelFromName(name, gameId = getGame()) { function getVehicleNameFromModel(model, gameId = getGame()) { let vehicles = getGameConfig().vehicles[gameId]; - for(let i in vehicles) { - if(isNaN(model)) { - if(toLowerCase(vehicles[i][0]).indexOf(toLowerCase(model)) != -1) { + for (let i in vehicles) { + if (isNaN(model)) { + if (toLowerCase(vehicles[i][0]).indexOf(toLowerCase(model)) != -1) { return vehicles[i][1]; } } else { - if(vehicles[i][0] == toInteger(model)) { + if (vehicles[i][0] == toInteger(model)) { return vehicles[i][1]; } } @@ -1639,11 +1643,11 @@ function getSkinModelIndexFromParams(params, gameId = getGame()) { let fromName = getSkinIndexFromName(params, gameId); let fromModel = getSkinIndexFromModel(params, gameId); - if(fromModel && !fromName) { + if (fromModel && !fromName) { return fromModel; } - if(!fromModel && fromName) { + if (!fromModel && fromName) { return fromName; } @@ -1654,8 +1658,8 @@ function getSkinModelIndexFromParams(params, gameId = getGame()) { function getSkinNameFromModel(model, gameId = getGame()) { let skins = getGameConfig().skins[gameId]; - for(let i in skins) { - if(toLowerCase(skins[i][0]).indexOf(toLowerCase(model)) != -1) { + for (let i in skins) { + if (toLowerCase(skins[i][0]).indexOf(toLowerCase(model)) != -1) { return skins[i][1]; } } @@ -1666,7 +1670,7 @@ function getSkinNameFromModel(model, gameId = getGame()) { // =========================================================================== function getSkinNameFromIndex(index, gameId = getGame()) { - if(typeof getGameConfig().skins[gameId][index] != "undefined") { + if (typeof getGameConfig().skins[gameId][index] != "undefined") { return getGameConfig().skins[gameId][index][1]; } @@ -1677,8 +1681,8 @@ function getSkinNameFromIndex(index, gameId = getGame()) { function getSkinModelFromName(name, gameId = getGame()) { let skins = getGameConfig().skins[gameId]; - for(let i in skins) { - if(toLowerCase(skins[i][1]).indexOf(toLowerCase(name)) != -1) { + for (let i in skins) { + if (toLowerCase(skins[i][1]).indexOf(toLowerCase(name)) != -1) { return skins[i][0]; } } @@ -1690,11 +1694,11 @@ function getObjectModelIndexFromParams(params, gameId = getGame()) { let fromName = getObjectModelIndexFromName(params, gameId); let fromModel = getObjectModelIndexFromModel(params, gameId); - if(fromModel && !fromName) { + if (fromModel && !fromName) { return fromModel; } - if(!fromModel && fromName) { + if (!fromModel && fromName) { return fromName; } @@ -1705,8 +1709,8 @@ function getObjectModelIndexFromParams(params, gameId = getGame()) { function getObjectNameFromModel(model, gameId = getGame()) { let objects = getGameConfig().objects[gameId]; - for(let i in objects) { - if(toLowerCase(objects[i][0]).indexOf(toLowerCase(model)) != -1) { + for (let i in objects) { + if (toLowerCase(objects[i][0]).indexOf(toLowerCase(model)) != -1) { return objects[i][1]; } } @@ -1718,8 +1722,8 @@ function getObjectNameFromModel(model, gameId = getGame()) { function getObjectModelFromName(name, gameId = getGame()) { let objects = getGameConfig().objects[gameId]; - for(let i in objects) { - if(toLowerCase(objects[i][1]).indexOf(toLowerCase(name)) != -1) { + for (let i in objects) { + if (toLowerCase(objects[i][1]).indexOf(toLowerCase(name)) != -1) { return objects[i][0]; } } @@ -1728,8 +1732,8 @@ function getObjectModelFromName(name, gameId = getGame()) { // =========================================================================== function getPosToRightOfPos(pos, angle, distance) { - let x = (pos.x+((Math.cos((angle-1.57)+(Math.PI/2)))*distance)); - let y = (pos.y+((Math.sin((angle-1.57)+(Math.PI/2)))*distance)); + let x = (pos.x + ((Math.cos((angle - 1.57) + (Math.PI / 2))) * distance)); + let y = (pos.y + ((Math.sin((angle - 1.57) + (Math.PI / 2))) * distance)); let rightPos = toVector3(x, y, pos.z); @@ -1739,8 +1743,8 @@ function getPosToRightOfPos(pos, angle, distance) { // =========================================================================== function getPosToLeftOfPos(pos, angle, distance) { - let x = (pos.x+((Math.cos((angle+1.57)+(Math.PI/2)))*distance)); - let y = (pos.y+((Math.sin((angle+1.57)+(Math.PI/2)))*distance)); + let x = (pos.x + ((Math.cos((angle + 1.57) + (Math.PI / 2))) * distance)); + let y = (pos.y + ((Math.sin((angle + 1.57) + (Math.PI / 2))) * distance)); let leftPos = toVector3(x, y, pos.z); @@ -1754,18 +1758,18 @@ function getPosInFrontOfPos(pos, angle, distance) { let y = pos.y; let z = pos.z; - if(getGame() != VRR_GAME_MAFIA_ONE) { - x = (pos.x+((Math.cos(angle+(Math.PI/2)))*distance)); - y = (pos.y+((Math.sin(angle+(Math.PI/2)))*distance)); + if (getGame() != VRR_GAME_MAFIA_ONE) { + x = (pos.x + ((Math.cos(angle + (Math.PI / 2))) * distance)); + y = (pos.y + ((Math.sin(angle + (Math.PI / 2))) * distance)); } else { - while(angle < 0.0) + while (angle < 0.0) angle += 360.0; - while(angle > 360.0) + while (angle > 360.0) angle -= 360.0; - x = (pos.x+((Math.cos(angle-(Math.PI/2)))*distance)); - z = (pos.z+((Math.sin(angle+(Math.PI/2)))*distance)); + x = (pos.x + ((Math.cos(angle - (Math.PI / 2))) * distance)); + z = (pos.z + ((Math.sin(angle + (Math.PI / 2))) * distance)); } return toVector3(x, y, z); @@ -1778,14 +1782,14 @@ function getPosBehindPos(pos, angle, distance) { let y = pos.y; let z = pos.z; - if(getGame() < VRR_GAME_MAFIA_ONE) { - y = (pos.y+((Math.sin(angle-(Math.PI/2)))*distance)); + if (getGame() < VRR_GAME_MAFIA_ONE) { + y = (pos.y + ((Math.sin(angle - (Math.PI / 2))) * distance)); } else { angle = radToDeg(angle); - z = (pos.z+((Math.sin(angle-(Math.PI/2)))*distance)); + z = (pos.z + ((Math.sin(angle - (Math.PI / 2))) * distance)); } - x = (pos.x+((Math.cos(angle-(Math.PI/2)))*distance)); + x = (pos.x + ((Math.cos(angle - (Math.PI / 2))) * distance)); return toVector3(x, y, z); } @@ -1793,19 +1797,19 @@ function getPosBehindPos(pos, angle, distance) { // =========================================================================== function getPosAbovePos(pos, distance) { - return toVector3(pos.x, pos.y, pos.z+distance); + return toVector3(pos.x, pos.y, pos.z + distance); } // =========================================================================== function getPosBelowPos(pos, distance) { - return toVector3(pos.x, pos.y, pos.z-distance); + return toVector3(pos.x, pos.y, pos.z - distance); } // =========================================================================== function applyOffsetToPos(position, position2) { - return toVector3(position.x+position2.x, position.y+position2.y, position.z+position2.z); + return toVector3(position.x + position2.x, position.y + position2.y, position.z + position2.z); } // =========================================================================== @@ -1840,10 +1844,9 @@ function boolToInt(boolVal) { function fixAngle(angle) { angle = radToDeg(angle); - if(angle < 0) - { + if (angle < 0) { angle = Math.abs(angle); - angle = ((180-angle+1)+180); + angle = ((180 - angle + 1) + 180); } return degToRad(angle); } @@ -1887,8 +1890,8 @@ function radToDeg(rad) { // =========================================================================== function getHeadingFromPosToPos(pos1, pos2) { - let x = pos2.x-pos1.x; - let y = pos2.y-pos1.y; + let x = pos2.x - pos1.x; + let y = pos2.y - pos1.y; let rad = Math.atan2(y, x); let deg = radToDeg(rad); deg -= 90; @@ -1900,12 +1903,12 @@ function getHeadingFromPosToPos(pos1, pos2) { function getAngleInCircleFromCenter(center, total, current) { let gap = 360 / total; - let deg = Math.floor(gap*current); + let deg = Math.floor(gap * current); - if(deg <= 0) { + if (deg <= 0) { deg = 1; } else { - if(deg >= 360) { + if (deg >= 360) { deg = 359; } } @@ -1917,7 +1920,7 @@ function getAngleInCircleFromCenter(center, total, current) { function getArrayOfElementId(elements) { let tempArray = []; - for(let i in elements) { + for (let i in elements) { tempArray.push(elements[i].id); } @@ -1927,7 +1930,7 @@ function getArrayOfElementId(elements) { // =========================================================================== function getCurrentUnixTimestamp() { - return new Date().getTime()/1000; + return new Date().getTime() / 1000; } // =========================================================================== @@ -1953,10 +1956,10 @@ function msToTime(duration) { // =========================================================================== function generateRandomString(length, characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") { - var result = ''; + var result = ''; var charactersLength = characters.length; - for ( var i = 0; i < length; i++ ) { - result += characters.charAt(Math.floor(Math.random() * charactersLength)); + for (var i = 0; i < length; i++) { + result += characters.charAt(Math.floor(Math.random() * charactersLength)); } return result; } @@ -1964,7 +1967,7 @@ function generateRandomString(length, characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZab // =========================================================================== function doesWordStartWithVowel(word) { - switch(word.substr(0,1).toLowerCase()) { + switch (word.substr(0, 1).toLowerCase()) { case "a": case "e": case "i": @@ -1982,7 +1985,7 @@ function doesWordStartWithVowel(word) { // =========================================================================== function getProperDeterminerForName(word) { - switch(word.substr(0,1).toLowerCase()) { + switch (word.substr(0, 1).toLowerCase()) { case "a": case "e": case "i": @@ -2005,7 +2008,7 @@ function getPluralForm(name) { function removeHexColoursFromString(str) { let matchRegex = /#([a-f0-9]{3}|[a-f0-9]{4}(?:[a-f0-9]{2}){0,2})\b/gi; let matchedHexes = str.match(matchRegex); - for(let i in matchHex) { + for (let i in matchHex) { str.replace(matchedHexes, `{${i}}`); } @@ -2030,15 +2033,15 @@ async function waitUntil(condition) { // =========================================================================== function getGameLocationFromParams(params) { - if(isNaN(params)) { + if (isNaN(params)) { let locations = getGameConfig().locations[getGame()]; - for(let i in locations) { - if(toLowerCase(locations[i][0]).indexOf(toLowerCase(params)) != -1) { + for (let i in locations) { + if (toLowerCase(locations[i][0]).indexOf(toLowerCase(params)) != -1) { return i; } } } else { - if(typeof getGameConfig().locations[getGame()][params] != "undefined") { + if (typeof getGameConfig().locations[getGame()][params] != "undefined") { return toInteger(params); } } @@ -2081,12 +2084,12 @@ function breakText(text, maxLength) { let lines = []; let j = Math.floor(text.length / maxLength); - for(let i = 0; i < j; i++) { - lines.push(text.substr(i*maxLength,maxLength)); + for (let i = 0; i < j; i++) { + lines.push(text.substr(i * maxLength, maxLength)); } - let line = text.substr(j*maxLength, text.length % maxLength); - if(line.length > 0) { + let line = text.substr(j * maxLength, text.length % maxLength); + if (line.length > 0) { lines.push(line); } @@ -2096,7 +2099,7 @@ function breakText(text, maxLength) { // =========================================================================== function getSpeedFromVelocity(vel) { - return Math.sqrt(vel.x*vel.x + vel.y*vel.y + vel.z*vel.z); + return Math.sqrt(vel.x * vel.x + vel.y * vel.y + vel.z * vel.z); } // =========================================================================== @@ -2120,34 +2123,34 @@ function getCardinalDirection(pos1, pos2) { let nw = 7; let na = 8; - if(b < 0 && a < 0){ - if(x < (y/2)){ + if (b < 0 && a < 0) { + if (x < (y / 2)) { return no; - } else if(y < (x/2)){ + } else if (y < (x / 2)) { return ea; } else { return ne; } - } else if(b < 0 && a >= 0){ - if(x < (y/2)){ + } else if (b < 0 && a >= 0) { + if (x < (y / 2)) { return no; - } else if(y < (x/2)){ + } else if (y < (x / 2)) { return we; } else { return nw; } - } else if(b >= 0 && a >= 0){ - if(x < (y/2)){ + } else if (b >= 0 && a >= 0) { + if (x < (y / 2)) { return so; - } else if(y < (x/2)){ + } else if (y < (x / 2)) { return we; } else { return sw; } - } else if(b >= 0 && a < 0){ - if(x < (y/2)){ + } else if (b >= 0 && a < 0) { + if (x < (y / 2)) { return so; - } else if(y < (x/2)){ + } else if (y < (x / 2)) { return ea; } else { return se; @@ -2163,7 +2166,7 @@ function getCardinalDirection(pos1, pos2) { function getTimeDifferenceDisplay(timeStamp2, timeStamp1) { timeStamp1 = timeStamp1 * 1000; timeStamp2 = timeStamp2 * 1000; - if(isNaN(timeStamp1) || isNaN(timeStamp2)) { + if (isNaN(timeStamp1) || isNaN(timeStamp2)) { return "Unknown"; } @@ -2178,7 +2181,7 @@ function getTimeDifferenceDisplay(timeStamp2, timeStamp1) { // =========================================================================== function doesWordStartWithVowel(word) { - switch(toLowerCase(word.substr(0,1))) { + switch (toLowerCase(word.substr(0, 1))) { case "a": case "e": case "i": @@ -2196,7 +2199,7 @@ function doesWordStartWithVowel(word) { // =========================================================================== function replaceEmojiIntoString(message) { - for(let i in emojiReplaceString) { + for (let i in emojiReplaceString) { message = message.replace(emojiReplaceString[i][0], emojiReplaceString[i][1]); } return message; @@ -2209,22 +2212,22 @@ function makeReadableTime(hour, minute) { let minuteStr = toString(minute); let meridianStr = "AM"; - if(hour < 10) { + if (hour < 10) { hourStr = "0" + toString(hour); meridianStr = "AM"; } - if(hour > 11) { - let actualHour = hour-12; - if(actualHour < 10) { - hourStr = "0" + toString(hour-12); + if (hour > 11) { + let actualHour = hour - 12; + if (actualHour < 10) { + hourStr = "0" + toString(hour - 12); } else { - hourStr = toString(hour-12); + hourStr = toString(hour - 12); } meridianStr = "PM"; } - if(minute < 10) { + if (minute < 10) { minuteStr = "0" + toString(minute); } @@ -2234,14 +2237,14 @@ function makeReadableTime(hour, minute) { // =========================================================================== function getCardinalDirectionName(cardinalDirectionId) { - let cardinalDirections = ["North", "Northeast", "East", "Southeast", "South", "Southwest", "West", "Northwest", "Unknown" ]; + let cardinalDirections = ["North", "Northeast", "East", "Southeast", "South", "Southwest", "West", "Northwest", "Unknown"]; return cardinalDirections[cardinalDirectionId]; } // =========================================================================== function getWeekDayName(weekdayId) { - let weekdayNames = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ]; + let weekdayNames = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]; return weekdayNames[weekdayId]; } @@ -2260,9 +2263,9 @@ function getLockedUnlockedEmojiFromBool(boolVal) { // =========================================================================== -String.prototype.format = function() { +String.prototype.format = function () { let a = this; - for(let i in arguments) { + for (let i in arguments) { a = a.replace("{" + String(i) + "}", arguments[i]); } return a; @@ -2277,8 +2280,8 @@ function ArrayBufferToString(buffer) { // =========================================================================== function getElementTypeName(typeId) { - if(getGame() == VRR_GAME_MAFIA_ONE) { - switch(typeId) { + if (getGame() == VRR_GAME_MAFIA_ONE) { + switch (typeId) { case ELEMENT_VEHICLE: return "Vehicle"; @@ -2292,7 +2295,7 @@ function getElementTypeName(typeId) { return "Unknown" } } else { - switch(typeId) { + switch (typeId) { case ELEMENT_VEHICLE: return "Vehicle"; @@ -2330,7 +2333,7 @@ function getElementTypeName(typeId) { function fillStringWithCharacter(character, amount) { let tempString = ""; - for(let i = 0; i <= amount; i++) { + for (let i = 0; i <= amount; i++) { tempString = tempString + toString(character); } return tempString; @@ -2351,7 +2354,7 @@ function getCurrentTimeStampWithTimeZone(timeZone) { let tzDate = new Date(date.toLocaleString('en-US', { timeZone: timeZone })); let offset = utcDate.getTime() - tzDate.getTime(); - date.setTime( date.getTime() + offset ); + date.setTime(date.getTime() + offset); return date; }; @@ -2366,7 +2369,7 @@ function getSyncerFromId(syncerId) { // =========================================================================== function isConsole(client) { - if(client == null) { + if (client == null) { return false; } @@ -2395,8 +2398,8 @@ function isSamePlayer(client1, client2) { */ function getConsoleClient() { let clients = getClients(); - for(let i in clients) { - if(isConsole(clients[i])) { + for (let i in clients) { + if (isConsole(clients[i])) { return clients[i]; } } @@ -2477,11 +2480,11 @@ function getHexColourByType(typeName) { // =========================================================================== function getPlayerColour(client) { - if(getPlayerData(client) != false) { - if(!isPlayerLoggedIn(client)) { + if (getPlayerData(client) != false) { + if (!isPlayerLoggedIn(client)) { return getColourByName("darkGrey"); } else { - if(isPlayerWorking(client)) { + if (isPlayerWorking(client)) { return getJobData(getJobIndexFromDatabaseId(getPlayerCurrentSubAccount(client).job)).colour; } } @@ -2514,9 +2517,9 @@ function getBoolRedGreenInlineColour(boolValue) { */ function hexToRgb(h) { return [ - '0x'+h[1]+h[2]|0, - '0x'+h[3]+h[4]|0, - '0x'+h[5]+h[6]|0 + '0x' + h[1] + h[2] | 0, + '0x' + h[3] + h[4] | 0, + '0x' + h[5] + h[6] | 0 ]; } @@ -2532,7 +2535,7 @@ function hexToRgb(h) { * */ function rgbToHex(r, g, b) { - return "#"+((1<<24)+(r<<16)+(g<<8)+ b).toString(16).slice(1); + return "#" + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1); } // =========================================================================== @@ -2546,8 +2549,8 @@ function rgbToHex(r, g, b) { */ function getClientChatColour(client) { let tempJob = getPlayerCurrentSubAccount(client).job; - if(tempJob != -1) { - if(getPlayerData(client).isWorking) { + if (tempJob != -1) { + if (getPlayerData(client).isWorking) { return getJobData(tempJob).jobColour; } } @@ -2645,7 +2648,7 @@ function hexFromToColour(colour) { * */ function replaceColoursInMessage(messageText) { - if(messageText == null) { + if (messageText == null) { return ""; } @@ -2661,13 +2664,13 @@ function replaceColoursInMessage(messageText) { tempRegex = new RegExp(tempFind, 'g'); messageText = messageText.replace(tempRegex, "[#FFFFFF]"); - for(let i in getServerColours().hex.byName) { + for (let i in getServerColours().hex.byName) { let find = `{${i}}`; let re = new RegExp(find, 'g'); messageText = messageText.replace(re, `[#${getServerColours().hex.byName[i]}]`); } - for(let i in getServerColours().hex.byType) { + for (let i in getServerColours().hex.byType) { let find = `{${i}}`; let re = new RegExp(find, 'g'); messageText = messageText.replace(re, `[#${getServerColours().hex.byType[i]}]`); @@ -2686,15 +2689,15 @@ function replaceColoursInMessage(messageText) { * */ function removeColoursInMessage(messageText) { - if(messageText == null) { + if (messageText == null) { return ""; } - if(typeof messageText != "string") { + if (typeof messageText != "string") { return ""; } - if(messageText == "") { + if (messageText == "") { return ""; } @@ -2710,13 +2713,13 @@ function removeColoursInMessage(messageText) { tempRegex = new RegExp(tempFind, 'g'); messageText = messageText.replace(tempRegex, ""); - for(let i in getServerColours().hex.byName) { + for (let i in getServerColours().hex.byName) { let find = `{${i}}`; let re = new RegExp(find, 'g'); messageText = messageText.replace(re, ""); } - for(let i in getServerColours().hex.byType) { + for (let i in getServerColours().hex.byType) { let find = `{${i}}`; let re = new RegExp(find, 'g'); messageText = messageText.replace(re, ""); @@ -2735,8 +2738,8 @@ function removeColoursInMessage(messageText) { * */ function replaceEmojiInString(messageString) { - for(let i in emojiReplaceString) { - while(messageString.indexOf(emojiReplaceString[i][0]) != -1) { + for (let i in emojiReplaceString) { + while (messageString.indexOf(emojiReplaceString[i][0]) != -1) { messageString = messageString.replace(emojiReplaceString[i][0], emojiReplaceString[i][1]); } } @@ -2781,8 +2784,8 @@ function getPlayerLocationName(client) { function getGameAreaFromPos(position) { let areas = getGameConfig().areas[getGame()]; - for(let i in areas) { - if(isPointInPoly(areas[i].borders, position)) { + for (let i in areas) { + if (isPointInPoly(areas[i].borders, position)) { return i; } } @@ -2791,10 +2794,10 @@ function getGameAreaFromPos(position) { // =========================================================================== function isPosInPoly(poly, position) { - for(var c = false, i = -1, l = poly.length, j = l - 1; ++i < l; j = i) + for (var c = false, i = -1, l = poly.length, j = l - 1; ++i < l; j = i) ((poly[i].y <= position.y && position.y < poly[j].y) || (poly[j].y <= position.y && position.y < poly[i].y)) - && (position.x < (poly[j].x - poly[i].x) * (position[1] - poly[i].y) / (poly[j].y - poly[i].y) + poly[i].x) - && (c = !c); + && (position.x < (poly[j].x - poly[i].x) * (position[1] - poly[i].y) / (poly[j].y - poly[i].y) + poly[i].x) + && (c = !c); return c; } @@ -2805,7 +2808,7 @@ function createBitFlagTable(keyNames) { let bitTable = {}; let incVal = 1; - for(let i in keyNames) { + for (let i in keyNames) { let key = keyNames[i]; bitTable[key] = bitVal; bitVal = 1 << incVal; @@ -2817,15 +2820,15 @@ function createBitFlagTable(keyNames) { // =========================================================================== function hasBitFlag(allFlags, checkForFlag) { - if(allFlags == 0) { + if (allFlags == 0) { return false; } - if(allFlags == -1) { + if (allFlags == -1) { return true; } - if((allFlags & checkForFlag) == checkForFlag) { + if ((allFlags & checkForFlag) == checkForFlag) { return true; } diff --git a/third-party/mexui/Core/Utility.js b/third-party/mexui/Core/Utility.js index 25098920..052b4ea5 100644 --- a/third-party/mexui/Core/Utility.js +++ b/third-party/mexui/Core/Utility.js @@ -5,69 +5,58 @@ mexui.util.monthNames = ['january', 'february', 'march', 'april', 'may', 'june', mexui.util.weekDayNames = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']; // functions -mexui.util.extend = function(d, b) -{ +mexui.util.extend = function (d, b) { d.prototype = Object.create(b.prototype); d.prototype.constructor = b; }; -mexui.util.isPointInRectangle = function(point, position, size) -{ - if(!point) +mexui.util.isPointInRectangle = function (point, position, size) { + if (!point) return false; // temp bug fix - + return point.x >= position.x && point.y >= position.y && point.x <= (position.x + size.x) && point.y <= (position.y + size.y); }; -mexui.util.isCursorInRectangle = function(position, size) -{ +mexui.util.isCursorInRectangle = function (position, size) { return mexui.util.isPointInRectangle(gui.cursorPosition, position, size); }; -mexui.util.addVec2 = function(vec2a, vec2b) -{ +mexui.util.addVec2 = function (vec2a, vec2b) { return new Vec2(vec2a.x + vec2b.x, vec2a.y + vec2b.y); }; -mexui.util.subtractVec2 = function(vec2a, vec2b) -{ +mexui.util.subtractVec2 = function (vec2a, vec2b) { return new Vec2(vec2a.x - vec2b.x, vec2a.y - vec2b.y); }; -mexui.util.addVec3 = function(vec3a, vec3b) -{ +mexui.util.addVec3 = function (vec3a, vec3b) { return new Vec3(vec3a.x + vec3b.x, vec3a.y + vec3b.y, vec3a.z + vec3b.z); }; -mexui.util.createControlConstructor = function(controlName, hasEntries, constructor) -{ +mexui.util.createControlConstructor = function (controlName, hasEntries, constructor) { mexui.Control[controlName] = constructor; mexui.util.extend(mexui.Control[controlName], hasEntries ? mexui.Entity.ControlWithEntries : mexui.Component.Control); }; -mexui.util.linkBaseControlStyles = function(controlName, derivedStyles) -{ +mexui.util.linkBaseControlStyles = function (controlName, derivedStyles) { mexui.Control[controlName].defaultStyles = mexui.util.linkStyles(mexui.Component.Control.defaultStyles, derivedStyles); }; -mexui.util.linkStyles = function(baseStyles, derivedStyles) -{ +mexui.util.linkStyles = function (baseStyles, derivedStyles) { derivedStyles = derivedStyles || {}; - - for(var k in baseStyles) - { - switch(k) - { + + for (var k in baseStyles) { + switch (k) { case 'focus': case 'hover': continue; } - - if(!derivedStyles[k]) + + if (!derivedStyles[k]) derivedStyles[k] = {}; - if(!(derivedStyles[k].__proto__ instanceof Object)) + if (!(derivedStyles[k].__proto__ instanceof Object)) derivedStyles[k].__proto__ = baseStyles[k]; - + /* var hoverBaseStyles = JSON.parse(JSON.stringify(baseStyles[k])); if(!derivedStyles[k].hover) @@ -76,39 +65,33 @@ mexui.util.linkStyles = function(baseStyles, derivedStyles) derivedStyles[k].hover.__proto__ = hoverBaseStyles; */ } - + return mexui.util.linkGlobalStyles(mexui.Entity.StyleableEntity.globalDefaultStyles, derivedStyles); //return derivedStyles; }; -mexui.util.linkGlobalStyles = function(baseStyles, derivedStyles) -{ +mexui.util.linkGlobalStyles = function (baseStyles, derivedStyles) { derivedStyles = derivedStyles || {}; - - for(var k in derivedStyles) - { - switch(k) - { + + for (var k in derivedStyles) { + switch (k) { case 'focus': case 'hover': continue; } - - if(!(derivedStyles[k].__proto__ instanceof Object)) - { + + if (!(derivedStyles[k].__proto__ instanceof Object)) { derivedStyles[k].__proto__ = baseStyles.all; } } - - for(var k in derivedStyles) - { - switch(k) - { + + for (var k in derivedStyles) { + switch (k) { case 'focus': case 'hover': continue; } - + /* if(!derivedStyles[k].hasOwnProperty('hover')) { @@ -116,88 +99,72 @@ mexui.util.linkGlobalStyles = function(baseStyles, derivedStyles) derivedStyles[k].hover.__proto__ = derivedStyles[k]; } */ - - if(derivedStyles[k].focus) - { - if(!(derivedStyles[k].focus.__proto__ instanceof Object)) - { + + if (derivedStyles[k].focus) { + if (!(derivedStyles[k].focus.__proto__ instanceof Object)) { derivedStyles[k].focus.__proto__ = baseStyles.all; } - - if(derivedStyles[k].focus.hover) - { - if(!(derivedStyles[k].focus.hover.__proto__ instanceof Object)) - { + + if (derivedStyles[k].focus.hover) { + if (!(derivedStyles[k].focus.hover.__proto__ instanceof Object)) { derivedStyles[k].focus.hover.__proto__ = baseStyles.all; } } } - - if(derivedStyles[k].hover) - { - if(!(derivedStyles[k].hover.__proto__ instanceof Object)) - { + + if (derivedStyles[k].hover) { + if (!(derivedStyles[k].hover.__proto__ instanceof Object)) { derivedStyles[k].hover.__proto__ = baseStyles.all; } } } - + return derivedStyles; }; -String.prototype.repeat = function(count) -{ +String.prototype.repeat = function (count) { return Array(count + 1).join(this); }; -mexui.util.isLetter = function(character) -{ +mexui.util.isLetter = function (character) { var ord = character.charCodeAt(0); return (ord >= 65 && ord <= 90) || (ord >= 97 && ord <= 122); }; -mexui.util.isDigit = function(character) -{ +mexui.util.isDigit = function (character) { var ord = character.charCodeAt(0); return ord >= 48 && ord <= 57; }; -mexui.util.isLetterOrDigit = function(character) -{ +mexui.util.isLetterOrDigit = function (character) { return mexui.util.isLetter(character) || mexui.util.isDigit(character); }; -mexui.util.isCharacterInOctetRange = function(character, min, max) -{ +mexui.util.isCharacterInOctetRange = function (character, min, max) { var ord = character.charCodeAt(0); return ord >= min && ord <= max; }; -mexui.util.interpolateScalar = function(a, b, f) -{ +mexui.util.interpolateScalar = function (a, b, f) { return a + ((b - a) * f); }; -mexui.util.doesContainEOLChar = function(text) -{ +mexui.util.doesContainEOLChar = function (text) { return text.indexOf("\n") != -1 || text.indexOf("\r") != -1; }; -mexui.util.splitLines = function(text) -{ +mexui.util.splitLines = function (text) { text = text.replace("\r\n", "\n"); text = text.replace("\r", "\n"); return text.split("\n"); }; -mexui.util.getStringCount = function(text, find) -{ +mexui.util.getStringCount = function (text, find) { var count = 0; var index = 0; - for(;;) - { + for (; ;) { index = text.indexOf(find, index); - if(index == -1) + if (index == -1) break; count++; index += find.length; @@ -205,90 +172,76 @@ mexui.util.getStringCount = function(text, find) return count; }; -mexui.util.stack = function() -{ +mexui.util.stack = function () { var err = new Error(); console.log(err.stack); }; -mexui.util.deg = function(rad) -{ +mexui.util.deg = function (rad) { return rad * (180 / Math.PI); }; -mexui.util.rad = function(deg) -{ +mexui.util.rad = function (deg) { return deg * (Math.PI / 180); }; -mexui.util.round = function(x, n) -{ +mexui.util.round = function (x, n) { return parseFloat(Math.round(x * Math.pow(10, n)) / Math.pow(10, n)).toFixed(n); }; -mexui.util.getCenterPosition = function(largerSize, smallerSize) -{ +mexui.util.getCenterPosition = function (largerSize, smallerSize) { return new Vec2( (largerSize.x - smallerSize.x) / 2.0, (largerSize.y - smallerSize.y) / 2.0 ); }; -mexui.util.getWindowSize = function() -{ - return new Vec2(gta.width, gta.height); +mexui.util.getWindowSize = function () { + return new Vec2(game.width, game.height); }; -mexui.util.isRectangleInsideRectangle = function(pos1, size1, pos2, size2) -{ - return !(pos2.x > (pos1.x + size1.x) || - (pos2.x + size2.x) < pos1.x || - pos2.y > (pos1.y + size1.y) || - (pos2.y + size2.y) < pos1.y); +mexui.util.isRectangleInsideRectangle = function (pos1, size1, pos2, size2) { + return !(pos2.x > (pos1.x + size1.x) || + (pos2.x + size2.x) < pos1.x || + pos2.y > (pos1.y + size1.y) || + (pos2.y + size2.y) < pos1.y); }; -mexui.util.mergeStyles = function(styles, pseudoPartNames) -{ +mexui.util.mergeStyles = function (styles, pseudoPartNames) { var styles3 = {}; var styles2 = [styles]; - while(styles2[0]) - { + while (styles2[0]) { styles2 = [styles2[0]]; - for(var i in pseudoPartNames) - { + for (var i in pseudoPartNames) { var pseudoPartName = pseudoPartNames[i]; - - if(styles2[0] && styles2[0].hasOwnProperty(pseudoPartName)) + + if (styles2[0] && styles2[0].hasOwnProperty(pseudoPartName)) styles2.push(styles2[0][pseudoPartName]); } - - for(var i=styles2.length-1; i>=0; i--) - { - if(styles2[i] == null) + + for (var i = styles2.length - 1; i >= 0; i--) { + if (styles2[i] == null) continue; - - for(var k in styles2[i]) - { - switch(k) - { + + for (var k in styles2[i]) { + switch (k) { case 'focus': case 'hover': - + case 'transitionTime': case 'transitionDelay': - + case 'transitionDelayStartTime': case 'transitionStartTime': case 'transitionStarted': case 'transitionEnded': case 'transitionReverting': - + continue; } - if(styles2[i].hasOwnProperty(k) && styles3[k] == null) - { + if (styles2[i].hasOwnProperty(k) && styles3[k] == null) { var styleValue = styles2[i][k]; - + /* if(i > 0 && (styles2[i].transitionTime != null || styles2[i].transitionDelay != null)) { @@ -301,7 +254,7 @@ mexui.util.mergeStyles = function(styles, pseudoPartNames) { styles2[i].transitionEnded = true; styleValue = styles2[0][k]; - + delete styles2[i].transitionDelayStartTime; delete styles2[i].transitionStartTime; delete styles2[i].transitionStarted; @@ -348,87 +301,75 @@ mexui.util.mergeStyles = function(styles, pseudoPartNames) } } */ - + styles3[k] = styleValue; } } } - - for(var i in styles2) - { - if(styles2[i]) + + for (var i in styles2) { + if (styles2[i]) styles2[i] = styles2[i].__proto__; } } - + return styles3; }; -mexui.util.getTransitionStyles = function(styles, pseudoPartNames, progress) -{ +mexui.util.getTransitionStyles = function (styles, pseudoPartNames, progress) { var styles3 = {}; var styles2 = [styles]; - while(styles2[0]) - { + while (styles2[0]) { styles2 = [styles2[0]]; - for(var i in pseudoPartNames) - { + for (var i in pseudoPartNames) { var pseudoPartName = pseudoPartNames[i]; - - if(styles2[0] && styles2[0].hasOwnProperty(pseudoPartName)) + + if (styles2[0] && styles2[0].hasOwnProperty(pseudoPartName)) styles2.push(styles2[0][pseudoPartName]); } - - for(var i=styles2.length-1; i>=0; i--) - { - if(styles2[i] == null) + + for (var i = styles2.length - 1; i >= 0; i--) { + if (styles2[i] == null) continue; - - for(var k in styles2[i]) - { - switch(k) - { + + for (var k in styles2[i]) { + switch (k) { case 'focus': case 'hover': - + case 'transitionTime': case 'transitionDelay': - + continue; } - if(styles2[i].hasOwnProperty(k) && styles3[k] == null) - { + if (styles2[i].hasOwnProperty(k) && styles3[k] == null) { var styleValue = styles2[i][k]; - - if(i > 0) - { + + if (i > 0) { var mainStyleValue = styles2[0][k]; var pseudoStyleValue = styles2[i][k]; - + //console.log(mainStyleValue+' '+pseudoStyleValue); - + styleValue = mexui.util.interpolateStyle(k, progress, mainStyleValue, pseudoStyleValue); } - + styles3[k] = styleValue; } } } - - for(var i in styles2) - { - if(styles2[i]) + + for (var i in styles2) { + if (styles2[i]) styles2[i] = styles2[i].__proto__; } } - + return styles3; }; -mexui.util.interpolateStyle = function(styleName, progress, styleValueFrom, styleValueTo) -{ - switch(styleName) - { +mexui.util.interpolateStyle = function (styleName, progress, styleValueFrom, styleValueTo) { + switch (styleName) { case 'backgroundColour': case 'backgroundColor': case 'textColour': @@ -437,9 +378,9 @@ mexui.util.interpolateStyle = function(styleName, progress, styleValueFrom, styl case 'lineColor': case 'borderColour': case 'borderColor': - if(styleValueFrom == 'none') + if (styleValueFrom == 'none') styleValueFrom = toColour(255, 255, 255, 0); - if(styleValueTo == 'none') + if (styleValueTo == 'none') styleValueTo = toColour(255, 255, 255, 0); return mexui.util.interpolateColour(progress, styleValueFrom, styleValueTo); default: @@ -447,25 +388,21 @@ mexui.util.interpolateStyle = function(styleName, progress, styleValueFrom, styl } }; -mexui.util.interpolateColour = function(progress, styleValueFrom, styleValueTo) -{ +mexui.util.interpolateColour = function (progress, styleValueFrom, styleValueTo) { var rgbFrom = mexui.util.fromColour(styleValueFrom); var rgbTo = mexui.util.fromColour(styleValueTo); var rgba = []; - for(var i=0; i<4; i++) - { + for (var i = 0; i < 4; i++) { rgba[i] = mexui.util.interpolateScalar(progress, rgbFrom[i], rgbTo[i]); } return toColour.apply(null, rgba); }; -mexui.util.interpolateScalar = function(progress, valueFrom, valueTo) -{ +mexui.util.interpolateScalar = function (progress, valueFrom, valueTo) { return valueFrom + ((valueTo - valueFrom) * progress); }; -mexui.util.fromColour = function(colour) -{ +mexui.util.fromColour = function (colour) { return [ (colour >> 16) & 0xFF, (colour >> 8) & 0xFF, @@ -474,77 +411,64 @@ mexui.util.fromColour = function(colour) ]; }; -mexui.util.time = function() -{ - return gta.tickCount; +mexui.util.time = function () { + return sdl.ticks; }; -mexui.util.isIntChar = function(character) -{ +mexui.util.isIntChar = function (character) { return mexui.util.isPositiveIntChar(character); }; -mexui.util.isPositiveIntChar = function(character) -{ +mexui.util.isPositiveIntChar = function (character) { return mexui.util.isDigit(character) || character == '-' || character == '+' || character == 'e' || character == 'E'; }; -mexui.util.isFloatChar = function(character) -{ +mexui.util.isFloatChar = function (character) { return mexui.util.isIntChar(character) || character == '.'; }; -mexui.util.isPositiveFloatChar = function(character) -{ +mexui.util.isPositiveFloatChar = function (character) { return mexui.util.isPositiveIntChar(character) || character == '.'; }; -mexui.util.isInt = function(str) -{ +mexui.util.isInt = function (str) { var strInt = parseInt(str); - return !isNaN(strInt) && str.length == (strInt+'').length; + return !isNaN(strInt) && str.length == (strInt + '').length; }; -mexui.util.isPositiveInt = function(str) -{ +mexui.util.isPositiveInt = function (str) { var strInt = parseInt(str); - return !isNaN(strInt) && strInt >= 0 && str.length == (strInt+'').length; + return !isNaN(strInt) && strInt >= 0 && str.length == (strInt + '').length; }; -mexui.util.isFloat = function(str) -{ +mexui.util.isFloat = function (str) { var strFloat = parseFloat(str); var firstDot = str.indexOf('.'); var addOffset = (str.substr(str.length - 2, 2) == '.0' && firstDot == (str.length - 2)) ? 2 : 0; - if(firstDot == 0) + if (firstDot == 0) addOffset--; - return !isNaN(strFloat) && str.length == ((strFloat+'').length + addOffset); + return !isNaN(strFloat) && str.length == ((strFloat + '').length + addOffset); }; -mexui.util.isPositiveFloat = function(str) -{ +mexui.util.isPositiveFloat = function (str) { var strFloat = parseFloat(str); var firstDot = str.indexOf('.'); var addOffset = (str.substr(str.length - 2, 2) == '.0' && firstDot == (str.length - 2)) ? 2 : 0; - if(firstDot == 0) + if (firstDot == 0) addOffset--; - return !isNaN(strFloat) && strFloat >= 0.0 && str.length == ((strFloat+'').length + addOffset); + return !isNaN(strFloat) && strFloat >= 0.0 && str.length == ((strFloat + '').length + addOffset); }; -mexui.util.isMonthName = function(text) -{ +mexui.util.isMonthName = function (text) { return mexui.util.inArrayOrStartsWithInArray(text, mexui.util.monthNames, 3); }; -mexui.util.isWeekDayName = function(text) -{ +mexui.util.isWeekDayName = function (text) { return mexui.util.inArrayOrStartsWithInArray(text, mexui.util.weekDayNames, 3); }; -mexui.util.isDayIdSuffix = function(text) -{ - switch(text.toLowerCase()) - { +mexui.util.isDayIdSuffix = function (text) { + switch (text.toLowerCase()) { case 'st': case 'nd': case 'rd': @@ -554,151 +478,129 @@ mexui.util.isDayIdSuffix = function(text) return false; }; -mexui.util.isDayIdSuffixForDayId = function(dayId, text) -{ - switch(text.toLowerCase()) - { - case 'st': return dayId == 1 || dayId == 21 || dayId == 31; - case 'nd': return dayId == 2 || dayId == 22; - case 'rd': return dayId == 3 || dayId == 23; - case 'th': return !(dayId >= 1 && dayId <= 3) && !(dayId >= 21 && dayId <= 23) && dayId != 31; - default: return false; +mexui.util.isDayIdSuffixForDayId = function (dayId, text) { + switch (text.toLowerCase()) { + case 'st': return dayId == 1 || dayId == 21 || dayId == 31; + case 'nd': return dayId == 2 || dayId == 22; + case 'rd': return dayId == 3 || dayId == 23; + case 'th': return !(dayId >= 1 && dayId <= 3) && !(dayId >= 21 && dayId <= 23) && dayId != 31; + default: return false; } }; -mexui.util.isDayId = function(text) -{ - if(text.length == 2 && text.substr(0, 1) == '0') +mexui.util.isDayId = function (text) { + if (text.length == 2 && text.substr(0, 1) == '0') text = text.substr(1); - - if(mexui.util.isPositiveInt(text)) - { + + if (mexui.util.isPositiveInt(text)) { var _int = parseInt(text); - if(_int >= 1 && _int <= 31) + if (_int >= 1 && _int <= 31) return true; } - + return false; }; -mexui.util.isDayIdWithOptionalSuffix = function(text) -{ - if(mexui.util.isDayId(text)) +mexui.util.isDayIdWithOptionalSuffix = function (text) { + if (mexui.util.isDayId(text)) return true; - - if(text.length > 2) - { + + if (text.length > 2) { var last2Chars = text.substr(text.length - 2, 2); - if(mexui.util.isDayIdSuffix(last2Chars)) - { + if (mexui.util.isDayIdSuffix(last2Chars)) { var textWithoutLast2Chars = text.substr(0, text.length - 2); - if(mexui.util.isDayId(textWithoutLast2Chars) && mexui.util.isDayIdSuffixForDayId(parseInt(textWithoutLast2Chars), last2Chars)) - { + if (mexui.util.isDayId(textWithoutLast2Chars) && mexui.util.isDayIdSuffixForDayId(parseInt(textWithoutLast2Chars), last2Chars)) { return true; } } } - + return false; }; -mexui.util.inArrayOrStartsWithInArray = function(text, arr, startsWithCharCount) -{ +mexui.util.inArrayOrStartsWithInArray = function (text, arr, startsWithCharCount) { text = text.toLowerCase(); - - for(var i in arr) - { - if(text === arr[i]) - { + + for (var i in arr) { + if (text === arr[i]) { return true; } } - - if(text.length == startsWithCharCount) - { - for(var i in arr) - { - if(text === arr[i].substr(0, startsWithCharCount)) - { + + if (text.length == startsWithCharCount) { + for (var i in arr) { + if (text === arr[i].substr(0, startsWithCharCount)) { return true; } } } - + return false; }; -mexui.util.isMonthIdOrName = function(text) -{ +mexui.util.isMonthIdOrName = function (text) { var text2 = text; - if(text2.length == 2 && text2.substr(0, 1) == '0') + if (text2.length == 2 && text2.substr(0, 1) == '0') text2 = text2.substr(1); - - if(mexui.util.isPositiveInt(text2)) - { + + if (mexui.util.isPositiveInt(text2)) { var _int = parseInt(text2); - if(_int >= 1 && _int <= 12) + if (_int >= 1 && _int <= 12) return true; } - + return mexui.util.isMonthName(text); }; -mexui.util.isWeekDayId = function(text) -{ +mexui.util.isWeekDayId = function (text) { var text2 = text; - if(text2.length == 2 && text2.substr(0, 1) == '0') + if (text2.length == 2 && text2.substr(0, 1) == '0') text2 = text2.substr(1); - - if(mexui.util.isPositiveInt(text2)) - { + + if (mexui.util.isPositiveInt(text2)) { var _int = parseInt(text2); - if(_int >= 1 && _int <= 7) + if (_int >= 1 && _int <= 7) return true; } - + return false; }; -mexui.util.isWeekDayIdOrName = function(text) -{ +mexui.util.isWeekDayIdOrName = function (text) { var text2 = text; - if(text2.length == 2 && text2.substr(0, 1) == '0') + if (text2.length == 2 && text2.substr(0, 1) == '0') text2 = text2.substr(1); - - if(mexui.util.isPositiveInt(text2)) - { + + if (mexui.util.isPositiveInt(text2)) { var _int = parseInt(text2); - if(_int >= 1 && _int <= 7) + if (_int >= 1 && _int <= 7) return true; } - + return mexui.util.isWeekDayName(text); }; -mexui.util.expand2DigitYear = function(year, twoDigitYearCapOffset) -{ +mexui.util.expand2DigitYear = function (year, twoDigitYearCapOffset) { var currentFullYear = new Date().getFullYear(); - var currentTwoDigitYearPlusCapOffset = parseInt((currentFullYear+'').substr(2, 2)) + twoDigitYearCapOffset; - if(year <= currentTwoDigitYearPlusCapOffset) + var currentTwoDigitYearPlusCapOffset = parseInt((currentFullYear + '').substr(2, 2)) + twoDigitYearCapOffset; + if (year <= currentTwoDigitYearPlusCapOffset) year += currentFullYear - (currentFullYear % 100); else year += (currentFullYear - (currentFullYear % 100)) - 100; return year; }; -mexui.util.isYear = function(text, minYear, maxYear, twoDigitYearCapOffset) -{ +mexui.util.isYear = function (text, minYear, maxYear, twoDigitYearCapOffset) { var _int = parseInt(text); - - if(isNaN(_int)) + + if (isNaN(_int)) return false; - - if(_int >= 0 && _int <= 99) + + if (_int >= 0 && _int <= 99) _int = mexui.util.expand2DigitYear(_int, twoDigitYearCapOffset); - - if(_int < minYear || _int > maxYear) + + if (_int < minYear || _int > maxYear) return false; - + return true; }; \ No newline at end of file diff --git a/third-party/mexui/mexui.js b/third-party/mexui/mexui.js index 12d736d9..186c3bf8 100644 --- a/third-party/mexui/mexui.js +++ b/third-party/mexui/mexui.js @@ -1,92 +1,78 @@ var mexui = {}; // data initialization -mexui.Entity = {}; -mexui.Component = {}; -mexui.Control = {}; -mexui.Entry = {}; +mexui.Entity = {}; +mexui.Component = {}; +mexui.Control = {}; +mexui.Entry = {}; -mexui.windows = []; +mexui.windows = []; -mexui.fonts = {}; -mexui.images = {}; +mexui.fonts = {}; +mexui.images = {}; -mexui.focusedControl = null; -mexui.hoveredComponent = null; +mexui.focusedControl = null; +mexui.hoveredComponent = null; // initialization -mexui.init = function() -{ +mexui.init = function () { mexui.native.loadImage('mexui/Images/down-arrow.png', 'downArrow'); mexui.bindEvents(); mexui.startTimers(); }; // events -mexui.bindEvents = function() -{ - addEventHandler('onMouseDown', function(event, mouse, button) - { - var e = mexui.triggerEvent('onMouseDown', {button: button}); - if(!e.clickedAControl) - { +mexui.bindEvents = function () { + addEventHandler('onMouseDown', function (event, mouse, button) { + var e = mexui.triggerEvent('onMouseDown', { button: button }); + if (!e.clickedAControl) { mexui.focusedControl = null; } }); - addEventHandler('onMouseUp', function(event, mouse, button) - { - mexui.triggerEvent('onMouseUp', {button: button}); + addEventHandler('onMouseUp', function (event, mouse, button) { + mexui.triggerEvent('onMouseUp', { button: button }); }); - addEventHandler('onMouseMove', function(event, mouse, isAbsolute, position) - { - if(isAbsolute) + addEventHandler('onMouseMove', function (event, mouse, isAbsolute, position) { + if (isAbsolute) return; - + mexui.triggerEvent('onMouseMove', new Vec2(position.x, position.y), true); }); - addEventHandler('onMouseWheel', function(event, mouse, offset, flipped) - { + addEventHandler('onMouseWheel', function (event, mouse, offset, flipped) { mexui.triggerEvent('onMouseWheel', offset); }); - addEventHandler('onKeyDown', function(event, key, pkey, mods) - { + addEventHandler('onKeyDown', function (event, key, pkey, mods) { mexui.triggerEvent('onKeyDown', key, mods); - - if(key == SDLK_TAB) - { + + if (key == SDLK_TAB) { mexui.cycleFocusedControl(); } }); - addEventHandler('onCharacter', function(event, character) - { + addEventHandler('onCharacter', function (event, character) { mexui.triggerEvent('onCharacter', character); - - if(character == 't' || character == 'T') - { + + if (character == 't' || character == 'T') { var textInput = mexui.getFocusedTextInput(); - if(textInput) - { + if (textInput) { //event.preventDefault(); } } }); - + { - var eventName = gta.game == GAME_GTA_SA ? 'onDrawnHUD' : 'onBeforeDrawHUD'; - addEventHandler(eventName, function(event) - { + var eventName = (game.game == VRR_GAME_GTA_SA || game.game == VRR_GAME_MAFIA_ONE) ? 'onDrawnHUD' : 'onBeforeDrawHUD'; + addEventHandler(eventName, function (event) { mexui.render(); }); } }; -mexui.unbindEvents = function() -{ +mexui.unbindEvents = function () { removeEventHandler('onMouseDown'); removeEventHandler('onMouseUp'); removeEventHandler('onMouseMove'); @@ -97,62 +83,51 @@ mexui.unbindEvents = function() }; // timers -mexui.startTimers = function() -{ +mexui.startTimers = function () { setInterval(mexui.toggleTextInputCaretShownForBlink, 400); }; // render -mexui.render = function() -{ - for(var i in mexui.windows) - { - if(mexui.windows[i].shown) +mexui.render = function () { + for (var i in mexui.windows) { + if (mexui.windows[i].shown) mexui.windows[i].render.call(mexui.windows[i]); } - for(var i in mexui.windows) - { - if(mexui.windows[i].shown) + for (var i in mexui.windows) { + if (mexui.windows[i].shown) mexui.windows[i].renderAfter.call(mexui.windows[i]); } }; // model -mexui.triggerEvent = function(eventName, data, callBaseMethodFirst) -{ +mexui.triggerEvent = function (eventName, data, callBaseMethodFirst) { var e = new mexui.Component.Event(); - - if(data.button !== undefined) + + if (data.button !== undefined) e.button = data.button; - + var windows = mexui.windows.slice(0, mexui.windows.length).reverse(); - for(var i in windows) - { - if(windows[i].shown) - { - if(callBaseMethodFirst) - { - if(mexui.Entity.Component.prototype[eventName]) - { + for (var i in windows) { + if (windows[i].shown) { + if (callBaseMethodFirst) { + if (mexui.Entity.Component.prototype[eventName]) { mexui.Entity.Component.prototype[eventName].call(windows[i], e, data); - if(e.used) + if (e.used) break; } - + windows[i][eventName].call(windows[i], e, data); - if(e.used) + if (e.used) break; } - else - { + else { windows[i][eventName].call(windows[i], e, data); - if(e.used) + if (e.used) break; - - if(mexui.Entity.Component.prototype[eventName]) - { + + if (mexui.Entity.Component.prototype[eventName]) { mexui.Entity.Component.prototype[eventName].call(windows[i], e, data); - if(e.used) + if (e.used) break; } } @@ -161,141 +136,122 @@ mexui.triggerEvent = function(eventName, data, callBaseMethodFirst) return e; }; -mexui.getTopWindow = function() -{ - for(var i = mexui.windows.length - 1, j = 0; i >= j; i--) - { - if(mexui.windows[i].shown) +mexui.getTopWindow = function () { + for (var i = mexui.windows.length - 1, j = 0; i >= j; i--) { + if (mexui.windows[i].shown) return mexui.windows[i]; } return null; }; -mexui.getShownWindows = function() -{ +mexui.getShownWindows = function () { var shownWindows = []; - for(var i = mexui.windows.length - 1, j = 0; i >= j; i--) - { - if(mexui.windows[i].shown) + for (var i = mexui.windows.length - 1, j = 0; i >= j; i--) { + if (mexui.windows[i].shown) shownWindows.push(mexui.windows[i]); } return shownWindows; }; -mexui.getNextShownWindows = function(afterWindow) -{ +mexui.getNextShownWindows = function (afterWindow) { var shownWindows = mexui.getShownWindows(); - + var windowIndex = shownWindows.indexOf(afterWindow); - + var windows2 = shownWindows.splice(0, windowIndex + 1); var args = windows2; args.unshift(0); args.unshift(shownWindows.length); shownWindows.splice.apply(shownWindows, args); - + return shownWindows; }; -mexui.cycleFocusedControl = function() -{ +mexui.cycleFocusedControl = function () { // no windows are created - if(mexui.windows.length == 0) + if (mexui.windows.length == 0) return; - + // no control is focused - if(!mexui.focusedControl) - { + if (!mexui.focusedControl) { var topWindow = mexui.getTopWindow(); - if(!topWindow) + if (!topWindow) return; - + mexui.focusedControl = topWindow.getFirstShownControl(); return; } - + // a control is focused var focusedControlWindow = mexui.focusedControl.window; var nextControl = focusedControlWindow.getNextShownControl(mexui.focusedControl); - if(nextControl) - { + if (nextControl) { mexui.focusedControl = nextControl; return; } - + // set focus to first control on next window that has a control shown var shownWindows = mexui.getNextShownWindows(focusedControlWindow); - for(var i in shownWindows) - { + for (var i in shownWindows) { var window = shownWindows[i]; var firstControl = window.getFirstShownControl(); - if(firstControl) - { + if (firstControl) { mexui.focusedControl = firstControl; return; } } }; -mexui.getFocusedTextInput = function() -{ - if(!mexui.focusedControl) +mexui.getFocusedTextInput = function () { + if (!mexui.focusedControl) return null; - - if(!(mexui.focusedControl instanceof mexui.Control.TextInput)) + + if (!(mexui.focusedControl instanceof mexui.Control.TextInput)) return null; - + return mexui.focusedControl; }; -mexui.toggleTextInputCaretShownForBlink = function() -{ +mexui.toggleTextInputCaretShownForBlink = function () { var textInput = mexui.getFocusedTextInput(); - if(!textInput) + if (!textInput) return; - + textInput.caretShownForBlink = !textInput.caretShownForBlink; }; -mexui.setHoveredComponent = function(component) -{ +mexui.setHoveredComponent = function (component) { //component.hovered = true; mexui.hoveredComponent = component; }; -mexui.clearHoveredComponent = function() -{ +mexui.clearHoveredComponent = function () { //mexui.hoveredComponent.hovered = false; mexui.hoveredComponent = null; }; // api -mexui.window = function(x, y, w, h, title, styles) -{ +mexui.window = function (x, y, w, h, title, styles) { var window = new mexui.Component.Window(x, y, w, h, title, styles); mexui.windows.push(window); return window; }; -mexui.isAnyWindowShown = function() -{ - for(var i in mexui.windows) - { - if(mexui.windows[i].shown) +mexui.isAnyWindowShown = function () { + for (var i in mexui.windows) { + if (mexui.windows[i].shown) return true; } return false; }; -mexui.setInput = function(showInput) -{ +mexui.setInput = function (showInput) { gui.showCursor(showInput, !showInput); - if(localClient.player && gta.game != GAME_GTA_IV) - { - if(showInput) - gta.setCameraLookAtEntity(new Vec3(gta.cameraMatrix.m41, gta.cameraMatrix.m42, gta.cameraMatrix.m43), localPlayer, false); + + if (localClient.player && game.game >= GAME_GTA_IV) { + if (showInput) + game.setCameraLookAtEntity(new Vec3(game.cameraMatrix.m41, game.cameraMatrix.m42, game.cameraMatrix.m43), localPlayer, false); else - gta.restoreCamera(false); + game.restoreCamera(false); } }; -