Merge branch 'nightly' into non-server-elements
This commit is contained in:
@@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -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");
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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);
|
||||
|
||||
|
||||
@@ -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.<SubAccountData>} 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"]);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -1223,3 +1224,12 @@ function showLocaleChooserForPlayer(client) {
|
||||
}
|
||||
|
||||
// ==========================================================================
|
||||
|
||||
function sendPlayerLocaleStrings(client) {
|
||||
let strings = getGlobalConfig().locale.sendStringsToClient;
|
||||
for (let i in strings) {
|
||||
sendNetworkEventToPlayer("vrr.localeString", client, strings[i], getLocaleString(client, strings[i]));
|
||||
}
|
||||
}
|
||||
|
||||
// ==========================================================================
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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");
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -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`);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -839,3 +839,52 @@ function lockCommand(command, params, client) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -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();
|
||||
}
|
||||
});
|
||||
@@ -1369,3 +1369,11 @@ function setElementShownByDefault(element, state) {
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function createAttachedGameBlip(element, type, size, colour = toColour(255, 255, 255, 255)) {
|
||||
if (isGameFeatureSupported("attachedBlips")) {
|
||||
return game.createBlipAttachedTo(element, type, size, colour, true, false);
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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();
|
||||
|
||||
@@ -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 <id> 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);
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
378
third-party/mexui/Core/Utility.js
vendored
378
third-party/mexui/Core/Utility.js
vendored
@@ -5,67 +5,56 @@ 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];
|
||||
|
||||
/*
|
||||
@@ -81,29 +70,23 @@ mexui.util.linkStyles = function(baseStyles, 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;
|
||||
@@ -117,26 +100,20 @@ mexui.util.linkGlobalStyles = function(baseStyles, derivedStyles)
|
||||
}
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -145,59 +122,49 @@ mexui.util.linkGlobalStyles = function(baseStyles, derivedStyles)
|
||||
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,72 +172,59 @@ 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)
|
||||
{
|
||||
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);
|
||||
(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':
|
||||
|
||||
@@ -285,8 +239,7 @@ mexui.util.mergeStyles = function(styles, pseudoPartNames)
|
||||
|
||||
continue;
|
||||
}
|
||||
if(styles2[i].hasOwnProperty(k) && styles3[k] == null)
|
||||
{
|
||||
if (styles2[i].hasOwnProperty(k) && styles3[k] == null) {
|
||||
var styleValue = styles2[i][k];
|
||||
|
||||
/*
|
||||
@@ -354,9 +307,8 @@ mexui.util.mergeStyles = function(styles, pseudoPartNames)
|
||||
}
|
||||
}
|
||||
|
||||
for(var i in styles2)
|
||||
{
|
||||
if(styles2[i])
|
||||
for (var i in styles2) {
|
||||
if (styles2[i])
|
||||
styles2[i] = styles2[i].__proto__;
|
||||
}
|
||||
}
|
||||
@@ -364,30 +316,24 @@ mexui.util.mergeStyles = function(styles, pseudoPartNames)
|
||||
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':
|
||||
|
||||
@@ -396,12 +342,10 @@ mexui.util.getTransitionStyles = function(styles, pseudoPartNames, progress)
|
||||
|
||||
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];
|
||||
|
||||
@@ -415,9 +359,8 @@ mexui.util.getTransitionStyles = function(styles, pseudoPartNames, progress)
|
||||
}
|
||||
}
|
||||
|
||||
for(var i in styles2)
|
||||
{
|
||||
if(styles2[i])
|
||||
for (var i in styles2) {
|
||||
if (styles2[i])
|
||||
styles2[i] = styles2[i].__proto__;
|
||||
}
|
||||
}
|
||||
@@ -425,10 +368,8 @@ mexui.util.getTransitionStyles = function(styles, pseudoPartNames, progress)
|
||||
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,46 +478,38 @@ 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;
|
||||
}
|
||||
}
|
||||
@@ -602,24 +518,18 @@ mexui.util.isDayIdWithOptionalSuffix = function(text)
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -628,76 +538,68 @@ mexui.util.inArrayOrStartsWithInArray = function(text, arr, startsWithCharCount)
|
||||
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;
|
||||
|
||||
196
third-party/mexui/mexui.js
vendored
196
third-party/mexui/mexui.js
vendored
@@ -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,29 +136,24 @@ 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);
|
||||
@@ -197,17 +167,15 @@ mexui.getNextShownWindows = function(afterWindow)
|
||||
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();
|
||||
@@ -217,85 +185,73 @@ mexui.cycleFocusedControl = function()
|
||||
// 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);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user