Merge branch 'nightly' into non-server-elements

This commit is contained in:
Vortrex
2022-06-14 05:57:21 -05:00
35 changed files with 5469 additions and 5423 deletions

View File

@@ -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");
}
}

View File

@@ -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));
}
// ===========================================================================

View File

@@ -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();
}
// ===========================================================================

View File

@@ -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");

View File

@@ -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();
}