Merge branch 'nightly' into non-server-elements
This commit is contained in:
@@ -40,13 +40,13 @@ function initChangePasswordGUI() {
|
|||||||
passwordChange.window.titleBarHeight = 0;
|
passwordChange.window.titleBarHeight = 0;
|
||||||
passwordChange.window.titleBarShown = false;
|
passwordChange.window.titleBarShown = false;
|
||||||
|
|
||||||
passwordChange.window.image(85, -10, 140, 140, mainLogoPath, {
|
passwordChange.window.image(100, 20, 75, 75, mainLogoPath, {
|
||||||
focused: {
|
focused: {
|
||||||
borderColour: toColour(0, 0, 0, 0),
|
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: {
|
main: {
|
||||||
textSize: 10.0,
|
textSize: 10.0,
|
||||||
textAlign: 0.5,
|
textAlign: 0.5,
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ function initResetPasswordGUI() {
|
|||||||
});
|
});
|
||||||
passwordReset.emailInput.placeholder = "Email";
|
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: {
|
main: {
|
||||||
backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha),
|
backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha),
|
||||||
textColour: toColour(primaryTextColour[0], primaryTextColour[1], primaryTextColour[2], 255),
|
textColour: toColour(primaryTextColour[0], primaryTextColour[1], primaryTextColour[2], 255),
|
||||||
@@ -141,7 +141,7 @@ function showResetPasswordGUI() {
|
|||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
function checkResetPassword() {
|
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]);
|
sendNetworkEventToServer("vrr.checkResetPassword", passwordReset.emailInput.lines[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,7 +162,7 @@ function resetPasswordCodeInputGUI() {
|
|||||||
|
|
||||||
passwordReset.messageLabel.text = getLocaleString("GUIResetPasswordCodeInputLabel");
|
passwordReset.messageLabel.text = getLocaleString("GUIResetPasswordCodeInputLabel");
|
||||||
//passwordReset.messageLabel.styles.main.textColour = toColour(180, 32, 32, 255);
|
//passwordReset.messageLabel.styles.main.textColour = toColour(180, 32, 32, 255);
|
||||||
passwordReset.emailInput.text = "";
|
passwordReset.emailInput.lines[0] = "";
|
||||||
passwordReset.emailInput.placeholder = getLocaleString("GUIResetPasswordCodePlaceholder");
|
passwordReset.emailInput.placeholder = getLocaleString("GUIResetPasswordCodePlaceholder");
|
||||||
|
|
||||||
guiSubmitKey = checkResetPassword;
|
guiSubmitKey = checkResetPassword;
|
||||||
|
|||||||
@@ -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");
|
|
||||||
@@ -202,6 +202,7 @@ function setLocalPlayerInterior(interior) {
|
|||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (areServerElementsSupported() && isGameFeatureSupported("interior")) {
|
||||||
let vehicles = getElementsByType(ELEMENT_VEHICLE);
|
let vehicles = getElementsByType(ELEMENT_VEHICLE);
|
||||||
for (let i in vehicles) {
|
for (let i in vehicles) {
|
||||||
if (getEntityData(vehicles[i], "vrr.interior")) {
|
if (getEntityData(vehicles[i], "vrr.interior")) {
|
||||||
@@ -209,6 +210,7 @@ function setLocalPlayerInterior(interior) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
|
|||||||
@@ -801,9 +801,10 @@ function createAccount(name, password, email = "") {
|
|||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
function checkLogin(client, password) {
|
async function checkLogin(client, password) {
|
||||||
getPlayerData(client).loginAttemptsRemaining = getPlayerData(client).loginAttemptsRemaining - 1;
|
getPlayerData(client).loginAttemptsRemaining = getPlayerData(client).loginAttemptsRemaining - 1;
|
||||||
if (getPlayerData(client).loginAttemptsRemaining <= 0) {
|
if (getPlayerData(client).loginAttemptsRemaining <= 0) {
|
||||||
|
getPlayerData(client).customDisconnectReason = "Kicked - Failed to login";
|
||||||
disconnectPlayer(client);
|
disconnectPlayer(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -840,9 +841,10 @@ 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.`);
|
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"))) {
|
// Disabling email login alerts for now. It hangs the server for a couple seconds. Need a way to thread it.
|
||||||
sendAccountLoginFailedNotification(getPlayerData(client).accountData.emailAddress, getPlayerName(client), getPlayerIP(client), getGame());
|
//if (isAccountEmailVerified(getPlayerData(client).accountData) && !isAccountSettingFlagEnabled(getPlayerData(client).accountData, getAccountSettingsFlagValue("AuthAttemptAlert"))) {
|
||||||
}
|
// await sendAccountLoginFailedNotification(getPlayerData(client).accountData.emailAddress, getPlayerName(client), getPlayerIP(client), getGame());
|
||||||
|
//}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -856,9 +858,10 @@ 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.`);
|
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"))) {
|
// Disabling email login alerts for now. It hangs the server for a couple seconds. Need a way to thread it.
|
||||||
sendAccountLoginFailedNotification(getPlayerData(client).accountData.emailAddress, getPlayerName(client), getPlayerIP(client), getGame());
|
//if (isAccountEmailVerified(getPlayerData(client).accountData) && !isAccountSettingFlagEnabled(getPlayerData(client).accountData, getAccountSettingsFlagValue("AuthAttemptAlert"))) {
|
||||||
}
|
// await sendAccountLoginFailedNotification(getPlayerData(client).accountData.emailAddress, getPlayerName(client), getPlayerIP(client), getGame());
|
||||||
|
//}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -875,9 +878,10 @@ function checkLogin(client, password) {
|
|||||||
|
|
||||||
loginSuccess(client);
|
loginSuccess(client);
|
||||||
|
|
||||||
if(isAccountEmailVerified(getPlayerData(client).accountData) && !isAccountSettingFlagEnabled(getPlayerData(client).accountData, getAccountSettingsFlagValue("AuthAttemptAlert"))) {
|
// Disabling email login alerts for now. It hangs the server for a couple seconds. Need a way to thread it.
|
||||||
sendAccountLoginSuccessNotification(getPlayerData(client).accountData.emailAddress, getPlayerName(client), getPlayerIP(client), getGame());
|
//if (isAccountEmailVerified(getPlayerData(client).accountData) && !isAccountSettingFlagEnabled(getPlayerData(client).accountData, getAccountSettingsFlagValue("AuthAttemptAlert"))) {
|
||||||
}
|
// await sendAccountLoginSuccessNotification(getPlayerData(client).accountData.emailAddress, getPlayerName(client), getPlayerIP(client), getGame());
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
@@ -984,6 +988,7 @@ function checkRegistration(client, password, confirmPassword = "", emailAddress
|
|||||||
|
|
||||||
if (doesServerHaveTesterOnlyEnabled() && !isPlayerATester(client)) {
|
if (doesServerHaveTesterOnlyEnabled() && !isPlayerATester(client)) {
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
|
getPlayerData(client).customDisconnectReason = "Kicked - Not a tester";
|
||||||
disconnectPlayer(client);
|
disconnectPlayer(client);
|
||||||
}, 5000);
|
}, 5000);
|
||||||
|
|
||||||
@@ -1029,22 +1034,23 @@ function checkAccountResetPasswordRequest(client, inputText) {
|
|||||||
getPlayerData(client).passwordResetCode = passwordResetCode;
|
getPlayerData(client).passwordResetCode = passwordResetCode;
|
||||||
showPlayerResetPasswordCodeInputGUI(client);
|
showPlayerResetPasswordCodeInputGUI(client);
|
||||||
sendPasswordResetEmail(client, passwordResetCode);
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case VRR_RESETPASS_STATE_CODEINPUT: {
|
case VRR_RESETPASS_STATE_CODEINPUT: {
|
||||||
|
logToConsole(LOG_INFO, `${getPlayerDisplayForConsole(client)} submitted code for password reset (${inputText}) ...`);
|
||||||
if (inputText != "") {
|
if (inputText != "") {
|
||||||
if (getPlayerData(client).passwordResetCode == toUpperCase(inputText)) {
|
if (getPlayerData(client).passwordResetCode == toUpperCase(inputText)) {
|
||||||
getPlayerData(client).passwordResetState = VRR_RESETPASS_STATE_SETPASS;
|
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 ...`);
|
logToConsole(LOG_INFO, `${getPlayerDisplayForConsole(client)} entered the correct reset password verification code. Awaiting new password input ...`);
|
||||||
} else {
|
} else {
|
||||||
getPlayerData(client).passwordResetState = VRR_RESETPASS_STATE_NONE;
|
|
||||||
getPlayerData(client).passwordResetAttemptsRemaining = getPlayerData(client).passwordResetAttemptsRemaining - 1;
|
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)`);
|
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) {
|
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, no more attempts remaining, kicking ...)`);
|
||||||
|
getPlayerData(client).customDisconnectReason = "Kicked - Failed to login";
|
||||||
disconnectPlayer(client);
|
disconnectPlayer(client);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -1191,8 +1197,8 @@ function initClient(client) {
|
|||||||
sendPlayerGUIInit(client);
|
sendPlayerGUIInit(client);
|
||||||
updatePlayerSnowState(client);
|
updatePlayerSnowState(client);
|
||||||
|
|
||||||
logToConsole(LOG_DEBUG, `[VRR.Account] Showing connect camera to ${getPlayerDisplayForConsole(client)} ...`);
|
//logToConsole(LOG_DEBUG, `[VRR.Account] Showing connect camera to ${getPlayerDisplayForConsole(client)} ...`);
|
||||||
showConnectCameraToPlayer(client);
|
//showConnectCameraToPlayer(client);
|
||||||
|
|
||||||
messageClient(`Please wait ...`, client, getColourByName("softGreen"));
|
messageClient(`Please wait ...`, client, getColourByName("softGreen"));
|
||||||
|
|
||||||
@@ -1248,8 +1254,6 @@ function initClient(client) {
|
|||||||
|
|
||||||
getServerData().clients[getPlayerId(client)].keyBinds = loadAccountKeybindsFromDatabase(getServerData().clients[getPlayerId(client)].accountData.databaseId);
|
getServerData().clients[getPlayerId(client)].keyBinds = loadAccountKeybindsFromDatabase(getServerData().clients[getPlayerId(client)].accountData.databaseId);
|
||||||
sendAccountKeyBindsToClient(client);
|
sendAccountKeyBindsToClient(client);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}, 2500);
|
}, 2500);
|
||||||
@@ -1523,7 +1527,7 @@ function sendAccountLoginFailedNotification(emailAddress, name, ip, game = getGa
|
|||||||
emailBodyText = emailBodyText.replace("{IPADDRESS}", ip);
|
emailBodyText = emailBodyText.replace("{IPADDRESS}", ip);
|
||||||
emailBodyText = emailBodyText.replace("{LOCATION}", `${cityName}, ${subDivisionName}, ${countryName}`);
|
emailBodyText = emailBodyText.replace("{LOCATION}", `${cityName}, ${subDivisionName}, ${countryName}`);
|
||||||
emailBodyText = emailBodyText.replace("{SERVERNAME}", getServerName());
|
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 failed on ${getServerName()}`, emailBodyText);
|
||||||
return true;
|
return true;
|
||||||
@@ -1541,9 +1545,9 @@ function sendAccountLoginSuccessNotification(emailAddress, name, ip, game = getG
|
|||||||
emailBodyText = emailBodyText.replace("{IPADDRESS}", ip);
|
emailBodyText = emailBodyText.replace("{IPADDRESS}", ip);
|
||||||
emailBodyText = emailBodyText.replace("{LOCATION}", `${cityName}, ${subDivisionName}, ${countryName}`);
|
emailBodyText = emailBodyText.replace("{LOCATION}", `${cityName}, ${subDivisionName}, ${countryName}`);
|
||||||
emailBodyText = emailBodyText.replace("{SERVERNAME}", getServerName());
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1569,6 +1573,7 @@ function checkPlayerTwoFactorAuthentication(client, authCode) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getPlayerData(client).customDisconnectReason = "Kicked - Failed to login";
|
||||||
disconnectPlayer(client);
|
disconnectPlayer(client);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,9 +37,11 @@ function accountBanCommand(command, params, client) {
|
|||||||
|
|
||||||
logToConsole(LOG_WARN, `[VRR.Ban]: ${getPlayerDisplayForConsole(targetClient)} (${getPlayerData(targetClient).accountData.name}) account was banned by ${getPlayerDisplayForConsole(client)}. Reason: ${reason}`);
|
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);
|
banAccount(getPlayerData(targetClient).accountData.databaseId, getPlayerData(client).accountData.databaseId, reason);
|
||||||
disconnectPlayer(client);
|
|
||||||
|
getPlayerData(targetClient).customDisconnectReason = `Banned - ${reason}`;
|
||||||
|
disconnectPlayer(targetClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
@@ -67,10 +69,11 @@ function subAccountBanCommand(command, params, client, fromDiscord) {
|
|||||||
|
|
||||||
logToConsole(LOG_WARN, `[VRR.Ban]: ${getPlayerDisplayForConsole(targetClient)} (${getPlayerData(targetClient).accountData.name})'s subaccount was banned by ${getPlayerDisplayForConsole(client)}. Reason: ${reason}`);
|
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);
|
banSubAccount(getPlayerData(targetClient).currentSubAccountData.databaseId, getPlayerData(client).accountData.databaseId, reason);
|
||||||
|
|
||||||
disconnectPlayer(client);
|
getPlayerData(targetClient).customDisconnectReason = `Banned - ${reason}`;
|
||||||
|
disconnectPlayer(targetClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
@@ -99,6 +102,7 @@ function ipBanCommand(command, params, client, fromDiscord) {
|
|||||||
announceAdminAction(`PlayerIPBanned`, `{ALTCOLOUR}${getPlayerName(targetClient)}{MAINCOLOUR}`);
|
announceAdminAction(`PlayerIPBanned`, `{ALTCOLOUR}${getPlayerName(targetClient)}{MAINCOLOUR}`);
|
||||||
banIPAddress(getPlayerIP(targetClient), getPlayerData(client).accountData.databaseId, reason);
|
banIPAddress(getPlayerIP(targetClient), getPlayerData(client).accountData.databaseId, reason);
|
||||||
|
|
||||||
|
getPlayerData(targetClient).customDisconnectReason = `IP Banned - ${reason}`;
|
||||||
serverBanIP(getPlayerIP(targetClient));
|
serverBanIP(getPlayerIP(targetClient));
|
||||||
disconnectPlayer(targetClient);
|
disconnectPlayer(targetClient);
|
||||||
}
|
}
|
||||||
@@ -130,6 +134,7 @@ function subNetBanCommand(command, params, client, fromDiscord) {
|
|||||||
announceAdminAction(`PlayerSubNetBanned`, `{ALTCOLOUR}${getPlayerName(client)}{MAINCOLOUR}`);
|
announceAdminAction(`PlayerSubNetBanned`, `{ALTCOLOUR}${getPlayerName(client)}{MAINCOLOUR}`);
|
||||||
banSubNet(getPlayerIP(targetClient), getSubNet(getPlayerIP(targetClient), octetAmount), getPlayerData(client).accountData.databaseId, reason);
|
banSubNet(getPlayerIP(targetClient), getSubNet(getPlayerIP(targetClient), octetAmount), getPlayerData(client).accountData.databaseId, reason);
|
||||||
|
|
||||||
|
getPlayerData(client).customDisconnectReason = `IP Subnet Banned - ${reason}`;
|
||||||
serverBanIP(getPlayerIP(targetClient));
|
serverBanIP(getPlayerIP(targetClient));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ function loadBusinessesFromDatabase() {
|
|||||||
let dbAssoc;
|
let dbAssoc;
|
||||||
|
|
||||||
if (dbConnection) {
|
if (dbConnection) {
|
||||||
dbQuery = queryDatabase(dbConnection, `SELECT * FROM biz_main WHERE biz_server = ${getServerId()}`);
|
dbQuery = queryDatabase(dbConnection, `SELECT * FROM biz_main WHERE biz_deleted = 0 AND biz_server = ${getServerId()}`);
|
||||||
if (dbQuery) {
|
if (dbQuery) {
|
||||||
if (dbQuery.numRows > 0) {
|
if (dbQuery.numRows > 0) {
|
||||||
while (dbAssoc = fetchQueryAssoc(dbQuery)) {
|
while (dbAssoc = fetchQueryAssoc(dbQuery)) {
|
||||||
@@ -1606,6 +1606,10 @@ function isPlayerInAnyBusiness(client) {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function getPlayerBusiness(client) {
|
function getPlayerBusiness(client) {
|
||||||
|
if (getServerData().businesses.length == 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (getPlayerDimension(client) == getGameConfig().mainWorldDimension[getGame()]) {
|
if (getPlayerDimension(client) == getGameConfig().mainWorldDimension[getGame()]) {
|
||||||
let closestEntrance = getClosestBusinessEntrance(getPlayerPosition(client), getPlayerDimension(client));
|
let closestEntrance = getClosestBusinessEntrance(getPlayerPosition(client), getPlayerDimension(client));
|
||||||
if (getDistance(getPlayerPosition(client), getBusinessData(closestEntrance).entrancePosition) <= getGlobalConfig().enterPropertyDistance) {
|
if (getDistance(getPlayerPosition(client), getBusinessData(closestEntrance).entrancePosition) <= getGlobalConfig().enterPropertyDistance) {
|
||||||
@@ -1738,6 +1742,10 @@ function createAllBusinessPickups() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isGameFeatureSupported("pickups")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
for (let i in getServerData().businesses) {
|
for (let i in getServerData().businesses) {
|
||||||
createBusinessEntrancePickup(i);
|
createBusinessEntrancePickup(i);
|
||||||
createBusinessExitPickup(i);
|
createBusinessExitPickup(i);
|
||||||
@@ -1760,6 +1768,10 @@ function createAllBusinessBlips() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isGameFeatureSupported("blips")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
for (let i in getServerData().businesses) {
|
for (let i in getServerData().businesses) {
|
||||||
createBusinessEntranceBlip(i);
|
createBusinessEntranceBlip(i);
|
||||||
createBusinessExitBlip(i);
|
createBusinessExitBlip(i);
|
||||||
@@ -1784,6 +1796,10 @@ function createBusinessEntrancePickup(businessId) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isGameFeatureSupported("pickups")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
let businessData = getBusinessData(businessId);
|
let businessData = getBusinessData(businessId);
|
||||||
|
|
||||||
//if(businessData.hasInterior) {
|
//if(businessData.hasInterior) {
|
||||||
@@ -1844,10 +1860,18 @@ function createBusinessEntrancePickup(businessId) {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function createBusinessEntranceBlip(businessId) {
|
function createBusinessEntranceBlip(businessId) {
|
||||||
|
if (!areServerElementsSupported()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!getServerConfig().createBusinessBlips) {
|
if (!getServerConfig().createBusinessBlips) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isGameFeatureSupported("blips")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
let businessData = getBusinessData(businessId);
|
let businessData = getBusinessData(businessId);
|
||||||
|
|
||||||
//if(businessData.hasInterior) {
|
//if(businessData.hasInterior) {
|
||||||
@@ -1906,6 +1930,10 @@ function createBusinessExitPickup(businessId) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isGameFeatureSupported("pickups")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
let businessData = getBusinessData(businessId);
|
let businessData = getBusinessData(businessId);
|
||||||
|
|
||||||
//if(!businessData.hasInterior) {
|
//if(!businessData.hasInterior) {
|
||||||
@@ -1963,6 +1991,10 @@ function createBusinessExitBlip(businessId) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isGameFeatureSupported("blips")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
let businessData = getBusinessData(businessId);
|
let businessData = getBusinessData(businessId);
|
||||||
|
|
||||||
//if(!businessData.hasInterior) {
|
//if(!businessData.hasInterior) {
|
||||||
@@ -2010,7 +2042,7 @@ function createBusinessExitBlip(businessId) {
|
|||||||
* @return {Boolean} Whether or not the business was deleted
|
* @return {Boolean} Whether or not the business was deleted
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function deleteBusiness(businessId, deletedBy = 0) {
|
function deleteBusiness(businessId, whoDeleted = 0) {
|
||||||
let tempBusinessData = getServerData().businesses[businessId];
|
let tempBusinessData = getServerData().businesses[businessId];
|
||||||
|
|
||||||
let dbConnection = connectToDatabase();
|
let dbConnection = connectToDatabase();
|
||||||
@@ -2020,7 +2052,7 @@ function deleteBusiness(businessId, deletedBy = 0) {
|
|||||||
deleteBusinessPickups(businessId);
|
deleteBusinessPickups(businessId);
|
||||||
|
|
||||||
if (dbConnection) {
|
if (dbConnection) {
|
||||||
dbQuery = queryDatabase(dbConnection, `DELETE FROM biz_main WHERE biz_id = ${tempBusinessData.databaseId}`);
|
dbQuery = queryDatabase(dbConnection, `UPDATE biz_main WHERE biz_deleted = 1, biz_when_deleted = UNIX_TIMESTAMP(), biz_who_deleted = ${whoDeleted} WHERE biz_id ${tempBusinessData.databaseId}`);
|
||||||
if (dbQuery) {
|
if (dbQuery) {
|
||||||
freeDatabaseQuery(dbQuery);
|
freeDatabaseQuery(dbQuery);
|
||||||
}
|
}
|
||||||
@@ -2160,6 +2192,10 @@ function deleteBusinessEntrancePickup(businessId) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isGameFeatureSupported("pickups")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (getBusinessData(businessId).entrancePickup != null) {
|
if (getBusinessData(businessId).entrancePickup != null) {
|
||||||
//removeFromWorld(getBusinessData(businessId).entrancePickup);
|
//removeFromWorld(getBusinessData(businessId).entrancePickup);
|
||||||
deleteGameElement(getBusinessData(businessId).entrancePickup);
|
deleteGameElement(getBusinessData(businessId).entrancePickup);
|
||||||
@@ -2183,6 +2219,10 @@ function deleteBusinessExitPickup(businessId) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isGameFeatureSupported("pickups")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (getBusinessData(businessId).exitPickup != null) {
|
if (getBusinessData(businessId).exitPickup != null) {
|
||||||
//removeFromWorld(getBusinessData(businessId).exitPickup);
|
//removeFromWorld(getBusinessData(businessId).exitPickup);
|
||||||
deleteGameElement(getBusinessData(businessId).exitPickup);
|
deleteGameElement(getBusinessData(businessId).exitPickup);
|
||||||
@@ -2202,6 +2242,10 @@ function deleteBusinessEntranceBlip(businessId) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isGameFeatureSupported("blips")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (getBusinessData(businessId).entranceBlip != null) {
|
if (getBusinessData(businessId).entranceBlip != null) {
|
||||||
//removeFromWorld(getBusinessData(businessId).entranceBlip);
|
//removeFromWorld(getBusinessData(businessId).entranceBlip);
|
||||||
deleteGameElement(getBusinessData(businessId).entranceBlip);
|
deleteGameElement(getBusinessData(businessId).entranceBlip);
|
||||||
@@ -2221,6 +2265,10 @@ function deleteBusinessExitBlip(businessId) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isGameFeatureSupported("blip")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (getBusinessData(businessId).exitBlip != null) {
|
if (getBusinessData(businessId).exitBlip != null) {
|
||||||
//removeFromWorld(getBusinessData(businessId).exitBlip);
|
//removeFromWorld(getBusinessData(businessId).exitBlip);
|
||||||
deleteGameElement(getBusinessData(businessId).exitBlip);
|
deleteGameElement(getBusinessData(businessId).exitBlip);
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ function removeClanRank(clanId, rankId) {
|
|||||||
return false;
|
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);
|
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}`);
|
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();
|
//saveAllClansToDatabase();
|
||||||
|
|
||||||
let dbConnection = connectToDatabase();
|
let dbConnection = connectToDatabase();
|
||||||
if(dbConnection) {
|
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);
|
freeDatabaseQuery(dbQuery);
|
||||||
disconnectFromDatabase(dbConnection);
|
disconnectFromDatabase(dbConnection);
|
||||||
|
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ class ServerConfigData {
|
|||||||
money: dbAssoc["svr_newchar_money"],
|
money: dbAssoc["svr_newchar_money"],
|
||||||
bank: dbAssoc["svr_newchar_bank"],
|
bank: dbAssoc["svr_newchar_bank"],
|
||||||
skin: dbAssoc["svr_newchar_skin"],
|
skin: dbAssoc["svr_newchar_skin"],
|
||||||
},
|
};
|
||||||
|
|
||||||
this.connectCameraPosition = toVector3(dbAssoc["svr_connectcam_pos_x"], dbAssoc["svr_connectcam_pos_y"], dbAssoc["svr_connectcam_pos_z"]);
|
this.connectCameraPosition = toVector3(dbAssoc["svr_connectcam_pos_x"], dbAssoc["svr_connectcam_pos_y"], dbAssoc["svr_connectcam_pos_z"]);
|
||||||
this.connectCameraLookAt = toVector3(dbAssoc["svr_connectcam_lookat_x"], dbAssoc["svr_connectcam_lookat_y"], dbAssoc["svr_connectcam_lookat_z"]);
|
this.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.createJobBlips = intToBool(toInteger(dbAssoc["svr_job_blips"]));
|
||||||
this.createBusinessBlips = intToBool(toInteger(dbAssoc["svr_biz_blips"]));
|
this.createBusinessBlips = intToBool(toInteger(dbAssoc["svr_biz_blips"]));
|
||||||
this.createHouseBlips = intToBool(toInteger(dbAssoc["svr_house_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.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.guiColourSecondary = [toInteger(dbAssoc["svr_gui_col2_r"]), toInteger(dbAssoc["svr_gui_col2_g"]), toInteger(dbAssoc["svr_gui_col2_b"])];
|
||||||
this.guiTextColourPrimary = [toInteger(dbAssoc["svr_gui_textcol1_r"]), toInteger(dbAssoc["svr_gui_textcol1_g"]), toInteger(dbAssoc["svr_gui_textcol1_b"])];
|
this.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 {
|
class ClientData {
|
||||||
constructor(client, accountData, subAccounts) {
|
constructor(client, accountData, subAccounts) {
|
||||||
|
/** @member {AccountData} accountData */
|
||||||
this.accountData = accountData;
|
this.accountData = accountData;
|
||||||
|
|
||||||
|
/** @member {Array.<SubAccountData>} subAccounts */
|
||||||
this.subAccounts = subAccounts; // Characters
|
this.subAccounts = subAccounts; // Characters
|
||||||
|
|
||||||
this.client = client;
|
this.client = client;
|
||||||
this.currentSubAccount = -1;
|
this.currentSubAccount = -1;
|
||||||
this.loggedIn = false;
|
this.loggedIn = false;
|
||||||
@@ -239,6 +244,7 @@ class ClientData {
|
|||||||
this.incomingDamageMultiplier = 1;
|
this.incomingDamageMultiplier = 1;
|
||||||
this.weaponDamageEvent = VRR_WEAPON_DAMAGE_EVENT_NORMAL;
|
this.weaponDamageEvent = VRR_WEAPON_DAMAGE_EVENT_NORMAL;
|
||||||
|
|
||||||
|
// Animation
|
||||||
this.currentAnimation = -1;
|
this.currentAnimation = -1;
|
||||||
this.currentAnimationPositionOffset = false;
|
this.currentAnimationPositionOffset = false;
|
||||||
this.currentAnimationPositionReturnTo = false;
|
this.currentAnimationPositionReturnTo = false;
|
||||||
@@ -247,16 +253,13 @@ class ClientData {
|
|||||||
|
|
||||||
this.passwordResetState = VRR_RESETPASS_STATE_NONE;
|
this.passwordResetState = VRR_RESETPASS_STATE_NONE;
|
||||||
this.passwordResetCode = "";
|
this.passwordResetCode = "";
|
||||||
|
|
||||||
this.lastJobVehicle = null;
|
this.lastJobVehicle = null;
|
||||||
this.health = 100;
|
this.health = 100;
|
||||||
this.locale = 0;
|
this.locale = 0;
|
||||||
|
|
||||||
this.enteringVehicle = null;
|
this.enteringVehicle = null;
|
||||||
|
|
||||||
this.customDisconnectReason = "";
|
this.customDisconnectReason = "";
|
||||||
|
|
||||||
this.interiorCutscene = -1;
|
this.interiorCutscene = -1;
|
||||||
|
this.playerBlip = null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -275,15 +278,14 @@ class AccountData {
|
|||||||
};
|
};
|
||||||
this.staffTitle = "";
|
this.staffTitle = "";
|
||||||
this.ircAccount = "";
|
this.ircAccount = "";
|
||||||
this.discordAccount = 0,
|
this.discordAccount = 0;
|
||||||
this.settings = 0,
|
this.settings = 0;
|
||||||
this.emailAddress = "";
|
this.emailAddress = "";
|
||||||
this.ipAddress = 0,
|
this.ipAddress = 0;
|
||||||
|
|
||||||
this.notes = [];
|
this.notes = [];
|
||||||
this.messages = [];
|
this.messages = [];
|
||||||
this.contacts = [];
|
this.contacts = [];
|
||||||
this.subAccounts = [];
|
|
||||||
|
|
||||||
this.emailVerificationCode = "";
|
this.emailVerificationCode = "";
|
||||||
this.twoFactorAuthVerificationCode = "";
|
this.twoFactorAuthVerificationCode = "";
|
||||||
|
|||||||
@@ -135,6 +135,7 @@ function playerClientStarted(client) {
|
|||||||
|
|
||||||
function playerClientStopped(client) {
|
function playerClientStopped(client) {
|
||||||
logToConsole(LOG_DEBUG, `[VRR.Client] ${getPlayerDisplayForConsole(client)}'s client resources have stopped (possibly error?). Kicking them from the server ...`);
|
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);
|
disconnectPlayer(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -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,
|
houseBlipStreamOutDistance: 120,
|
||||||
jobBlipStreamInDistance: -1,
|
jobBlipStreamInDistance: -1,
|
||||||
jobBlipStreamOutDistance: -1,
|
jobBlipStreamOutDistance: -1,
|
||||||
|
playerBlipStreamInDistance: -1,
|
||||||
|
playerBlipStreamOutDistance: -1,
|
||||||
handcuffPlayerDistance: 3,
|
handcuffPlayerDistance: 3,
|
||||||
firstAidKitPlayerDistance: 3,
|
firstAidKitPlayerDistance: 3,
|
||||||
|
droppedItemPickupRange: 2,
|
||||||
passwordRequiredCapitals: 0,
|
passwordRequiredCapitals: 0,
|
||||||
passwordRequiredNumbers: 0,
|
passwordRequiredNumbers: 0,
|
||||||
passwordRequiredSymbols: 0,
|
passwordRequiredSymbols: 0,
|
||||||
@@ -261,7 +264,7 @@ function saveServerConfigToDatabase() {
|
|||||||
["svr_inflation_multiplier", getServerConfig().inflationMultiplier],
|
["svr_inflation_multiplier", getServerConfig().inflationMultiplier],
|
||||||
["svr_intro_music", getServerConfig().introMusicURL],
|
["svr_intro_music", getServerConfig().introMusicURL],
|
||||||
["svr_gui", getServerConfig().useGUI],
|
["svr_gui", getServerConfig().useGUI],
|
||||||
["svr_logo", getServerConfig().useLogo],
|
["svr_logo", getServerConfig().showLogo],
|
||||||
["svr_snow_falling", getServerConfig().fallingSnow],
|
["svr_snow_falling", getServerConfig().fallingSnow],
|
||||||
["svr_snow_ground", getServerConfig().groundSnow],
|
["svr_snow_ground", getServerConfig().groundSnow],
|
||||||
["svr_biz_blips", getServerConfig().createBusinessBlips],
|
["svr_biz_blips", getServerConfig().createBusinessBlips],
|
||||||
@@ -650,7 +653,7 @@ function toggleServerGUICommand(command, params, client) {
|
|||||||
|
|
||||||
getServerConfig().needsSaved = true;
|
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();
|
updateServerRules();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ function messageDiscordChatChannel(messageString) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
messageString = removeColoursInMessage(messageString);
|
messageString = removeColoursInMessage(messageString);
|
||||||
triggerWebHook(messageString, getServerId(), VRR_DISCORD_WEBHOOK_LOG);
|
triggerDiscordWebHook(messageString, getServerId(), VRR_DISCORD_WEBHOOK_LOG);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
@@ -121,7 +121,7 @@ function messageDiscordEventChannel(messageString) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
messageString = removeColoursInMessage(messageString);
|
messageString = removeColoursInMessage(messageString);
|
||||||
triggerWebHook(messageString, getServerId(), VRR_DISCORD_WEBHOOK_LOG);
|
triggerDiscordWebHook(messageString, getServerId(), VRR_DISCORD_WEBHOOK_LOG);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
@@ -140,7 +140,31 @@ function messageDiscordAdminChannel(messageString) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
messageString = removeColoursInMessage(messageString);
|
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) {
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
@@ -31,19 +31,19 @@ function playerPayDay(client) {
|
|||||||
let grossIncome = getPlayerData(client).payDayAmount;
|
let grossIncome = getPlayerData(client).payDayAmount;
|
||||||
|
|
||||||
// Passive income
|
// Passive income
|
||||||
grossIncome = grossIncome + getGlobalConfig().economy.passiveIncomePerPayDay;
|
grossIncome = Math.round(grossIncome + getGlobalConfig().economy.passiveIncomePerPayDay);
|
||||||
|
|
||||||
// Payday bonus
|
// Payday bonus
|
||||||
grossIncome = grossIncome*getGlobalConfig().economy.grossIncomeMultiplier;
|
grossIncome = Math.round(grossIncome * getGlobalConfig().economy.grossIncomeMultiplier);
|
||||||
|
|
||||||
// Double bonus
|
// Double bonus
|
||||||
if (isDoubleBonusActive()) {
|
if (isDoubleBonusActive()) {
|
||||||
grossIncome = grossIncome*2;
|
grossIncome = Math.round(grossIncome * 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
let incomeTaxAmount = Math.round(calculateIncomeTax(wealth));
|
let incomeTaxAmount = Math.round(calculateIncomeTax(wealth));
|
||||||
|
|
||||||
let netIncome = grossIncome-incomeTaxAmount;
|
let netIncome = Math.round(grossIncome - incomeTaxAmount);
|
||||||
|
|
||||||
messagePlayerAlert(client, "== Payday! =============================");
|
messagePlayerAlert(client, "== Payday! =============================");
|
||||||
messagePlayerInfo(client, `Paycheck: {ALTCOLOUR}$${grossIncome}`);
|
messagePlayerInfo(client, `Paycheck: {ALTCOLOUR}$${grossIncome}`);
|
||||||
@@ -167,7 +167,7 @@ function attemptRepossession(client, totalToPay) {
|
|||||||
function repossessFirstAsset(client) {
|
function repossessFirstAsset(client) {
|
||||||
let vehicles = getAllVehiclesOwnedByPlayer(client);
|
let vehicles = getAllVehiclesOwnedByPlayer(client);
|
||||||
if (vehicles.length > 0) {
|
if (vehicles.length > 0) {
|
||||||
deleteVehicle(vehicles[0])
|
deleteVehicle(vehicles[0]);
|
||||||
return getGlobalConfig().economy.upKeepCosts.upKeepPerVehicle;
|
return getGlobalConfig().economy.upKeepCosts.upKeepPerVehicle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,11 +14,12 @@ function initEmailScript() {
|
|||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
function sendEmail(toEmail, toName, subject, body) {
|
async function sendEmail(toEmail, toName, subject, body) {
|
||||||
if (!checkForSMTPModule()) {
|
if (!checkForSMTPModule()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Promise.resolve().then(() => {
|
||||||
module.smtp.send(
|
module.smtp.send(
|
||||||
getEmailConfig().smtp.host,
|
getEmailConfig().smtp.host,
|
||||||
getEmailConfig().smtp.port,
|
getEmailConfig().smtp.port,
|
||||||
@@ -30,7 +31,9 @@ function sendEmail(toEmail, toName, subject, body) {
|
|||||||
subject,
|
subject,
|
||||||
body,
|
body,
|
||||||
getEmailConfig().smtp.from,
|
getEmailConfig().smtp.from,
|
||||||
getEmailConfig().smtp.fromName);
|
getEmailConfig().smtp.fromName
|
||||||
|
);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|||||||
@@ -109,9 +109,11 @@ function onPlayerQuit(event, client, quitReasonId) {
|
|||||||
updateConnectionLogOnQuit(client, quitReasonId);
|
updateConnectionLogOnQuit(client, quitReasonId);
|
||||||
|
|
||||||
let reasonText = disconnectReasons[quitReasonId];
|
let reasonText = disconnectReasons[quitReasonId];
|
||||||
if(getPlayerData(client).customDisconnectReason != "" && getPlayerData(client).customDisconnectReason != undefined && getPlayerData(client).customDisconnectReason != false && getPlayerData(client).customDisconnectReason != null) {
|
if (getPlayerData(client) != false) {
|
||||||
|
if (getPlayerData(client).customDisconnectReason != "") {
|
||||||
reasonText = getPlayerData(client).customDisconnectReason;
|
reasonText = getPlayerData(client).customDisconnectReason;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
messageDiscordEventChannel(`👋 ${getPlayerName(client)} has left the server (${reasonText})`);
|
messageDiscordEventChannel(`👋 ${getPlayerName(client)} has left the server (${reasonText})`);
|
||||||
|
|
||||||
@@ -420,6 +422,7 @@ function onPlayerDeath(client, position) {
|
|||||||
updatePlayerSpawnedState(client, true);
|
updatePlayerSpawnedState(client, true);
|
||||||
makePlayerStopAnimation(client);
|
makePlayerStopAnimation(client);
|
||||||
setPlayerControlState(client, true);
|
setPlayerControlState(client, true);
|
||||||
|
resetPlayerBlip(client);
|
||||||
} else {
|
} else {
|
||||||
let closestHospital = getClosestHospital(getPlayerPosition(client));
|
let closestHospital = getClosestHospital(getPlayerPosition(client));
|
||||||
despawnPlayer(client);
|
despawnPlayer(client);
|
||||||
@@ -443,6 +446,7 @@ function onPlayerDeath(client, position) {
|
|||||||
updatePlayerSpawnedState(client, true);
|
updatePlayerSpawnedState(client, true);
|
||||||
makePlayerStopAnimation(client);
|
makePlayerStopAnimation(client);
|
||||||
setPlayerControlState(client, true);
|
setPlayerControlState(client, true);
|
||||||
|
resetPlayerBlip(client);
|
||||||
}
|
}
|
||||||
}, 2000);
|
}, 2000);
|
||||||
}, 1000);
|
}, 1000);
|
||||||
@@ -455,7 +459,7 @@ function onPlayerDeath(client, position) {
|
|||||||
["log_death_pos_y", position.y],
|
["log_death_pos_y", position.y],
|
||||||
["log_death_pos_z", position.x],
|
["log_death_pos_z", position.x],
|
||||||
];
|
];
|
||||||
let queryString = createDatabaseInsertQuery("log_death", data);
|
let queryString = createDatabaseInsertQuery("log_death", queryData);
|
||||||
addToQueryQueue(queryString);
|
addToQueryQueue(queryString);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -470,19 +474,23 @@ function onPedSpawn(ped) {
|
|||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
function onPlayerSpawn(client) {
|
async function onPlayerSpawn(client) {
|
||||||
logToConsole(LOG_DEBUG, `[VRR.Event] Checking for ${getPlayerDisplayForConsole(client)}'s player ped`);
|
//logToConsole(LOG_DEBUG, `[VRR.Event] Checking for ${getPlayerDisplayForConsole(client)}'s player ped`);
|
||||||
//if(getPlayerPed(client) == null) {
|
//if(getPlayerPed(client) == null) {
|
||||||
// logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)}'s player element not set yet. Rechecking ...`);
|
// logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)}'s player element not set yet. Rechecking ...`);
|
||||||
// setTimeout(onPlayerSpawn, 500, client);
|
// setTimeout(onPlayerSpawn, 500, client);
|
||||||
// return false;
|
// 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`);
|
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.`);
|
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);
|
disconnectPlayer(client);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -490,6 +498,7 @@ function onPlayerSpawn(client) {
|
|||||||
logToConsole(LOG_DEBUG, `[VRR.Event] Checking ${getPlayerDisplayForConsole(client)}'s login status`);
|
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.`);
|
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);
|
disconnectPlayer(client);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -497,6 +506,7 @@ function onPlayerSpawn(client) {
|
|||||||
logToConsole(LOG_DEBUG, `[VRR.Event] Checking ${getPlayerDisplayForConsole(client)}'s selected character status`);
|
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.`);
|
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);
|
disconnectPlayer(client);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -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, "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"));
|
//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}`);
|
logToConsole(LOG_DEBUG, `[VRR.Event] Setting player interior for ${getPlayerDisplayForConsole(client)} to ${getPlayerCurrentSubAccount(client).interior}`);
|
||||||
setPlayerInterior(client, getPlayerCurrentSubAccount(client).interior);
|
setPlayerInterior(client, getPlayerCurrentSubAccount(client).interior);
|
||||||
|
|
||||||
@@ -638,6 +654,8 @@ function onPlayerSpawn(client) {
|
|||||||
|
|
||||||
getPlayerData(client).payDayTickStart = sdl.ticks;
|
getPlayerData(client).payDayTickStart = sdl.ticks;
|
||||||
|
|
||||||
|
//sendPlayerLocaleStrings(client);
|
||||||
|
|
||||||
// Stop playing intro music and any other radio
|
// Stop playing intro music and any other radio
|
||||||
stopRadioStreamForPlayer(client);
|
stopRadioStreamForPlayer(client);
|
||||||
|
|
||||||
@@ -654,6 +672,8 @@ function onPlayerSpawn(client) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resetPlayerBlip(client)
|
||||||
|
|
||||||
messageDiscordEventChannel(`🧍 ${getPlayerName(client)} spawned as ${getCharacterFullName(client)}`);
|
messageDiscordEventChannel(`🧍 ${getPlayerName(client)} spawned as ${getCharacterFullName(client)}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ function playerPromptAnswerNo(client) {
|
|||||||
case VRR_PROMPT_CREATEFIRSTCHAR:
|
case VRR_PROMPT_CREATEFIRSTCHAR:
|
||||||
logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)} chose not to create a first character. Kicking them from the server ...`);
|
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");
|
showPlayerErrorGUI(client, "You don't have a character to play. Goodbye!", "No Characters");
|
||||||
|
getPlayerData(targetClient).customDisconnectReason = `Kicked - Didn't create a character`;
|
||||||
setTimeout(function () { disconnectPlayer(client); }, 5000);
|
setTimeout(function () { disconnectPlayer(client); }, 5000);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ function loadHousesFromDatabase() {
|
|||||||
let dbAssoc;
|
let dbAssoc;
|
||||||
|
|
||||||
if (dbConnection) {
|
if (dbConnection) {
|
||||||
let dbQuery = queryDatabase(dbConnection, `SELECT * FROM house_main WHERE house_server = ${getServerId()}`);
|
let dbQuery = queryDatabase(dbConnection, `SELECT * FROM house_main WHERE house_deleted = 0 AND house_server = ${getServerId()}`);
|
||||||
if (dbQuery) {
|
if (dbQuery) {
|
||||||
if (dbQuery.numRows > 0) {
|
if (dbQuery.numRows > 0) {
|
||||||
while (dbAssoc = fetchQueryAssoc(dbQuery)) {
|
while (dbAssoc = fetchQueryAssoc(dbQuery)) {
|
||||||
@@ -544,7 +544,7 @@ function deleteHouse(houseId, whoDeleted = 0) {
|
|||||||
let dbQuery = null;
|
let dbQuery = null;
|
||||||
|
|
||||||
if (dbConnection) {
|
if (dbConnection) {
|
||||||
dbQuery = queryDatabase(dbConnection, `DELETE FROM house_main WHERE house_id = ${tempHouseData.databaseId}`);
|
dbQuery = queryDatabase(dbConnection, `UPDATE house_main SET house_deleted = 1, house_when_deleted = UNIX_TIMESTAMP(), house_who_deleted = ${whoDeleted} WHERE house_id = ${tempHouseData.databaseId}`);
|
||||||
if (dbQuery) {
|
if (dbQuery) {
|
||||||
freeDatabaseQuery(dbQuery);
|
freeDatabaseQuery(dbQuery);
|
||||||
}
|
}
|
||||||
@@ -659,7 +659,10 @@ function getClosestHouseExit(position, dimension) {
|
|||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
function getPlayerHouse(client) {
|
function getPlayerHouse(client) {
|
||||||
if(getServerData().houses.length > 0) {
|
if (getServerData().houses.length == 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (getPlayerDimension(client) == getGameConfig().mainWorldDimension[getGame()]) {
|
if (getPlayerDimension(client) == getGameConfig().mainWorldDimension[getGame()]) {
|
||||||
let closestEntrance = getClosestHouseEntrance(getPlayerPosition(client), getPlayerDimension(client));
|
let closestEntrance = getClosestHouseEntrance(getPlayerPosition(client), getPlayerDimension(client));
|
||||||
if (getDistance(getPlayerPosition(client), getHouseData(closestEntrance).entrancePosition) <= getGlobalConfig().enterPropertyDistance) {
|
if (getDistance(getPlayerPosition(client), getHouseData(closestEntrance).entrancePosition) <= getGlobalConfig().enterPropertyDistance) {
|
||||||
@@ -677,7 +680,6 @@ function getPlayerHouse(client) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -847,6 +849,10 @@ function createHouseEntrancePickup(houseId) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isGameFeatureSupported("pickups")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!getHouseData(houseId)) {
|
if (!getHouseData(houseId)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -900,6 +906,10 @@ function createHouseEntranceBlip(houseId) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isGameFeatureSupported("blips")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!getHouseData(houseId)) {
|
if (!getHouseData(houseId)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -953,6 +963,10 @@ function createHouseExitPickup(houseId) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isGameFeatureSupported("pickups")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!getHouseData(houseId)) {
|
if (!getHouseData(houseId)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -997,6 +1011,10 @@ function createHouseExitBlip(houseId) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isGameFeatureSupported("blips")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!getHouseData(houseId)) {
|
if (!getHouseData(houseId)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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");
|
|
||||||
@@ -20,7 +20,7 @@ function loadItemsFromDatabase() {
|
|||||||
let dbConnection = connectToDatabase();
|
let dbConnection = connectToDatabase();
|
||||||
let dbFetchAssoc;
|
let dbFetchAssoc;
|
||||||
if (dbConnection) {
|
if (dbConnection) {
|
||||||
let dbQuery = queryDatabase(dbConnection, `SELECT * FROM item_main WHERE item_server = ${getServerId()}`);
|
let dbQuery = queryDatabase(dbConnection, `SELECT * FROM item_main WHERE item_deleted = 0 AND item_server = ${getServerId()}`);
|
||||||
if (dbQuery) {
|
if (dbQuery) {
|
||||||
if (dbQuery.numRows > 0) {
|
if (dbQuery.numRows > 0) {
|
||||||
while (dbFetchAssoc = fetchQueryAssoc(dbQuery)) {
|
while (dbFetchAssoc = fetchQueryAssoc(dbQuery)) {
|
||||||
@@ -42,7 +42,7 @@ function loadItemTypesFromDatabase() {
|
|||||||
let dbConnection = connectToDatabase();
|
let dbConnection = connectToDatabase();
|
||||||
let dbFetchAssoc;
|
let dbFetchAssoc;
|
||||||
if (dbConnection) {
|
if (dbConnection) {
|
||||||
let dbQuery = queryDatabase(dbConnection, `SELECT * FROM item_type WHERE item_type_enabled = 1 AND item_type_server = ${getServerId()}`);
|
let dbQuery = queryDatabase(dbConnection, `SELECT * FROM item_type WHERE item_type_deleted = 0 AND item_type_enabled = 1 AND item_type_server = ${getServerId()}`);
|
||||||
if (dbQuery) {
|
if (dbQuery) {
|
||||||
if (getQueryNumRows(dbQuery) > 0) {
|
if (getQueryNumRows(dbQuery) > 0) {
|
||||||
while (dbFetchAssoc = fetchQueryAssoc(dbQuery)) {
|
while (dbFetchAssoc = fetchQueryAssoc(dbQuery)) {
|
||||||
@@ -296,24 +296,26 @@ function pickupItemCommand(command, params, client) {
|
|||||||
|
|
||||||
if (!getItemData(itemId)) {
|
if (!getItemData(itemId)) {
|
||||||
//messagePlayerError(client, `The item you're trying to pick up is bugged. A bug report has been sent to the server developers.`);
|
//messagePlayerError(client, `The item you're trying to pick up is bugged. A bug report has been sent to the server developers.`);
|
||||||
|
messagePlayerError(client, getPlayerLocale(client, "NoItemCloseEnough"));
|
||||||
submitBugReport(client, `(AUTOMATED REPORT) Pickup Item: Getting item data for item ${itemId} on ground returned false.`);
|
submitBugReport(client, `(AUTOMATED REPORT) Pickup Item: Getting item data for item ${itemId} on ground returned false.`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!getItemTypeData(getItemData(itemId).itemTypeIndex)) {
|
if (!getItemTypeData(getItemData(itemId).itemTypeIndex)) {
|
||||||
//messagePlayerError(client, `The item you're trying to pick up is bugged. A bug report has been sent to the server developers.`);
|
//messagePlayerError(client, `The item you're trying to pick up is bugged. A bug report has been sent to the server developers.`);
|
||||||
|
messagePlayerError(client, getPlayerLocale(client, "NoItemCloseEnough"));
|
||||||
submitBugReport(client, `(AUTOMATED REPORT) Pickup Item: Getting item type ${getItemData(itemId).itemType} data for item ${itemId}/${getItemData(itemId).databaseId} on ground returned false.`);
|
submitBugReport(client, `(AUTOMATED REPORT) Pickup Item: Getting item type ${getItemData(itemId).itemType} data for item ${itemId}/${getItemData(itemId).databaseId} on ground returned false.`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getDistance(getPlayerPosition(client), getItemData(itemId).position) > getGlobalConfig().droppedItemPickupRange) {
|
if (getDistance(getPlayerPosition(client), getItemData(itemId).position) > getGlobalConfig().droppedItemPickupRange) {
|
||||||
messagePlayerError(client, `You're too far away!`);
|
messagePlayerError(client, getPlayerLocale(client, "NoItemCloseEnough"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
let firstSlot = getPlayerFirstEmptyHotBarSlot(client);
|
let firstSlot = getPlayerFirstEmptyHotBarSlot(client);
|
||||||
if (firstSlot == -1) {
|
if (firstSlot == -1) {
|
||||||
messagePlayerError(client, `You don't have any space to carry this (full inventory)!`);
|
messagePlayerError(client, getPlayerLocale(client, "NoSpaceSelfInventory"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -359,25 +361,25 @@ function dropItemCommand(command, params, client) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (hotBarSlot == -1) {
|
if (hotBarSlot == -1) {
|
||||||
messagePlayerError(client, `You don't have any item selected/equipped.`);
|
messagePlayerError(client, getLocaleString(client, "NoItemEquipped"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getPlayerData(client).hotBarItems[hotBarSlot] == -1) {
|
if (getPlayerData(client).hotBarItems[hotBarSlot] == -1) {
|
||||||
messagePlayerError(client, `You don't have an item in your active slot.`);
|
messagePlayerError(client, getLocaleString(client, "NoItemInActiveSlot"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
let itemId = getPlayerData(client).hotBarItems[hotBarSlot];
|
let itemId = getPlayerData(client).hotBarItems[hotBarSlot];
|
||||||
|
|
||||||
if (!getItemData(itemId)) {
|
if (!getItemData(itemId)) {
|
||||||
messagePlayerError(client, `The item you're trying to drop is bugged. A bug report has been sent to the server developers.`);
|
messagePlayerError(client, getLocaleString(client, "DropItemBugged"));
|
||||||
submitBugReport(client, `(AUTOMATED REPORT) Drop Item: Getting item data for item ${itemId} in player hotbar slot ${hotBarSlot} (cache ${getPlayerData(client).hotBarItems[hotBarSlot]}) returned false.`);
|
submitBugReport(client, `(AUTOMATED REPORT) Drop Item: Getting item data for item ${itemId} in player hotbar slot ${hotBarSlot} (cache ${getPlayerData(client).hotBarItems[hotBarSlot]}) returned false.`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!getItemTypeData(getItemData(itemId).itemTypeIndex)) {
|
if (!getItemTypeData(getItemData(itemId).itemTypeIndex)) {
|
||||||
messagePlayerError(client, `The item you're trying to drop is bugged. A bug report has been sent to the server developers.`);
|
messagePlayerError(client, getLocaleString(client, "DropItemBugged"));
|
||||||
submitBugReport(client, `(AUTOMATED REPORT) Drop Item: Getting item type ${getItemData(itemId).itemType} data for item ${itemId}/${getItemData(itemId).databaseId} in player hotbar slot ${hotBarSlot} (cache ${getPlayerData(client).hotBarItems[hotBarSlot]}) returned false.`);
|
submitBugReport(client, `(AUTOMATED REPORT) Drop Item: Getting item type ${getItemData(itemId).itemType} data for item ${itemId}/${getItemData(itemId).databaseId} in player hotbar slot ${hotBarSlot} (cache ${getPlayerData(client).hotBarItems[hotBarSlot]}) returned false.`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -393,7 +395,7 @@ function dropItemCommand(command, params, client) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isPlayerItemFromJobEquipment(client, hotBarSlot)) {
|
if (isPlayerItemFromJobEquipment(client, hotBarSlot)) {
|
||||||
messagePlayerError(client, `You can't drop job items`);
|
messagePlayerError(client, getLocaleString(client, "CantDropJobEquipmentItem"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -449,7 +451,7 @@ function putItemCommand(command, params, client) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isPlayerItemFromJobEquipment(client, hotBarSlot)) {
|
if (isPlayerItemFromJobEquipment(client, hotBarSlot)) {
|
||||||
messagePlayerError(client, `You can't put job items`);
|
messagePlayerError(client, getLocaleString(client, "CantPutJobEquipmentItem"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -480,7 +482,7 @@ function takeItemCommand(command, params, client) {
|
|||||||
|
|
||||||
let firstSlot = getPlayerFirstEmptyHotBarSlot(client);
|
let firstSlot = getPlayerFirstEmptyHotBarSlot(client);
|
||||||
if (firstSlot == -1) {
|
if (firstSlot == -1) {
|
||||||
messagePlayerError(client, `You don't have any space to hold another item (full inventory)!`);
|
messagePlayerError(client, getLocaleString(client, "NoSpaceSelfInventory"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -490,7 +492,7 @@ function takeItemCommand(command, params, client) {
|
|||||||
let itemId = bestOwner[2];
|
let itemId = bestOwner[2];
|
||||||
|
|
||||||
if (bestOwner[1] == VRR_ITEM_OWNER_NONE) {
|
if (bestOwner[1] == VRR_ITEM_OWNER_NONE) {
|
||||||
messagePlayerError(client, `You aren't near anything to take items from!`);
|
messagePlayerError(client, getLocaleString(client, "NothingToTakeItemFrom"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -559,15 +561,16 @@ function setItemTypeDropModelCommand(command, params, client) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let itemTypeIndex = getItemTypeFromParams(splitParams.slice(0, -1).join(" "));
|
let itemTypeIndex = getItemTypeFromParams(splitParams.slice(0, -1).join(" "));
|
||||||
let modelId = splitParams[splitParams.length-1];
|
let modelIndex = getObjectModelIndexFromParams(splitParams.slice(-1).join(" "));
|
||||||
|
|
||||||
if (!getItemTypeData(itemTypeIndex)) {
|
if (!getItemTypeData(itemTypeIndex)) {
|
||||||
messagePlayerError(client, getLocaleString(client, "InvalidItemType"));
|
messagePlayerError(client, getLocaleString(client, "InvalidItemType"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
getItemTypeData(itemTypeIndex).dropModel = modelId;
|
getItemTypeData(itemTypeIndex).dropModel = modelIndex;
|
||||||
messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} set item type {ALTCOLOUR}${getItemTypeData(itemTypeIndex).name} dropped object model to ${modelId}`);
|
getItemTypeData(itemTypeIndex).needsSaved = true;
|
||||||
|
messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} set item type {ALTCOLOUR}${getItemTypeData(itemTypeIndex).name}'s dropped object model index to ${modelIndex}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
@@ -596,6 +599,7 @@ function setItemTypeOrderPriceCommand(command, params, client) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getItemTypeData(itemTypeIndex).orderPrice = orderPrice;
|
getItemTypeData(itemTypeIndex).orderPrice = orderPrice;
|
||||||
|
getItemTypeData(itemTypeIndex).needsSaved = true;
|
||||||
messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} set item type {ALTCOLOUR}${getItemTypeData(itemTypeIndex).name} {MAINCOLOUR}base price to {ALTCOLOUR}$${orderPrice}`);
|
messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} set item type {ALTCOLOUR}${getItemTypeData(itemTypeIndex).name} {MAINCOLOUR}base price to {ALTCOLOUR}$${orderPrice}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -625,7 +629,8 @@ function setItemTypeRiskMultiplierCommand(command, params, client) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getItemTypeData(itemTypeIndex).riskMultiplier = riskMultiplier;
|
getItemTypeData(itemTypeIndex).riskMultiplier = riskMultiplier;
|
||||||
messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} set item type {ALTCOLOUR}${getItemTypeData(itemTypeIndex).name} {MAINCOLOUR}risk multilier to {ALTCOLOUR}$${riskMultiplier}`);
|
getItemTypeData(itemTypeIndex).needsSaved = true;
|
||||||
|
messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} set item type {ALTCOLOUR}${getItemTypeData(itemTypeIndex).name}{MAINCOLOUR} risk multiplier to {ALTCOLOUR}$${riskMultiplier}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
@@ -653,6 +658,7 @@ function toggleItemTypeEnabledCommand(command, params, client) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getItemTypeData(itemTypeIndex).enabled = !getItemTypeData(itemTypeIndex).enabled;
|
getItemTypeData(itemTypeIndex).enabled = !getItemTypeData(itemTypeIndex).enabled;
|
||||||
|
getItemTypeData(itemTypeIndex).needsSaved = true;
|
||||||
messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} ${getEnabledDisabledFromBool(getItemTypeData(itemTypeIndex).enabled)} item type {ALTCOLOUR}${getItemTypeData(itemTypeIndex).name}`);
|
messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} ${getEnabledDisabledFromBool(getItemTypeData(itemTypeIndex).enabled)} item type {ALTCOLOUR}${getItemTypeData(itemTypeIndex).name}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -682,6 +688,7 @@ function setItemTypeUseTypeCommand(command, params, client) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getItemTypeData(itemTypeIndex).useType = useType;
|
getItemTypeData(itemTypeIndex).useType = useType;
|
||||||
|
getItemTypeData(itemTypeIndex).needsSaved = true;
|
||||||
messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} set item type {ALTCOLOUR}${getItemTypeData(itemTypeIndex).name}{MAINCOLOUR} use type to {ALTCOLOUR}$${useType}`);
|
messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} set item type {ALTCOLOUR}${getItemTypeData(itemTypeIndex).name}{MAINCOLOUR} use type to {ALTCOLOUR}$${useType}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -711,6 +718,7 @@ function setItemTypeUseValueCommand(command, params, client) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getItemTypeData(itemTypeIndex).useValue = useValue;
|
getItemTypeData(itemTypeIndex).useValue = useValue;
|
||||||
|
getItemTypeData(itemTypeIndex).needsSaved = true;
|
||||||
messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} set item type {ALTCOLOUR}${getItemTypeData(itemTypeIndex).name}{MAINCOLOUR} use value to {ALTCOLOUR}$${useValue}`);
|
messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} set item type {ALTCOLOUR}${getItemTypeData(itemTypeIndex).name}{MAINCOLOUR} use value to {ALTCOLOUR}$${useValue}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -720,6 +728,7 @@ function playerUseItem(client, hotBarSlot) {
|
|||||||
let itemIndex = getPlayerData(client).hotBarItems[hotBarSlot];
|
let itemIndex = getPlayerData(client).hotBarItems[hotBarSlot];
|
||||||
|
|
||||||
if (itemIndex == -1) {
|
if (itemIndex == -1) {
|
||||||
|
logToConsole(LOG_DEBUG | LOG_WARN, `[VRR.Item] ${getPlayerDisplayForConsole(client)} tried to use an empty hotbar slot ${hotBarSlot}`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -729,7 +738,13 @@ function playerUseItem(client, hotBarSlot) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(getItemTypeData(getItemData(itemIndex).itemTypeIndex).useType) {
|
let itemData = getItemData(itemIndex);
|
||||||
|
let itemTypeData = getItemTypeData(itemData.itemTypeIndex);
|
||||||
|
let hotBarItems = getPlayerData(client).hotBarItems;
|
||||||
|
|
||||||
|
logToConsole(LOG_DEBUG, `[VRR.Item] ${getPlayerDisplayForConsole(client)} used a ${itemTypeData.name} (use type ${itemTypeData.useType} - ${typeof itemTypeData.useType}) item (ID: ${itemData.index}/${itemData.databaseId}, TypeID: ${itemTypeData.index}/${itemTypeData.databaseId})`);
|
||||||
|
|
||||||
|
switch (toInteger(itemTypeData.useType)) {
|
||||||
case VRR_ITEM_USETYPE_SKIN: {
|
case VRR_ITEM_USETYPE_SKIN: {
|
||||||
getPlayerData(client).itemActionItem = itemIndex;
|
getPlayerData(client).itemActionItem = itemIndex;
|
||||||
forcePlayerIntoSkinSelect(client);
|
forcePlayerIntoSkinSelect(client);
|
||||||
@@ -737,27 +752,33 @@ function playerUseItem(client, hotBarSlot) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case VRR_ITEM_USETYPE_WEAPON: {
|
case VRR_ITEM_USETYPE_WEAPON: {
|
||||||
for(let i in getPlayerData(client).hotBarItems) {
|
for (let i in hotBarItems) {
|
||||||
if(getPlayerData(client).hotBarItems[i] != -1) {
|
if (hotBarItems[i] != -1) {
|
||||||
if(getItemData(getPlayerData(client).hotBarItems[i]) != false) {
|
if (getItemData(hotBarItems[i]) != false) {
|
||||||
if(getItemTypeData(getItemData(getPlayerData(client).hotBarItems[i]).itemTypeIndex).useType == VRR_ITEM_USETYPE_AMMO_CLIP) {
|
if (getItemTypeData(getItemData(hotBarItems[i]).itemTypeIndex).useType == VRR_ITEM_USETYPE_AMMO_CLIP) {
|
||||||
if(getItemTypeData(getItemData(getPlayerData(client).hotBarItems[i]).itemTypeIndex).useId == getItemTypeData(getItemData(itemIndex).itemTypeIndex).databaseId) {
|
let ammoItemData = getItemData(hotBarItems[i]);
|
||||||
givePlayerWeaponAmmo(client, getItemData(getPlayerData(client).hotBarItems[i]).value);
|
let ammoItemTypeData = getItemTypeData(ammoItemData.itemTypeIndex);
|
||||||
getItemData(getPlayerData(client).hotBarItems[hotBarSlot]).value = getItemData(getPlayerData(client).hotBarItems[hotBarSlot]).value + getItemData(getPlayerData(client).hotBarItems[i]).value;
|
if (ammoItemTypeData.useId == itemTypeData.databaseId) {
|
||||||
deleteItem(getPlayerData(client).hotBarItems[i]);
|
givePlayerWeaponAmmo(client, ammoItemData.value);
|
||||||
meActionToNearbyPlayers(client, `loads some ammo into their ${getItemTypeData(getItemData(itemIndex).itemTypeIndex).name}`);
|
itemData.value = itemData.value + ammoItemData.value;
|
||||||
|
deleteItem(hotBarItems[i]);
|
||||||
|
meActionToNearbyPlayers(client, `loads some ammo into their ${itemTypeData.name}`);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
messagePlayerError(client, `You don't have any ammo to load into your ${getItemTypeData(getItemData(itemIndex).itemTypeIndex).name}!`);
|
messagePlayerError(client, getLocaleString(client, "NoAmmoToLoadIntoWeapon", itemTypeData.name));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case VRR_ITEM_USETYPE_AMMO_CLIP: {
|
case VRR_ITEM_USETYPE_AMMO_CLIP: {
|
||||||
messagePlayerError(client, `To load this ammo into a weapon, equip the weapon and ${(doesPlayerHaveKeyBindForCommand(client, "use")) ? `press {ALTCOLOUR}${toUpperCase(getKeyNameFromId(getPlayerKeyBindForCommand(client, "use").key))}` : `{ALTCOLOUR}/use`}`);
|
if (doesPlayerHaveKeyBindForCommand(client, "use")) {
|
||||||
|
messagePlayerError(client, getLocaleString(client, "LoadAmmoIntoWeaponHelpKeyPress", `{ALTCOLOUR}${toUpperCase(getKeyNameFromId(getPlayerKeyBindForCommand(client, "use").key))}{MAINCOLOUR}`));
|
||||||
|
} else {
|
||||||
|
messagePlayerError(client, getLocaleString(client, "LoadAmmoIntoWeaponHelpCommand", `{ALTCOLOUR}/use{MAINCOLOUR}`));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -767,9 +788,9 @@ function playerUseItem(client, hotBarSlot) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case VRR_ITEM_USETYPE_FOOD: {
|
case VRR_ITEM_USETYPE_FOOD: {
|
||||||
meActionToNearbyPlayers(client, `eats some of their ${getItemName(itemIndex)}`);
|
meActionToNearbyPlayers(client, `eats some of their ${itemTypeData.name}`);
|
||||||
givePlayerHealth(client, getItemTypeData(getItemData(itemIndex).itemTypeIndex).useValue);
|
givePlayerHealth(client, itemTypeData.useValue);
|
||||||
getItemData(itemIndex).value = getItemData(itemIndex).value - getItemTypeData(getItemData(itemIndex).itemTypeIndex).useValue;
|
itemData.value = itemData.value - tempItemTypeData.useValue;
|
||||||
if (getItemData(itemIndex).value <= 0) {
|
if (getItemData(itemIndex).value <= 0) {
|
||||||
deleteItem(itemIndex);
|
deleteItem(itemIndex);
|
||||||
switchPlayerActiveHotBarSlot(client, -1);
|
switchPlayerActiveHotBarSlot(client, -1);
|
||||||
@@ -778,10 +799,10 @@ function playerUseItem(client, hotBarSlot) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case VRR_ITEM_USETYPE_DRINK: {
|
case VRR_ITEM_USETYPE_DRINK: {
|
||||||
meActionToNearbyPlayers(client, `drinks some of their ${getItemName(itemIndex)}`);
|
meActionToNearbyPlayers(client, `drinks some of their ${itemTypeData.name}`);
|
||||||
givePlayerHealth(client, getItemTypeData(getItemData(itemIndex).itemTypeIndex).useValue);
|
givePlayerHealth(client, itemTypeData.useValue);
|
||||||
getItemData(itemIndex).value = getItemData(itemIndex).value - getItemTypeData(getItemData(itemIndex).itemTypeIndex).useValue;
|
itemData.value = itemData.value - itemTypeData.useValue;
|
||||||
if(getItemData(itemIndex).value <= 0) {
|
if (itemData.value <= 0) {
|
||||||
deleteItem(itemIndex);
|
deleteItem(itemIndex);
|
||||||
switchPlayerActiveHotBarSlot(client, -1);
|
switchPlayerActiveHotBarSlot(client, -1);
|
||||||
}
|
}
|
||||||
@@ -789,8 +810,8 @@ function playerUseItem(client, hotBarSlot) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case VRR_ITEM_USETYPE_ARMOUR: {
|
case VRR_ITEM_USETYPE_ARMOUR: {
|
||||||
meActionToNearbyPlayers(client, `puts on a ${getItemName(itemIndex)}`);
|
meActionToNearbyPlayers(client, `puts on a ${itemTypeData.name}`);
|
||||||
givePlayerArmour(client, getItemData(itemIndex).useValue);
|
givePlayerArmour(client, itemTypeData.useValue);
|
||||||
deleteItem(itemIndex);
|
deleteItem(itemIndex);
|
||||||
switchPlayerActiveHotBarSlot(client, -1);
|
switchPlayerActiveHotBarSlot(client, -1);
|
||||||
break;
|
break;
|
||||||
@@ -800,17 +821,17 @@ function playerUseItem(client, hotBarSlot) {
|
|||||||
let closestPlayer = getClosestPlayer(getPlayerPosition(client), client);
|
let closestPlayer = getClosestPlayer(getPlayerPosition(client), client);
|
||||||
|
|
||||||
if (!getPlayerData(closestPlayer)) {
|
if (!getPlayerData(closestPlayer)) {
|
||||||
messagePlayerError(client, "There isn't anyone close enough to tie up!");
|
messagePlayerError(client, getLocaleString(client, "NobodyCloseEnoughToTie"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getDistance(getPlayerPosition(closestPlayer), getPlayerPosition(client)) > getGlobalConfig().handcuffPlayerDistance) {
|
if (getDistance(getPlayerPosition(closestPlayer), getPlayerPosition(client)) > getGlobalConfig().handcuffPlayerDistance) {
|
||||||
messagePlayerError(client, "There isn't anyone close enough to tie up!");
|
messagePlayerError(client, getLocaleString(client, "NobodyCloseEnoughToTie"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isPlayerSurrendered(closestPlayer)) {
|
if (!isPlayerSurrendered(closestPlayer)) {
|
||||||
messagePlayerError(client, `${getCharacterFullName(closestPlayer)} can't be tied! They either need to have their hands up, be knocked out, or tazed`);
|
messagePlayerError(client, getLocaleString(client, "PlayerNotSurrenderedTie", getCharacterFullName(closestPlayer)));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -833,12 +854,12 @@ function playerUseItem(client, hotBarSlot) {
|
|||||||
let closestPlayer = getClosestPlayer(getPlayerPosition(client), client);
|
let closestPlayer = getClosestPlayer(getPlayerPosition(client), client);
|
||||||
|
|
||||||
if (!getPlayerData(closestPlayer)) {
|
if (!getPlayerData(closestPlayer)) {
|
||||||
messagePlayerError(client, "There isn't anyone close enough to handcuff!");
|
messagePlayerError(client, getLocaleString(client, "NobodyCloseEnoughToHandcuff"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getDistance(getPlayerPosition(closestPlayer), getPlayerPosition(client)) > getGlobalConfig().handcuffPlayerDistance) {
|
if (getDistance(getPlayerPosition(closestPlayer), getPlayerPosition(client)) > getGlobalConfig().handcuffPlayerDistance) {
|
||||||
messagePlayerError(client, "There isn't anyone close enough to handcuff!");
|
messagePlayerError(client, getLocaleString(client, "NobodyCloseEnoughToHandcuff"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -847,7 +868,7 @@ function playerUseItem(client, hotBarSlot) {
|
|||||||
meActionToNearbyPlayers(client, `takes their key and removes the handcuffs from ${getCharacterFullName(closestPlayer)}`);
|
meActionToNearbyPlayers(client, `takes their key and removes the handcuffs from ${getCharacterFullName(closestPlayer)}`);
|
||||||
} else {
|
} else {
|
||||||
if (!isPlayerSurrendered(closestPlayer)) {
|
if (!isPlayerSurrendered(closestPlayer)) {
|
||||||
messagePlayerError(client, `${getCharacterFullName(closestPlayer)} can't be cuffed! They either need to have their hands up, be knocked out, or tazed`);
|
messagePlayerError(client, getLocaleString(client, "PlayerNotSurrenderedHandcuffed", getCharacterFullName(closestPlayer)));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -857,19 +878,14 @@ function playerUseItem(client, hotBarSlot) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case VRR_ITEM_USETYPE_NONE: {
|
|
||||||
messagePlayerError(client, `The ${getItemName(itemIndex)} doesn't do anything when you try to use it.`);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case VRR_ITEM_USETYPE_VEHREPAIR: {
|
case VRR_ITEM_USETYPE_VEHREPAIR: {
|
||||||
let vehicle = getClosestVehicle(getPlayerPosition(client));
|
let vehicle = getClosestVehicle(getPlayerPosition(client));
|
||||||
if (getDistance(getPlayerPosition(client), getVehiclePosition(vehicle)) <= getGlobalConfig().vehicleRepairDistance) {
|
if (getDistance(getPlayerPosition(client), getVehiclePosition(vehicle)) <= getGlobalConfig().vehicleRepairDistance) {
|
||||||
meActionToNearbyPlayers(client, `takes their repair kit and fixes the vehicle`);
|
meActionToNearbyPlayers(client, `takes their repair kit and fixes the vehicle`);
|
||||||
repairVehicle(vehicle);
|
repairVehicle(vehicle);
|
||||||
|
|
||||||
getItemData(itemIndex).value = getItemData(itemIndex).value - getItemTypeData(getItemData(itemIndex).itemTypeIndex).useValue;
|
itemData.value = itemData.value - itemTypeData.useValue;
|
||||||
if(getItemData(itemIndex).value <= 0) {
|
if (itemData.value <= 0) {
|
||||||
destroyItem(itemIndex);
|
destroyItem(itemIndex);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -881,8 +897,8 @@ function playerUseItem(client, hotBarSlot) {
|
|||||||
case VRR_ITEM_USETYPE_VEHUPGRADE_PART: {
|
case VRR_ITEM_USETYPE_VEHUPGRADE_PART: {
|
||||||
let vehicle = getClosestVehicle(getPlayerPosition(client));
|
let vehicle = getClosestVehicle(getPlayerPosition(client));
|
||||||
if (getDistance(getPlayerPosition(client), getVehiclePosition(vehicle)) <= getGlobalConfig().vehicleRepairDistance) {
|
if (getDistance(getPlayerPosition(client), getVehiclePosition(vehicle)) <= getGlobalConfig().vehicleRepairDistance) {
|
||||||
meActionToNearbyPlayers(client, `takes their upgrade kit and adds a ${getItemName(itemIndex)} to the vehicle.`);
|
meActionToNearbyPlayers(client, `takes their upgrade kit and adds a ${itemTypeData.name} to the vehicle.`);
|
||||||
addVehicleUpgrade(vehicle, getItemData(itemIndex).useId);
|
addVehicleUpgrade(vehicle, itemTypeData.useId);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -891,7 +907,7 @@ function playerUseItem(client, hotBarSlot) {
|
|||||||
let vehicle = getClosestVehicle(getPlayerPosition(client));
|
let vehicle = getClosestVehicle(getPlayerPosition(client));
|
||||||
if (getDistance(getPlayerPosition(client), getVehiclePosition(vehicle)) <= getGlobalConfig().vehicleRepairDistance) {
|
if (getDistance(getPlayerPosition(client), getVehiclePosition(vehicle)) <= getGlobalConfig().vehicleRepairDistance) {
|
||||||
meActionToNearbyPlayers(client, `takes their decal kit and adds some decals to the vehicle.`);
|
meActionToNearbyPlayers(client, `takes their decal kit and adds some decals to the vehicle.`);
|
||||||
setVehicleLivery(vehicle, getItemData(itemIndex).value);
|
setVehicleLivery(vehicle, itemData.value);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -899,13 +915,13 @@ function playerUseItem(client, hotBarSlot) {
|
|||||||
case VRR_ITEM_USETYPE_VEHCOLOUR: {
|
case VRR_ITEM_USETYPE_VEHCOLOUR: {
|
||||||
let vehicle = getClosestVehicle(getPlayerPosition(client));
|
let vehicle = getClosestVehicle(getPlayerPosition(client));
|
||||||
if (getDistance(getPlayerPosition(client), getVehiclePosition(vehicle)) <= getGlobalConfig().vehicleRepairDistance) {
|
if (getDistance(getPlayerPosition(client), getVehiclePosition(vehicle)) <= getGlobalConfig().vehicleRepairDistance) {
|
||||||
if(getItemData(itemIndex).useId == 1) {
|
if (itemData.useId == 1) {
|
||||||
meActionToNearbyPlayers(client, `takes their vehicle colour kit and changes the primary colour of the vehicle.`);
|
meActionToNearbyPlayers(client, `takes their vehicle colour kit and changes the primary colour of the vehicle.`);
|
||||||
vehicle.colour1 = getItemData(itemIndex).value;
|
vehicle.colour1 = itemData.value;
|
||||||
} else {
|
} else {
|
||||||
if(getItemData(itemIndex).useId == 1) {
|
if (itemTypeData.useId == 1) {
|
||||||
meActionToNearbyPlayers(client, `takes their vehicle colour kit and changes the secondary colour of the vehicle.`);
|
meActionToNearbyPlayers(client, `takes their vehicle colour kit and changes the secondary colour of the vehicle.`);
|
||||||
vehicle.colour2 = getItemData(itemIndex).value;
|
vehicle.colour2 = itemData.value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -918,26 +934,26 @@ function playerUseItem(client, hotBarSlot) {
|
|||||||
if (getDistance(getPlayerPosition(client), getVehiclePosition(vehicle)) <= getDistance(getPlayerPosition(client), getFuelPumpData(fuelPump).position)) {
|
if (getDistance(getPlayerPosition(client), getVehiclePosition(vehicle)) <= getDistance(getPlayerPosition(client), getFuelPumpData(fuelPump).position)) {
|
||||||
if (getDistance(getPlayerPosition(client), getVehiclePosition(vehicle)) <= getGlobalConfig().vehicleRepairDistance) {
|
if (getDistance(getPlayerPosition(client), getVehiclePosition(vehicle)) <= getGlobalConfig().vehicleRepairDistance) {
|
||||||
meActionToNearbyPlayers(client, `takes their fuel can and refills the vehicle`);
|
meActionToNearbyPlayers(client, `takes their fuel can and refills the vehicle`);
|
||||||
if(getItemData(itemIndex).value < getItemTypeData(getItemData(itemIndex).itemTypeIndex).useValue) {
|
if (itemData.value < itemTypeData.useValue) {
|
||||||
getVehicleData(vehicle).fuel += getItemData(itemIndex).value;
|
getVehicleData(vehicle).fuel += itemData.value;
|
||||||
} else {
|
} else {
|
||||||
getVehicleData(vehicle).fuel += getItemTypeData(getItemData(itemIndex).itemTypeIndex).useValue;
|
getVehicleData(vehicle).fuel += itemTypeData.useValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
getItemData(itemIndex).value = getItemData(itemIndex).value - getItemTypeData(getItemData(itemIndex).itemTypeIndex).useValue;
|
itemData.value = itemData.value - itemTypeData.useValue;
|
||||||
//if(getItemData(itemIndex).value <= 0) {
|
//if(itemData.value <= 0) {
|
||||||
// destroyItem(itemIndex);
|
// destroyItem(itemIndex);
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (getDistance(getPlayerPosition(client), getFuelPumpData(fuelPump).position) <= getGlobalConfig().vehicleRepairDistance) {
|
if (getDistance(getPlayerPosition(client), getFuelPumpData(fuelPump).position) <= getGlobalConfig().vehicleRepairDistance) {
|
||||||
if(getItemData(itemIndex).useId == 1) {
|
if (itemData.useId == 1) {
|
||||||
meActionToNearbyPlayers(client, `takes their vehicle colour kit and changes the primary colour of the vehicle.`);
|
meActionToNearbyPlayers(client, `takes their vehicle colour kit and changes the primary colour of the vehicle.`);
|
||||||
vehicle.colour1 = getItemTypeData(itemIndex).value;
|
vehicle.colour1 = itemTypeData.value;
|
||||||
} else {
|
} else {
|
||||||
if(getItemData(itemIndex).useId == 1) {
|
if (itemData.useId == 1) {
|
||||||
meActionToNearbyPlayers(client, `takes their vehicle colour kit and changes the secondary colour of the vehicle.`);
|
meActionToNearbyPlayers(client, `takes their vehicle colour kit and changes the secondary colour of the vehicle.`);
|
||||||
vehicle.colour2 = getItemData(itemIndex).value;
|
vehicle.colour2 = itemData.value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -946,20 +962,19 @@ function playerUseItem(client, hotBarSlot) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case VRR_ITEM_USETYPE_WALKIETALKIE: {
|
case VRR_ITEM_USETYPE_WALKIETALKIE: {
|
||||||
getItemData(itemIndex).enabled = !getItemData(itemIndex).enabled;
|
itemData.enabled = !itemData.enabled;
|
||||||
//messagePlayerAlert(client, `You turned ${getBoolRedGreenInlineColour(getItemData(itemIndex).enabled)}${toUpperCase(getOnOffFromBool(getItemData(itemIndex).enabled))} {MAINCOLOUR}your walkie talkie in slot ${getPlayerData(client).activeHotBarSlot+1} {ALTCOLOUR}${getItemValueDisplayForItem(itemIndex)}`);
|
meActionToNearbyPlayers(client, `turns ${toLowerCase(getOnOffFromBool(itemData.enabled))} their walkie-talkie`);
|
||||||
meActionToNearbyPlayers(client, `turns ${toLowerCase(getOnOffFromBool(getItemData(itemIndex).enabled))} their walkie-talkie`);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case VRR_ITEM_USETYPE_PHONE: {
|
case VRR_ITEM_USETYPE_PHONE: {
|
||||||
if(getItemData(itemIndex).value == 0) {
|
if (itemData.value == 0) {
|
||||||
let phoneNumber = generateRandomPhoneNumber();
|
let phoneNumber = generateRandomPhoneNumber();
|
||||||
getItemData(itemIndex).value = phoneNumber;
|
itemData.value = phoneNumber;
|
||||||
messagePlayerAlert(client, `Your ${getItemName(itemIndex)} has been set up with number ${phoneNumber}`);
|
messagePlayerAlert(client, `Your ${itemTypeData.name} has been set up with number ${phoneNumber}`);
|
||||||
} else {
|
} else {
|
||||||
getItemData(itemIndex).enabled = !getItemData(itemIndex).enabled;
|
itemData.enabled = !itemData.enabled;
|
||||||
if(getItemData(itemIndex).enabled) {
|
if (itemData.enabled) {
|
||||||
//messagePlayerAlert(client, `You turned on your phone in slot ${getPlayerData(client).activeHotBarSlot+1} ${getItemValueDisplayForItem(itemIndex)}`);
|
//messagePlayerAlert(client, `You turned on your phone in slot ${getPlayerData(client).activeHotBarSlot+1} ${getItemValueDisplayForItem(itemIndex)}`);
|
||||||
meActionToNearbyPlayers(client, `turns on their phone`);
|
meActionToNearbyPlayers(client, `turns on their phone`);
|
||||||
} else {
|
} else {
|
||||||
@@ -971,8 +986,8 @@ function playerUseItem(client, hotBarSlot) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case VRR_ITEM_USETYPE_SMOKEDRUG: {
|
case VRR_ITEM_USETYPE_SMOKEDRUG: {
|
||||||
meActionToNearbyPlayers(client, `smokes some ${getItemName(itemIndex)}`);
|
meActionToNearbyPlayers(client, `smokes some ${itemTypeData.name}`);
|
||||||
getPlayerData(client).incomingDamageMultiplier = getPlayerData(client).incomingDamageMultiplier-(getItemTypeData(getItemData(itemIndex).itemTypeIndex).useValue/100);
|
getPlayerData(client).incomingDamageMultiplier = getPlayerData(client).incomingDamageMultiplier - (itemTypeData.useValue / 100);
|
||||||
if (getPlayerData(client).incomingDamageMultiplier < 0.25) {
|
if (getPlayerData(client).incomingDamageMultiplier < 0.25) {
|
||||||
getPlayerData(client).incomingDamageMultiplier = 0.25;
|
getPlayerData(client).incomingDamageMultiplier = 0.25;
|
||||||
}
|
}
|
||||||
@@ -982,8 +997,8 @@ function playerUseItem(client, hotBarSlot) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case VRR_ITEM_USETYPE_SNORTDRUG: {
|
case VRR_ITEM_USETYPE_SNORTDRUG: {
|
||||||
meActionToNearbyPlayers(client, `snorts some ${getItemName(itemIndex)}`);
|
meActionToNearbyPlayers(client, `snorts some ${itemTypeData.name}`);
|
||||||
getPlayerData(client).incomingDamageMultiplier = getPlayerData(client).incomingDamageMultiplier-(getItemTypeData(getItemData(itemIndex).itemTypeIndex).useValue/100);
|
getPlayerData(client).incomingDamageMultiplier = getPlayerData(client).incomingDamageMultiplier - (itemTypeData.useValue / 100);
|
||||||
if (getPlayerData(client).incomingDamageMultiplier < 0.25) {
|
if (getPlayerData(client).incomingDamageMultiplier < 0.25) {
|
||||||
getPlayerData(client).incomingDamageMultiplier = 0.25;
|
getPlayerData(client).incomingDamageMultiplier = 0.25;
|
||||||
}
|
}
|
||||||
@@ -993,8 +1008,8 @@ function playerUseItem(client, hotBarSlot) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case VRR_ITEM_USETYPE_INJECTDRUG: {
|
case VRR_ITEM_USETYPE_INJECTDRUG: {
|
||||||
meActionToNearbyPlayers(client, `shoots up some ${getItemName(itemIndex)}`);
|
meActionToNearbyPlayers(client, `shoots up some ${itemTypeData.name}`);
|
||||||
getPlayerData(client).incomingDamageMultiplier = getPlayerData(client).incomingDamageMultiplier-(getItemTypeData(getItemData(itemIndex).itemTypeIndex).useValue/100);
|
getPlayerData(client).incomingDamageMultiplier = getPlayerData(client).incomingDamageMultiplier - (itemTypeData.useValue / 100);
|
||||||
if (getPlayerData(client).incomingDamageMultiplier < 0.25) {
|
if (getPlayerData(client).incomingDamageMultiplier < 0.25) {
|
||||||
getPlayerData(client).incomingDamageMultiplier = 0.25;
|
getPlayerData(client).incomingDamageMultiplier = 0.25;
|
||||||
}
|
}
|
||||||
@@ -1004,9 +1019,9 @@ function playerUseItem(client, hotBarSlot) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case VRR_ITEM_USETYPE_PLANT: {
|
case VRR_ITEM_USETYPE_PLANT: {
|
||||||
meActionToNearbyPlayers(client, `bends down and plants a ${getItemName(itemIndex)} in the ground`);
|
meActionToNearbyPlayers(client, `bends down and plants a ${itemTypeData.name} in the ground`);
|
||||||
createGroundPlant(itemIndex);
|
createGroundPlant(itemIndex);
|
||||||
if(getItemData(itemIndex).value == 0) {
|
if (itemData.value == 0) {
|
||||||
destroyItem(itemIndex);
|
destroyItem(itemIndex);
|
||||||
switchPlayerActiveHotBarSlot(client, -1);
|
switchPlayerActiveHotBarSlot(client, -1);
|
||||||
}
|
}
|
||||||
@@ -1048,25 +1063,31 @@ function playerUseItem(client, hotBarSlot) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case VRR_ITEM_USETYPE_LOTTOTICKET: {
|
case VRR_ITEM_USETYPE_LOTTOTICKET: {
|
||||||
|
messagePlayerError(client, getLocaleString(client, "ItemDoesntDoAnythingOnUse", itemTypeData.name));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case VRR_ITEM_USETYPE_AREARADIO: {
|
case VRR_ITEM_USETYPE_AREARADIO: {
|
||||||
let state = getItemData(itemIndex)
|
itemData.enabled = !itemData.enabled;
|
||||||
meActionToNearbyPlayers(client, `turns ${getOnOffFromBool(state)} the boombox radio`);
|
meActionToNearbyPlayers(client, `turns ${getOnOffFromBool(itemData.enabled)} the boombox radio`);
|
||||||
messagePlayerAlert(client, `Use /radiostation to set the radio station and drop it on the ground to play`);
|
messagePlayerAlert(client, getLocaleString(client, "ItemRadioStationTip", `{ALTCOLOUR}/radiostation{MAINCOLOUR}`));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case VRR_ITEM_USETYPE_PERSONALRADIO: {
|
case VRR_ITEM_USETYPE_PERSONALRADIO: {
|
||||||
meActionToNearbyPlayers(client, `turns ${getOnOffFromBool(state)} the boombox radio`);
|
itemData.enabled = !itemData.enabled;
|
||||||
messagePlayerAlert(client, `Use /radiostation to set the radio station`);
|
meActionToNearbyPlayers(client, `turns ${getOnOffFromBool(itemData.enabled)} their personal radio`);
|
||||||
|
messagePlayerAlert(client, getLocaleString(client, "ItemRadioStationTip", `{ALTCOLOUR}/radiostation{MAINCOLOUR}`));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case VRR_ITEM_USETYPE_NONE: {
|
||||||
|
messagePlayerError(client, getLocaleString(client, "ItemDoesntDoAnythingOnUse", itemTypeData.name));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
messagePlayerError(client, `The ${getItemName(itemIndex)} doesn't do anything when you try to use it.`);
|
messagePlayerError(client, getLocaleString(client, "ItemDoesntDoAnythingOnUse", itemTypeData.name));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1444,7 +1465,7 @@ function cachePlayerHotBarItems(client) {
|
|||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
function deleteItem(itemId) {
|
function deleteItem(itemId, whoDeleted = -1) {
|
||||||
let owner = -1;
|
let owner = -1;
|
||||||
let ownerTypeString = "Unknown";
|
let ownerTypeString = "Unknown";
|
||||||
switch (getItemData(itemId).ownerType) {
|
switch (getItemData(itemId).ownerType) {
|
||||||
@@ -1515,7 +1536,7 @@ function deleteItem(itemId) {
|
|||||||
logToConsole(LOG_DEBUG, `Deleted item ${itemId} (DBID: ${getItemData(itemId).databaseId}, Owner Type: ${ownerTypeString}, Owner ID: ${getItemData(itemId).ownerId})`);
|
logToConsole(LOG_DEBUG, `Deleted item ${itemId} (DBID: ${getItemData(itemId).databaseId}, Owner Type: ${ownerTypeString}, Owner ID: ${getItemData(itemId).ownerId})`);
|
||||||
|
|
||||||
if (getItemData(itemId).databaseId > 0) {
|
if (getItemData(itemId).databaseId > 0) {
|
||||||
quickDatabaseQuery(`DELETE FROM item_main WHERE item_id = ${getItemData(itemId).databaseId}`);
|
quickDatabaseQuery(`UPDATE item_main SET item_deleted = 1, item_when_deleted = UNIX_TIMESTAMP() WHERE item_id = ${getItemData(itemId).databaseId}`);
|
||||||
}
|
}
|
||||||
getServerData().items[itemId] = false;
|
getServerData().items[itemId] = false;
|
||||||
setAllItemDataIndexes();
|
setAllItemDataIndexes();
|
||||||
@@ -2223,9 +2244,54 @@ function getOrderPriceForItemType(itemType) {
|
|||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
function clearPlayerItemActionState(client) {
|
function clearPlayerItemActionState(client) {
|
||||||
|
if (getPlayerData(client).itemActionItem != -1) {
|
||||||
|
switch (getPlayerData(client).itemActionState) {
|
||||||
|
case VRR_ITEM_ACTION_DROP: {
|
||||||
|
if (getItemTypeData(getItemData(getPlayerData(client).itemActionItem).itemTypeIndex).dropAnimationIndex != -1) {
|
||||||
|
makePlayerStopAnimation(client);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case VRR_ITEM_ACTION_USE: {
|
||||||
|
if (getItemTypeData(getItemData(getPlayerData(client).itemActionItem).itemTypeIndex).useAnimationIndex != -1) {
|
||||||
|
makePlayerStopAnimation(client);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case VRR_ITEM_ACTION_PICKUP: {
|
||||||
|
if (getItemTypeData(getItemData(getPlayerData(client).itemActionItem).itemTypeIndex).pickupAnimationIndex != -1) {
|
||||||
|
makePlayerStopAnimation(client);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case VRR_ITEM_ACTION_TAKE: {
|
||||||
|
if (getItemTypeData(getItemData(getPlayerData(client).itemActionItem).itemTypeIndex).takeAnimationIndex != -1) {
|
||||||
|
makePlayerStopAnimation(client);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case VRR_ITEM_ACTION_PUT: {
|
||||||
|
if (getItemTypeData(getItemData(getPlayerData(client).itemActionItem).itemTypeIndex).putAnimationIndex != -1) {
|
||||||
|
makePlayerStopAnimation(client);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case VRR_ITEM_ACTION_SWITCH: {
|
||||||
|
if (getItemTypeData(getItemData(getPlayerData(client).itemActionItem).itemTypeIndex).switchAnimationIndex != -1) {
|
||||||
|
makePlayerStopAnimation(client);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
getPlayerData(client).itemActionState = VRR_ITEM_ACTION_NONE;
|
getPlayerData(client).itemActionState = VRR_ITEM_ACTION_NONE;
|
||||||
getPlayerData(client).itemActionItem = -1;
|
getPlayerData(client).itemActionItem = -1;
|
||||||
makePlayerStopAnimation(client);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ function loadJobsFromDatabase() {
|
|||||||
let dbAssoc;
|
let dbAssoc;
|
||||||
|
|
||||||
if (dbConnection) {
|
if (dbConnection) {
|
||||||
dbQuery = queryDatabase(dbConnection, `SELECT * FROM job_main WHERE job_enabled = 1 AND job_server = ${getServerId()}`);
|
dbQuery = queryDatabase(dbConnection, `SELECT * FROM job_main WHERE job_deleted = 0 AND job_enabled = 1 AND job_server = ${getServerId()}`);
|
||||||
if (dbQuery) {
|
if (dbQuery) {
|
||||||
if (dbQuery.numRows > 0) {
|
if (dbQuery.numRows > 0) {
|
||||||
while (dbAssoc = fetchQueryAssoc(dbQuery)) {
|
while (dbAssoc = fetchQueryAssoc(dbQuery)) {
|
||||||
@@ -89,7 +89,7 @@ function loadJobRoutesFromDatabase(jobDatabaseId) {
|
|||||||
let dbAssoc;
|
let dbAssoc;
|
||||||
|
|
||||||
if (dbConnection) {
|
if (dbConnection) {
|
||||||
dbQuery = queryDatabase(dbConnection, `SELECT * FROM job_route WHERE job_route_enabled = 1 AND job_route_job = ${jobDatabaseId}`);
|
dbQuery = queryDatabase(dbConnection, `SELECT * FROM job_route WHERE job_route_deleted = 0 AND job_route_enabled = 1 AND job_route_job = ${jobDatabaseId}`);
|
||||||
if (dbQuery) {
|
if (dbQuery) {
|
||||||
if (dbQuery.numRows > 0) {
|
if (dbQuery.numRows > 0) {
|
||||||
while (dbAssoc = fetchQueryAssoc(dbQuery)) {
|
while (dbAssoc = fetchQueryAssoc(dbQuery)) {
|
||||||
@@ -119,7 +119,7 @@ function loadJobRouteLocationsFromDatabase(jobRouteId) {
|
|||||||
let dbAssoc;
|
let dbAssoc;
|
||||||
|
|
||||||
if (dbConnection) {
|
if (dbConnection) {
|
||||||
dbQuery = queryDatabase(dbConnection, `SELECT * FROM job_route_loc WHERE job_route_loc_enabled = 1 AND job_route_loc_route = ${jobRouteId}`);
|
dbQuery = queryDatabase(dbConnection, `SELECT * FROM job_route_loc WHERE job_route_loc_deleted = 0 AND job_route_loc_enabled = 1 AND job_route_loc_route = ${jobRouteId}`);
|
||||||
if (dbQuery) {
|
if (dbQuery) {
|
||||||
if (dbQuery.numRows > 0) {
|
if (dbQuery.numRows > 0) {
|
||||||
while (dbAssoc = fetchQueryAssoc(dbQuery)) {
|
while (dbAssoc = fetchQueryAssoc(dbQuery)) {
|
||||||
@@ -148,7 +148,7 @@ function loadJobEquipmentsFromDatabase(jobDatabaseId) {
|
|||||||
let dbAssoc;
|
let dbAssoc;
|
||||||
|
|
||||||
if (dbConnection) {
|
if (dbConnection) {
|
||||||
dbQuery = queryDatabase(dbConnection, "SELECT * FROM `job_equip` WHERE `job_equip_enabled` = 1 AND `job_equip_job` = " + toString(jobDatabaseId));
|
dbQuery = queryDatabase(dbConnection, `SELECT * FROM job_equip WHERE job_equip_deleted = 0 AND job_equip_enabled = 1 AND job_equip_job = ${jobDatabaseId}`);
|
||||||
if (dbQuery) {
|
if (dbQuery) {
|
||||||
if (dbQuery.numRows > 0) {
|
if (dbQuery.numRows > 0) {
|
||||||
while (dbAssoc = fetchQueryAssoc(dbQuery)) {
|
while (dbAssoc = fetchQueryAssoc(dbQuery)) {
|
||||||
@@ -178,7 +178,7 @@ function loadJobLocationsFromDatabase(jobDatabaseId) {
|
|||||||
let dbAssoc;
|
let dbAssoc;
|
||||||
|
|
||||||
if (dbConnection) {
|
if (dbConnection) {
|
||||||
dbQuery = queryDatabase(dbConnection, "SELECT * FROM `job_loc` WHERE `job_loc_enabled` = 1 AND `job_loc_job` = " + toString(jobDatabaseId));
|
dbQuery = queryDatabase(dbConnection, `SELECT * FROM job_loc WHERE job_loc_deleted = 0 AND job_loc_enabled = 1 AND job_loc_job = ${jobDatabaseId}`);
|
||||||
if (dbQuery) {
|
if (dbQuery) {
|
||||||
if (dbQuery.numRows > 0) {
|
if (dbQuery.numRows > 0) {
|
||||||
while (dbAssoc = fetchQueryAssoc(dbQuery)) {
|
while (dbAssoc = fetchQueryAssoc(dbQuery)) {
|
||||||
@@ -643,7 +643,7 @@ function stopWorking(client) {
|
|||||||
sendPlayerStopJobRoute(client);
|
sendPlayerStopJobRoute(client);
|
||||||
|
|
||||||
let jobId = getPlayerJob(client);
|
let jobId = getPlayerJob(client);
|
||||||
messageDiscordEventChannel(`💼 ${getPlayerName(client)} has stopped working as a ${getJobData(jobId).name}`);
|
messageDiscordEventChannel(`💼 ${getCharacterFullName(client)} has stopped working as a ${getJobData(jobId).name}`);
|
||||||
|
|
||||||
switch (getJobType(jobId)) {
|
switch (getJobType(jobId)) {
|
||||||
case VRR_JOB_POLICE:
|
case VRR_JOB_POLICE:
|
||||||
@@ -950,8 +950,8 @@ function reloadAllJobsCommand(command, params, client) {
|
|||||||
|
|
||||||
Promise.resolve().then(() => {
|
Promise.resolve().then(() => {
|
||||||
getServerData().jobs = loadJobsFromDatabase();
|
getServerData().jobs = loadJobsFromDatabase();
|
||||||
createJobLocationPickup(i, j);
|
createAllJobPickups();
|
||||||
createJobLocationBlip(i, j);
|
createAllJobBlips();
|
||||||
});
|
});
|
||||||
|
|
||||||
announceAdminAction("AllJobsReloaded");
|
announceAdminAction("AllJobsReloaded");
|
||||||
@@ -2381,6 +2381,10 @@ function createJobLocationPickup(jobId, locationId) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isGameFeatureSupported("pickups")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
let tempJobData = getJobData(jobId);
|
let tempJobData = getJobData(jobId);
|
||||||
|
|
||||||
if (tempJobData.pickupModel != -1) {
|
if (tempJobData.pickupModel != -1) {
|
||||||
@@ -2418,6 +2422,10 @@ function createJobLocationBlip(jobId, locationId) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isGameFeatureSupported("blips")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
let tempJobData = getJobData(jobId);
|
let tempJobData = getJobData(jobId);
|
||||||
|
|
||||||
if (getJobData(jobId).blipModel == -1) {
|
if (getJobData(jobId).blipModel == -1) {
|
||||||
@@ -2438,8 +2446,8 @@ function createJobLocationBlip(jobId, locationId) {
|
|||||||
if (getGlobalConfig().jobBlipStreamInDistance == -1 || getGlobalConfig().jobBlipStreamOutDistance == -1) {
|
if (getGlobalConfig().jobBlipStreamInDistance == -1 || getGlobalConfig().jobBlipStreamOutDistance == -1) {
|
||||||
blip.netFlags.distanceStreaming = false;
|
blip.netFlags.distanceStreaming = false;
|
||||||
} else {
|
} else {
|
||||||
setElementStreamInDistance(getServerData().jobs[i].locations[j].blip, getGlobalConfig().jobBlipStreamInDistance);
|
setElementStreamInDistance(blip, getGlobalConfig().jobBlipStreamInDistance);
|
||||||
setElementStreamOutDistance(getServerData().jobs[i].locations[j].blip, getGlobalConfig().jobBlipStreamOutDistance);
|
setElementStreamOutDistance(blip, getGlobalConfig().jobBlipStreamOutDistance);
|
||||||
}
|
}
|
||||||
|
|
||||||
setElementOnAllDimensions(blip, false);
|
setElementOnAllDimensions(blip, false);
|
||||||
@@ -3098,6 +3106,10 @@ function replaceJobRouteStringsInMessage(messageText, jobId, jobRouteId) {
|
|||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
function updateJobBlipsForPlayer(client) {
|
function updateJobBlipsForPlayer(client) {
|
||||||
|
if (!areServerElementsSupported()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
for (let i in getServerData().jobs) {
|
for (let i in getServerData().jobs) {
|
||||||
for (let j in getServerData().jobs[i].locations) {
|
for (let j in getServerData().jobs[i].locations) {
|
||||||
if (getPlayerJob(client) == 0 || getPlayerJob(client) == i) {
|
if (getPlayerJob(client) == 0 || getPlayerJob(client) == i) {
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ function setLocaleCommand(command, params, client) {
|
|||||||
getPlayerData(client).accountData.locale = localeId;
|
getPlayerData(client).accountData.locale = localeId;
|
||||||
getPlayerData(client).locale = localeId;
|
getPlayerData(client).locale = localeId;
|
||||||
messagePlayerSuccess(client, getLocaleString(client, "LocaleChanged1", getLocaleString(client, "LocaleNativeName")));
|
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().cachedTranslationFrom.fill([]);
|
||||||
getServerData().cachedTranslations.fill(getServerData().cachedTranslationFrom);
|
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`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|||||||
@@ -218,10 +218,10 @@ function enterExitPropertyCommand(command, params, client) {
|
|||||||
|
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
setPlayerInCutsceneInterior(client, closestProperty.exitCutscene);
|
setPlayerInCutsceneInterior(client, closestProperty.exitCutscene);
|
||||||
setPlayerPosition(client, closestProperty.exitPosition);
|
|
||||||
setPlayerHeading(client, closestProperty.exitRotation);
|
|
||||||
setPlayerDimension(client, closestProperty.exitDimension);
|
setPlayerDimension(client, closestProperty.exitDimension);
|
||||||
setPlayerInterior(client, closestProperty.exitInterior);
|
setPlayerInterior(client, closestProperty.exitInterior);
|
||||||
|
setPlayerPosition(client, closestProperty.exitPosition);
|
||||||
|
setPlayerHeading(client, closestProperty.exitRotation);
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
if (isFadeCameraSupported()) {
|
if (isFadeCameraSupported()) {
|
||||||
fadeCamera(client, true, 1.0);
|
fadeCamera(client, true, 1.0);
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
@@ -297,7 +297,7 @@ function spawnAllNPCs() {
|
|||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
function deleteNPCCommand(command, params, client) {
|
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"));
|
messagePlayerError(client, getLocaleString(client, "InvalidNPC"));
|
||||||
@@ -333,7 +333,7 @@ function setNPCAnimationCommand(command, params, client) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
let closestNPC = getClosestNPC(getPlayerPosition(client));
|
let closestNPC = getClosestNPC(getPlayerPosition(client), getPlayerDimension(client), getPlayerInterior(client));
|
||||||
let animationId = getAnimationFromParams(getParam(params, " ", 1));
|
let animationId = getAnimationFromParams(getParam(params, " ", 1));
|
||||||
let animationPositionOffset = 1;
|
let animationPositionOffset = 1;
|
||||||
|
|
||||||
@@ -370,7 +370,7 @@ function setNPCNameCommand(command, params, client) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
let closestNPC = getClosestNPC(getPlayerPosition(client));
|
let closestNPC = getClosestNPC(getPlayerPosition(client), getPlayerDimension(client), getPlayerInterior(client));
|
||||||
let name = params;
|
let name = params;
|
||||||
|
|
||||||
if (!getNPCData(closestNPC)) {
|
if (!getNPCData(closestNPC)) {
|
||||||
@@ -389,7 +389,7 @@ function setNPCNameCommand(command, params, client) {
|
|||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
function toggleNPCLookAtClosestPlayerCommand(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"));
|
messagePlayerError(client, getLocaleString(client, "InvalidNPC"));
|
||||||
@@ -471,12 +471,9 @@ function getNPCInfoCommand(command, params, client) {
|
|||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
function getClosestNPC(position) {
|
function getClosestNPC(position, interior, dimension) {
|
||||||
let npcs = getServerData().npcs;
|
let npcs = getServerData().npcs;
|
||||||
|
|
||||||
let interior = getPlayerInterior(client);
|
|
||||||
let dimension = getPlayerDimension(client);
|
|
||||||
|
|
||||||
let closest = 0;
|
let closest = 0;
|
||||||
for (let i in npcs) {
|
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) {
|
if (getDistance(npcs[i].ped.position, position) < getDistance(npcs[closest].ped.position, position) && npcs[closest].interior == interior && npcs[closest].dimension == dimension) {
|
||||||
|
|||||||
@@ -45,7 +45,8 @@ function kickClientCommand(command, params, client) {
|
|||||||
|
|
||||||
//getPlayerData(targetClient).customDisconnectReason = reason;
|
//getPlayerData(targetClient).customDisconnectReason = reason;
|
||||||
announceAdminAction(`PlayerKicked`, getPlayerName(targetClient));
|
announceAdminAction(`PlayerKicked`, getPlayerName(targetClient));
|
||||||
targetdisconnectPlayer(client);
|
getPlayerData(targetClient).customDisconnectReason = `Kicked - ${reason}`;
|
||||||
|
disconnectPlayer(targetClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
@@ -85,7 +86,6 @@ function setStaffTitleCommand(command, params, client) {
|
|||||||
getPlayerData(targetClient).accountData.staffTitle = staffTitle;
|
getPlayerData(targetClient).accountData.staffTitle = staffTitle;
|
||||||
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} set {ALTCOLOUR}${getPlayerName(targetClient)}'s{MAINCOLOUR} staff title to ${staffTitle}`);
|
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} set {ALTCOLOUR}${getPlayerName(targetClient)}'s{MAINCOLOUR} staff title to ${staffTitle}`);
|
||||||
messagePlayerAlert(targetClient, `${getPlayerName(client)} set your staff title to ${staffTitle}`);
|
messagePlayerAlert(targetClient, `${getPlayerName(client)} set your staff title to ${staffTitle}`);
|
||||||
//targetdisconnectPlayer(client);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|||||||
@@ -120,6 +120,8 @@ function loadServerDataFromDatabase() {
|
|||||||
getServerData().localeStrings = loadAllLocaleStrings();
|
getServerData().localeStrings = loadAllLocaleStrings();
|
||||||
getServerData().allowedSkins = getAllowedSkins(getGame());
|
getServerData().allowedSkins = getAllowedSkins(getGame());
|
||||||
|
|
||||||
|
getServerData().itemTypes = loadItemTypesFromDatabase();
|
||||||
|
|
||||||
// Translation Cache
|
// Translation Cache
|
||||||
getServerData().cachedTranslations = new Array(getGlobalConfig().locale.locales.length);
|
getServerData().cachedTranslations = new Array(getGlobalConfig().locale.locales.length);
|
||||||
getServerData().cachedTranslationFrom = new Array(getGlobalConfig().locale.locales.length);
|
getServerData().cachedTranslationFrom = new Array(getGlobalConfig().locale.locales.length);
|
||||||
@@ -128,7 +130,6 @@ function loadServerDataFromDatabase() {
|
|||||||
|
|
||||||
// Only load these if the server isn't a testing/dev server
|
// Only load these if the server isn't a testing/dev server
|
||||||
if (!getServerConfig().devServer) {
|
if (!getServerConfig().devServer) {
|
||||||
getServerData().itemTypes = loadItemTypesFromDatabase();
|
|
||||||
getServerData().items = loadItemsFromDatabase();
|
getServerData().items = loadItemsFromDatabase();
|
||||||
getServerData().businesses = loadBusinessesFromDatabase();
|
getServerData().businesses = loadBusinessesFromDatabase();
|
||||||
getServerData().houses = loadHousesFromDatabase();
|
getServerData().houses = loadHousesFromDatabase();
|
||||||
|
|||||||
@@ -245,16 +245,12 @@ function showCharacterSelectToClient(client) {
|
|||||||
//}, 500);
|
//}, 500);
|
||||||
logToConsole(LOG_DEBUG, `[VRR.SubAccount] ${getPlayerDisplayForConsole(client)} is being shown the character select GUI`);
|
logToConsole(LOG_DEBUG, `[VRR.SubAccount] ${getPlayerDisplayForConsole(client)} is being shown the character select GUI`);
|
||||||
} else {
|
} else {
|
||||||
//let emojiNumbers = ["➊", "➋", "➌", "➍", "➎", "➏", "➐", "➑", "➒"];
|
let charactersList = getPlayerData(client).subAccounts.map((sacct, index) => `{teal}${index + 1}: {ALTCOLOUR}${sacct.firstName} ${sacct.lastName}`);
|
||||||
//let emojiNumbers = ["①", "②", "③", "④", "⑤", "⑥", "⑦", "⑧", "⑨"];
|
let chunkedList = splitArrayIntoChunks(charactersList, 5);
|
||||||
//let emojiNumbers = ["1️⃣", "2️⃣", "3️⃣", "4️⃣", "5️⃣", "6️⃣", "7️⃣", "8️⃣", "9️⃣"];
|
messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderCharactersListSelf")));
|
||||||
messagePlayerNormal(client, `You have the following characters. Use /usechar <id> to select one:`, getColourByName("teal"));
|
for (let i in chunkedList) {
|
||||||
getPlayerData(client).subAccounts.forEach(function(subAccount, index) {
|
messagePlayerNormal(client, chunkedList[i].join("{MAINCOLOUR}, "));
|
||||||
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})`);
|
|
||||||
});
|
|
||||||
logToConsole(LOG_DEBUG, `[VRR.SubAccount] ${getPlayerDisplayForConsole(client)} is being shown the character select/list message (GUI disabled)`);
|
logToConsole(LOG_DEBUG, `[VRR.SubAccount] ${getPlayerDisplayForConsole(client)} is being shown the character select/list message (GUI disabled)`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -302,7 +298,6 @@ function checkNewCharacter(client, firstName, lastName) {
|
|||||||
getPlayerData(client).subAccounts = loadSubAccountsFromAccount(getPlayerData(client).accountData.databaseId);
|
getPlayerData(client).subAccounts = loadSubAccountsFromAccount(getPlayerData(client).accountData.databaseId);
|
||||||
getPlayerData(client).currentSubAccount = 0;
|
getPlayerData(client).currentSubAccount = 0;
|
||||||
getPlayerData(client).creatingCharacter = false;
|
getPlayerData(client).creatingCharacter = false;
|
||||||
let tempSubAccount = getPlayerData(client).subAccounts[0];
|
|
||||||
showCharacterSelectToClient(client);
|
showCharacterSelectToClient(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -582,5 +577,6 @@ function forcePlayerIntoSwitchCharacterScreen(client) {
|
|||||||
getPlayerData(client).switchingCharacter = true;
|
getPlayerData(client).switchingCharacter = true;
|
||||||
|
|
||||||
showConnectCameraToPlayer(client);
|
showConnectCameraToPlayer(client);
|
||||||
|
|
||||||
showCharacterSelectToClient(client);
|
showCharacterSelectToClient(client);
|
||||||
}
|
}
|
||||||
@@ -237,14 +237,14 @@ function checkPayDays() {
|
|||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
function showRandomTipToAllPlayers() {
|
function showRandomTipToAllPlayers() {
|
||||||
let tipId = getRandom(0, randomTips.length-1);
|
|
||||||
|
|
||||||
let clients = getClients();
|
let clients = getClients();
|
||||||
for (let i in clients) {
|
for (let i in clients) {
|
||||||
if (isClientInitialized(clients[i])) {
|
if (isClientInitialized(clients[i])) {
|
||||||
if (isPlayerLoggedIn(clients[i]) && isPlayerSpawned(clients[i])) {
|
if (isPlayerLoggedIn(clients[i]) && isPlayerSpawned(clients[i])) {
|
||||||
if (!doesPlayerHaveRandomTipsDisabled(clients[i])) {
|
if (!doesPlayerHaveRandomTipsDisabled(clients[i])) {
|
||||||
messagePlayerTimedRandomTip(null, randomTips[tipId]);
|
let localeId = getPlayerLocaleId(clients[i]);
|
||||||
|
let tipId = getRandom(0, getServerData().localeStrings[localeId]["RandomTips"].length - 1);
|
||||||
|
messagePlayerTip(clients[i], getGroupedLocaleString(clients[i], "RandomTips", tipId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -394,30 +394,6 @@ 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() {
|
function clearTemporaryVehicles() {
|
||||||
let vehicles = getElementsByType(ELEMENT_VEHICLE);
|
let vehicles = getElementsByType(ELEMENT_VEHICLE);
|
||||||
for (let i in vehicles) {
|
for (let i in vehicles) {
|
||||||
@@ -452,6 +428,7 @@ function clearTemporaryPeds() {
|
|||||||
|
|
||||||
function kickAllClients() {
|
function kickAllClients() {
|
||||||
getClients().forEach((client) => {
|
getClients().forEach((client) => {
|
||||||
|
getPlayerData(client).customDisconnectReason = `Kicked - All clients are being disconnected`;
|
||||||
disconnectPlayer(client);
|
disconnectPlayer(client);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -112,19 +112,19 @@ function saveVehicleToDatabase(vehicleDataId) {
|
|||||||
["veh_col2_isrgb", boolToInt(tempVehicleData.colour2IsRGBA)],
|
["veh_col2_isrgb", boolToInt(tempVehicleData.colour2IsRGBA)],
|
||||||
["veh_col3_isrgb", boolToInt(tempVehicleData.colour3IsRGBA)],
|
["veh_col3_isrgb", boolToInt(tempVehicleData.colour3IsRGBA)],
|
||||||
["veh_col4_isrgb", boolToInt(tempVehicleData.colour4IsRGBA)],
|
["veh_col4_isrgb", boolToInt(tempVehicleData.colour4IsRGBA)],
|
||||||
["veh_extra1", tempVehicleData.extras[0]],
|
//["veh_extra1", tempVehicleData.extras[0]],
|
||||||
["veh_extra2", tempVehicleData.extras[1]],
|
//["veh_extra2", tempVehicleData.extras[1]],
|
||||||
["veh_extra3", tempVehicleData.extras[2]],
|
//["veh_extra3", tempVehicleData.extras[2]],
|
||||||
["veh_extra4", tempVehicleData.extras[3]],
|
//["veh_extra4", tempVehicleData.extras[3]],
|
||||||
["veh_extra5", tempVehicleData.extras[4]],
|
//["veh_extra5", tempVehicleData.extras[4]],
|
||||||
["veh_extra6", tempVehicleData.extras[5]],
|
//["veh_extra6", tempVehicleData.extras[5]],
|
||||||
["veh_extra7", tempVehicleData.extras[6]],
|
//["veh_extra7", tempVehicleData.extras[6]],
|
||||||
["veh_extra8", tempVehicleData.extras[7]],
|
//["veh_extra8", tempVehicleData.extras[7]],
|
||||||
["veh_extra9", tempVehicleData.extras[8]],
|
//["veh_extra9", tempVehicleData.extras[8]],
|
||||||
["veh_extra10", tempVehicleData.extras[9]],
|
//["veh_extra10", tempVehicleData.extras[9]],
|
||||||
["veh_extra11", tempVehicleData.extras[10]],
|
//["veh_extra11", tempVehicleData.extras[10]],
|
||||||
["veh_extra12", tempVehicleData.extras[11]],
|
//["veh_extra12", tempVehicleData.extras[11]],
|
||||||
["veh_extra13", tempVehicleData.extras[12]],
|
//["veh_extra13", tempVehicleData.extras[12]],
|
||||||
["veh_engine", intToBool(tempVehicleData.engine)],
|
["veh_engine", intToBool(tempVehicleData.engine)],
|
||||||
["veh_lights", intToBool(tempVehicleData.lights)],
|
["veh_lights", intToBool(tempVehicleData.lights)],
|
||||||
["veh_health", toInteger(tempVehicleData.health)],
|
["veh_health", toInteger(tempVehicleData.health)],
|
||||||
@@ -346,7 +346,7 @@ function deleteVehicleCommand(command, params, client) {
|
|||||||
let dataIndex = getEntityData(vehicle, "vrr.dataSlot");
|
let dataIndex = getEntityData(vehicle, "vrr.dataSlot");
|
||||||
let vehicleName = getVehicleName(vehicle);
|
let vehicleName = getVehicleName(vehicle);
|
||||||
|
|
||||||
quickDatabaseQuery(`DELETE FROM veh_main WHERE veh_id = ${getVehicleData(vehicle).databaseId}`);
|
quickDatabaseQuery(`UPDATE veh_main SET veh_deleted = 1 WHERE veh_id = ${getVehicleData(vehicle).databaseId}`);
|
||||||
|
|
||||||
getServerData().vehicles.splice(dataIndex, 1);
|
getServerData().vehicles.splice(dataIndex, 1);
|
||||||
destroyElement(vehicle);
|
destroyElement(vehicle);
|
||||||
|
|||||||
@@ -119,6 +119,16 @@ let supportedFeatures = {
|
|||||||
[VRR_GAME_MAFIA_TWO]: false,
|
[VRR_GAME_MAFIA_TWO]: false,
|
||||||
[VRR_GAME_MAFIA_THREE]: false
|
[VRR_GAME_MAFIA_THREE]: false
|
||||||
},
|
},
|
||||||
|
attachedBlips: {
|
||||||
|
[VRR_GAME_GTA_III]: true,
|
||||||
|
[VRR_GAME_GTA_VC]: true,
|
||||||
|
[VRR_GAME_GTA_SA]: true,
|
||||||
|
[VRR_GAME_GTA_IV]: false,
|
||||||
|
[VRR_GAME_GTA_IV_EFLC]: false,
|
||||||
|
[VRR_GAME_MAFIA_ONE]: false,
|
||||||
|
[VRR_GAME_MAFIA_TWO]: false,
|
||||||
|
[VRR_GAME_MAFIA_THREE]: false
|
||||||
|
},
|
||||||
fightStyles: {
|
fightStyles: {
|
||||||
[VRR_GAME_GTA_III]: false,
|
[VRR_GAME_GTA_III]: false,
|
||||||
[VRR_GAME_GTA_VC]: false,
|
[VRR_GAME_GTA_VC]: false,
|
||||||
@@ -159,6 +169,16 @@ let supportedFeatures = {
|
|||||||
[VRR_GAME_MAFIA_ONE]: false,
|
[VRR_GAME_MAFIA_ONE]: false,
|
||||||
[VRR_GAME_MAFIA_TWO]: false,
|
[VRR_GAME_MAFIA_TWO]: false,
|
||||||
[VRR_GAME_MAFIA_THREE]: false
|
[VRR_GAME_MAFIA_THREE]: false
|
||||||
|
},
|
||||||
|
interior: {
|
||||||
|
[VRR_GAME_GTA_III]: false,
|
||||||
|
[VRR_GAME_GTA_VC]: true,
|
||||||
|
[VRR_GAME_GTA_SA]: true,
|
||||||
|
[VRR_GAME_GTA_IV]: false,
|
||||||
|
[VRR_GAME_GTA_IV_EFLC]: false,
|
||||||
|
[VRR_GAME_MAFIA_ONE]: false,
|
||||||
|
[VRR_GAME_MAFIA_TWO]: false,
|
||||||
|
[VRR_GAME_MAFIA_THREE]: false
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -3998,6 +4018,20 @@ let gameData = {
|
|||||||
[170, "Grenade"],
|
[170, "Grenade"],
|
||||||
[182, "RemoteDetonator"],
|
[182, "RemoteDetonator"],
|
||||||
[1319, "GenericPackageWhite"],
|
[1319, "GenericPackageWhite"],
|
||||||
|
[1343, "WoodenBox"],
|
||||||
|
[1339, "CardboardBox"],
|
||||||
|
[1336, "RustyBarrel"],
|
||||||
|
[1348, "TrashDumpster"],
|
||||||
|
[1338, "WoodenPallet"],
|
||||||
|
[1360, "TrafficCone"],
|
||||||
|
[1310, "WashingMachine"],
|
||||||
|
[1347, "TrashBin"],
|
||||||
|
[1396, "MailBox"],
|
||||||
|
[1359, "OrangeRoundRoadBarrier"],
|
||||||
|
[1398, "ParkBench"],
|
||||||
|
[1344, "RedBarrel"],
|
||||||
|
[1349, "StraightRoadBarrier"]
|
||||||
|
[1337, "YellowBarrel"],
|
||||||
],
|
],
|
||||||
[VRR_GAME_GTA_VC]: [ // GTA VC
|
[VRR_GAME_GTA_VC]: [ // GTA VC
|
||||||
[259, "BrassKnuckles"],
|
[259, "BrassKnuckles"],
|
||||||
@@ -4285,6 +4319,7 @@ let gameData = {
|
|||||||
// Hospitals
|
// Hospitals
|
||||||
["All Saints General Hospital", [1182.67, -1323.81, 13.579], 1.543, null],
|
["All Saints General Hospital", [1182.67, -1323.81, 13.579], 1.543, null],
|
||||||
["County General Hospital", [2034.7567, -1403.1083, 17.2931], 0.0, null],
|
["County General Hospital", [2034.7567, -1403.1083, 17.2931], 0.0, null],
|
||||||
|
["San Fierro Medical Center", [-2654.14, 635.36, 14.45], 3.0, null],
|
||||||
|
|
||||||
// Strip Clubs
|
// Strip Clubs
|
||||||
["Pig Pen Strip Club", [2420.906982, -1222.321777, 25.348423], 0.0, null],
|
["Pig Pen Strip Club", [2420.906982, -1222.321777, 25.348423], 0.0, null],
|
||||||
@@ -4758,6 +4793,8 @@ let gameData = {
|
|||||||
[VRR_GAME_GTA_III]: [1],
|
[VRR_GAME_GTA_III]: [1],
|
||||||
[VRR_GAME_GTA_VC]: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],
|
[VRR_GAME_GTA_VC]: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],
|
||||||
[VRR_GAME_GTA_SA]: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
|
[VRR_GAME_GTA_SA]: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
|
||||||
|
[VRR_GAME_GTA_IV]: [1, 2, 3],
|
||||||
|
[VRR_GAME_GTA_IV_EFLC]: [1, 2, 3],
|
||||||
},
|
},
|
||||||
blipSprites: {
|
blipSprites: {
|
||||||
[VRR_GAME_GTA_III]: { // GTA III
|
[VRR_GAME_GTA_III]: { // GTA III
|
||||||
@@ -5709,6 +5746,13 @@ let gameData = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
interiors: {
|
interiors: {
|
||||||
|
[VRR_GAME_GTA_III]: {
|
||||||
|
Apartment1: [toVector3(891.87, -308.28, 8.72), 0, false, -1],
|
||||||
|
JailCell: [toVector3(328.40, -1093.31, 25.98), 0, false, -1],
|
||||||
|
Church: [toVector3(13.87, -1122.43, 26.12), 0, false, -1],
|
||||||
|
Mansion: [toVector3(1461.00, -173.87, 55.78), 0, false, -1],
|
||||||
|
Garage: [toVector3(-420.69, 289.86, 62.96), 0, false, -1],
|
||||||
|
},
|
||||||
[VRR_GAME_GTA_VC]: { // GTA VC
|
[VRR_GAME_GTA_VC]: { // GTA VC
|
||||||
Mall: [toVector3(379.62, 1007.00, 19.22), 4, false, -1],
|
Mall: [toVector3(379.62, 1007.00, 19.22), 4, false, -1],
|
||||||
MalibuClub: [toVector3(489.83, -76.49, 11.48), 17, false, -1],
|
MalibuClub: [toVector3(489.83, -76.49, 11.48), 17, false, -1],
|
||||||
@@ -6108,16 +6152,28 @@ let gameData = {
|
|||||||
],
|
],
|
||||||
[VRR_GAME_GTA_VC]: [ // GTA VC
|
[VRR_GAME_GTA_VC]: [ // GTA VC
|
||||||
{
|
{
|
||||||
position: toVector3(493.14, 709.31, 11.80),
|
position: toVector3(-883.56, -469.39, 13.11),
|
||||||
heading: 1.5,
|
heading: -1.5,
|
||||||
blip: false,
|
blip: false,
|
||||||
name: "Unknown",
|
name: "Little Havana Hospital",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
position: toVector3(-826.06, 1144.41, 12.41),
|
position: toVector3(-135.38, -980.33, 10.46),
|
||||||
heading: 1.5,
|
heading: -1.5,
|
||||||
blip: false,
|
blip: false,
|
||||||
name: "Unknown",
|
name: "Ocean Beach Hospital",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
position: toVector3(-822.60, 1150.78, 12.41),
|
||||||
|
heading: 0.0,
|
||||||
|
blip: false,
|
||||||
|
name: "Downtown Hospital",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
position: toVector3(493.86, 700.72, 12.10),
|
||||||
|
heading: 1.02,
|
||||||
|
blip: false,
|
||||||
|
name: "Vice Point Hospital",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
[VRR_GAME_GTA_SA]: [ // GTA SA
|
[VRR_GAME_GTA_SA]: [ // GTA SA
|
||||||
|
|||||||
@@ -7,6 +7,10 @@
|
|||||||
// TYPE: Shared (JavaScript)
|
// TYPE: Shared (JavaScript)
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
|
let emojiNumbers = ["➊", "➋", "➌", "➍", "➎", "➏", "➐", "➑", "➒"];
|
||||||
|
//let emojiNumbers = ["①", "②", "③", "④", "⑤", "⑥", "⑦", "⑧", "⑨"];
|
||||||
|
//let emojiNumbers = ["1️⃣", "2️⃣", "3️⃣", "4️⃣", "5️⃣", "6️⃣", "7️⃣", "8️⃣", "9️⃣"];
|
||||||
|
|
||||||
let bindableKeys = {
|
let bindableKeys = {
|
||||||
8: "backspace",
|
8: "backspace",
|
||||||
9: "tab",
|
9: "tab",
|
||||||
@@ -1840,8 +1844,7 @@ function boolToInt(boolVal) {
|
|||||||
|
|
||||||
function fixAngle(angle) {
|
function fixAngle(angle) {
|
||||||
angle = radToDeg(angle);
|
angle = radToDeg(angle);
|
||||||
if(angle < 0)
|
if (angle < 0) {
|
||||||
{
|
|
||||||
angle = Math.abs(angle);
|
angle = Math.abs(angle);
|
||||||
angle = ((180 - angle + 1) + 180);
|
angle = ((180 - angle + 1) + 180);
|
||||||
}
|
}
|
||||||
|
|||||||
298
third-party/mexui/Core/Utility.js
vendored
298
third-party/mexui/Core/Utility.js
vendored
@@ -5,59 +5,48 @@ mexui.util.monthNames = ['january', 'february', 'march', 'april', 'may', 'june',
|
|||||||
mexui.util.weekDayNames = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'];
|
mexui.util.weekDayNames = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'];
|
||||||
|
|
||||||
// functions
|
// functions
|
||||||
mexui.util.extend = function(d, b)
|
mexui.util.extend = function (d, b) {
|
||||||
{
|
|
||||||
d.prototype = Object.create(b.prototype);
|
d.prototype = Object.create(b.prototype);
|
||||||
d.prototype.constructor = b;
|
d.prototype.constructor = b;
|
||||||
};
|
};
|
||||||
|
|
||||||
mexui.util.isPointInRectangle = function(point, position, size)
|
mexui.util.isPointInRectangle = function (point, position, size) {
|
||||||
{
|
|
||||||
if (!point)
|
if (!point)
|
||||||
return false; // temp bug fix
|
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);
|
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);
|
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);
|
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);
|
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);
|
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.Control[controlName] = constructor;
|
||||||
mexui.util.extend(mexui.Control[controlName], hasEntries ? mexui.Entity.ControlWithEntries : mexui.Component.Control);
|
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.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 || {};
|
derivedStyles = derivedStyles || {};
|
||||||
|
|
||||||
for(var k in baseStyles)
|
for (var k in baseStyles) {
|
||||||
{
|
switch (k) {
|
||||||
switch(k)
|
|
||||||
{
|
|
||||||
case 'focus':
|
case 'focus':
|
||||||
case 'hover':
|
case 'hover':
|
||||||
continue;
|
continue;
|
||||||
@@ -81,29 +70,23 @@ mexui.util.linkStyles = function(baseStyles, derivedStyles)
|
|||||||
//return derivedStyles;
|
//return derivedStyles;
|
||||||
};
|
};
|
||||||
|
|
||||||
mexui.util.linkGlobalStyles = function(baseStyles, derivedStyles)
|
mexui.util.linkGlobalStyles = function (baseStyles, derivedStyles) {
|
||||||
{
|
|
||||||
derivedStyles = derivedStyles || {};
|
derivedStyles = derivedStyles || {};
|
||||||
|
|
||||||
for(var k in derivedStyles)
|
for (var k in derivedStyles) {
|
||||||
{
|
switch (k) {
|
||||||
switch(k)
|
|
||||||
{
|
|
||||||
case 'focus':
|
case 'focus':
|
||||||
case 'hover':
|
case 'hover':
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!(derivedStyles[k].__proto__ instanceof Object))
|
if (!(derivedStyles[k].__proto__ instanceof Object)) {
|
||||||
{
|
|
||||||
derivedStyles[k].__proto__ = baseStyles.all;
|
derivedStyles[k].__proto__ = baseStyles.all;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(var k in derivedStyles)
|
for (var k in derivedStyles) {
|
||||||
{
|
switch (k) {
|
||||||
switch(k)
|
|
||||||
{
|
|
||||||
case 'focus':
|
case 'focus':
|
||||||
case 'hover':
|
case 'hover':
|
||||||
continue;
|
continue;
|
||||||
@@ -117,26 +100,20 @@ mexui.util.linkGlobalStyles = function(baseStyles, derivedStyles)
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if(derivedStyles[k].focus)
|
if (derivedStyles[k].focus) {
|
||||||
{
|
if (!(derivedStyles[k].focus.__proto__ instanceof Object)) {
|
||||||
if(!(derivedStyles[k].focus.__proto__ instanceof Object))
|
|
||||||
{
|
|
||||||
derivedStyles[k].focus.__proto__ = baseStyles.all;
|
derivedStyles[k].focus.__proto__ = baseStyles.all;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(derivedStyles[k].focus.hover)
|
if (derivedStyles[k].focus.hover) {
|
||||||
{
|
if (!(derivedStyles[k].focus.hover.__proto__ instanceof Object)) {
|
||||||
if(!(derivedStyles[k].focus.hover.__proto__ instanceof Object))
|
|
||||||
{
|
|
||||||
derivedStyles[k].focus.hover.__proto__ = baseStyles.all;
|
derivedStyles[k].focus.hover.__proto__ = baseStyles.all;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(derivedStyles[k].hover)
|
if (derivedStyles[k].hover) {
|
||||||
{
|
if (!(derivedStyles[k].hover.__proto__ instanceof Object)) {
|
||||||
if(!(derivedStyles[k].hover.__proto__ instanceof Object))
|
|
||||||
{
|
|
||||||
derivedStyles[k].hover.__proto__ = baseStyles.all;
|
derivedStyles[k].hover.__proto__ = baseStyles.all;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -145,57 +122,47 @@ mexui.util.linkGlobalStyles = function(baseStyles, derivedStyles)
|
|||||||
return derivedStyles;
|
return derivedStyles;
|
||||||
};
|
};
|
||||||
|
|
||||||
String.prototype.repeat = function(count)
|
String.prototype.repeat = function (count) {
|
||||||
{
|
|
||||||
return Array(count + 1).join(this);
|
return Array(count + 1).join(this);
|
||||||
};
|
};
|
||||||
|
|
||||||
mexui.util.isLetter = function(character)
|
mexui.util.isLetter = function (character) {
|
||||||
{
|
|
||||||
var ord = character.charCodeAt(0);
|
var ord = character.charCodeAt(0);
|
||||||
return (ord >= 65 && ord <= 90) || (ord >= 97 && ord <= 122);
|
return (ord >= 65 && ord <= 90) || (ord >= 97 && ord <= 122);
|
||||||
};
|
};
|
||||||
|
|
||||||
mexui.util.isDigit = function(character)
|
mexui.util.isDigit = function (character) {
|
||||||
{
|
|
||||||
var ord = character.charCodeAt(0);
|
var ord = character.charCodeAt(0);
|
||||||
return ord >= 48 && ord <= 57;
|
return ord >= 48 && ord <= 57;
|
||||||
};
|
};
|
||||||
|
|
||||||
mexui.util.isLetterOrDigit = function(character)
|
mexui.util.isLetterOrDigit = function (character) {
|
||||||
{
|
|
||||||
return mexui.util.isLetter(character) || mexui.util.isDigit(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);
|
var ord = character.charCodeAt(0);
|
||||||
return ord >= min && ord <= max;
|
return ord >= min && ord <= max;
|
||||||
};
|
};
|
||||||
|
|
||||||
mexui.util.interpolateScalar = function(a, b, f)
|
mexui.util.interpolateScalar = function (a, b, f) {
|
||||||
{
|
|
||||||
return a + ((b - a) * 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;
|
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", "\n");
|
||||||
text = text.replace("\r", "\n");
|
text = text.replace("\r", "\n");
|
||||||
return text.split("\n");
|
return text.split("\n");
|
||||||
};
|
};
|
||||||
|
|
||||||
mexui.util.getStringCount = function(text, find)
|
mexui.util.getStringCount = function (text, find) {
|
||||||
{
|
|
||||||
var count = 0;
|
var count = 0;
|
||||||
var index = 0;
|
var index = 0;
|
||||||
for(;;)
|
for (; ;) {
|
||||||
{
|
|
||||||
index = text.indexOf(find, index);
|
index = text.indexOf(find, index);
|
||||||
if (index == -1)
|
if (index == -1)
|
||||||
break;
|
break;
|
||||||
@@ -205,72 +172,59 @@ mexui.util.getStringCount = function(text, find)
|
|||||||
return count;
|
return count;
|
||||||
};
|
};
|
||||||
|
|
||||||
mexui.util.stack = function()
|
mexui.util.stack = function () {
|
||||||
{
|
|
||||||
var err = new Error();
|
var err = new Error();
|
||||||
console.log(err.stack);
|
console.log(err.stack);
|
||||||
};
|
};
|
||||||
|
|
||||||
mexui.util.deg = function(rad)
|
mexui.util.deg = function (rad) {
|
||||||
{
|
|
||||||
return rad * (180 / Math.PI);
|
return rad * (180 / Math.PI);
|
||||||
};
|
};
|
||||||
|
|
||||||
mexui.util.rad = function(deg)
|
mexui.util.rad = function (deg) {
|
||||||
{
|
|
||||||
return deg * (Math.PI / 180);
|
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);
|
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(
|
return new Vec2(
|
||||||
(largerSize.x - smallerSize.x) / 2.0,
|
(largerSize.x - smallerSize.x) / 2.0,
|
||||||
(largerSize.y - smallerSize.y) / 2.0
|
(largerSize.y - smallerSize.y) / 2.0
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
mexui.util.getWindowSize = function()
|
mexui.util.getWindowSize = function () {
|
||||||
{
|
return new Vec2(game.width, game.height);
|
||||||
return new Vec2(gta.width, gta.height);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
mexui.util.isRectangleInsideRectangle = function(pos1, size1, pos2, size2)
|
mexui.util.isRectangleInsideRectangle = function (pos1, size1, pos2, size2) {
|
||||||
{
|
|
||||||
return !(pos2.x > (pos1.x + size1.x) ||
|
return !(pos2.x > (pos1.x + size1.x) ||
|
||||||
(pos2.x + size2.x) < pos1.x ||
|
(pos2.x + size2.x) < pos1.x ||
|
||||||
pos2.y > (pos1.y + size1.y) ||
|
pos2.y > (pos1.y + size1.y) ||
|
||||||
(pos2.y + size2.y) < pos1.y);
|
(pos2.y + size2.y) < pos1.y);
|
||||||
};
|
};
|
||||||
|
|
||||||
mexui.util.mergeStyles = function(styles, pseudoPartNames)
|
mexui.util.mergeStyles = function (styles, pseudoPartNames) {
|
||||||
{
|
|
||||||
var styles3 = {};
|
var styles3 = {};
|
||||||
var styles2 = [styles];
|
var styles2 = [styles];
|
||||||
while(styles2[0])
|
while (styles2[0]) {
|
||||||
{
|
|
||||||
styles2 = [styles2[0]];
|
styles2 = [styles2[0]];
|
||||||
for(var i in pseudoPartNames)
|
for (var i in pseudoPartNames) {
|
||||||
{
|
|
||||||
var pseudoPartName = pseudoPartNames[i];
|
var pseudoPartName = pseudoPartNames[i];
|
||||||
|
|
||||||
if (styles2[0] && styles2[0].hasOwnProperty(pseudoPartName))
|
if (styles2[0] && styles2[0].hasOwnProperty(pseudoPartName))
|
||||||
styles2.push(styles2[0][pseudoPartName]);
|
styles2.push(styles2[0][pseudoPartName]);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(var i=styles2.length-1; i>=0; i--)
|
for (var i = styles2.length - 1; i >= 0; i--) {
|
||||||
{
|
|
||||||
if (styles2[i] == null)
|
if (styles2[i] == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for(var k in styles2[i])
|
for (var k in styles2[i]) {
|
||||||
{
|
switch (k) {
|
||||||
switch(k)
|
|
||||||
{
|
|
||||||
case 'focus':
|
case 'focus':
|
||||||
case 'hover':
|
case 'hover':
|
||||||
|
|
||||||
@@ -285,8 +239,7 @@ mexui.util.mergeStyles = function(styles, pseudoPartNames)
|
|||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(styles2[i].hasOwnProperty(k) && styles3[k] == null)
|
if (styles2[i].hasOwnProperty(k) && styles3[k] == null) {
|
||||||
{
|
|
||||||
var styleValue = styles2[i][k];
|
var styleValue = styles2[i][k];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -354,8 +307,7 @@ mexui.util.mergeStyles = function(styles, pseudoPartNames)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(var i in styles2)
|
for (var i in styles2) {
|
||||||
{
|
|
||||||
if (styles2[i])
|
if (styles2[i])
|
||||||
styles2[i] = styles2[i].__proto__;
|
styles2[i] = styles2[i].__proto__;
|
||||||
}
|
}
|
||||||
@@ -364,30 +316,24 @@ mexui.util.mergeStyles = function(styles, pseudoPartNames)
|
|||||||
return styles3;
|
return styles3;
|
||||||
};
|
};
|
||||||
|
|
||||||
mexui.util.getTransitionStyles = function(styles, pseudoPartNames, progress)
|
mexui.util.getTransitionStyles = function (styles, pseudoPartNames, progress) {
|
||||||
{
|
|
||||||
var styles3 = {};
|
var styles3 = {};
|
||||||
var styles2 = [styles];
|
var styles2 = [styles];
|
||||||
while(styles2[0])
|
while (styles2[0]) {
|
||||||
{
|
|
||||||
styles2 = [styles2[0]];
|
styles2 = [styles2[0]];
|
||||||
for(var i in pseudoPartNames)
|
for (var i in pseudoPartNames) {
|
||||||
{
|
|
||||||
var pseudoPartName = pseudoPartNames[i];
|
var pseudoPartName = pseudoPartNames[i];
|
||||||
|
|
||||||
if (styles2[0] && styles2[0].hasOwnProperty(pseudoPartName))
|
if (styles2[0] && styles2[0].hasOwnProperty(pseudoPartName))
|
||||||
styles2.push(styles2[0][pseudoPartName]);
|
styles2.push(styles2[0][pseudoPartName]);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(var i=styles2.length-1; i>=0; i--)
|
for (var i = styles2.length - 1; i >= 0; i--) {
|
||||||
{
|
|
||||||
if (styles2[i] == null)
|
if (styles2[i] == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for(var k in styles2[i])
|
for (var k in styles2[i]) {
|
||||||
{
|
switch (k) {
|
||||||
switch(k)
|
|
||||||
{
|
|
||||||
case 'focus':
|
case 'focus':
|
||||||
case 'hover':
|
case 'hover':
|
||||||
|
|
||||||
@@ -396,12 +342,10 @@ mexui.util.getTransitionStyles = function(styles, pseudoPartNames, progress)
|
|||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(styles2[i].hasOwnProperty(k) && styles3[k] == null)
|
if (styles2[i].hasOwnProperty(k) && styles3[k] == null) {
|
||||||
{
|
|
||||||
var styleValue = styles2[i][k];
|
var styleValue = styles2[i][k];
|
||||||
|
|
||||||
if(i > 0)
|
if (i > 0) {
|
||||||
{
|
|
||||||
var mainStyleValue = styles2[0][k];
|
var mainStyleValue = styles2[0][k];
|
||||||
var pseudoStyleValue = styles2[i][k];
|
var pseudoStyleValue = styles2[i][k];
|
||||||
|
|
||||||
@@ -415,8 +359,7 @@ mexui.util.getTransitionStyles = function(styles, pseudoPartNames, progress)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(var i in styles2)
|
for (var i in styles2) {
|
||||||
{
|
|
||||||
if (styles2[i])
|
if (styles2[i])
|
||||||
styles2[i] = styles2[i].__proto__;
|
styles2[i] = styles2[i].__proto__;
|
||||||
}
|
}
|
||||||
@@ -425,10 +368,8 @@ mexui.util.getTransitionStyles = function(styles, pseudoPartNames, progress)
|
|||||||
return styles3;
|
return styles3;
|
||||||
};
|
};
|
||||||
|
|
||||||
mexui.util.interpolateStyle = function(styleName, progress, styleValueFrom, styleValueTo)
|
mexui.util.interpolateStyle = function (styleName, progress, styleValueFrom, styleValueTo) {
|
||||||
{
|
switch (styleName) {
|
||||||
switch(styleName)
|
|
||||||
{
|
|
||||||
case 'backgroundColour':
|
case 'backgroundColour':
|
||||||
case 'backgroundColor':
|
case 'backgroundColor':
|
||||||
case 'textColour':
|
case 'textColour':
|
||||||
@@ -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 rgbFrom = mexui.util.fromColour(styleValueFrom);
|
||||||
var rgbTo = mexui.util.fromColour(styleValueTo);
|
var rgbTo = mexui.util.fromColour(styleValueTo);
|
||||||
var rgba = [];
|
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]);
|
rgba[i] = mexui.util.interpolateScalar(progress, rgbFrom[i], rgbTo[i]);
|
||||||
}
|
}
|
||||||
return toColour.apply(null, rgba);
|
return toColour.apply(null, rgba);
|
||||||
};
|
};
|
||||||
|
|
||||||
mexui.util.interpolateScalar = function(progress, valueFrom, valueTo)
|
mexui.util.interpolateScalar = function (progress, valueFrom, valueTo) {
|
||||||
{
|
|
||||||
return valueFrom + ((valueTo - valueFrom) * progress);
|
return valueFrom + ((valueTo - valueFrom) * progress);
|
||||||
};
|
};
|
||||||
|
|
||||||
mexui.util.fromColour = function(colour)
|
mexui.util.fromColour = function (colour) {
|
||||||
{
|
|
||||||
return [
|
return [
|
||||||
(colour >> 16) & 0xFF,
|
(colour >> 16) & 0xFF,
|
||||||
(colour >> 8) & 0xFF,
|
(colour >> 8) & 0xFF,
|
||||||
@@ -474,45 +411,37 @@ mexui.util.fromColour = function(colour)
|
|||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
mexui.util.time = function()
|
mexui.util.time = function () {
|
||||||
{
|
return sdl.ticks;
|
||||||
return gta.tickCount;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
mexui.util.isIntChar = function(character)
|
mexui.util.isIntChar = function (character) {
|
||||||
{
|
|
||||||
return mexui.util.isPositiveIntChar(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';
|
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 == '.';
|
return mexui.util.isIntChar(character) || character == '.';
|
||||||
};
|
};
|
||||||
|
|
||||||
mexui.util.isPositiveFloatChar = function(character)
|
mexui.util.isPositiveFloatChar = function (character) {
|
||||||
{
|
|
||||||
return mexui.util.isPositiveIntChar(character) || character == '.';
|
return mexui.util.isPositiveIntChar(character) || character == '.';
|
||||||
};
|
};
|
||||||
|
|
||||||
mexui.util.isInt = function(str)
|
mexui.util.isInt = function (str) {
|
||||||
{
|
|
||||||
var strInt = parseInt(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);
|
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 strFloat = parseFloat(str);
|
||||||
var firstDot = str.indexOf('.');
|
var firstDot = str.indexOf('.');
|
||||||
var addOffset = (str.substr(str.length - 2, 2) == '.0' && firstDot == (str.length - 2)) ? 2 : 0;
|
var addOffset = (str.substr(str.length - 2, 2) == '.0' && firstDot == (str.length - 2)) ? 2 : 0;
|
||||||
@@ -521,8 +450,7 @@ mexui.util.isFloat = function(str)
|
|||||||
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 strFloat = parseFloat(str);
|
||||||
var firstDot = str.indexOf('.');
|
var firstDot = str.indexOf('.');
|
||||||
var addOffset = (str.substr(str.length - 2, 2) == '.0' && firstDot == (str.length - 2)) ? 2 : 0;
|
var addOffset = (str.substr(str.length - 2, 2) == '.0' && firstDot == (str.length - 2)) ? 2 : 0;
|
||||||
@@ -531,20 +459,16 @@ mexui.util.isPositiveFloat = function(str)
|
|||||||
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);
|
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);
|
return mexui.util.inArrayOrStartsWithInArray(text, mexui.util.weekDayNames, 3);
|
||||||
};
|
};
|
||||||
|
|
||||||
mexui.util.isDayIdSuffix = function(text)
|
mexui.util.isDayIdSuffix = function (text) {
|
||||||
{
|
switch (text.toLowerCase()) {
|
||||||
switch(text.toLowerCase())
|
|
||||||
{
|
|
||||||
case 'st':
|
case 'st':
|
||||||
case 'nd':
|
case 'nd':
|
||||||
case 'rd':
|
case 'rd':
|
||||||
@@ -554,10 +478,8 @@ mexui.util.isDayIdSuffix = function(text)
|
|||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
mexui.util.isDayIdSuffixForDayId = function(dayId, text)
|
mexui.util.isDayIdSuffixForDayId = function (dayId, text) {
|
||||||
{
|
switch (text.toLowerCase()) {
|
||||||
switch(text.toLowerCase())
|
|
||||||
{
|
|
||||||
case 'st': return dayId == 1 || dayId == 21 || dayId == 31;
|
case 'st': return dayId == 1 || dayId == 21 || dayId == 31;
|
||||||
case 'nd': return dayId == 2 || dayId == 22;
|
case 'nd': return dayId == 2 || dayId == 22;
|
||||||
case 'rd': return dayId == 3 || dayId == 23;
|
case 'rd': return dayId == 3 || dayId == 23;
|
||||||
@@ -566,13 +488,11 @@ mexui.util.isDayIdSuffixForDayId = function(dayId, text)
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
mexui.util.isDayId = function(text)
|
mexui.util.isDayId = function (text) {
|
||||||
{
|
|
||||||
if (text.length == 2 && text.substr(0, 1) == '0')
|
if (text.length == 2 && text.substr(0, 1) == '0')
|
||||||
text = text.substr(1);
|
text = text.substr(1);
|
||||||
|
|
||||||
if(mexui.util.isPositiveInt(text))
|
if (mexui.util.isPositiveInt(text)) {
|
||||||
{
|
|
||||||
var _int = parseInt(text);
|
var _int = parseInt(text);
|
||||||
if (_int >= 1 && _int <= 31)
|
if (_int >= 1 && _int <= 31)
|
||||||
return true;
|
return true;
|
||||||
@@ -581,19 +501,15 @@ mexui.util.isDayId = function(text)
|
|||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
mexui.util.isDayIdWithOptionalSuffix = function(text)
|
mexui.util.isDayIdWithOptionalSuffix = function (text) {
|
||||||
{
|
|
||||||
if (mexui.util.isDayId(text))
|
if (mexui.util.isDayId(text))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if(text.length > 2)
|
if (text.length > 2) {
|
||||||
{
|
|
||||||
var last2Chars = text.substr(text.length - 2, 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);
|
var textWithoutLast2Chars = text.substr(0, text.length - 2);
|
||||||
if(mexui.util.isDayId(textWithoutLast2Chars) && mexui.util.isDayIdSuffixForDayId(parseInt(textWithoutLast2Chars), last2Chars))
|
if (mexui.util.isDayId(textWithoutLast2Chars) && mexui.util.isDayIdSuffixForDayId(parseInt(textWithoutLast2Chars), last2Chars)) {
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -602,24 +518,18 @@ mexui.util.isDayIdWithOptionalSuffix = function(text)
|
|||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
mexui.util.inArrayOrStartsWithInArray = function(text, arr, startsWithCharCount)
|
mexui.util.inArrayOrStartsWithInArray = function (text, arr, startsWithCharCount) {
|
||||||
{
|
|
||||||
text = text.toLowerCase();
|
text = text.toLowerCase();
|
||||||
|
|
||||||
for(var i in arr)
|
for (var i in arr) {
|
||||||
{
|
if (text === arr[i]) {
|
||||||
if(text === arr[i])
|
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(text.length == startsWithCharCount)
|
if (text.length == startsWithCharCount) {
|
||||||
{
|
for (var i in arr) {
|
||||||
for(var i in arr)
|
if (text === arr[i].substr(0, startsWithCharCount)) {
|
||||||
{
|
|
||||||
if(text === arr[i].substr(0, startsWithCharCount))
|
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -628,14 +538,12 @@ mexui.util.inArrayOrStartsWithInArray = function(text, arr, startsWithCharCount)
|
|||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
mexui.util.isMonthIdOrName = function(text)
|
mexui.util.isMonthIdOrName = function (text) {
|
||||||
{
|
|
||||||
var text2 = 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);
|
text2 = text2.substr(1);
|
||||||
|
|
||||||
if(mexui.util.isPositiveInt(text2))
|
if (mexui.util.isPositiveInt(text2)) {
|
||||||
{
|
|
||||||
var _int = parseInt(text2);
|
var _int = parseInt(text2);
|
||||||
if (_int >= 1 && _int <= 12)
|
if (_int >= 1 && _int <= 12)
|
||||||
return true;
|
return true;
|
||||||
@@ -644,14 +552,12 @@ mexui.util.isMonthIdOrName = function(text)
|
|||||||
return mexui.util.isMonthName(text);
|
return mexui.util.isMonthName(text);
|
||||||
};
|
};
|
||||||
|
|
||||||
mexui.util.isWeekDayId = function(text)
|
mexui.util.isWeekDayId = function (text) {
|
||||||
{
|
|
||||||
var text2 = 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);
|
text2 = text2.substr(1);
|
||||||
|
|
||||||
if(mexui.util.isPositiveInt(text2))
|
if (mexui.util.isPositiveInt(text2)) {
|
||||||
{
|
|
||||||
var _int = parseInt(text2);
|
var _int = parseInt(text2);
|
||||||
if (_int >= 1 && _int <= 7)
|
if (_int >= 1 && _int <= 7)
|
||||||
return true;
|
return true;
|
||||||
@@ -660,14 +566,12 @@ mexui.util.isWeekDayId = function(text)
|
|||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
mexui.util.isWeekDayIdOrName = function(text)
|
mexui.util.isWeekDayIdOrName = function (text) {
|
||||||
{
|
|
||||||
var text2 = 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);
|
text2 = text2.substr(1);
|
||||||
|
|
||||||
if(mexui.util.isPositiveInt(text2))
|
if (mexui.util.isPositiveInt(text2)) {
|
||||||
{
|
|
||||||
var _int = parseInt(text2);
|
var _int = parseInt(text2);
|
||||||
if (_int >= 1 && _int <= 7)
|
if (_int >= 1 && _int <= 7)
|
||||||
return true;
|
return true;
|
||||||
@@ -676,8 +580,7 @@ mexui.util.isWeekDayIdOrName = function(text)
|
|||||||
return mexui.util.isWeekDayName(text);
|
return mexui.util.isWeekDayName(text);
|
||||||
};
|
};
|
||||||
|
|
||||||
mexui.util.expand2DigitYear = function(year, twoDigitYearCapOffset)
|
mexui.util.expand2DigitYear = function (year, twoDigitYearCapOffset) {
|
||||||
{
|
|
||||||
var currentFullYear = new Date().getFullYear();
|
var currentFullYear = new Date().getFullYear();
|
||||||
var currentTwoDigitYearPlusCapOffset = parseInt((currentFullYear + '').substr(2, 2)) + twoDigitYearCapOffset;
|
var currentTwoDigitYearPlusCapOffset = parseInt((currentFullYear + '').substr(2, 2)) + twoDigitYearCapOffset;
|
||||||
if (year <= currentTwoDigitYearPlusCapOffset)
|
if (year <= currentTwoDigitYearPlusCapOffset)
|
||||||
@@ -687,8 +590,7 @@ mexui.util.expand2DigitYear = function(year, twoDigitYearCapOffset)
|
|||||||
return year;
|
return year;
|
||||||
};
|
};
|
||||||
|
|
||||||
mexui.util.isYear = function(text, minYear, maxYear, twoDigitYearCapOffset)
|
mexui.util.isYear = function (text, minYear, maxYear, twoDigitYearCapOffset) {
|
||||||
{
|
|
||||||
var _int = parseInt(text);
|
var _int = parseInt(text);
|
||||||
|
|
||||||
if (isNaN(_int))
|
if (isNaN(_int))
|
||||||
|
|||||||
140
third-party/mexui/mexui.js
vendored
140
third-party/mexui/mexui.js
vendored
@@ -15,78 +15,64 @@ mexui.focusedControl = null;
|
|||||||
mexui.hoveredComponent = null;
|
mexui.hoveredComponent = null;
|
||||||
|
|
||||||
// initialization
|
// initialization
|
||||||
mexui.init = function()
|
mexui.init = function () {
|
||||||
{
|
|
||||||
mexui.native.loadImage('mexui/Images/down-arrow.png', 'downArrow');
|
mexui.native.loadImage('mexui/Images/down-arrow.png', 'downArrow');
|
||||||
mexui.bindEvents();
|
mexui.bindEvents();
|
||||||
mexui.startTimers();
|
mexui.startTimers();
|
||||||
};
|
};
|
||||||
|
|
||||||
// events
|
// events
|
||||||
mexui.bindEvents = function()
|
mexui.bindEvents = function () {
|
||||||
{
|
addEventHandler('onMouseDown', function (event, mouse, button) {
|
||||||
addEventHandler('onMouseDown', function(event, mouse, button)
|
|
||||||
{
|
|
||||||
var e = mexui.triggerEvent('onMouseDown', { button: button });
|
var e = mexui.triggerEvent('onMouseDown', { button: button });
|
||||||
if(!e.clickedAControl)
|
if (!e.clickedAControl) {
|
||||||
{
|
|
||||||
mexui.focusedControl = null;
|
mexui.focusedControl = null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
addEventHandler('onMouseUp', function(event, mouse, button)
|
addEventHandler('onMouseUp', function (event, mouse, button) {
|
||||||
{
|
|
||||||
mexui.triggerEvent('onMouseUp', { button: button });
|
mexui.triggerEvent('onMouseUp', { button: button });
|
||||||
});
|
});
|
||||||
|
|
||||||
addEventHandler('onMouseMove', function(event, mouse, isAbsolute, position)
|
addEventHandler('onMouseMove', function (event, mouse, isAbsolute, position) {
|
||||||
{
|
|
||||||
if (isAbsolute)
|
if (isAbsolute)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mexui.triggerEvent('onMouseMove', new Vec2(position.x, position.y), true);
|
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);
|
mexui.triggerEvent('onMouseWheel', offset);
|
||||||
});
|
});
|
||||||
|
|
||||||
addEventHandler('onKeyDown', function(event, key, pkey, mods)
|
addEventHandler('onKeyDown', function (event, key, pkey, mods) {
|
||||||
{
|
|
||||||
mexui.triggerEvent('onKeyDown', key, mods);
|
mexui.triggerEvent('onKeyDown', key, mods);
|
||||||
|
|
||||||
if(key == SDLK_TAB)
|
if (key == SDLK_TAB) {
|
||||||
{
|
|
||||||
mexui.cycleFocusedControl();
|
mexui.cycleFocusedControl();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
addEventHandler('onCharacter', function(event, character)
|
addEventHandler('onCharacter', function (event, character) {
|
||||||
{
|
|
||||||
mexui.triggerEvent('onCharacter', character);
|
mexui.triggerEvent('onCharacter', character);
|
||||||
|
|
||||||
if(character == 't' || character == 'T')
|
if (character == 't' || character == 'T') {
|
||||||
{
|
|
||||||
var textInput = mexui.getFocusedTextInput();
|
var textInput = mexui.getFocusedTextInput();
|
||||||
if(textInput)
|
if (textInput) {
|
||||||
{
|
|
||||||
//event.preventDefault();
|
//event.preventDefault();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
{
|
{
|
||||||
var eventName = gta.game == GAME_GTA_SA ? 'onDrawnHUD' : 'onBeforeDrawHUD';
|
var eventName = (game.game == VRR_GAME_GTA_SA || game.game == VRR_GAME_MAFIA_ONE) ? 'onDrawnHUD' : 'onBeforeDrawHUD';
|
||||||
addEventHandler(eventName, function(event)
|
addEventHandler(eventName, function (event) {
|
||||||
{
|
|
||||||
mexui.render();
|
mexui.render();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
mexui.unbindEvents = function()
|
mexui.unbindEvents = function () {
|
||||||
{
|
|
||||||
removeEventHandler('onMouseDown');
|
removeEventHandler('onMouseDown');
|
||||||
removeEventHandler('onMouseUp');
|
removeEventHandler('onMouseUp');
|
||||||
removeEventHandler('onMouseMove');
|
removeEventHandler('onMouseMove');
|
||||||
@@ -97,43 +83,34 @@ mexui.unbindEvents = function()
|
|||||||
};
|
};
|
||||||
|
|
||||||
// timers
|
// timers
|
||||||
mexui.startTimers = function()
|
mexui.startTimers = function () {
|
||||||
{
|
|
||||||
setInterval(mexui.toggleTextInputCaretShownForBlink, 400);
|
setInterval(mexui.toggleTextInputCaretShownForBlink, 400);
|
||||||
};
|
};
|
||||||
|
|
||||||
// render
|
// render
|
||||||
mexui.render = function()
|
mexui.render = function () {
|
||||||
{
|
for (var i in mexui.windows) {
|
||||||
for(var i in mexui.windows)
|
|
||||||
{
|
|
||||||
if (mexui.windows[i].shown)
|
if (mexui.windows[i].shown)
|
||||||
mexui.windows[i].render.call(mexui.windows[i]);
|
mexui.windows[i].render.call(mexui.windows[i]);
|
||||||
}
|
}
|
||||||
for(var i in mexui.windows)
|
for (var i in mexui.windows) {
|
||||||
{
|
|
||||||
if (mexui.windows[i].shown)
|
if (mexui.windows[i].shown)
|
||||||
mexui.windows[i].renderAfter.call(mexui.windows[i]);
|
mexui.windows[i].renderAfter.call(mexui.windows[i]);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// model
|
// model
|
||||||
mexui.triggerEvent = function(eventName, data, callBaseMethodFirst)
|
mexui.triggerEvent = function (eventName, data, callBaseMethodFirst) {
|
||||||
{
|
|
||||||
var e = new mexui.Component.Event();
|
var e = new mexui.Component.Event();
|
||||||
|
|
||||||
if (data.button !== undefined)
|
if (data.button !== undefined)
|
||||||
e.button = data.button;
|
e.button = data.button;
|
||||||
|
|
||||||
var windows = mexui.windows.slice(0, mexui.windows.length).reverse();
|
var windows = mexui.windows.slice(0, mexui.windows.length).reverse();
|
||||||
for(var i in windows)
|
for (var i in windows) {
|
||||||
{
|
if (windows[i].shown) {
|
||||||
if(windows[i].shown)
|
if (callBaseMethodFirst) {
|
||||||
{
|
if (mexui.Entity.Component.prototype[eventName]) {
|
||||||
if(callBaseMethodFirst)
|
|
||||||
{
|
|
||||||
if(mexui.Entity.Component.prototype[eventName])
|
|
||||||
{
|
|
||||||
mexui.Entity.Component.prototype[eventName].call(windows[i], e, data);
|
mexui.Entity.Component.prototype[eventName].call(windows[i], e, data);
|
||||||
if (e.used)
|
if (e.used)
|
||||||
break;
|
break;
|
||||||
@@ -143,14 +120,12 @@ mexui.triggerEvent = function(eventName, data, callBaseMethodFirst)
|
|||||||
if (e.used)
|
if (e.used)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
windows[i][eventName].call(windows[i], e, data);
|
windows[i][eventName].call(windows[i], e, data);
|
||||||
if (e.used)
|
if (e.used)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if(mexui.Entity.Component.prototype[eventName])
|
if (mexui.Entity.Component.prototype[eventName]) {
|
||||||
{
|
|
||||||
mexui.Entity.Component.prototype[eventName].call(windows[i], e, data);
|
mexui.Entity.Component.prototype[eventName].call(windows[i], e, data);
|
||||||
if (e.used)
|
if (e.used)
|
||||||
break;
|
break;
|
||||||
@@ -161,29 +136,24 @@ mexui.triggerEvent = function(eventName, data, callBaseMethodFirst)
|
|||||||
return e;
|
return e;
|
||||||
};
|
};
|
||||||
|
|
||||||
mexui.getTopWindow = function()
|
mexui.getTopWindow = function () {
|
||||||
{
|
for (var i = mexui.windows.length - 1, j = 0; i >= j; i--) {
|
||||||
for(var i = mexui.windows.length - 1, j = 0; i >= j; i--)
|
|
||||||
{
|
|
||||||
if (mexui.windows[i].shown)
|
if (mexui.windows[i].shown)
|
||||||
return mexui.windows[i];
|
return mexui.windows[i];
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
mexui.getShownWindows = function()
|
mexui.getShownWindows = function () {
|
||||||
{
|
|
||||||
var shownWindows = [];
|
var shownWindows = [];
|
||||||
for(var i = mexui.windows.length - 1, j = 0; i >= j; i--)
|
for (var i = mexui.windows.length - 1, j = 0; i >= j; i--) {
|
||||||
{
|
|
||||||
if (mexui.windows[i].shown)
|
if (mexui.windows[i].shown)
|
||||||
shownWindows.push(mexui.windows[i]);
|
shownWindows.push(mexui.windows[i]);
|
||||||
}
|
}
|
||||||
return shownWindows;
|
return shownWindows;
|
||||||
};
|
};
|
||||||
|
|
||||||
mexui.getNextShownWindows = function(afterWindow)
|
mexui.getNextShownWindows = function (afterWindow) {
|
||||||
{
|
|
||||||
var shownWindows = mexui.getShownWindows();
|
var shownWindows = mexui.getShownWindows();
|
||||||
|
|
||||||
var windowIndex = shownWindows.indexOf(afterWindow);
|
var windowIndex = shownWindows.indexOf(afterWindow);
|
||||||
@@ -197,15 +167,13 @@ mexui.getNextShownWindows = function(afterWindow)
|
|||||||
return shownWindows;
|
return shownWindows;
|
||||||
};
|
};
|
||||||
|
|
||||||
mexui.cycleFocusedControl = function()
|
mexui.cycleFocusedControl = function () {
|
||||||
{
|
|
||||||
// no windows are created
|
// no windows are created
|
||||||
if (mexui.windows.length == 0)
|
if (mexui.windows.length == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// no control is focused
|
// no control is focused
|
||||||
if(!mexui.focusedControl)
|
if (!mexui.focusedControl) {
|
||||||
{
|
|
||||||
var topWindow = mexui.getTopWindow();
|
var topWindow = mexui.getTopWindow();
|
||||||
if (!topWindow)
|
if (!topWindow)
|
||||||
return;
|
return;
|
||||||
@@ -217,28 +185,24 @@ mexui.cycleFocusedControl = function()
|
|||||||
// a control is focused
|
// a control is focused
|
||||||
var focusedControlWindow = mexui.focusedControl.window;
|
var focusedControlWindow = mexui.focusedControl.window;
|
||||||
var nextControl = focusedControlWindow.getNextShownControl(mexui.focusedControl);
|
var nextControl = focusedControlWindow.getNextShownControl(mexui.focusedControl);
|
||||||
if(nextControl)
|
if (nextControl) {
|
||||||
{
|
|
||||||
mexui.focusedControl = nextControl;
|
mexui.focusedControl = nextControl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set focus to first control on next window that has a control shown
|
// set focus to first control on next window that has a control shown
|
||||||
var shownWindows = mexui.getNextShownWindows(focusedControlWindow);
|
var shownWindows = mexui.getNextShownWindows(focusedControlWindow);
|
||||||
for(var i in shownWindows)
|
for (var i in shownWindows) {
|
||||||
{
|
|
||||||
var window = shownWindows[i];
|
var window = shownWindows[i];
|
||||||
var firstControl = window.getFirstShownControl();
|
var firstControl = window.getFirstShownControl();
|
||||||
if(firstControl)
|
if (firstControl) {
|
||||||
{
|
|
||||||
mexui.focusedControl = firstControl;
|
mexui.focusedControl = firstControl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
mexui.getFocusedTextInput = function()
|
mexui.getFocusedTextInput = function () {
|
||||||
{
|
|
||||||
if (!mexui.focusedControl)
|
if (!mexui.focusedControl)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
@@ -248,8 +212,7 @@ mexui.getFocusedTextInput = function()
|
|||||||
return mexui.focusedControl;
|
return mexui.focusedControl;
|
||||||
};
|
};
|
||||||
|
|
||||||
mexui.toggleTextInputCaretShownForBlink = function()
|
mexui.toggleTextInputCaretShownForBlink = function () {
|
||||||
{
|
|
||||||
var textInput = mexui.getFocusedTextInput();
|
var textInput = mexui.getFocusedTextInput();
|
||||||
if (!textInput)
|
if (!textInput)
|
||||||
return;
|
return;
|
||||||
@@ -257,45 +220,38 @@ mexui.toggleTextInputCaretShownForBlink = function()
|
|||||||
textInput.caretShownForBlink = !textInput.caretShownForBlink;
|
textInput.caretShownForBlink = !textInput.caretShownForBlink;
|
||||||
};
|
};
|
||||||
|
|
||||||
mexui.setHoveredComponent = function(component)
|
mexui.setHoveredComponent = function (component) {
|
||||||
{
|
|
||||||
//component.hovered = true;
|
//component.hovered = true;
|
||||||
mexui.hoveredComponent = component;
|
mexui.hoveredComponent = component;
|
||||||
};
|
};
|
||||||
|
|
||||||
mexui.clearHoveredComponent = function()
|
mexui.clearHoveredComponent = function () {
|
||||||
{
|
|
||||||
//mexui.hoveredComponent.hovered = false;
|
//mexui.hoveredComponent.hovered = false;
|
||||||
mexui.hoveredComponent = null;
|
mexui.hoveredComponent = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
// api
|
// 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);
|
var window = new mexui.Component.Window(x, y, w, h, title, styles);
|
||||||
mexui.windows.push(window);
|
mexui.windows.push(window);
|
||||||
return window;
|
return window;
|
||||||
};
|
};
|
||||||
|
|
||||||
mexui.isAnyWindowShown = function()
|
mexui.isAnyWindowShown = function () {
|
||||||
{
|
for (var i in mexui.windows) {
|
||||||
for(var i in mexui.windows)
|
|
||||||
{
|
|
||||||
if (mexui.windows[i].shown)
|
if (mexui.windows[i].shown)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
mexui.setInput = function(showInput)
|
mexui.setInput = function (showInput) {
|
||||||
{
|
|
||||||
gui.showCursor(showInput, !showInput);
|
gui.showCursor(showInput, !showInput);
|
||||||
if(localClient.player && gta.game != GAME_GTA_IV)
|
|
||||||
{
|
if (localClient.player && game.game >= GAME_GTA_IV) {
|
||||||
if (showInput)
|
if (showInput)
|
||||||
gta.setCameraLookAtEntity(new Vec3(gta.cameraMatrix.m41, gta.cameraMatrix.m42, gta.cameraMatrix.m43), localPlayer, false);
|
game.setCameraLookAtEntity(new Vec3(game.cameraMatrix.m41, game.cameraMatrix.m42, game.cameraMatrix.m43), localPlayer, false);
|
||||||
else
|
else
|
||||||
gta.restoreCamera(false);
|
game.restoreCamera(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user