Merge branch 'nightly' into ragemp

This commit is contained in:
Vortrex
2022-05-20 16:51:43 -05:00
142 changed files with 8651 additions and 7284 deletions

View File

@@ -63,7 +63,7 @@ function listAccentsCommand(command, params, client) {
let chunkedList = splitArrayIntoChunks(accentList, 8);
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "AccentList")));
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "AccentsListHeader")));
for(let i in chunkedList) {
messagePlayerInfo(client, chunkedList[i].join(", "));
}
@@ -91,7 +91,7 @@ function getAccentFromParams(params) {
function reloadAccentConfigurationCommand(command, params, client) {
getGlobalConfig().accents = loadAccentConfig();
messageAdmins(`${client.name} {MAINCOLOUR}has reloaded the accent list`);
messageAdmins(`{adminOrange}${getPlayerName(client)} {MAINCOLOUR}has reloaded the accent list`);
}
// ===========================================================================
@@ -111,7 +111,7 @@ function addAccentCommand(command, params, client) {
getGlobalConfig().accents.push(newAccentName);
saveAccentConfig();
messageAdmins(`${client.name}{MAINCOLOUR} added a new accent: ${newAccentName}`);
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} added a new accent: {ALTCOLOUR}${newAccentName}{MAINCOLOUR}`);
}
// ===========================================================================
@@ -131,7 +131,7 @@ function removeAccentCommand(command, params, client) {
getGlobalConfig().accents.push(newAccentName);
saveAccentConfig();
messageAdmins(`${client.name}{MAINCOLOUR} added a new accent: ${newAccentName}`);
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} removed an accent: {ALTCOLOUR}${newAccentName}{MAINCOLOUR}`);
}
// ===========================================================================

View File

@@ -92,14 +92,15 @@ function toggleAutoSelectLastCharacterCommand(command, params, client) {
// ===========================================================================
function toggleAccountGUICommand(command, params, client) {
// Remember, the flag is BACKWARD. Enabled = NO GUI!
let flagValue = getAccountSettingsFlagValue("NoGUI");
if(doesPlayerHaveGUIEnabled(client)) {
getPlayerData(client).accountData.settings = removeBitFlag(getPlayerData(client).accountData.settings, flagValue);
messagePlayerNormal(client, getLocaleString(client, "GUIAccountSettingToggle", `{softRed}${toUpperCase(getLocaleString(client, "Off"))}{MAINCOLOUR}`));
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} has toggled GUI for their account ON.`);
} else {
getPlayerData(client).accountData.settings = addBitFlag(getPlayerData(client).accountData.settings, flagValue);
messagePlayerNormal(client, getLocaleString(client, "GUIAccountSettingToggle", `{softRed}${toUpperCase(getLocaleString(client, "Off"))}{MAINCOLOUR}`));
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} has toggled GUI for their account OFF.`);
} else {
getPlayerData(client).accountData.settings = removeBitFlag(getPlayerData(client).accountData.settings, flagValue);
messagePlayerNormal(client, getLocaleString(client, "GUIAccountSettingToggle", `{softGreen}${toUpperCase(getLocaleString(client, "On"))}{MAINCOLOUR}`));
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} has toggled GUI for their account ON.`);
}
@@ -111,7 +112,7 @@ function toggleAccountGUICommand(command, params, client) {
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the login GUI`);
} else {
hideAllPlayerGUI(client);
messagePlayerNormal(client, `👋 Welcome back to ${getServerName()}, ${getPlayerName(client)}! Please /login to continue.`, getColourByName("softGreen"));
messagePlayerNormal(client, getLocaleString(client, "WelcomeBack", getServerName(), getPlayerName(client), "{ALTCOLOUR}/login{MAINCOLOUR}"));
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the login message (GUI disabled)`);
}
} else {
@@ -120,7 +121,7 @@ function toggleAccountGUICommand(command, params, client) {
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the register GUI`);
} else {
hideAllPlayerGUI(client);
messagePlayerNormal(client, `👋 Welcome to ${getServerName()}, ${getPlayerName(client)}! Please /register to continue.`, getColourByName("softGreen"));
messagePlayerNormal(client, getLocaleString(client, "WelcomeNewPlayer", getServerName(), getPlayerName(client), "{ALTCOLOUR}/register{MAINCOLOUR}"));
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the register message (GUI disabled)`);
}
}
@@ -133,13 +134,13 @@ function toggleAccountGUICommand(command, params, client) {
function toggleAccountLoginAttemptNotificationsCommand(command, params, client) {
let flagValue = getAccountSettingsFlagValue("AuthAttemptAlert");
if(hasBitFlag(getPlayerData(client).accountData.settings, flagValue)) {
if(doesPlayerHaveLoginAlertsEnabled(client)) {
getPlayerData(client).accountData.settings = removeBitFlag(getPlayerData(client).accountData.settings, flagValue);
messagePlayerNormal(client, `⚙️ You will ${getBoolRedGreenInlineColour(true)}now {MAINCOLOUR}be notified by email when somebody tries to login to your account`);
messagePlayerNormal(client, `⚙️ You turned ${getBoolRedGreenInlineColour(false)}OFF{MAINCOLOUR} notification by email when somebody tries to login to your account`);
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} has toggled the login attempt email notifications OFF for their account`);
} else {
getPlayerData(client).accountData.settings = addBitFlag(getPlayerData(client).accountData.settings, flagValue);
messagePlayerNormal(client, `⚙️ You will ${getBoolRedGreenInlineColour(false)}not {MAINCOLOUR}be notified by email when somebody tries to login to your account`);
messagePlayerNormal(client, `⚙️ You turned ${getBoolRedGreenInlineColour(true)}ON{MAINCOLOUR} notification by email when somebody tries to login to your account`);
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} has toggled the login attempt email notifications OFF for their account`);
}
@@ -153,14 +154,14 @@ function toggleAccountServerLogoCommand(command, params, client) {
if(!doesPlayerHaveLogoEnabled(client)) {
getPlayerData(client).accountData.settings = removeBitFlag(getPlayerData(client).accountData.settings, flagValue);
messagePlayerNormal(client, `⚙️ You will ${getBoolRedGreenInlineColour(true)}now {MAINCOLOUR}be shown the server logo (if enabled on current server)`);
messagePlayerSuccess(client, getLocaleString(client, "AccountServerLogoSet", `${getBoolRedGreenInlineColour(true)}${getLocaleString(client, "On")}{MAINCOLOUR}`));
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} has toggled the server logo ON for their account`);
if(getServerConfig().showLogo) {
updatePlayerShowLogoState(client, true);
}
} else {
getPlayerData(client).accountData.settings = addBitFlag(getPlayerData(client).accountData.settings, flagValue);
messagePlayerNormal(client, `⚙️ You will ${getBoolRedGreenInlineColour(false)}not {MAINCOLOUR}be shown the server logo.`);
messagePlayerSuccess(client, getLocaleString(client, "AccountServerLogoSet", `${getBoolRedGreenInlineColour(false)}${getLocaleString(client, "Off")}{MAINCOLOUR}`));
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} has toggled the server logo OFF for their account`);
updatePlayerShowLogoState(client, false);
}
@@ -189,11 +190,11 @@ function toggleAccountTwoFactorAuthCommand(command, params, client) {
if(!doesPlayerHaveTwoFactorAuthEnabled(client)) {
getPlayerData(client).accountData.settings = addBitFlag(getPlayerData(client).accountData.settings, flagValue);
messagePlayerSuccess(client, `{MAINCOLOUR}You have turned ${getBoolRedGreenInlineColour(false)}ON {MAINCOLOUR} two factor authentication!{ALTCOLOUR}${addtoAuthenticatorCode}`);
messagePlayerSuccess(client, getLocaleString(client, "TwoFactorAuthSet", `${getBoolRedGreenInlineColour(true)}${getLocaleString(client, "On")}{MAINCOLOUR}`));
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} has toggled two-factor authentication ON for their account`);
} else {
getPlayerData(client).accountData.settings = removeBitFlag(getPlayerData(client).accountData.settings, flagValue);
messagePlayerSuccess(client, `You have turned ${getBoolRedGreenInlineColour(false)}OFF {MAINCOLOUR}two-factor authentication for login.`);
messagePlayerSuccess(client, getLocaleString(client, "TwoFactorAuthSet", `${getBoolRedGreenInlineColour(false)}${toUpperCase(getLocaleString(client, "Off"))}{MAINCOLOUR}`));
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} has toggled two-factor authentication OFF for their account`);
}
return true;
@@ -203,7 +204,7 @@ function toggleAccountTwoFactorAuthCommand(command, params, client) {
function registerCommand(command, params, client) {
if(isPlayerRegistered(client)) {
messagePlayerError(client, `Your name is already registered!`);
messagePlayerError(client, getLocaleString(client, "AccountNameAlreadyRegistered"));
return false;
}
@@ -235,8 +236,8 @@ function changeAccountPasswordCommand(command, params, client) {
}
if(!doesPasswordMeetRequirements(newPassword)) {
messagePlayerError(client, `The new password must meet the requirements!`);
messagePlayerInfo(client, `Passwords must have at least one capital letter, one lowercase letter, and one number!`);
messagePlayerError(client, getLocaleString(client, "PasswordNotGoodEnough"));
messagePlayerInfo(client, getLocaleString(client, "PasswordNeedsBase", `${getLocaleString(client, "PasswordNeedsCapitals", getGlobalConfig().passwordRequiredCapitals)}, ${getLocaleString(client, "PasswordNeedsSymbols", getGlobalConfig().passwordRequiredSymbols)}`));
return false;
}
@@ -253,12 +254,12 @@ function setAccountChatScrollLinesCommand(command, params, client) {
}
if(isNaN(params)) {
messagePlayerError(client, `The line amount must be a number!`);
messagePlayerError(client, getLocaleString(client, "ChatScrollLinesNotNumber"));
return false;
}
if(toInteger(params) < 1 || toInteger(params) > 6) {
messagePlayerError(client, `The line amount must be between 1 and 6!`);
messagePlayerError(client, getLocaleString(client, "ChatScrollLinesMustBeBetween", getGlobalConfig().minChatLines, getGlobalConfig().maxChatLines));
return false;
}
@@ -266,7 +267,7 @@ function setAccountChatScrollLinesCommand(command, params, client) {
getPlayerData(client).accountData.chatScrollLines = lines;
sendPlayerChatScrollLines(client, lines);
messagePlayerSuccess(client, `Your chatbox will now scroll ${toInteger(lines)} lines at a time!`);
messagePlayerSuccess(client, getLocaleString(client, "ChatScrollLinesSet", lines));
}
// ===========================================================================
@@ -300,7 +301,7 @@ function setAccountEmailCommand(command, params, client) {
let emailAddress = getParam(params, " ", 1);
if(!isValidEmailAddress(emailAddress)) {
messagePlayerError(client, `The email '${emailAddress} is not valid!`);
messagePlayerError(client, getLocaleString(client, "RegistrationFailedInvalidEmail"));
return false;
}
@@ -310,7 +311,7 @@ function setAccountEmailCommand(command, params, client) {
//}
if(getPlayerData(client).accountData.emailAddress != "" && isAccountEmailVerified(getPlayerData(client).accountData)) {
messagePlayerError(client, `You already set your email and verified it!`);
messagePlayerError(client, getLocaleString(client, "AccountEmailAlreadySetAndVerified"));
return false;
}
@@ -320,9 +321,9 @@ function setAccountEmailCommand(command, params, client) {
setAccountEmailVerificationCode(getPlayerData(client).accountData, emailVerificationCode);
sendEmailVerificationEmail(client, emailVerificationCode);
messagePlayerSuccess(client, `Your email has been set!`);
messagePlayerAlert(client, `Please verify your email to enable extra account security and recovery features.`);
messagePlayerAlert(client, `A verification code and instructions have been sent to your email.`);
messagePlayerSuccess(client, getLocaleString(client, "EmailSet"));
messagePlayerAlert(client, getLocaleString(client, "RegistrationEmailVerifyReminder"));
messagePlayerAlert(client, getLocaleString(client, "EmailVerificationCodeSent"));
saveAccountToDatabase(getPlayerData(client).accountData);
}
@@ -342,7 +343,7 @@ function verifyAccountEmailCommand(command, params, client) {
}
if(module.hashing.sha512(verificationCode) != getPlayerData(client).accountData.emailVerificationCode) {
messagePlayerError(client, `Invalid email verification code! A new one has been created and sent to your email.`);
messagePlayerError(client, getLocaleString(client, "InvalidEmailVerificationCode"));
let emailVerificationCode = generateEmailVerificationCode();
setAccountEmailVerificationCode(getPlayerData(client).accountData, emailVerificationCode);
sendEmailVerificationEmail(client, emailVerificationCode);
@@ -352,8 +353,8 @@ function verifyAccountEmailCommand(command, params, client) {
getPlayerData(client).accountData.flags.moderation = addBitFlag(getPlayerData(client).accountData.flags.moderation, getModerationFlagValue("EmailVerified"));
getPlayerData(client).accountData.emailVerificationCode = "";
messagePlayerSuccess(client, `Your email has been verified!`);
messagePlayerAlert(client, `You can now use your email for password resets, two-factor authentication, alerts, and more!`);
messagePlayerSuccess(client, getLocaleString(client, "EmailVerified"));
messagePlayerAlert(client, getLocaleString(client, "EmailVerifiedTip"));
saveAccountToDatabase(getPlayerData(client).accountData);
}
@@ -583,14 +584,14 @@ function loginSuccess(client) {
if(doesPlayerHaveStaffPermission(client, "Developer") || doesPlayerHaveStaffPermission(client, "ManageServer")) {
logToConsole(LOG_WARN, `[VRR.Account] ${getPlayerDisplayForConsole(client)} has needed permissions and is being given administrator access`);
client.administrator = true;
setPlayerNativeAdminState(client, true);
}
if(doesServerHaveTesterOnlyEnabled()) {
if(!hasBitFlag(getPlayerData(client).accountData.flags.moderation, getModerationFlagValue("IsTester"))) {
setTimeout(function() {
getPlayerData(client).customDisconnectReason = "Kicked - Not a tester";
client.disconnect();
disconnectPlayer(client);
}, 3500);
if(doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) {
@@ -607,7 +608,7 @@ function loginSuccess(client) {
if(getPlayerData(client).subAccounts.length == 0) {
if(doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) {
showPlayerPromptGUI(client, getLocaleString(client, "NoCharactersGUIMessage"), getLocaleString(client, "NoCharactersGUIWindowTitle"), getLocaleString(client, "Yes"), getLocaleString(client, "No"));
showPlayerPrompt(client, getLocaleString(client, "NoCharactersGUIMessage"), getLocaleString(client, "NoCharactersGUIWindowTitle"), getLocaleString(client, "Yes"), getLocaleString(client, "No"));
getPlayerData(client).promptType = VRR_PROMPT_CREATEFIRSTCHAR;
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the no characters prompt GUI`);
} else {
@@ -618,11 +619,20 @@ function loginSuccess(client) {
showCharacterSelectToClient(client);
}
getPlayerData(client).accountData.ipAddress = client.ip;
getPlayerData(client).accountData.ipAddress = getPlayerIP(client);
sendPlayerChatScrollLines(client, getPlayerData(client).accountData.chatScrollLines);
messagePlayerNormal(null, `👋 ${getPlayerName(client)} has joined the server`, getColourByName("softYellow"));
messageDiscordChatChannel(`👋 ${getPlayerName(client)} has joined the server`);
//let countryName = "Unknown";
//if(getCountryNameFromIP(getPlayerIP(client))) {
// countryName = getCountryNameFromIP(getPlayerIP(client));
//}
//let clients = getClients();
//for(let i in clients) {
// messagePlayerNormal(clients[i], getLocaleString(clients[i], "PlayerJoinedServer", `{ALTCOLOUR}${getPlayerName(client)}{MAINCOLOUR}`, `{ALTCOLOUR}${countryName}{MAINCOLOUR}`), getColourByName("softYellow"));
//}
}
// ===========================================================================
@@ -794,7 +804,7 @@ function createAccount(name, password, email = "") {
function checkLogin(client, password) {
getPlayerData(client).loginAttemptsRemaining = getPlayerData(client).loginAttemptsRemaining-1;
if(getPlayerData(client).loginAttemptsRemaining <= 0) {
client.disconnect();
disconnectPlayer(client);
}
if(isPlayerLoggedIn(client)) {
@@ -830,8 +840,8 @@ function checkLogin(client, password) {
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the login message (GUI disabled) with ${getPlayerData(client).loginAttemptsRemaining} login attempts remaining alert.`);
}
if(isAccountEmailVerified(getPlayerData(client).accountData) && isAccountSettingFlagEnabled(getPlayerData(client).accountData, getAccountSettingsFlagValue("AuthAttemptAlert"))) {
sendAccountLoginFailedNotification(getPlayerData(client).accountData.emailAddress, client.name, client.ip, getServerGame());
if(isAccountEmailVerified(getPlayerData(client).accountData) && !isAccountSettingFlagEnabled(getPlayerData(client).accountData, getAccountSettingsFlagValue("AuthAttemptAlert"))) {
sendAccountLoginFailedNotification(getPlayerData(client).accountData.emailAddress, getPlayerName(client), getPlayerIP(client), getGame());
}
return false;
}
@@ -846,17 +856,18 @@ function checkLogin(client, password) {
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the login message (GUI disabled) with ${getPlayerData(client).loginAttemptsRemaining} login attempts remaining alert.`);
}
if(isAccountEmailVerified(getPlayerData(client).accountData) && isAccountSettingFlagEnabled(getPlayerData(client).accountData, getAccountSettingsFlagValue("AuthAttemptAlert"))) {
sendAccountLoginFailedNotification(getPlayerData(client).accountData.emailAddress, client.name, client.ip, getServerGame());
if(isAccountEmailVerified(getPlayerData(client).accountData) && !isAccountSettingFlagEnabled(getPlayerData(client).accountData, getAccountSettingsFlagValue("AuthAttemptAlert"))) {
sendAccountLoginFailedNotification(getPlayerData(client).accountData.emailAddress, getPlayerName(client), getPlayerIP(client), getGame());
}
return false;
}
//if(doesPlayerHaveTwoFactorAuthEnabled(client)) {
// getPlayerData(client).twoFactorAuthCode = toUpperCase(generateRandomString(6));
// showPlayerTwoFactorAuthenticationGUI(client);
// return true;
//}
if(doesPlayerHaveTwoFactorAuthEnabled(client) && checkForSMTPModule() && getEmailConfig().enabled) {
getPlayerData(client).twoFactorAuthCode = toUpperCase(generateRandomString(6));
showPlayerTwoFactorAuthenticationGUI(client);
sendAccountTwoFactorAuthCode(getPlayerData(client).accountData.emailAddress, getPlayerName(client), getPlayerData(client).twoFactorAuthCode);
return true;
}
if(doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) {
showPlayerLoginSuccessGUI(client);
@@ -864,8 +875,8 @@ function checkLogin(client, password) {
loginSuccess(client);
if(isAccountEmailVerified(getPlayerData(client).accountData) && isAccountSettingFlagEnabled(getPlayerData(client).accountData, getAccountSettingsFlagValue("AuthAttemptAlert"))) {
sendAccountLoginSuccessNotification(getPlayerData(client).accountData.emailAddress, client.name, client.ip, getServerGame());
if(isAccountEmailVerified(getPlayerData(client).accountData) && !isAccountSettingFlagEnabled(getPlayerData(client).accountData, getAccountSettingsFlagValue("AuthAttemptAlert"))) {
sendAccountLoginSuccessNotification(getPlayerData(client).accountData.emailAddress, getPlayerName(client), getPlayerIP(client), getGame());
}
}
@@ -973,7 +984,7 @@ function checkRegistration(client, password, confirmPassword = "", emailAddress
if(doesServerHaveTesterOnlyEnabled() && !isPlayerATester(client)) {
setTimeout(function() {
client.disconnect();
disconnectPlayer(client);
}, 5000);
if(doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) {
@@ -990,7 +1001,7 @@ function checkRegistration(client, password, confirmPassword = "", emailAddress
if(doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) {
showPlayerRegistrationSuccessGUI(client);
showPlayerPromptGUI(client, getLocaleString(client, "NoCharactersMessage"), getLocaleString(client, "NoCharactersWindowTitle"), getLocaleString(client, "Yes"), getLocaleString(client, "No"));
showPlayerPrompt(client, getLocaleString(client, "NoCharactersMessage"), getLocaleString(client, "NoCharactersWindowTitle"), getLocaleString(client, "Yes"), getLocaleString(client, "No"));
getPlayerData(client).promptType = VRR_PROMPT_CREATEFIRSTCHAR;
} else {
messagePlayerAlert(client, getLocaleString(client, "NoCharactersChatMessage"), `{ALTCOLOUR}/newchar{MAINCOLOUR}`);
@@ -1024,7 +1035,7 @@ function checkAccountResetPasswordRequest(client, inputText) {
logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)} entered the correct reset password verification code. Awaiting new password input ...`);
} else {
getPlayerData(client).passwordResetState = VRR_RESETPASS_STATE_NONE;
client.disconnect();
disconnectPlayer(client);
logToConsole(LOG_DEBUG|LOG_WARN, `${getPlayerDisplayForConsole(client)} failed to reset their password (verification code not correct)`);
}
}
@@ -1038,7 +1049,7 @@ function checkAccountChangePassword(client, newPassword, confirmNewPassword) {
if(!isPlayerLoggedIn(client)) {
if(getPlayerData(client).passwordResetState != VRR_RESETPASS_STATE_SETPASS) {
//getPlayerData(client).passwordResetState = VRR_RESETPASS_STATE_NONE;
//client.disconnect();
//disconnectPlayer(client);
logToConsole(LOG_DEBUG|LOG_WARN, `${getPlayerDisplayForConsole(client)} failed to change their password (not logged in or not using reset password)`);
return false;
}
@@ -1089,7 +1100,7 @@ function isValidEmailAddress(emailAddress) {
// ===========================================================================
function savePlayersToDatabase() {
function saveAllPlayersToDatabase() {
logToConsole(LOG_DEBUG, "[VRR.Account]: Saving all clients to database ...");
getClients().forEach(function(client) {
savePlayerToDatabase(client);
@@ -1115,7 +1126,7 @@ function savePlayerToDatabase(client) {
//let subAccountData = getPlayerCurrentSubAccount(client);
if(getPlayerPed(client) != null) {
if(getPlayerData(client).returnToPosition != null) {
if(getPlayerData(client).returnToPosition != null && getPlayerData(client).returnToType != VRR_RETURNTO_TYPE_ADMINGET) {
getPlayerCurrentSubAccount(client).spawnPosition = getPlayerData(client).returnToPosition;
getPlayerCurrentSubAccount(client).spawnHeading = getPlayerData(client).returnToHeading.z;
getPlayerCurrentSubAccount(client).interior = getPlayerData(client).returnToInterior;
@@ -1141,11 +1152,11 @@ function initClient(client) {
return false;
}
if(client.getData("vrr.isInitialized") != null || client.getData("vrr.isInitialized") == true) {
if(doesEntityDataExist(client, "vrr.isInitialized") || getEntityData(client, "vrr.isInitialized") == true) {
return false;
}
client.setData("vrr.isInitialized", true, false);
setEntityData(client, "vrr.isInitialized", true, false);
sendPlayerGUIColours(client);
sendPlayerGUIInit(client);
@@ -1157,19 +1168,19 @@ function initClient(client) {
setTimeout(function() {
if(client != null) {
clearChatBox(client);
let tempAccountData = loadAccountFromName(getPlayerName(client), true);
let tempSubAccounts = loadSubAccountsFromAccount(tempAccountData.databaseId);
getServerData().clients[client.index] = new ClientData(client, tempAccountData, tempSubAccounts);
getServerData().clients[getPlayerId(client)] = new ClientData(client, tempAccountData, tempSubAccounts);
getServerData().clients[client.index].sessionId = saveConnectionToDatabase(client);
getServerData().clients[client.index].connectTime = getCurrentUnixTimestamp();
getServerData().clients[getPlayerId(client)].sessionId = saveConnectionToDatabase(client);
getServerData().clients[getPlayerId(client)].connectTime = getCurrentUnixTimestamp();
requestClientInfo(client);
if(tempAccountData != false) {
if(isAccountAutoIPLoginEnabled(tempAccountData) && getPlayerData(client).accountData.ipAddress == client.ip) {
sendPlayerLocaleId(client, getPlayerData(client).accountData.locale);
if(isAccountAutoIPLoginEnabled(tempAccountData) && getPlayerData(client).accountData.ipAddress == getPlayerIP(client)) {
messagePlayerAlert(client, getLocaleString(client, "AutoLoggedInIP"));
loginSuccess(client);
playRadioStreamForPlayer(client, getServerIntroMusicURL(), true, getPlayerStreamingRadioVolume(client));
@@ -1182,7 +1193,7 @@ function initClient(client) {
messagePlayerNormal(client, getLocaleString(client, "WelcomeBack", getServerName(), getPlayerName(client), "/login"),getColourByName("softGreen"));
//if(checkForGeoIPModule()) {
// let iso = module.geoip.getCountryISO(client.ip);
// let iso = module.geoip.getCountryISO(getPlayerIP(client));
// let localeId = getLocaleFromCountryISO(iso);
//}
//showGameMessage(client, getLocaleString(client, "LocaleOffer", `/lang ${getLocaleData(localeId)[2]}`), getColourByName("white"), 10000, "Roboto");
@@ -1190,6 +1201,7 @@ function initClient(client) {
playRadioStreamForPlayer(client, getServerIntroMusicURL(), true, getPlayerStreamingRadioVolume(client));
}
} else {
sendPlayerLocaleId(client, 0);
if(doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) {
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the register GUI.`);
showPlayerRegistrationGUI(client);
@@ -1200,9 +1212,12 @@ function initClient(client) {
playRadioStreamForPlayer(client, getServerIntroMusicURL(), true, getPlayerStreamingRadioVolume(client));
}
getServerData().clients[client.index].keyBinds = loadAccountKeybindsFromDatabase(getServerData().clients[client.index].accountData.databaseId);
getServerData().clients[getPlayerId(client)].keyBinds = loadAccountKeybindsFromDatabase(getServerData().clients[getPlayerId(client)].accountData.databaseId);
sendAccountKeyBindsToClient(client);
}
}, 2500);
}
@@ -1212,7 +1227,7 @@ function saveConnectionToDatabase(client) {
let dbConnection = connectToDatabase();
if(dbConnection) {
let safeName = escapeDatabaseString(dbConnection, getPlayerName(client));
let dbQueryString = `INSERT INTO conn_main (conn_when_connect, conn_server, conn_script_version, conn_game_version, conn_client_version, conn_name, conn_ip) VALUES (NOW(), ${getServerConfig().databaseId}, '${scriptVersion}', '${client.gameVersion}', '0.0.0', '${safeName}', '${client.ip}')`;
let dbQueryString = `INSERT INTO conn_main (conn_when_connect, conn_server, conn_script_version, conn_game_version, conn_client_version, conn_name, conn_ip) VALUES (NOW(), ${getServerConfig().databaseId}, '${scriptVersion}', '${getPlayerGameVersion(client)}', '0.0.0', '${safeName}', '${getPlayerIP(client)}')`;
queryDatabase(dbConnection, dbQueryString);
return getDatabaseInsertId(dbConnection);
}
@@ -1406,7 +1421,13 @@ function isAccountTwoFactorAuthenticationVerified(accountData) {
// ===========================================================================
function doesPlayerHaveTwoFactorAuthEnabled(client) {
return hasBitFlag(getPlayerData(client).accountData.flags.settings, getAccountSettingsFlagValue("TwoFactorAuth"));
return hasBitFlag(getPlayerData(client).accountData.settings, getAccountSettingsFlagValue("TwoFactorAuth"));
}
// ===========================================================================
function doesPlayerHaveLoginAlertsEnabled(client) {
return hasBitFlag(getPlayerData(client).accountData.settings, getAccountSettingsFlagValue("AuthAttemptAlert"));
}
// ===========================================================================
@@ -1464,7 +1485,7 @@ function verifyAccountEmail(accountData, verificationCode) {
// ===========================================================================
function sendAccountLoginFailedNotification(emailAddress, name, ip, game = getServerGame()) {
function sendAccountLoginFailedNotification(emailAddress, name, ip, game = getGame()) {
let countryName = module.geoip.getCountryName(getGlobalConfig().geoIPCountryDatabaseFilePath, ip);
let subDivisionName = module.geoip.getSubdivisionName(getGlobalConfig().geoIPCityDatabaseFilePath, ip);
let cityName = module.geoip.getCityName(getGlobalConfig().geoIPCityDatabaseFilePath, ip);
@@ -1472,7 +1493,7 @@ function sendAccountLoginFailedNotification(emailAddress, name, ip, game = getSe
let emailBodyText = getEmailConfig().bodyContent.accountAuthFailAlert;
emailBodyText = emailBodyText.replace("{GAMENAME}", getGameName(game));
emailBodyText = emailBodyText.replace("{IPADDRESS}", ip);
emailBodyText = emailBodyText.replace("{LOCATION}", `${cityName}, ${countryName}, ${countryName}`);
emailBodyText = emailBodyText.replace("{LOCATION}", `${cityName}, ${subDivisionName}, ${countryName}`);
emailBodyText = emailBodyText.replace("{SERVERNAME}", getServerName());
emailBodyText = emailBodyText.replace("{TIMESTAMP}", date.toLocaleString('en-US'));
@@ -1482,7 +1503,7 @@ function sendAccountLoginFailedNotification(emailAddress, name, ip, game = getSe
// ===========================================================================
function sendAccountLoginSuccessNotification(emailAddress, name, ip, game = getServerGame()) {
function sendAccountLoginSuccessNotification(emailAddress, name, ip, game = getGame()) {
let countryName = module.geoip.getCountryName(getGlobalConfig().geoIPCountryDatabaseFilePath, ip);
let subDivisionName = module.geoip.getSubdivisionName(getGlobalConfig().geoIPCityDatabaseFilePath, ip);
let cityName = module.geoip.getCityName(getGlobalConfig().geoIPCityDatabaseFilePath, ip);
@@ -1520,7 +1541,7 @@ function checkPlayerTwoFactorAuthentication(client, authCode) {
}
}
client.disconnect();
disconnectPlayer(client);
return false;
}
@@ -1530,4 +1551,16 @@ function isPlayerATester(client) {
}
// ===========================================================================
function sendAccountTwoFactorAuthCode(emailAddress, name, twoFactorAuthCode) {
let emailBodyText = getEmailConfig().bodyContent.twoFactorAuthentication;
emailBodyText = emailBodyText.replace("{2FACODE}", twoFactorAuthCode);
emailBodyText = emailBodyText.replace("{GAMENAME}", getGameName(getGame()));
emailBodyText = emailBodyText.replace("{SERVERNAME}", getServerName());
sendEmail(emailAddress, name, `Login code for ${getServerName()}`, emailBodyText);
return true;
}
// ===========================================================================

View File

@@ -25,7 +25,7 @@ function playPlayerAnimationCommand(command, params, client) {
if(!animationSlot) {
messagePlayerError(client, getLocaleString(client, "InvalidAnimation"));
messagePlayerInfo(client, getLocaleString(client, "AnimationHelpTip"), `{ALTCOLOUR}/animlist{MAINCOLOUR}`);
messagePlayerInfo(client, getLocaleString(client, "AnimationCommandTip", `{ALTCOLOUR}/animlist{MAINCOLOUR}`));
return false;
}
@@ -64,13 +64,13 @@ function stopPlayerAnimationCommand(command, params, client) {
getPlayerData(client).animationStart = 0;
getPlayerData(client).animationForced = false;
setPlayerMouseCameraState(client, false);
//setPlayerMouseCameraState(client, false);
}
// ===========================================================================
function showAnimationListCommand(command, params, client) {
let animList = getGameConfig().animations[getServerGame()].map(function(x) { return x.name; });
let animList = getGameConfig().animations[getGame()].map(function(x) { return x.name; });
let chunkedList = splitArrayIntoChunks(animList, 10);
@@ -87,7 +87,7 @@ function showAnimationListCommand(command, params, client) {
* @param {number} animationSlot - The slot index of the animation
* @return {Array} The animation's data (array)
*/
function getAnimationData(animationSlot, gameId = getServerGame()) {
function getAnimationData(animationSlot, gameId = getGame()) {
return getGameConfig().animations[gameId][animationSlot];
}
@@ -144,7 +144,7 @@ function makePlayerStopAnimation(client) {
// ===========================================================================
function getAnimationFromParams(params) {
let animations = getGameConfig().animations[getServerGame()];
let animations = getGameConfig().animations[getGame()];
if(isNaN(params)) {
for(let i in animations) {
if(toLowerCase(animations[i].name).indexOf(toLowerCase(params)) != -1) {
@@ -152,7 +152,7 @@ function getAnimationFromParams(params) {
}
}
} else {
if(typeof getGameConfig().animations[getServerGame()][params] != "undefined") {
if(typeof getGameConfig().animations[getGame()][params] != "undefined") {
return toInteger(params);
}
}

View File

@@ -7,8 +7,6 @@
// TYPE: Server (JavaScript)
// ===========================================================================
// ===========================================================================
function initBanScript() {
logToConsole(LOG_INFO, "[VRR.Ban]: Initializing ban script ...");
logToConsole(LOG_INFO, "[VRR.Ban]: Ban script initialized!");
@@ -39,7 +37,7 @@ function accountBanCommand(command, params, client) {
logToConsole(LOG_WARN, `[VRR.Ban]: ${getPlayerDisplayForConsole(targetClient)} (${getPlayerData(targetClient).accountData.name}) account was banned by ${getPlayerDisplayForConsole(client)}. Reason: ${reason}`);
announceAdminAction(`PlayerAccountBanned`, `{ALTCOLOUR}${targetClient.name}{MAINCOLOUR}`);
announceAdminAction(`PlayerAccountBanned`, `{ALTCOLOUR}${getPlayerName(client)}{MAINCOLOUR}`);
banAccount(getPlayerData(targetClient).accountData.databaseId, getPlayerData(client).accountData.databaseId, reason);
disconnectPlayer(client);
}
@@ -69,7 +67,7 @@ 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}`);
announceAdminAction(`PlayerCharacterBanned`, `{ALTCOLOUR}${targetClient.name}{MAINCOLOUR}`);
announceAdminAction(`PlayerCharacterBanned`, `{ALTCOLOUR}${getPlayerName(client)}{MAINCOLOUR}`);
banSubAccount(getPlayerData(targetClient).currentSubAccountData.databaseId, getPlayerData(client).accountData.databaseId, reason);
disconnectPlayer(client);
@@ -98,11 +96,11 @@ function ipBanCommand(command, params, client, fromDiscord) {
return false;
}
announceAdminAction(`PlayerIPBanned`, `{ALTCOLOUR}${targetClient.name}{MAINCOLOUR}`);
banIPAddress(targetClient.ip, getPlayerData(client).accountData.databaseId, reason);
announceAdminAction(`PlayerIPBanned`, `{ALTCOLOUR}${getPlayerName(targetClient)}{MAINCOLOUR}`);
banIPAddress(getPlayerIP(targetClient), getPlayerData(client).accountData.databaseId, reason);
server.banIP(targetClient.ip);
targetClient.disconnect();
serverBanIP(getPlayerIP(targetClient));
disconnectPlayer(targetClient);
}
// ===========================================================================
@@ -129,10 +127,10 @@ function subNetBanCommand(command, params, client, fromDiscord) {
return false;
}
announceAdminAction(`PlayerSubNetBanned`, `{ALTCOLOUR}${targetClient.name}{MAINCOLOUR}`);
banSubNet(targetClient.ip, getSubNet(targetClient.ip, octetAmount), getPlayerData(client).accountData.databaseId, reason);
announceAdminAction(`PlayerSubNetBanned`, `{ALTCOLOUR}${getPlayerName(client)}{MAINCOLOUR}`);
banSubNet(getPlayerIP(targetClient), getSubNet(getPlayerIP(targetClient), octetAmount), getPlayerData(client).accountData.databaseId, reason);
server.banIP(targetClient.ip);
serverBanIP(getPlayerIP(targetClient));
}
// ===========================================================================
@@ -254,13 +252,9 @@ function unbanSubNet(ipAddressStart, ipAddressEnd, adminAccountId) {
// ===========================================================================
function isAccountBanned(accountId) {
let bans = getServerData().bans;
for(let i in bans) {
if(bans[i].type == VRR_BANTYPE_ACCOUNT) {
if(bans[i].detail == accountId) {
return true;
}
}
let bans = getServerData().bans.filter(ban => ban.type === VRR_BANTYPE_ACCOUNT && ban.detail === accountId);
if(bans.length > 0) {
return true;
}
return false;
@@ -269,13 +263,9 @@ function isAccountBanned(accountId) {
// ===========================================================================
function isSubAccountBanned(subAccountId) {
let bans = getServerData().bans;
for(let i in bans) {
if(bans[i].type == VRR_BANTYPE_SUBACCOUNT) {
if(bans[i].detail == subAccountId) {
return true;
}
}
let bans = getServerData().bans.filter(ban => ban.type === VRR_BANTYPE_SUBACCOUNT && ban.detail === subAccountId);
if(bans.length > 0) {
return true;
}
return false;
@@ -284,13 +274,9 @@ function isSubAccountBanned(subAccountId) {
// ===========================================================================
function isIpAddressBanned(ipAddress) {
let bans = getServerData().bans;
for(let i in bans) {
if(bans[i].type == VRR_BANTYPE_IPADDRESS) {
if(bans[i].detail == ipAddress) {
return true;
}
}
let bans = getServerData().bans.filter(ban => ban.type === VRR_BANTYPE_IPADDRESS && ban.detail === ipAddress);
if(bans.length > 0) {
return true;
}
return false;

View File

@@ -7,8 +7,6 @@
// TYPE: Server (JavaScript)
// ===========================================================================
// ===========================================================================
let serverBitFlags = {
staffFlags: {},
moderationFlags: {},
@@ -244,40 +242,6 @@ function initBitFlagScript() {
// ===========================================================================
function createBitFlagTable(keyNames) {
let bitVal = 0;
let bitTable = {};
let incVal = 1;
for(let i in keyNames) {
let key = keyNames[i];
bitTable[key] = bitVal;
bitVal = 1 << incVal;
incVal++;
}
return bitTable;
}
// ===========================================================================
function hasBitFlag(allFlags, checkForFlag) {
if(allFlags == 0) {
return false;
}
if(allFlags == -1) {
return true;
}
if((allFlags & checkForFlag) == checkForFlag) {
return true;
}
return false;
}
// ===========================================================================
function doesPlayerHaveStaffPermission(client, requiredFlags) {
if(isConsole(client)) {
return true;
@@ -415,18 +379,6 @@ function takePlayerStaffFlag(client, flagName) {
// ===========================================================================
function addBitFlag(allFlags, flagValue) {
return allFlags | flagValue;
}
// ===========================================================================
function removeBitFlag(allFlags, flagValue) {
return allFlags ^ flagValue;
}
// ===========================================================================
function takePlayerStaffFlag(client, flagName) {
if(!getStaffFlagValue(flagName)) {
return false;
@@ -455,20 +407,4 @@ function getServerBitFlagKeys() {
return serverBitFlagKeys;
}
// ===========================================================================
function createBitwiseTable(tableKeys) {
let bitVal = 0;
let bitTable = {};
let incVal = 1;
for(let i in tableKeys) {
let key = tableKeys[i];
bitTable[key] = bitVal;
bitVal = 1 << incVal;
incVal++;
}
return bitTable;
}
// ===========================================================================

File diff suppressed because it is too large Load Diff

View File

@@ -173,7 +173,7 @@ function adminChatCommand(command, params, client) {
return false;
}
messageAdmins(`{jobYellow}[Admin Chat] {ALTCOLOUR}${getPlayerName(client)} [#CCCCCC](${getPlayerStaffTitle(client)}){MAINCOLOUR}: ${params}`);
messageAdmins(`{jobYellow}[Admin Chat] {ALTCOLOUR}${getPlayerName(client)}: ${params}`);
}
// ===========================================================================

View File

@@ -9,11 +9,6 @@
function initClanScript() {
logToConsole(LOG_INFO, "[VRR.Clan]: Initializing clans script ...");
if(!getServerConfig().devServer) {
getServerData().clans = loadClansFromDatabase();
}
setAllClanDataIndexes();
logToConsole(LOG_INFO, "[VRR.Clan]: Clan script initialized successfully!");
return true;
}
@@ -36,7 +31,7 @@ function loadClansFromDatabase() {
//tempClanData.members = loadClanMembersFromDatabase(tempClanData.databaseId);
tempClanData.ranks = loadClanRanksFromDatabase(tempClanData.databaseId);
tempClans.push(tempClanData);
logToConsole(LOG_VERBOSE, `[VRR.Clan]: Clan '${tempClanData.name}' loaded from database successfully!`);
logToConsole(LOG_DEBUG, `[VRR.Clan]: Clan '${tempClanData.name}' loaded from database successfully!`);
}
}
freeDatabaseQuery(dbQuery);
@@ -705,8 +700,7 @@ function showClanRankFlagsCommand(command, params, client) {
let chunkedList = splitArrayIntoChunks(flagList, 6);
messagePlayerInfo(client, `{clanOrange}== {jobYellow}Clan Rank Flags (${getClanRankData(clanId, rankId).name}){clanOrange}===================`);
makeChatBoxSectionHeader(client, getLocaleString(client, "ClanRankFlags"), getClanRankData(clanId, rankId).name);
for(let i in chunkedList) {
messagePlayerInfo(client, chunkedList[i].join("{MAINCOLOUR}, "));
}
@@ -847,7 +841,7 @@ function setClanMemberRankCommand(command, params, client) {
let oldClanRank = getClanRankData(clanId, getPlayerClanRank(targetClient));
getPlayerCurrentSubAccount(targetClient).clanRank = getClanRankData(clanId, rankId).databaseId;
getPlayerCurrentSubAccount(targetClient).clanRankIndex = rankId;
messagePlayerSuccess(client, `You changed {ALTCOLOUR}${getCharacterFullName(targetClient)}'s {MAINCOLOUR}rank from {ALTCOLOUR}${oldClanRank.name} {MAINCOLOUR}to {ALTCOLOUR}${getClanRankData(clanId, rankId).name}`);
messagePlayerSuccess(client, `You changed {ALTCOLOUR}${getCharacterFullName(targetClient)}'s{MAINCOLOUR} rank from {ALTCOLOUR}${oldClanRank.name}{MAINCOLOUR} to {ALTCOLOUR}${getClanRankData(clanId, rankId).name}`);
}
// ===========================================================================
@@ -873,7 +867,7 @@ function createClan(name) {
// ===========================================================================
function deleteClan(clanId) {
saveClansToDatabase();
//saveAllClansToDatabase();
let dbConnection = connectToDatabase();
if(dbConnection) {
@@ -1086,7 +1080,7 @@ function setClanRankTitle(clanId, rankId, title) {
// ===========================================================================
function saveClansToDatabase() {
function saveAllClansToDatabase() {
if(getServerConfig().devServer) {
return false;
}
@@ -1214,7 +1208,7 @@ function showClanFlagListCommand(command, params, client) {
return false;
}
let rankId = getClanRankFromParams(clanId, getParam(params, " ", 1));
let rankId = getClanRankFromParams(clanId, getParam(params, " ", 1));
if(!getClanRankData(clanId, rankId)) {
messagePlayerError(client, getLocaleString(client, "ClanRankInvalid"));
@@ -1237,6 +1231,8 @@ let rankId = getClanRankFromParams(clanId, getParam(params, " ", 1));
}
*/
// ===========================================================================
/**
* @param {String} params - The params to search for
* @return {Number} The data index of a matching clan

View File

@@ -7,8 +7,6 @@
// TYPE: Server (JavaScript)
// ===========================================================================
// ===========================================================================
function initClassScript() {
logToConsole(LOG_INFO, "[VRR.Class]: Initializing class script ...");
logToConsole(LOG_INFO, "[VRR.Class]: Class script initialized successfully!");
@@ -59,6 +57,7 @@ class ServerConfigData {
this.inflationMultiplier = 1;
this.testerOnly = false;
this.devServer = false;
this.nameTagDistance = 50.0;
this.antiCheat = {
enabled: false,
@@ -89,7 +88,7 @@ class ServerConfigData {
this.discordConfig = {
sendEvents: true,
sendChat: true,
sendAdminEvents: true,
sendAdmin: true,
};
if(dbAssoc) {
@@ -109,27 +108,22 @@ class ServerConfigData {
this.minute = toInteger(dbAssoc["svr_start_time_min"]);
this.minuteDuration = toInteger(dbAssoc["svr_time_min_duration"]);
this.weather = toInteger(dbAssoc["svr_start_weather"]);
//this.fallingSnow = intToBool(toInteger(dbAssoc["svr_start_snow_falling"]));
//this.groundSnow = intToBool(toInteger(dbAssoc["svr_start_snow_ground"]));
//this.useGUI = intToBool(toInteger(dbAssoc["svr_gui_enabled"]));
//this.showLogo = intToBool(toInteger(dbAssoc["svr_logo_enabled"]));
//this.testerOnly = intToBool(toInteger(dbAssoc["svr_tester_only"]));
/*
this.createJobPickups = intToBool(toInteger(dbAssoc["svr_job_pickups_enabled"]));
this.createBusinessPickups = intToBool(toInteger(dbAssoc["svr_biz_pickups_enabled"]));
this.createHousePickups = intToBool(toInteger(dbAssoc["svr_house_pickups_enabled"]));
this.createJobBlips = intToBool(toInteger(dbAssoc["svr_job_blips_enabled"]));
this.createBusinessBlips = intToBool(toInteger(dbAssoc["svr_biz_blips_enabled"]));
this.createHouseBlips = intToBool(toInteger(dbAssoc["svr_house_blips_enabled"]));
*/
this.fallingSnow = intToBool(toInteger(dbAssoc["svr_snow_falling"]));
this.groundSnow = intToBool(toInteger(dbAssoc["svr_snow_ground"]));
this.useGUI = intToBool(toInteger(dbAssoc["svr_gui"]));
this.showLogo = intToBool(toInteger(dbAssoc["svr_logo"]));
this.createJobPickups = intToBool(toInteger(dbAssoc["svr_job_pickups"]));
this.createBusinessPickups = intToBool(toInteger(dbAssoc["svr_biz_pickups"]));
this.createHousePickups = intToBool(toInteger(dbAssoc["svr_house_pickups"]));
this.createJobBlips = intToBool(toInteger(dbAssoc["svr_job_blips"]));
this.createBusinessBlips = intToBool(toInteger(dbAssoc["svr_biz_blips"]));
this.createHouseBlips = intToBool(toInteger(dbAssoc["svr_house_blips"]));
this.guiColourPrimary = [toInteger(dbAssoc["svr_gui_col1_r"]), toInteger(dbAssoc["svr_gui_col1_g"]), toInteger(dbAssoc["svr_gui_col1_b"])];
this.guiColourSecondary = [toInteger(dbAssoc["svr_gui_col2_r"]), toInteger(dbAssoc["svr_gui_col2_g"]), toInteger(dbAssoc["svr_gui_col2_b"])];
this.guiTextColourPrimary = [toInteger(dbAssoc["svr_gui_textcol1_r"]), toInteger(dbAssoc["svr_gui_textcol1_g"]), toInteger(dbAssoc["svr_gui_textcol1_b"])];
//this.guiTextColourSecondary = [toInteger(dbAssoc["svr_gui_textcol2_r"]), toInteger(dbAssoc["svr_gui_textcol2_g"]), toInteger(dbAssoc["svr_gui_textcol2_b"])];
this.inflationMultiplier = toFloat(dbAssoc["svr_inflation_multiplier"]);
this.nameTagDistance = toFloat(dbAssoc["svr_nametag_distance"]);
this.discordBotToken = intToBool(dbAssoc["svr_discord_bot_token"]);
this.introMusicURL = dbAssoc["svr_intro_music"];
@@ -137,9 +131,9 @@ class ServerConfigData {
//this.realTimeZone = dbAssoc["svr_real_time_timezone"];
this.discord = {
sendEvents: true,
sendChat: true,
sendAdmin: true,
sendEvents: intToBool(dbAssoc["svr_discord_send_events"]),
sendChat: intToBool(dbAssoc["svr_discord_send_chat"]),
sendAdmin: intToBool(dbAssoc["svr_discord_send_admin"]),
};
}
}
@@ -252,7 +246,7 @@ class ClientData {
this.customDisconnectReason = "";
this.interiorCutscene = "";
this.interiorCutscene = -1;
}
};
@@ -540,7 +534,7 @@ class BusinessData {
this.entranceBlipModel = -1;
this.entrancePickup = null;
this.entranceBlip = null;
this.entranceCutscene = "";
this.entranceCutscene = -1;
this.exitPosition = false;
this.exitRotation = 0.0;
@@ -550,7 +544,7 @@ class BusinessData {
this.exitBlipModel = -1;
this.exitPickup = null;
this.exitBlip = null;
this.exitCutscene = "";
this.exitCutscene = -1;
this.entranceFee = 0;
this.till = 0;
@@ -561,6 +555,8 @@ class BusinessData {
this.triggers = [];
this.customInterior = false;
if(dbAssoc) {
this.databaseId = toInteger(dbAssoc["biz_id"]);
this.name = toString(dbAssoc["biz_name"]);
@@ -577,7 +573,7 @@ class BusinessData {
this.entranceDimension = toInteger(dbAssoc["biz_entrance_vw"]);
this.entrancePickupModel = toInteger(dbAssoc["biz_entrance_pickup"]);
this.entranceBlipModel = toInteger(dbAssoc["biz_entrance_blip"]);
this.entranceCutscene = toString(dbAssoc["biz_entrance_cutscene"]);
this.entranceCutscene = toInteger(dbAssoc["biz_entrance_cutscene"]);
this.exitPosition = toVector3(dbAssoc["biz_exit_pos_x"], dbAssoc["biz_exit_pos_y"], dbAssoc["biz_exit_pos_z"]);
this.exitRotation = toInteger(dbAssoc["biz_exit_rot_z"]);
@@ -585,14 +581,14 @@ class BusinessData {
this.exitDimension = toInteger(dbAssoc["biz_exit_vw"]);
this.exitPickupModel = toInteger(dbAssoc["biz_exit_pickup"]);
this.exitBlipModel = toInteger(dbAssoc["biz_exit_blip"]);
this.exitCutscene = toString(dbAssoc["biz_exit_cutscene"]);
this.exitCutscene = toInteger(dbAssoc["biz_exit_cutscene"]);
this.entranceFee = toInteger(dbAssoc["biz_entrance_fee"]);
this.till = toInteger(dbAssoc["biz_till"]);
this.labelHelpType = toInteger(dbAssoc["biz_label_help_type"]);
this.streamingRadioStation = toInteger(dbAssoc["biz_radiostation"]);
this.customInterior = intToBool(toInteger(dbAssoc["biz_custom_interior"]));
}
};
};
@@ -681,7 +677,6 @@ class HouseData {
this.entranceBlipModel = -1;
this.entrancePickup = null;
this.entranceBlip = null;
this.entranceCutscene = "";
this.exitPosition = false;
this.exitRotation = 0.0;
@@ -691,12 +686,13 @@ class HouseData {
this.exitBlipModel = -1;
this.exitPickup = null;
this.exitBlip = null;
this.exitCutscene = "";
this.streamingRadioStation = -1;
this.triggers = [];
this.customInterior = false;
if(dbAssoc) {
this.databaseId = toInteger(dbAssoc["house_id"]);
this.description = toString(dbAssoc["house_description"]);
@@ -715,7 +711,7 @@ class HouseData {
this.entranceDimension = toInteger(dbAssoc["house_entrance_vw"]);
this.entrancePickupModel = toInteger(dbAssoc["house_entrance_pickup"]);
this.entranceBlipModel = toInteger(dbAssoc["house_entrance_blip"]);
this.entranceCutscene = toString(dbAssoc["house_entrance_cutscene"]);
this.entranceCutscene = toInteger(dbAssoc["house_entrance_cutscene"]);
this.exitPosition = toVector3(toFloat(dbAssoc["house_exit_pos_x"]), toFloat(dbAssoc["house_exit_pos_y"]), toFloat(dbAssoc["house_exit_pos_z"]));
this.exitRotation = toFloat(dbAssoc["house_exit_rot_z"]);
@@ -723,7 +719,9 @@ class HouseData {
this.exitDimension = toInteger(dbAssoc["house_exit_vw"]);
this.exitPickupModel = toInteger(dbAssoc["house_exit_pickup"]);
this.exitBlipModel = toInteger(dbAssoc["house_exit_blip"]);
this.exitCutscene = toString(dbAssoc["house_exit_cutscene"]);
this.exitCutscene = toInteger(dbAssoc["house_exit_cutscene"]);
this.customInterior = intToBool(toInteger(dbAssoc["house_custom_interior"]));
}
}
};
@@ -1259,14 +1257,12 @@ class JobLocationData {
this.routeCache = [];
if(dbAssoc) {
this.databaseId = dbAssoc["job_loc_id"];
this.jobId = dbAssoc["job_loc_job"];
this.position = toVector3(dbAssoc["job_loc_pos_x"], dbAssoc["job_loc_pos_y"], dbAssoc["job_loc_pos_z"]);
this.blip = false;
this.pickup = false;
this.enabled = dbAssoc["job_loc_enabled"];
this.interior = dbAssoc["job_loc_int"];
this.dimension = dbAssoc["job_loc_vw"];
this.databaseId = toInteger(dbAssoc["job_loc_id"]);
this.jobId = toInteger(dbAssoc["job_loc_job"]);
this.position = toVector3(toFloat(dbAssoc["job_loc_pos_x"]), toFloat(dbAssoc["job_loc_pos_y"]), toFloat(dbAssoc["job_loc_pos_z"]));
this.enabled = toInteger(dbAssoc["job_loc_enabled"]);
this.interior = toInteger(dbAssoc["job_loc_int"]);
this.dimension = toInteger(dbAssoc["job_loc_vw"]);
}
}
};
@@ -1718,4 +1714,27 @@ class JobRouteLocationData {
this.pay = toInteger(dbAssoc["job_route_loc_pay"]);
}
}
};
};
class GateData {
constructor(dbAssoc = false) {
this.databaseId = 0;
this.name = "";
this.scriptName = "";
this.enabled = false;
this.position = toVector3(0.0, 0.0, 0.0);
this.locked = true;
this.ownerType = VRR_GATEOWNER_NONE;
this.ownerId = 0;
if(dbAssoc) {
this.databaseId = toInteger(dbAssoc["gate_id"]);
this.name = toString(dbAssoc["gate_name"]);
this.scriptName = toString(dbAssoc["gate_script_name"]);
this.enabled = intToBool(toInteger(dbAssoc["gate_enabled"]));
this.position = toVector3(toFloat(dbAssoc["gate_pos_x"]), toFloat(dbAssoc["gate_pos_y"]), toFloat(dbAssoc["gate_pos_z"]));
this.ownerType = toInteger(dbAssoc["gate_owner_type"]);
this.ownerId = toInteger(dbAssoc["gate_owner_id"]);
}
}
}

View File

@@ -67,6 +67,9 @@ function addAllNetworkHandlers() {
addNetworkEventHandler("vrr.itemActionDelayComplete", playerItemActionDelayComplete);
addNetworkEventHandler("vrr.weaponDamage", playerDamagedByPlayer);
// Locale
addNetworkEventHandler("vrr.localeSelect", playerSelectedNewLocale);
// Misc
addNetworkEventHandler("vrr.plr.pos", updatePositionInPlayerData);
addNetworkEventHandler("vrr.plr.rot", updateHeadingInPlayerData);
@@ -98,7 +101,7 @@ function updateAllPlayerNameTags() {
function updatePlayerPing(client) {
//logToConsole(LOG_DEBUG, `[VRR.Client] Sending ${getPlayerDisplayForConsole(client)}'s ping to all players`);
sendNetworkEventToPlayer("vrr.ping", null, getPlayerName(client), client.ping);
sendNetworkEventToPlayer("vrr.ping", null, getPlayerName(client), getPlayerPing(client));
}
// ===========================================================================
@@ -106,7 +109,7 @@ function updatePlayerPing(client) {
function playerClientReady(client) {
setEntityData(client, "vrr.isReady", true, false);
logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)}'s client resources are downloaded and ready!`);
if(client.getData("vrr.isStarted") == true) {
if(getEntityData(client, "vrr.isStarted") == true) {
initClient(client);
}
}
@@ -123,7 +126,7 @@ function playerGUIReady(client) {
function playerClientStarted(client) {
setEntityData(client, "vrr.isStarted", true, false);
logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)}'s client resources are started and running!`);
if(client.getData("vrr.isReady") == true) {
if(getEntityData(client, "vrr.isReady") == true) {
initClient(client);
}
}
@@ -132,14 +135,14 @@ function playerClientStarted(client) {
function playerClientStopped(client) {
logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)}'s client resources have stopped (possibly error?). Kicking them from the server ...`);
client.disconnect();
disconnectPlayer(client);
}
// ===========================================================================
function showGameMessage(client, text, colour, duration, fontName = "Pricedown") {
logToConsole(LOG_DEBUG, `[VRR.Client] Showing game message to ${getPlayerDisplayForConsole(client)} (${text}) for ${duration} milliseconds`);
sendNetworkEventToPlayer("vrr.smallGameMessage", client, text, colour, duration);
sendNetworkEventToPlayer("vrr.smallGameMessage", client, text, colour, duration, fontName);
}
// ===========================================================================
@@ -216,7 +219,7 @@ function syncPlayerProperties(client) {
// ===========================================================================
function updatePlayerSnowState(client) {
if(isSnowSupported(getServerGame())) {
if(isSnowSupported(getGame())) {
logToConsole(LOG_DEBUG, `[VRR.Client] Setting ${getPlayerDisplayForConsole(client)}'s snow state (Falling: ${toUpperCase(getOnOffFromBool(getServerConfig().fallingSnow))}, Ground: ${toUpperCase(getOnOffFromBool(getServerConfig().groundSnow))})`);
sendNetworkEventToPlayer("vrr.snow", client, getServerConfig().fallingSnow, getServerConfig().groundSnow);
}
@@ -381,8 +384,8 @@ function showPlayerCharacterSelectFailedGUI(client) {
// ===========================================================================
function showPlayerPromptGUI(client, promptMessage, promptTitle, yesButtonText, noButtonText) {
logToConsole(LOG_DEBUG, `[VRR.Client] Sending show prompt GUI signal to ${getPlayerDisplayForConsole(client)} (Title: ${promptTitle}, Message: ${promptMessage})`);
function showPlayerPromptGUI(client, promptMessage, promptTitle, yesButtonText = "Yes", noButtonText = "No") {
logToConsole(LOG_DEBUG, `[VRR.Client] Sending show prompt GUI signal to ${getPlayerDisplayForConsole(client)} (Title: ${promptTitle}, Message: ${promptMessage}, YesButton: ${yesButtonText}, NoButton: ${noButtonText})`);
sendNetworkEventToPlayer("vrr.showPrompt", client, promptMessage, promptTitle, yesButtonText, noButtonText);
}
@@ -404,7 +407,7 @@ function showPlayerErrorGUI(client, errorMessage, errorTitle, buttonText = "OK")
function sendRunCodeToClient(client, code, returnTo) {
logToConsole(LOG_DEBUG, `[VRR.Client] Sending runcode to ${getPlayerDisplayForConsole(client)} (returnTo: ${getPlayerDisplayForConsole(getClientFromIndex(returnTo))}, Code: ${code})`);
sendNetworkEventToPlayer("vrr.runCode", client, code, returnTo);
sendNetworkEventToPlayer("vrr.runCode", client, code, getPlayerId(returnTo));
}
// ===========================================================================
@@ -500,9 +503,9 @@ function sendPlayerFrozenState(client, state) {
// ===========================================================================
function clearPlayerWeapons(client) {
function clearPlayerWeapons(client, clearData = true) {
logToConsole(LOG_DEBUG, `[VRR.Client] Sending signal to ${getPlayerDisplayForConsole(client)} to clear weapons`);
sendNetworkEventToPlayer("vrr.clearWeapons", client);
sendNetworkEventToPlayer("vrr.clearWeapons", client, clearData);
}
// ===========================================================================
@@ -729,17 +732,17 @@ function updateHeadingInVehicleData(client, vehicle, heading) {
// ===========================================================================
function forcePlayerIntoSkinSelect(client) {
if(getGameConfig().skinChangePosition[getServerGame()].length > 0) {
if(typeof getGameConfig().skinChangePosition[getGame()] != "undefined") {
getPlayerData(client).returnToPosition = getPlayerPosition(client);
getPlayerData(client).returnToHeading = getPlayerHeading(client);
getPlayerData(client).returnToInterior = getPlayerInterior(client);
getPlayerData(client).returnToDimension = getPlayerDimension(client);
getPlayerData(client).returnToType = VRR_RETURNTO_TYPE_SKINSELECT;
setPlayerPosition(client, getGameConfig().skinChangePosition[getServerGame()][0]);
setPlayerHeading(client, getGameConfig().skinChangePosition[getServerGame()][1]);
setPlayerInterior(client, getGameConfig().skinChangePosition[getServerGame()][2]);
setPlayerDimension(client, client.index+500);
setPlayerPosition(client, getGameConfig().skinChangePosition[getGame()][0]);
setPlayerHeading(client, getGameConfig().skinChangePosition[getGame()][1]);
setPlayerInterior(client, getGameConfig().skinChangePosition[getGame()][2]);
setPlayerDimension(client, getPlayerId(client)+500);
}
sendNetworkEventToPlayer("vrr.skinSelect", client, true);
@@ -754,14 +757,14 @@ function updatePlayerCash(client) {
// ===========================================================================
function sendAllPoliceStationBlips(client) {
if(getGameConfig().blipSprites[getServerGame()].policeStation != -1) {
if(getGameConfig().blipSprites[getGame()].policeStation != -1) {
let tempBlips = [];
for(let i in getServerData().policeStations[getServerGame()]) {
for(let i in getServerData().policeStations[getGame()]) {
tempBlips.push([
getGameConfig().blipSprites[getServerGame()].policeStation,
getServerData().policeStations[getServerGame()][i].position.x,
getServerData().policeStations[getServerGame()][i].position.y,
getServerData().policeStations[getServerGame()][i].position.z,
getGameConfig().blipSprites[getGame()].policeStation,
getServerData().policeStations[getGame()][i].position.x,
getServerData().policeStations[getGame()][i].position.y,
getServerData().policeStations[getGame()][i].position.z,
3,
getColourByName("policeBlue"),
]);
@@ -773,14 +776,14 @@ function sendAllPoliceStationBlips(client) {
// ===========================================================================
function sendAllFireStationBlips(client) {
if(getGameConfig().blipSprites[getServerGame()].fireStation != -1) {
if(getGameConfig().blipSprites[getGame()].fireStation != -1) {
let tempBlips = [];
for(let i in getServerData().fireStations[getServerGame()]) {
for(let i in getServerData().fireStations[getGame()]) {
tempBlips.push([
getGameConfig().blipSprites[getServerGame()].fireStation,
getServerData().fireStations[getServerGame()][i].position.x,
getServerData().fireStations[getServerGame()][i].position.y,
getServerData().fireStations[getServerGame()][i].position.z,
getGameConfig().blipSprites[getGame()].fireStation,
getServerData().fireStations[getGame()][i].position.x,
getServerData().fireStations[getGame()][i].position.y,
getServerData().fireStations[getGame()][i].position.z,
3,
getColourByName("firefighterRed"),
]);
@@ -792,14 +795,14 @@ function sendAllFireStationBlips(client) {
// ===========================================================================
function sendAllHospitalBlips(client) {
if(getGameConfig().blipSprites[getServerGame()].hospital != -1) {
if(getGameConfig().blipSprites[getGame()].hospital != -1) {
let tempBlips = [];
for(let i in getServerData().hospitals[getServerGame()]) {
for(let i in getServerData().hospitals[getGame()]) {
tempBlips.push([
getGameConfig().blipSprites[getServerGame()].hospital,
getServerData().hospitals[getServerGame()][i].position.x,
getServerData().hospitals[getServerGame()][i].position.y,
getServerData().hospitals[getServerGame()][i].position.z,
getGameConfig().blipSprites[getGame()].hospital,
getServerData().hospitals[getGame()][i].position.x,
getServerData().hospitals[getGame()][i].position.y,
getServerData().hospitals[getGame()][i].position.z,
3,
getColourByName("medicPink"),
]);
@@ -811,14 +814,14 @@ function sendAllHospitalBlips(client) {
// ===========================================================================
function sendAllAmmunationBlips(client) {
if(getGameConfig().blipSprites[getServerGame()].ammunation != -1) {
if(getGameConfig().blipSprites[getGame()].ammunation != -1) {
let tempBlips = [];
for(let i in getServerData().ammunations[getServerGame()]) {
for(let i in getServerData().ammunations[getGame()]) {
tempBlips.push([
getGameConfig().blipSprites[getServerGame()].ammunation,
getServerData().ammunations[getServerGame()][i].position.x,
getServerData().ammunations[getServerGame()][i].position.y,
getServerData().ammunations[getServerGame()][i].position.z,
getGameConfig().blipSprites[getGame()].ammunation,
getServerData().ammunations[getGame()][i].position.x,
getServerData().ammunations[getGame()][i].position.y,
getServerData().ammunations[getGame()][i].position.z,
3,
0
]);
@@ -830,14 +833,14 @@ function sendAllAmmunationBlips(client) {
// ===========================================================================
function sendAllPayAndSprayBlips(client) {
if(getGameConfig().blipSprites[getServerGame()].payAndSpray != -1) {
if(getGameConfig().blipSprites[getGame()].payAndSpray != -1) {
let tempBlips = [];
for(let i in getServerData().payAndSprays[getServerGame()]) {
for(let i in getServerData().payAndSprays[getGame()]) {
tempBlips.push([
getGameConfig().blipSprites[getServerGame()].payAndSpray,
getServerData().payAndSprays[getServerGame()][i].position.x,
getServerData().payAndSprays[getServerGame()][i].position.y,
getServerData().payAndSprays[getServerGame()][i].position.z,
getGameConfig().blipSprites[getGame()].payAndSpray,
getServerData().payAndSprays[getGame()][i].position.x,
getServerData().payAndSprays[getGame()][i].position.y,
getServerData().payAndSprays[getGame()][i].position.z,
3,
0
]);
@@ -849,14 +852,14 @@ function sendAllPayAndSprayBlips(client) {
// ===========================================================================
function sendAllFuelStationBlips(client) {
if(getGameConfig().blipSprites[getServerGame()].fuelStation != -1) {
if(getGameConfig().blipSprites[getGame()].fuelStation != -1) {
let tempBlips = [];
for(let i in getServerData().fuelStations[getServerGame()]) {
for(let i in getServerData().fuelStations[getGame()]) {
tempBlips.push([
getGameConfig().blipSprites[getServerGame()].fuelStation,
getServerData().fuelStations[getServerGame()][i].position.x,
getServerData().fuelStations[getServerGame()][i].position.y,
getServerData().fuelStations[getServerGame()][i].position.z,
getGameConfig().blipSprites[getGame()].fuelStation,
getServerData().fuelStations[getGame()][i].position.x,
getServerData().fuelStations[getGame()][i].position.y,
getServerData().fuelStations[getGame()][i].position.z,
3,
getColourByName("burntOrange"),
]);
@@ -868,10 +871,9 @@ function sendAllFuelStationBlips(client) {
// ===========================================================================
function sendPlayerSetHealth(client, health) {
sendNetworkEventToPlayer("vrr.health", client, health);
sendNetworkEventToPlayer("vrr.health", client, toInteger(health));
}
// ===========================================================================
function sendPlayerSetArmour(client, armour) {
@@ -899,7 +901,7 @@ function playerFinishedSkinSelection(client, allowedSkinIndex) {
}
return false;
} else {
getPlayerCurrentSubAccount(client).skin = getSkinIndexFromModel(allowedSkins[allowedSkinIndex][0]);
getPlayerCurrentSubAccount(client).skin = getSkinIndexFromModel(getServerData().allowedSkins[allowedSkinIndex][0]);
if(isPlayerWorking(client)) {
messagePlayerAlert(client, "Your new skin has been saved but won't be shown until you stop working.");
setPlayerSkin(client, getJobData(getPlayerCurrentSubAccount(client).job).uniforms[getPlayerData(client).jobUniform].skinId);
@@ -926,7 +928,7 @@ function playerFinishedSkinSelection(client, allowedSkinIndex) {
switchPlayerActiveHotBarSlot(client, -1);
cachePlayerHotBarItems(client);
meActionToNearbyPlayers(client, `changes their skin to ${allowedSkins[allowedSkinIndex][1]}`);
meActionToNearbyPlayers(client, `changes their skin to ${getServerData().allowedSkins[allowedSkinIndex][1]}`);
}
}
@@ -1068,7 +1070,7 @@ function setPlayerBuyingVehicleState(client, state, vehicleId, position) {
function receiveVehiclePurchaseStateUpdateFromClient(client, state) {
if(getGlobalConfig().useServerSideVehiclePurchaseCheck == false) {
checkVehicleBuying(client);
checkVehiclePurchasing(client);
}
}
@@ -1170,11 +1172,33 @@ function tellPlayerToSpawn(client, skinId, position) {
// ==========================================================================
function sendPlayerLocaleStrings(client) {
let strings = getGlobalConfig().locale.sendStringsToClient;
for(let i in strings) {
sendNetworkEventToPlayer("vrr.localeString", client, strings[i], getLocaleString(client, strings[i]));
}
function sendNameTagDistanceToClient(client, distance) {
sendNetworkEventToPlayer("vrr.nameTagDistance", client, distance);
}
// ==========================================================================
function sendGPSBlipToPlayer(client, position, colour) {
sendNetworkEventToPlayer("vrr.showGPSBlip", client, position, colour);
}
// ==========================================================================
function playerSelectedNewLocale(client, localeId) {
getPlayerData(client).locale = localeId;
sendPlayerLocaleId(client, localeId);
}
// ==========================================================================
function sendPlayerLocaleId(client, localeId) {
sendNetworkEventToPlayer("vrr.locale", client, localeId);
}
// ==========================================================================
function showLocaleChooserForPlayer(client) {
sendNetworkEventToPlayer("vrr.localeChooser", client);
}
// ==========================================================================

View File

@@ -7,15 +7,8 @@
// TYPE: Server (JavaScript)
// ===========================================================================
let serverCommands = [];
// ===========================================================================
function initCommandScript() {
logToConsole(LOG_INFO, "[VRR.Command]: Initializing commands script ...");
serverCommands = loadCommands();
cacheAllCommandsAliases(serverCommands);
addAllCommandHandlers();
logToConsole(LOG_INFO, "[VRR.Command]: Initialized commands script!");
}
@@ -33,7 +26,6 @@ function loadCommands() {
new CommandData("register", registerCommand, "<password>", getStaffFlagValue("None"), false, false, "Creates an account"),
new CommandData("changepass", changeAccountPasswordCommand, "<old password> <new password>", getStaffFlagValue("None"), true, false, "Change an account password"),
new CommandData("iplogin", toggleAutoLoginByIPCommand, "", getStaffFlagValue("None"), true, false, "Toggle whether to automatically login if you join with the same IP as your last join"),
new CommandData("autolastchar", toggleAutoSelectLastCharacterCommand, "", getStaffFlagValue("None"), true, false, "Toggle whether to automatically spawn with the last character you played as"),
new CommandData("gui", toggleAccountGUICommand, "", getStaffFlagValue("None"), false, false, "Toggle whether to use GUI. If GUI is disabled on the server, it won't show even if you have GUI enabled."),
new CommandData("2fa", toggleAccountTwoFactorAuthCommand, "", getStaffFlagValue("None"), true, false, "Set up and use two-factor authentication."),
new CommandData("setemail", setAccountEmailCommand, "<email address>", getStaffFlagValue("None"), true, false, "Sets your email. To reset your password, you must have a valid email set and verified."),
@@ -75,8 +67,8 @@ function loadCommands() {
//new CommandData("delbizloc", deleteBusinessLocationCommand, "[id]", getStaffFlagValue("ManageBusinesses"), true, false),
new CommandData("bizreloadall", reloadAllBusinessesCommand, "", getStaffFlagValue("ManageBusinesses"), true, false, "Reloads all businesses from the database"),
new CommandData("bizlock", lockUnlockBusinessCommand, "", getStaffFlagValue("None"), true, true, "Locks a business"),
new CommandData("bizlights", toggleBusinessInteriorLightsCommand, "", getStaffFlagValue("None"), true, true, "Turns on/off a business's interior lights"),
//new CommandData("bizlock", lockUnlockBusinessCommand, "", getStaffFlagValue("None"), true, true, "Locks a business"),
//new CommandData("bizlights", toggleBusinessInteriorLightsCommand, "", getStaffFlagValue("None"), true, true, "Turns on/off a business's interior lights"),
new CommandData("bizbuy", buyBusinessCommand, "", getStaffFlagValue("None"), true, true, "Purchases a business"),
new CommandData("bizfee", setBusinessEntranceFeeCommand, "<amount>", getStaffFlagValue("None"), true, true, "Sets a fee to charge players when they enter the business."),
new CommandData("biztill", viewBusinessTillAmountCommand, "", getStaffFlagValue("None"), true, true, "Shows the business's till (cash register) amount"),
@@ -131,15 +123,11 @@ function loadCommands() {
new CommandData("clans", listClansCommand, "[search text]", getStaffFlagValue("None"), true, true, "List clans (search by partial name, if provided)"),
new CommandData("clanranks", listClanRanksCommand, "[clan name]", getStaffFlagValue("None"), true, true, "Shows a list of a clan's ranks"),
new CommandData("clanflags", showClanFlagListCommand, "", getStaffFlagValue("None"), true, true, "Shows a list of clan permission flags"),
new CommandData("addclan", createClanCommand, "<name>", getStaffFlagValue("ManageClans"), true, true, "Creates an new empty, unowned clan."),
new CommandData("delclan", deleteClanCommand, "<clan id>", getStaffFlagValue("ManageClans"), true, true, "Deletes a clan by ID or name"),
new CommandData("clanaddrank", createClanRankCommand, "<rank id> <name>", getStaffFlagValue("None"), true, true, "Adds a clan rank"),
new CommandData("clandelrank", deleteClanRankCommand, "<rank name>", getStaffFlagValue("None"), true, true, "Removes a clan rank"),
new CommandData("clansetrank", setClanMemberRankCommand, "<player name/id> <rank name>", getStaffFlagValue("None"), true, true, "Sets the rank of a clan member"),
new CommandData("clanowner", setClanOwnerCommand, "<player name/id>", getStaffFlagValue("None"), true, true, "Gives ownership of the clan to a player"),
new CommandData("clantag", setClanTagCommand, "<tag>", getStaffFlagValue("None"), true, true, "Sets a clan's main tag"),
new CommandData("clanranktag", setClanRankTagCommand, "<rank name/id> <tag>", getStaffFlagValue("None"), true, true, "Sets a clan rank's custom tag"),
@@ -181,11 +169,14 @@ function loadCommands() {
new CommandData("reloadaccentcfg", reloadAccentConfigurationCommand, "", getStaffFlagValue("Developer"), true, true, "Loads and applies the accent configuration and texts"),
new CommandData("setbizblips", toggleServerBusinessBlipsCommand, "<0/1 state>", getStaffFlagValue("ManageServer"), true, true, "Toggles all business blips on/off"),
new CommandData("setbusinessblips", toggleServerBusinessBlipsCommand, "<0/1 state>", getStaffFlagValue("ManageServer"), true, true, "Toggles all business blips on/off"),
new CommandData("sethouseblips", toggleServerHouseBlipsCommand, "<0/1 state>", getStaffFlagValue("ManageServer"), true, true, "Toggles all house blips on/off"),
new CommandData("setjobblips", toggleServerJobBlipsCommand, "<0/1 state>", getStaffFlagValue("ManageServer"), true, true, "Toggles all job blips on/off"),
new CommandData("setbizpickups", toggleServerBusinessPickupsCommand, "<0/1 state>", getStaffFlagValue("ManageServer"), true, true, "Toggles all business pickups on/off"),
new CommandData("setbusinesspickups", toggleServerBusinessPickupsCommand, "<0/1 state>", getStaffFlagValue("ManageServer"), true, true, "Toggles all business pickups on/off"),
new CommandData("sethousepickups", toggleServerHousePickupsCommand, "<0/1 state>", getStaffFlagValue("ManageServer"), true, true, "Toggles all house pickups on/off"),
new CommandData("setjobpickups", toggleServerJobPickupsCommand, "<0/1 state>", getStaffFlagValue("ManageServer"), true, true, "Toggles all job pickups on/off"),
new CommandData("nametagdistance", setServerNameTagDistanceCommand, "<distance>", getStaffFlagValue("ManageServer"), true, true, "Sets the distance at which name tags are displayed"),
],
core: [],
database: [
@@ -224,6 +215,20 @@ function loadCommands() {
email: [
new CommandData("testemail", testEmailCommand, "<email address>", getStaffFlagValue("Developer"), true, true),
],
gate: [
new CommandData("gate", triggerGateCommand, "", getStaffFlagValue("None"), true, true, "Opens/closes the nearest gate"),
new CommandData("opengate", triggerGateCommand, "", getStaffFlagValue("None"), true, true, "Opens/closes the nearest gate"),
new CommandData("closegate", triggerGateCommand, "", getStaffFlagValue("None"), true, true, "Opens/closes the nearest gate"),
new CommandData("housegate", triggerGateCommand, "", getStaffFlagValue("None"), true, true, "Opens/closes the nearest gate"),
new CommandData("bizgate", triggerGateCommand, "", getStaffFlagValue("None"), true, true, "Opens/closes the nearest gate"),
new CommandData("businessgate", triggerGateCommand, "", getStaffFlagValue("None"), true, true, "Opens/closes the nearest gate"),
new CommandData("door", triggerGateCommand, "", getStaffFlagValue("None"), true, true, "Opens/closes the nearest gate"),
new CommandData("opengate", triggerGateCommand, "", getStaffFlagValue("None"), true, true, "Opens/closes the nearest gate"),
new CommandData("closegate", triggerGateCommand, "", getStaffFlagValue("None"), true, true, "Opens/closes the nearest gate"),
new CommandData("opendoor", triggerGateCommand, "", getStaffFlagValue("None"), true, true, "Opens/closes the nearest gate"),
new CommandData("closedoor", triggerGateCommand, "", getStaffFlagValue("None"), true, true, "Opens/closes the nearest gate"),
new CommandData("garagedoor", triggerGateCommand, "", getStaffFlagValue("None"), true, true, "Opens/closes the nearest gate"),
],
help: [
new CommandData("help", helpCommand, "", getStaffFlagValue("None"), false, false, "Shows help messages for information"),
new CommandData("commands", helpCommand, "", getStaffFlagValue("None"), false, false, "Shows help messages for information"),
@@ -250,8 +255,9 @@ function loadCommands() {
new CommandData("housebuy", buyHouseCommand, "", getStaffFlagValue("None"), true, false, "Purchases a house"),
new CommandData("houseclan", setHouseClanCommand, "", getStaffFlagValue("None"), true, false, "Gives a house to your clan"),
new CommandData("housedesc", setHouseDescriptionCommand, "", getStaffFlagValue("ManageHouses"), true, false, "Sets a house's description"),
new CommandData("houselock", lockUnlockHouseCommand, "", getStaffFlagValue("None"), true, false, "Locks/unlocks a house door"),
new CommandData("houselights", toggleHouseInteriorLightsCommand, "", getStaffFlagValue("None"), true, false, "Turns on and off the lights inside a house"),
//new CommandData("houselock", lockUnlockHouseCommand, "", getStaffFlagValue("None"), true, false, "Locks/unlocks a house door"),
//new CommandData("houselights", toggleHouseInteriorLightsCommand, "", getStaffFlagValue("None"), true, false, "Turns on and off the lights inside a house"),
new CommandData("housedelowner", removeHouseOwnerCommand, "", getStaffFlagValue("ManageHouse"), true, true, "Removes the owner of a house, making the house unowned"),
new CommandData("houseowner", setHouseOwnerCommand, "", getStaffFlagValue("None"), true, false, "Gives a house to a player"),
new CommandData("housebuyprice", setHouseBuyPriceCommand, "", getStaffFlagValue("None"), true, false, "Sets the purchase price of a house so people can buy it"),
new CommandData("houserentprice", setHouseRentPriceCommand, "", getStaffFlagValue("None"), true, false, "Sets the rent price of a house so people can rent it"),
@@ -279,6 +285,8 @@ function loadCommands() {
new CommandData("houseitems", listHouseInventoryCommand, "", getStaffFlagValue("None"), true, false, "Shows the items in the house's storage"),
new CommandData("bizstorage", listBusinessStorageInventoryCommand, "", getStaffFlagValue("None"), true, false, "Shows the items in the business's extra storage (not buyable)"),
new CommandData("bizfloor", listBusinessFloorInventoryCommand, "", getStaffFlagValue("None"), true, false, "Shows the items that can be bought from the business"),
new CommandData("businessstorage", listBusinessStorageInventoryCommand, "", getStaffFlagValue("None"), true, false, "Shows the items in the business's extra storage (not buyable)"),
new CommandData("businessfloor", listBusinessFloorInventoryCommand, "", getStaffFlagValue("None"), true, false, "Shows the items that can be bought from the business"),
new CommandData("buylist", listBusinessFloorInventoryCommand, "", getStaffFlagValue("None"), true, false, "Shows the items that can be bought from the business"),
new CommandData("power", toggleItemEnabledCommand, "", getStaffFlagValue("None"), true, false, "Turns on or off an item"),
@@ -308,6 +316,10 @@ function loadCommands() {
new CommandData("uniform", jobUniformCommand, "[uniform]", getStaffFlagValue("None"), true, false, "Use a job uniform"),
new CommandData("equip", jobEquipmentCommand, "[equipment]", getStaffFlagValue("None"), true, false, "Get equipment for your job"),
new CommandData("jobs", jobListCommand, "", getStaffFlagValue("None"), true, false, "Shows a list of all jobs"),
new CommandData("joblist", jobListCommand, "", getStaffFlagValue("None"), true, false, "Shows a list of all jobs"),
new CommandData("alljobs", jobListCommand, "", getStaffFlagValue("None"), true, false, "Shows a list of all jobs"),
// Emergency Services (Police, Fire, EMS, etc)
new CommandData("department", jobDepartmentRadioCommand, "", getStaffFlagValue("None"), true, false, "Communicate with all emergency services (radio must be on and able to transmit)"),
new CommandData("d", jobDepartmentRadioCommand, "", getStaffFlagValue("None"), true, false, "Communicate with all emergency services (radio must be on and able to transmit)"),
@@ -327,11 +339,18 @@ function loadCommands() {
// Admin Job Stuff
new CommandData("addjob", createJobCommand, "<name>", getStaffFlagValue("ManageJobs"), true, false),
new CommandData("addjobloc", createJobLocationCommand, "<job name/id>", getStaffFlagValue("ManageJobs"), true, false),
new CommandData("addjoblocation", createJobLocationCommand, "<job name/id>", getStaffFlagValue("ManageJobs"), true, false),
new CommandData("addjobuniform", createJobUniformCommand, "<job name/id> <skin name/id>", getStaffFlagValue("ManageJobs"), true, false),
new CommandData("deljobloc", deleteJobLocationCommand, "", getStaffFlagValue("ManageJobs"), true, false),
new CommandData("deljoblocation", deleteJobLocationCommand, "", getStaffFlagValue("ManageJobs"), true, false),
new CommandData("deljobuniform", deleteJobUniformCommand, "<job name/id> <skin name/id>", getStaffFlagValue("ManageJobs"), true, false),
new CommandData("addjobroute", createJobRouteCommand, "<name>", getStaffFlagValue("ManageJobs"), true, false),
new CommandData("addjobrouteloc", createJobRouteLocationCommand, "<name>", getStaffFlagValue("ManageJobs"), true, false),
new CommandData("addjobroutelocation", createJobRouteLocationCommand, "<name>", getStaffFlagValue("ManageJobs"), true, false),
new CommandData("deljobroute", deleteJobRouteCommand, "", getStaffFlagValue("ManageJobs"), true, false),
new CommandData("deljobrouteloc", deleteJobRouteLocationCommand, "", getStaffFlagValue("ManageJobs"), true, false),
new CommandData("deljobroutelocation", deleteJobRouteLocationCommand, "", getStaffFlagValue("ManageJobs"), true, false),
new CommandData("jobroutelocpos", setJobRouteLocationPositionCommand, "", getStaffFlagValue("ManageJobs"), true, false),
new CommandData("jobroutename", setJobRouteNameCommand, "<name>", getStaffFlagValue("ManageJobs"), true, false),
new CommandData("jobroutepay", setJobRoutePayCommand, "<amount>", getStaffFlagValue("ManageJobs"), true, false),
new CommandData("jobroutestartmsg", setJobRouteStartMessageCommand, "<new message>", getStaffFlagValue("ManageJobs"), true, false),
@@ -341,7 +360,6 @@ function loadCommands() {
new CommandData("jobrouteenabled", toggleJobRouteEnabledCommand, "", getStaffFlagValue("ManageJobs"), true, false),
new CommandData("jobroutevehcolours", setJobRouteVehicleColoursCommand, "<colour 1> <colour 2>", getStaffFlagValue("ManageJobs"), true, false),
new CommandData("jobroutedelays", setJobRouteAllLocationDelaysCommand, "<time in milliseconds>", getStaffFlagValue("ManageJobs"), true, false),
new CommandData("jobcolour", setJobColourCommand, "<job id/name> <red> <green> <blue>", getStaffFlagValue("ManageJobs"), true, false),
new CommandData("jobblip", setJobBlipCommand, "<job id/name> <blip id/name>", getStaffFlagValue("ManageJobs"), true, false),
new CommandData("jobpickup", setJobPickupCommand, "<job id/name> <pickup id/name>", getStaffFlagValue("ManageJobs"), true, false),
@@ -354,8 +372,11 @@ function loadCommands() {
new CommandData("jobaddplayerbl", addPlayerToJobBlackListCommand, "<player name/id> [job id]", getStaffFlagValue("ManageJobs"), true, false),
new CommandData("jobdelplayerbl", removePlayerFromJobBlackListCommand, "<player name/id> [job id]", getStaffFlagValue("ManageJobs"), true, false),
new CommandData("jobdelplayerbl", removePlayerFromJobWhiteListCommand, "<player name/id> [job id]", getStaffFlagValue("ManageJobs"), true, false),
new CommandData("jobaddplrwl", addPlayerToJobWhiteListCommand, "<player name/id> [job id]", getStaffFlagValue("ManageJobs"), true, false),
new CommandData("jobaddplayerbl", addPlayerToJobBlackListCommand, "<player name/id> [job id]", getStaffFlagValue("ManageJobs"), true, false),
new CommandData("jobdelplayerbl", removePlayerFromJobBlackListCommand, "<player name/id> [job id]", getStaffFlagValue("ManageJobs"), true, false),
new CommandData("jobdelplrbl", removePlayerFromJobWhiteListCommand, "<player name/id> [job id]", getStaffFlagValue("ManageJobs"), true, false),
new CommandData("jobreloadall", reloadAllJobsCommand, "", getStaffFlagValue("ManageJobs"), true, false),
new CommandData("jobinfo", getJobInfoCommand, "", getStaffFlagValue("None"), true, true, "Get info for nearest or specified job"),
new CommandData("joblocinfo", getJobLocationInfoCommand, "", getStaffFlagValue("None"), true, true, "Get info for nearest or specified job location"),
],
@@ -384,6 +405,8 @@ function loadCommands() {
new CommandData("stuck", stuckPlayerCommand, "", getStaffFlagValue("None"), true, false, "Fixes your position and virtual world if bugged"),
new CommandData("gps", gpsCommand, "[item or place name]", getStaffFlagValue("None"), true, false, "Shows you locations for special places or where to buy items"),
new CommandData("speak", playerPedSpeakCommand, "<speech name>", getStaffFlagValue("None"), true, false, "Makes your ped say something in their game voice (IV only)"),
new CommandData("lock", lockCommand, "", getStaffFlagValue("None"), true, false, "Locks and unlocks your vehicle, house, or business"),
new CommandData("lights", lightsCommand, "", getStaffFlagValue("None"), true, false, "Turns on and off the lights for your vehicle, house, or business"),
],
npc: [
new CommandData("addnpc", createNPCCommand, "<skin id/name>", getStaffFlagValue("ManageNPCs"), true, false, "Creates an NPC with the specified skin"),
@@ -394,16 +417,17 @@ function loadCommands() {
//new CommandData("npcrespawn", respawnNPCCommand, "", getStaffFlagValue("ManageNPCs"), true, false, "Respawns the nearest NPC"),
],
race: [
new CommandData("addrace", createRaceCommand, "<name>", getStaffFlagValue("ManageRaces"), true, false, "Creates a race"),
new CommandData("delrace", deleteRaceCommand, "", getStaffFlagValue("ManageRaces"), true, false, "Deletes a race by name"),
new CommandData("addracecp", createRaceCheckPointCommand, "<name>", getStaffFlagValue("ManageRaces"), true, false, "Creates a race checkpoint"),
new CommandData("addracestart", createRaceStartPositionCommand, "<name>", getStaffFlagValue("ManageRaces"), true, false, "Creates a starting position for a race"),
new CommandData("delracestart", deleteRaceStartPositionCommand, "", getStaffFlagValue("ManageRaces"), true, false, "Deletes the closest starting position for a race"),
new CommandData("delracecp", deleteRaceCheckPointCommand, "", getStaffFlagValue("ManageRaces"), true, false, "Deletes the closest race checkpoint"),
new CommandData("racename", setRaceNameCommand, "<name>", getStaffFlagValue("ManageRaces"), true, false, "Sets a race's name"),
new CommandData("startrace", startRaceCommand, "", getStaffFlagValue("None"), true, false, "Starts a race"),
new CommandData("stoprace", stopRaceCommand, "", getStaffFlagValue("None"), true, false, "Stops racing (forfeits if in an active race)"),
new CommandData("stopAllRacesCommand", stopAllRacesCommand, "", getStaffFlagValue("ManageRaces"), true, false, "Stops a race"),
// Unfinished!
//new CommandData("addrace", createRaceCommand, "<name>", getStaffFlagValue("ManageRaces"), true, false, "Creates a race"),
//new CommandData("delrace", deleteRaceCommand, "", getStaffFlagValue("ManageRaces"), true, false, "Deletes a race by name"),
//new CommandData("addracecp", createRaceCheckPointCommand, "<name>", getStaffFlagValue("ManageRaces"), true, false, "Creates a race checkpoint"),
//new CommandData("addracestart", createRaceStartPositionCommand, "<name>", getStaffFlagValue("ManageRaces"), true, false, "Creates a starting position for a race"),
//new CommandData("delracestart", deleteRaceStartPositionCommand, "", getStaffFlagValue("ManageRaces"), true, false, "Deletes the closest starting position for a race"),
//new CommandData("delracecp", deleteRaceCheckPointCommand, "", getStaffFlagValue("ManageRaces"), true, false, "Deletes the closest race checkpoint"),
//new CommandData("racename", setRaceNameCommand, "<name>", getStaffFlagValue("ManageRaces"), true, false, "Sets a race's name"),
//new CommandData("startrace", startRaceCommand, "", getStaffFlagValue("None"), true, false, "Starts a race"),
//new CommandData("stoprace", stopRaceCommand, "", getStaffFlagValue("None"), true, false, "Stops racing (forfeits if in an active race)"),
//new CommandData("stopAllRacesCommand", stopAllRacesCommand, "", getStaffFlagValue("ManageRaces"), true, false, "Stops a race"),
],
radio: [
new CommandData("radiostation", playStreamingRadioCommand, "<radio station id>", getStaffFlagValue("None"), true, false, "Plays a radio station in your vehicle, house, or business (depending on which one you're in)"),
@@ -423,9 +447,12 @@ function loadCommands() {
new CommandData("getveh", getVehicleCommand, "<vehicle id>", getStaffFlagValue("BasicModeration"), true, true, "Teleports a vehicle to you."),
new CommandData("warpinveh", warpIntoVehicleCommand, "[vehicle id]", getStaffFlagValue("ManageVehicles"), true, false),
new CommandData("returnplr", returnPlayerCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Returns a player to their previous position."),
new CommandData("returnplayer", returnPlayerCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Returns a player to their previous position."),
new CommandData("gotopos", gotoPositionCommand, "<x> <y> <z> [int] [vw]", getStaffFlagValue("BasicModeration"), true, true, "Teleports you to specific coordinates with optional interior and dimension."),
new CommandData("gotoveh", gotoVehicleCommand, "<vehicle id>", getStaffFlagValue("BasicModeration"), true, true, "Teleports you to a vehicle by ID."),
new CommandData("gotovehicle", gotoVehicleCommand, "<vehicle id>", getStaffFlagValue("BasicModeration"), true, true, "Teleports you to a vehicle by ID."),
new CommandData("gotobiz", gotoBusinessCommand, "<business id/name>", getStaffFlagValue("BasicModeration"), true, true, "Teleports you to a business by ID or name."),
new CommandData("gotobusiness", gotoBusinessCommand, "<business id/name>", getStaffFlagValue("BasicModeration"), true, true, "Teleports you to a business by ID or name."),
new CommandData("gotohouse", gotoHouseCommand, "<house id/name>", getStaffFlagValue("BasicModeration"), true, true, "Teleports you to a house by ID or description."),
new CommandData("gotojob", gotoJobLocationCommand, "<job id/name> <location id>", getStaffFlagValue("BasicModeration"), true, true, "Teleports you to a job location by name and location ID."),
new CommandData("gotoloc", gotoGameLocationCommand, "<location name>", getStaffFlagValue("BasicModeration"), true, true, "Teleports you to a game location by name."),
@@ -443,6 +470,7 @@ function loadCommands() {
new CommandData("getstaffflags", getPlayerStaffFlagsCommand, "<player name/id>", getStaffFlagValue("ManageAdmins"), true, true, "Shows a list of all staff flags a player has (this server only)."),
new CommandData("clearstaffflags", removePlayerStaffFlagsCommand, "<player name/id>", getStaffFlagValue("ManageAdmins"), true, true, "Removes all staff flags for a player (this server only)."),
new CommandData("staffflags", getStaffFlagsCommand, "", getStaffFlagValue("ManageAdmins"), true, true, "Shows a list of all valid staff flag names."),
new CommandData("stafftitle", setPlayerStaffTitleCommand, "", getStaffFlagValue("ManageAdmins"), true, true, "Sets a player's staff title."),
new CommandData("givemoney", givePlayerMoneyCommand, "<player name/id> <amount>", getStaffFlagValue("serverManager"), true, true),
new CommandData("nonrpname", forceCharacterNameChangeCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Forces a player to change their current character's name."),
new CommandData("setname", setCharacterNameCommand, "<player name/id> <first name> <last name>", getStaffFlagValue("BasicModeration"), true, true, "Changes a character's name directly."),
@@ -451,21 +479,33 @@ function loadCommands() {
//new CommandData("setfightstyle", setPlayerFightStyleCommand, "<player name/id> <fight style name>", getStaffFlagValue("BasicModeration"), true, true, "Changes a character's fight style."),
new CommandData("setstars", setPlayerWantedLevelCommand, "<player name/id> <wanted level>", getStaffFlagValue("BasicModeration"), true, true, "Forces a player to have a wanted level"),
new CommandData("plrinfo", getPlayerInfoCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Shows basic info about the specified player"),
new CommandData("getplrhouse", getHousesOwnedByPlayerCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Shows a list of all houses owned by the player"),
new CommandData("getplrbiz", getBusinessesOwnedByPlayerCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Shows a list of all businesses owned by the player"),
new CommandData("getplrveh", getVehiclesOwnedByPlayerCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Shows a list of all vehicles owned by the player"),
new CommandData("playerinfo", getPlayerInfoCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Shows basic info about the specified player"),
new CommandData("getplrhouses", getHousesOwnedByPlayerCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Shows a list of all houses owned by the player"),
new CommandData("getplrbizs", getBusinessesOwnedByPlayerCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Shows a list of all businesses owned by the player"),
new CommandData("getplrbusinesses", getBusinessesOwnedByPlayerCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Shows a list of all businesses owned by the player"),
new CommandData("getplrvehs", getVehiclesOwnedByPlayerCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Shows a list of all vehicles owned by the player"),
new CommandData("getplrvehicles", getVehiclesOwnedByPlayerCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Shows a list of all vehicles owned by the player"),
new CommandData("getplayerhouses", getHousesOwnedByPlayerCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Shows a list of all houses owned by the player"),
new CommandData("getplayerbizs", getBusinessesOwnedByPlayerCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Shows a list of all businesses owned by the player"),
new CommandData("getplayerbusinesses", getBusinessesOwnedByPlayerCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Shows a list of all businesses owned by the player"),
new CommandData("getplayervehs", getVehiclesOwnedByPlayerCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Shows a list of all vehicles owned by the player"),
new CommandData("getplayervehicles", getVehiclesOwnedByPlayerCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Shows a list of all vehicles owned by the player"),
new CommandData("geoip", getPlayerGeoIPInformationCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Retrieves GeoIP information on a player (country & city)"),
new CommandData("ip", getPlayerIPInformationCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Retrieves IP information on a player"),
new CommandData("plrsync", toggleSyncForElementsSpawnedByPlayerCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Sets whether elements spawned by a player are synced (traffic, peds, etc)"),
new CommandData("health", setPlayerHealthCommand, "<player name/id> <health", getStaffFlagValue("BasicModeration"), true, true, "Sets a player's health"),
new CommandData("armour", setPlayerArmourCommand, "<player name/id> <armour>", getStaffFlagValue("BasicModeration"), true, true, "Sets a player's armour"),
new CommandData("infiniterun", setPlayerInfiniteRunCommand, "<player name/id> <state>", getStaffFlagValue("BasicModeration"), true, true, "Toggles a player's infinite sprint"),
new CommandData("atbiz", getPlayerCurrentBusinessCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Gets which business a player is at/in"),
new CommandData("atbusiness", getPlayerCurrentBusinessCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Gets which business a player is at/in"),
new CommandData("athouse", getPlayerCurrentHouseCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Gets which house a player is at/in"),
],
startup: [],
subAccount: [
new CommandData("switchchar", switchCharacterCommand, "", getStaffFlagValue("None"), true, false),
new CommandData("newchar", newCharacterCommand, "<first name> <last name>", getStaffFlagValue("None"), true, false),
new CommandData("usechar", useCharacterCommand, "<character id>", getStaffFlagValue("None"), true, false),
new CommandData("autolastchar", toggleAutoSelectLastCharacterCommand, "", getStaffFlagValue("None"), true, false, "Toggle whether to automatically spawn with the last character you played as"),
],
translate: [],
trigger: [
@@ -492,11 +532,9 @@ function loadCommands() {
new CommandData("oldcar", getLastVehicleInfoCommand, "", getStaffFlagValue("None"), true, false),
new CommandData("lastcar", getLastVehicleInfoCommand, "", getStaffFlagValue("None"), true, false),
new CommandData("lock", vehicleLockCommand, "", getStaffFlagValue("None"), true, false),
new CommandData("unlock", vehicleLockCommand, "", getStaffFlagValue("None"), true, false),
//new CommandData("unlock", vehicleLockCommand, "", getStaffFlagValue("None"), true, false),
new CommandData("engine", vehicleEngineCommand, "", getStaffFlagValue("None"), true, false),
new CommandData("siren", vehicleSirenCommand, "", getStaffFlagValue("None"), true, false),
new CommandData("lights", vehicleLightsCommand, "", getStaffFlagValue("None"), true, false),
new CommandData("vehowner", setVehicleOwnerCommand, "<player id/name>", getStaffFlagValue("ManageVehicles"), true, true),
new CommandData("vehpublic", setVehiclePublicCommand, "", getStaffFlagValue("ManageVehicles"), true, true),
@@ -547,10 +585,11 @@ function loadCommands() {
function addAllCommandHandlers() {
let commandCount = 0;
for(let i in serverCommands) {
for(let j in serverCommands[i]) {
logToConsole(LOG_DEBUG, `[VRR.Command] Adding command handler for ${i} - ${serverCommands[i][j].command}`);
addCommandHandler(serverCommands[i][j].command, processPlayerCommand);
let commands = getCommands();
for(let i in commands) {
for(let j in commands[i]) {
logToConsole(LOG_DEBUG, `[VRR.Command] Adding command handler for ${i} - ${commands[i][j].command}`);
addCommandHandler(commands[i][j].command, processPlayerCommand);
commandCount++;
}
}
@@ -583,7 +622,7 @@ function getCommandData(command) {
// ===========================================================================
function getCommands() {
return serverCommands;
return getServerData().commands;
}
// ===========================================================================
@@ -723,43 +762,44 @@ function processPlayerCommand(command, params, client) {
}
if(!doesCommandExist(toLowerCase(command))) {
console.warn(`[VRR.Command] ${getPlayerDisplayForConsole(client)} attempted to use command, but failed (invalid command): /${command} ${paramsDisplay}`);
logToConsole(LOG_WARN, `[VRR.Command] ${getPlayerDisplayForConsole(client)} attempted to use command, but failed (invalid command): /${command} ${paramsDisplay}`);
let possibleCommand = getCommandFromParams(command);
if(possibleCommand != false && doesPlayerHaveStaffPermission(client, getCommandRequiredPermissions(toLowerCase(possibleCommand.command)))) {
messagePlayerError(client, `The command {ALTCOLOUR}/${command} {MAINCOLOUR}does not exist! Did you mean {ALTCOLOUR}/${possibleCommand.command} ?`);
messagePlayerError(client, getLocaleString(client, "InvalidCommandPossibleMatchTip", `{ALTCOLOUR}/${command}{MAINCOLOUR}`, `{ALTCOLOUR}${toLowerCase(possibleCommand.command)}{MAINCOLOUR}`));
} else {
messagePlayerError(client, `The command {ALTCOLOUR}/${command} {MAINCOLOUR}does not exist! Use /help for commands and information.`);
messagePlayerError(client, getLocaleString(client, "InvalidCommandHelpTip", `{ALTCOLOUR}/${command}{MAINCOLOUR}`, `{ALTCOLOUR}/help{MAINCOLOUR}`));
}
return false;
}
if(!commandData.enabled) {
console.warn(`[VRR.Command] ${getPlayerDisplayForConsole(client)} attempted to use command, but failed (command is disabled): /${command} ${paramsDisplay}`);
messagePlayerError(client, `The command {ALTCOLOUR}/${command} {MAINCOLOUR}is disabled!`);
logToConsole(LOG_WARN, `[VRR.Command] ${getPlayerDisplayForConsole(client)} attempted to use command, but failed (command is disabled): /${command} ${paramsDisplay}`);
messagePlayerError(client, `The command {ALTCOLOUR}/${command}{MAINCOLOUR} is disabled!`);
messagePlayerError(client, getLocaleString(client, "CommandDisabled", `{ALTCOLOUR}/${command}{MAINCOLOUR}`));
return false;
}
if(doesCommandRequireLogin(toLowerCase(command))) {
if(!isPlayerLoggedIn(client)) {
console.warn(`[VRR.Command] ${getPlayerDisplayForConsole(client)} attempted to use command, but failed (requires login first): /${command} ${paramsDisplay}`);
messagePlayerError(client, `You must be logged in to use the {ALTCOLOUR}/${command} {MAINCOLOUR}command!`);
logToConsole(LOG_WARN, `[VRR.Command] ${getPlayerDisplayForConsole(client)} attempted to use command, but failed (requires login first): /${command} ${paramsDisplay}`);
messagePlayerError(client, getLocaleString(client, "CommandRequiresLogin", `{ALTCOLOUR}/${command}{MAINCOLOUR}`));
return false;
}
}
//if(isClientFromDiscord(client)) {
// if(!isCommandAllowedOnDiscord(command)) {
// console.warn(`[VRR.Command] ${getPlayerDisplayForConsole(client)} attempted to use command from discord, but failed (not available on discord): /${command} ${paramsDisplay}`);
// messagePlayerError(client, `The {ALTCOLOUR}/${command} {MAINCOLOUR} command isn't available on discord!`);
// return false;
// }
//}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
logToConsole(LOG_WARN, `[VRR.Command] ${getPlayerDisplayForConsole(client)} attempted to use command from discord, but failed (not available on discord): /${command} ${paramsDisplay}`);
messagePlayerError(client, `The {ALTCOLOUR}/${command}{MAINCOLOUR} command isn't available on discord!`);
return false;
}
}
if(!client.console) {
if(!isConsole(client)) {
if(!doesPlayerHaveStaffPermission(client, getCommandRequiredPermissions(toLowerCase(command)))) {
console.warn(`[VRR.Command] ${getPlayerDisplayForConsole(client)} attempted to use command, but failed (no permission): /${command} ${paramsDisplay}`);
messagePlayerError(client, `You do not have permission to use the {ALTCOLOUR}/${toLowerCase(command)} {MAINCOLOUR}command!`);
logToConsole(LOG_WARN, `[VRR.Command] ${getPlayerDisplayForConsole(client)} attempted to use command, but failed (no permission): /${command} ${paramsDisplay}`);
messagePlayerError(client, "CommandNoPermissions", `{ALTCOLOUR}/${toLowerCase(command)}{MAINCOLOUR}`);
return false;
}
}
@@ -785,9 +825,10 @@ addCommandHandler("cmd", function(command, params, client) {
// ===========================================================================
function listAllCommands() {
for(let i in serverCommands) {
for(let j in serverCommands[i]) {
logToConsole(LOG_DEBUG, serverCommands[i][j].command);
let commands = getCommands();
for(let i in commands) {
for(let j in commands[i]) {
logToConsole(LOG_DEBUG, commands[i][j].command);
}
}
}
@@ -796,9 +837,10 @@ function listAllCommands() {
function getAllCommandsInSingleArray() {
let tempCommands = [];
for(let i in serverCommands) {
for(let j in serverCommands[i]) {
tempCommands.push(serverCommands[i][j].command);
let commands = getCommands();
for(let i in commands) {
for(let j in commands[i]) {
tempCommands.push(commands[i][j].command);
}
}
@@ -809,9 +851,10 @@ function getAllCommandsInSingleArray() {
function getAllCommandsInGroupInSingleArray(groupName, staffFlag = "None") {
let tempCommands = [];
for(let i in serverCommands[groupName]) {
if(getCommandRequiredPermissions(serverCommands[groupName][i].command) == 0) {
tempCommands.push(serverCommands[groupName][i].command);
let commands = getCommands();
for(let i in commands[groupName]) {
if(getCommandRequiredPermissions(commands[groupName][i].command) == 0) {
tempCommands.push(commands[groupName][i].command);
}
}
@@ -822,11 +865,12 @@ function getAllCommandsInGroupInSingleArray(groupName, staffFlag = "None") {
function getAllCommandsForStaffFlagInSingleArray(staffFlagName) {
let tempCommands = [];
for(let i in serverCommands) {
for(let j in serverCommands[i]) {
if(getCommandRequiredPermissions(serverCommands[i][j].command) != 0) {
if(hasBitFlag(getCommandRequiredPermissions(serverCommands[i][j].command), getStaffFlagValue(staffFlagName))) {
tempCommands.push(serverCommands[i][j].command);
let commands = getCommands();
for(let i in commands) {
for(let j in commands[i]) {
if(getCommandRequiredPermissions(commands[i][j].command) != 0) {
if(hasBitFlag(getCommandRequiredPermissions(commands[i][j].command), getStaffFlagValue(staffFlagName))) {
tempCommands.push(commands[i][j].command);
}
}
}
@@ -848,13 +892,14 @@ function doesCommandExist(command) {
// ===========================================================================
function cacheAllCommandsAliases() {
for(let i in serverCommands) {
for(let j in serverCommands[i]) {
for(let k in serverCommands) {
for(let m in serverCommands[k]) {
if(serverCommands[i][j].handlerFunction == serverCommands[k][m].handlerFunction) {
serverCommands[i][j].aliases.push(serverCommands[k][m]);
serverCommands[k][m].aliases.push(serverCommands[i][j]);
let commands = getCommands();
for(let i in commands) {
for(let j in commands[i]) {
for(let k in commands) {
for(let m in commands[k]) {
if(commands[i][j].handlerFunction == commands[k][m].handlerFunction) {
commands[i][j].aliases.push(commands[k][m]);
commands[k][m].aliases.push(commands[i][j]);
}
}
}
@@ -904,10 +949,11 @@ function getParam(params, delimiter, index) {
// ===========================================================================
function getCommandFromParams(params) {
for(let i in serverCommands) {
for(let j in serverCommands[i]) {
if(toLowerCase(serverCommands[i][j].command).indexOf(toLowerCase(params)) != -1) {
return serverCommands[i][j];
let commands = getCommands();
for(let i in commands) {
for(let j in commands[i]) {
if(toLowerCase(commands[i][j].command).indexOf(toLowerCase(params)) != -1) {
return commands[i][j];
}
}
}

View File

@@ -8,8 +8,6 @@
// ===========================================================================
let serverConfig = false;
let databaseConfig = false;
let emailConfig = false;
let gameConfig = false;
// ===========================================================================
@@ -17,6 +15,11 @@ let gameConfig = false;
let globalConfig = {
keyBind: [],
economy: {},
database: {},
locale: {},
accents: {},
discord: {},
email: {},
accountPasswordHash: "SHA512",
npcFarProximity: 100,
npcMediumProximity: 40,
@@ -69,68 +72,97 @@ let globalConfig = {
vehicleInactiveRespawnDelay: 1800000, // 20 minutes
chatSectionHeaderLength: 96,
useServerSideVehiclePurchaseCheck: true,
useServerSideVehicleBurnCheck: false,
businessPickupStreamInDistance: 100,
businessPickupStreamOutDistance: 120,
housePickupStreamInDistance: 100,
housePickupStreamOutDistance: 120,
jobPickupStreamInDistance: 100,
jobPickupStreamOutDistance: 120,
businessBlipStreamInDistance: 200,
businessBlipStreamOutDistance: 220,
houseBlipStreamInDistance: 200,
houseBlipStreamOutDistance: 220,
jobBlipStreamInDistance: 200,
jobBlipStreamOutDistance: 220,
businessBlipStreamInDistance: 150,
businessBlipStreamOutDistance: 200,
houseBlipStreamInDistance: 100,
houseBlipStreamOutDistance: 120,
jobBlipStreamInDistance: -1,
jobBlipStreamOutDistance: -1,
handcuffPlayerDistance: 3,
firstAidKitPlayerDistance: 3,
passwordRequiredCapitals: 0,
passwordRequiredNumbers: 0,
passwordRequiredSymbols: 0,
minChatLines: 1,
maxChatLines: 6,
};
// ===========================================================================
function initConfigScript() {
logToConsole(LOG_INFO, "[VRR.Config]: Initializing config script ...");
logToConsole(LOG_DEBUG, "[VRR.Config]: Loading global config ...");
loadGlobalConfig();
logToConsole(LOG_INFO, "[VRR.Config]: Loading server config ...");
serverConfig = loadServerConfigFromGameAndPort(server.game, server.port, getMultiplayerMod());
logToConsole(LOG_INFO, "[VRR.Config]: Applying server config ...");
getServerConfig().fallingSnow = intToBool(toInteger(server.getCVar("vrr_fallingsnow")));
getServerConfig().groundSnow = intToBool(toInteger(server.getCVar("vrr_groundsnow")));
getServerConfig().useGUI = intToBool(toInteger(server.getCVar("vrr_gui")));
getServerConfig().showLogo = false;
getServerConfig().testerOnly = intToBool(toInteger(server.getCVar("vrr_testeronly")));
getServerConfig().discordEnabled = false;
getServerConfig().createJobPickups = intToBool(toInteger(server.getCVar("vrr_jobpickups")));
getServerConfig().createBusinessPickups = intToBool(toInteger(server.getCVar("vrr_businesspickups")));
getServerConfig().createHousePickups = intToBool(toInteger(server.getCVar("vrr_housepickups")));
getServerConfig().createJobBlips = intToBool(toInteger(server.getCVar("vrr_jobblips")));
getServerConfig().createBusinessBlips = intToBool(toInteger(server.getCVar("vrr_businessblips")));
getServerConfig().createHouseBlips = intToBool(toInteger(server.getCVar("vrr_houseblips")));
getServerConfig().useRealTime = intToBool(toInteger(server.getCVar("vrr_realtime")));
getServerConfig().antiCheat.enabled = intToBool(toInteger(server.getCVar("vrr_anticheat")));
applyConfigToServer(serverConfig);
logToConsole(LOG_DEBUG, "[VRR.Config]: Server config applied successfully!");
logToConsole(LOG_INFO, "[VRR.Config]: Config script initialized!");
}
// ===========================================================================
function loadGlobalConfig() {
getGlobalConfig().economy = loadEconomyConfig();
getGlobalConfig().locale = loadLocaleConfig();
getGlobalConfig().accents = loadAccentConfig();
getGlobalConfig().discord = loadDiscordConfig();
logToConsole(LOG_DEBUG, "[VRR.Config] Loading global configuration ...");
try {
getGlobalConfig().database = loadDatabaseConfig();
} catch(error) {
logToConsole(LOG_ERROR, `[VRR.Config] Failed to load global configuration. Error: ${error}`);
thisResource.stop();
}
try {
getGlobalConfig().economy = loadEconomyConfig();
} catch(error) {
logToConsole(LOG_ERROR, `[VRR.Config] Failed to load economy configuration. Error: ${error}`);
thisResource.stop();
}
try {
getGlobalConfig().locale = loadLocaleConfig();
} catch(error) {
logToConsole(LOG_ERROR, `[VRR.Config] Failed to load locale configuration. Error: ${error}`);
thisResource.stop();
}
try {
getGlobalConfig().accents = loadAccentConfig();
} catch(error) {
logToConsole(LOG_ERROR, `[VRR.Config] Failed to load accent configuration. Error: ${error}`);
thisResource.stop();
}
try {
getGlobalConfig().discord = loadDiscordConfig();
} catch(error) {
logToConsole(LOG_ERROR, `[VRR.Config] Failed to load discord configuration. Error: ${error}`);
thisResource.stop();
}
try {
getGlobalConfig().keyBind = loadKeyBindConfig();
} catch(error) {
logToConsole(LOG_ERROR, `[VRR.Config] Failed to load keybind configuration. Error: ${error}`);
thisResource.stop();
}
try {
getGlobalConfig().email = loadEmailConfig();
} catch(error) {
logToConsole(LOG_ERROR, `[VRR.Config] Failed to load email configuration. Error: ${error}`);
thisResource.stop();
}
logToConsole(LOG_DEBUG, "[VRR.Config] Loaded global configuration successfully!");
}
// ===========================================================================
function loadServerConfigFromGameAndPort(gameId, port, mpMod) {
function loadServerConfigFromGameAndPort(gameId, port) {
let dbConnection = connectToDatabase();
if(dbConnection) {
let dbQueryString = `SELECT * FROM svr_main WHERE svr_game = ${gameId} AND svr_port = ${port} AND svr_mpmod = ${mpMod} LIMIT 1;`;
let dbQueryString = `SELECT * FROM svr_main WHERE svr_game = ${gameId} AND svr_port = ${port} LIMIT 1;`;
let dbQuery = queryDatabase(dbConnection, dbQueryString);
if(dbQuery) {
if(dbQuery.numRows > 0) {
@@ -168,6 +200,12 @@ function loadServerConfigFromId(tempServerId) {
// ===========================================================================
function applyConfigToServer(tempServerConfig) {
logToConsole(LOG_INFO, "[VRR.Config]: Applying server config ...");
getServerConfig().devServer = intToBool(toInteger(server.getCVar("vrr_devserver")));
getServerConfig().testerOnly = intToBool(toInteger(server.getCVar("vrr_testeronly")));
logToConsole(LOG_DEBUG, "[VRR.Config]: Server config applied successfully!");
if(isTimeSupported()) {
logToConsole(LOG_DEBUG, `[VRR.Config]: Setting time to to ${tempServerConfig.hour}:${tempServerConfig.minute} with minute duration of ${tempServerConfig.minuteDuration}`);
setGameTime(tempServerConfig.hour, tempServerConfig.minute, tempServerConfig.minuteDuration);
@@ -225,6 +263,17 @@ function saveServerConfigToDatabase() {
["svr_charselect_vw", getServerConfig().characterSelectDimension],
["svr_inflation_multiplier", getServerConfig().inflationMultiplier],
["svr_intro_music", getServerConfig().introMusicURL],
["svr_gui", getServerConfig().useGUI],
["svr_logo", getServerConfig().useLogo],
["svr_snow_falling", getServerConfig().fallingSnow],
["svr_snow_ground", getServerConfig().groundSnow],
["svr_biz_blips", getServerConfig().createBusinessBlips],
["svr_biz_pickups", getServerConfig().createBusinessPickups],
["svr_house_blips", getServerConfig().createHouseBlips],
["svr_house_pickups", getServerConfig().createHousePickups],
["svr_job_blips", getServerConfig().createJobBlips],
["svr_job_pickups", getServerConfig().createJobPickups],
["svr_nametag_distance", getServerConfig().nameTagDistance],
];
let dbQuery = null;
@@ -372,7 +421,7 @@ function setWeatherCommand(command, params, client) {
getServerConfig().needsSaved = true;
announceAdminAction("ServerWeatherSet", getPlayerName(client), getGameConfig().weatherNames[getServerGame()][toInteger(weatherId)]);
announceAdminAction("ServerWeatherSet", getPlayerName(client), getGameConfig().weatherNames[getGame()][toInteger(weatherId)]);
updateServerRules();
return true;
}
@@ -441,7 +490,7 @@ function setServerGUIColoursCommand(command, params, client) {
getServerConfig().needsSaved = true;
//announceAdminAction(`${getPlayerName(client)} ${getInlineChatColourByName("orange")}set the server ${getBoolRedGreenInlineColour(fallingSnow)}${getOnOffFromBool(fallingSnow)} ${getInlineChatColourByName("orange")}and ground snow ${getBoolRedGreenInlineColour(groundSnow)}${getOnOffFromBool(groundSnow)}`);
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} has set the server GUI colours to ${colourRed}, ${colourGreen}, ${colourBlue}`);
//updateServerRules();
return true;
}
@@ -463,7 +512,7 @@ function toggleServerLogoCommand(command, params, client) {
updatePlayerShowLogoState(null, getServerConfig().useLogo);
//announceAdminAction(`${getPlayerName(client)}{MAINCOLOUR}${getBoolRedGreenInlineColour(doesServerHaveServerLogoEnabled())}${toUpperCase(getOnOffFromBool(getServerConfig().useLogo))}`);
announceAdminAction(`ServerLogoSet`, `{adminOrange}${getPlayerName(client)}{MAINCOLOUR}`, `${getBoolRedGreenInlineColour(getServerConfig().useLogo)}${toUpperCase(getOnOffFromBool(getServerConfig().useLogo))}`);
updateServerRules();
return true;
}
@@ -483,7 +532,7 @@ function toggleServerLogoCommand(command, params, client) {
getServerConfig().createJobBlips = !getServerConfig().createJobBlips;
getServerConfig().needsSaved = true;
announceAdminAction("ServerJobBlipsSet", `{adminRed}${getPlayerName(client)}{MAINCOLOUR}`, `${getBoolRedGreenInlineColour(getServerConfig().createJobBlips)}${toUpperCase(getOnOffFromBool(getServerConfig().createJobBlips))}{MAINCOLOUR}`);
announceAdminAction("ServerJobBlipsSet", `{adminOrange}${getPlayerName(client)}{MAINCOLOUR}`, `${getBoolRedGreenInlineColour(getServerConfig().createJobBlips)}${toUpperCase(getOnOffFromBool(getServerConfig().createJobBlips))}{MAINCOLOUR}`);
resetAllJobBlips();
return true;
}
@@ -503,7 +552,7 @@ function toggleServerLogoCommand(command, params, client) {
getServerConfig().createJobPickups = !getServerConfig().createJobPickups;
getServerConfig().needsSaved = true;
announceAdminAction("ServerJobPickupsSet", `{adminRed}${getPlayerName(client)}{MAINCOLOUR}`, `${getBoolRedGreenInlineColour(getServerConfig().createJobPickups)}${toUpperCase(getOnOffFromBool(getServerConfig().createJobPickups))}{MAINCOLOUR}`);
announceAdminAction("ServerJobPickupsSet", `{adminOrange}${getPlayerName(client)}{MAINCOLOUR}`, `${getBoolRedGreenInlineColour(getServerConfig().createJobPickups)}${toUpperCase(getOnOffFromBool(getServerConfig().createJobPickups))}{MAINCOLOUR}`);
resetAllJobPickups();
return true;
}
@@ -523,7 +572,7 @@ function toggleServerLogoCommand(command, params, client) {
getServerConfig().createBusinessBlips = !getServerConfig().createBusinessBlips;
getServerConfig().needsSaved = true;
announceAdminAction("ServerBusinessBlipsSet", `{adminRed}${getPlayerName(client)}{MAINCOLOUR}`, `${getBoolRedGreenInlineColour(getServerConfig().createBusinessBlips)}${toUpperCase(getOnOffFromBool(getServerConfig().createBusinessBlips))}{MAINCOLOUR}`);
announceAdminAction("ServerBusinessBlipsSet", `{adminOrange}${getPlayerName(client)}{MAINCOLOUR}`, `${getBoolRedGreenInlineColour(getServerConfig().createBusinessBlips)}${toUpperCase(getOnOffFromBool(getServerConfig().createBusinessBlips))}{MAINCOLOUR}`);
resetAllBusinessBlips();
return true;
}
@@ -543,7 +592,7 @@ function toggleServerLogoCommand(command, params, client) {
getServerConfig().createBusinessPickups = !getServerConfig().createBusinessPickups;
getServerConfig().needsSaved = true;
announceAdminAction("ServerBusinessPickupsSet", `{adminRed}${getPlayerName(client)}{MAINCOLOUR}`, `${getBoolRedGreenInlineColour(getServerConfig().createBusinessPickups)}${toUpperCase(getOnOffFromBool(getServerConfig().createBusinessPickups))}{MAINCOLOUR}`);
announceAdminAction("ServerBusinessPickupsSet", `{adminOrange}${getPlayerName(client)}{MAINCOLOUR}`, `${getBoolRedGreenInlineColour(getServerConfig().createBusinessPickups)}${toUpperCase(getOnOffFromBool(getServerConfig().createBusinessPickups))}{MAINCOLOUR}`);
resetAllBusinessPickups();
return true;
}
@@ -563,7 +612,7 @@ function toggleServerLogoCommand(command, params, client) {
getServerConfig().createHouseBlips = !getServerConfig().createHouseBlips;
getServerConfig().needsSaved = true;
announceAdminAction("ServerHouseBlipsSet", `{adminRed}${getPlayerName(client)}{MAINCOLOUR}`, `${getBoolRedGreenInlineColour(getServerConfig().createHouseBlips)}${toUpperCase(getOnOffFromBool(getServerConfig().createHouseBlips))}{MAINCOLOUR}`);
announceAdminAction("ServerHouseBlipsSet", `{adminOrange}${getPlayerName(client)}{MAINCOLOUR}`, `${getBoolRedGreenInlineColour(getServerConfig().createHouseBlips)}${toUpperCase(getOnOffFromBool(getServerConfig().createHouseBlips))}{MAINCOLOUR}`);
resetAllHouseBlips();
return true;
}
@@ -583,7 +632,7 @@ function toggleServerLogoCommand(command, params, client) {
getServerConfig().createHousePickups = !getServerConfig().createHousePickups;
getServerConfig().needsSaved = true;
announceAdminAction("ServerHousePickupsSet", `{adminRed}${getPlayerName(client)}{MAINCOLOUR}`, `${getBoolRedGreenInlineColour(getServerConfig().createHousePickups)}${toUpperCase(getOnOffFromBool(getServerConfig().createHousePickups))}{MAINCOLOUR}`);
announceAdminAction("ServerHousePickupsSet", `{adminOrange}${getPlayerName(client)}{MAINCOLOUR}`, `${getBoolRedGreenInlineColour(getServerConfig().createHousePickups)}${toUpperCase(getOnOffFromBool(getServerConfig().createHousePickups))}{MAINCOLOUR}`);
resetAllHousePickups();
return true;
}
@@ -604,7 +653,7 @@ function toggleServerGUICommand(command, params, client) {
getServerConfig().needsSaved = true;
announceAdminAction(`${getPlayerName(client)}{MAINCOLOUR} turned GUI ${toLowerCase(getOnOffFromBool(getServerConfig().useGUI))} for this server`);
announceAdminAction(`ServerGUISet`, `${getPlayerName(client)}{MAINCOLOUR}`, `{adminOrange}${getPlayerName(client)}{MAINCOLOUR}`, `${getBoolRedGreenInlineColour(getServerConfig().useGUI)}${toUpperCase(getOnOffFromBool(getServerConfig().useGUI))}{MAINCOLOUR}`);
updateServerRules();
return true;
}
@@ -628,6 +677,7 @@ function toggleServerUseRealWorldTimeCommand(command, params, client) {
//announceAdminAction(`${getPlayerName(client)}{MAINCOLOUR} turned real-world time ${getServerConfig().useRealTime} for this server (GMT ${addPositiveNegativeSymbol(getServerConfig().realTimeZone)})`);
updateServerGameTime();
updateServerRules();
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} turned real-world time ${getOnOffFromBool(getServerConfig().useRealTime)} for this server (GMT ${addPositiveNegativeSymbol(getServerConfig().realTimeZone)})`);
return true;
}
@@ -654,6 +704,8 @@ function setServerRealWorldTimeZoneCommand(command, params, client) {
//announceAdminAction(`${getPlayerName(client)} {MAINCOLOUR}set the time zone for in-game's real-world time to GMT ${addPositiveNegativeSymbol(getServerConfig().realTimeZone)}`);
updateServerGameTime();
updateServerRules();
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} set the timezone for in-game real-world time to GMT ${addPositiveNegativeSymbol(getServerConfig().realTimeZone)}`);
return true;
}
@@ -674,6 +726,7 @@ function reloadServerConfigurationCommand(command, params, client) {
updateServerRules();
messagePlayerSuccess(client, `You reloaded the server configuration!`);
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} reloaded the server config`);
return true;
}
@@ -689,8 +742,8 @@ function reloadServerConfigurationCommand(command, params, client) {
*
*/
function reloadEmailConfigurationCommand(command, params, client) {
emailConfig = loadEmailConfiguration();
messagePlayerSuccess(client, `You reloaded the email configuration!`);
getGlobalConfig().email = loadEmailConfig();
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} reloaded the email config`);
return true;
}
@@ -706,19 +759,43 @@ function reloadEmailConfigurationCommand(command, params, client) {
*
*/
function reloadDatabaseConfigurationCommand(command, params, client) {
if(databaseConfig.usePersistentConnection && isDatabaseConnected(persistentDatabaseConnection)) {
console.warn(`[VRR.Database] Closing persistent database connection`);
if(getDatabaseConfig().usePersistentConnection && isDatabaseConnected(persistentDatabaseConnection)) {
logToConsole(LOG_WARN, `[VRR.Database] Closing persistent database connection`);
persistentDatabaseConnection.close();
persistentDatabaseConnection = null;
}
databaseEnabled = false;
databaseConfig = loadEmailConfig();
messagePlayerSuccess(client, `You reloaded the database configuration!`);
getGlobalConfig().database = loadDatabaseConfig();
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} reloaded the database config`);
databaseEnabled = true;
if(databaseConfig.usePersistentConnection) {
if(getDatabaseConfig().usePersistentConnection) {
connectToDatabase();
}
return true;
}
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function setServerNameTagDistanceCommand(command, params, client) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
return false;
}
getServerConfig().nameTagDistance = toFloat(params);
getServerConfig().needsSaved = true;
sendNameTagDistanceToClient(null, getServerConfig().nameTagDistance);
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} set the name tag distance to ${getServerConfig().nameTagDistance}`);
return true;
}
@@ -731,6 +808,7 @@ function getServerIntroMusicURL() {
// ===========================================================================
function loadLocaleConfig() {
logToConsole(LOG_DEBUG, "[VRR.Config] Loading locale configuration");
let localeConfig = JSON.parse(loadTextFile(`config/locale.json`));
if(localeConfig != null) {
return localeConfig;
@@ -740,6 +818,7 @@ function loadLocaleConfig() {
// ===========================================================================
function loadEconomyConfig() {
logToConsole(LOG_DEBUG, "[VRR.Config] Loading economy configuration");
let economyConfig = JSON.parse(loadTextFile(`config/economy.json`));
if(economyConfig != null) {
return economyConfig;
@@ -749,6 +828,7 @@ function loadEconomyConfig() {
// ===========================================================================
function loadAccentConfig() {
logToConsole(LOG_DEBUG, "[VRR.Config] Loading accents configuration");
let accentConfig = JSON.parse(loadTextFile(`config/accents.json`));
if(accentConfig != null) {
return accentConfig;
@@ -758,10 +838,45 @@ function loadAccentConfig() {
// ===========================================================================
function loadDiscordConfig() {
logToConsole(LOG_DEBUG, "[VRR.Config] Loading discord configuration");
let discordConfig = JSON.parse(loadTextFile(`config/discord.json`));
if(discordConfig != null) {
return discordConfig;
}
return false;
}
// ===========================================================================
function loadDatabaseConfig() {
logToConsole(LOG_DEBUG, "[VRR.Config] Loading database configuration");
let databaseConfig = JSON.parse(loadTextFile("config/database.json"));
if(databaseConfig != null) {
return databaseConfig;
}
return false;
}
// ===========================================================================
function loadKeyBindConfig() {
logToConsole(LOG_DEBUG, "[VRR.Config] Loading keybind configuration");
let keyBindConfig = JSON.parse(loadTextFile("config/keybind.json"));
if(keyBindConfig != null) {
return keyBindConfig;
}
return false;
}
// ===========================================================================
function loadEmailConfig() {
logToConsole(LOG_DEBUG, "[VRR.Config] Loading email configuration");
let emailConfig = JSON.parse(loadTextFile("config/email.json"));
if(emailConfig != null) {
return emailConfig;
}
return false;
}
// ===========================================================================
@@ -830,4 +945,22 @@ function doesServerHaveGroundSnowEnabled() {
return getServerConfig().groundSnow;
}
// ===========================================================================
function getDatabaseConfig() {
return getGlobalConfig().database;
}
// ===========================================================================
function loadServerConfig() {
logToConsole(LOG_DEBUG, "[VRR.Config] Loading server configuration");
try {
serverConfig = loadServerConfigFromGameAndPort(getGame(), getServerPort());
} catch(error) {
logToConsole(LOG_ERROR, `[VRR.Config] Could not load server configuration for game ${getGame()} and port ${getServerPort}`);
thisResource.stop();
}
}
// ===========================================================================

View File

@@ -11,7 +11,11 @@
const VRR_PROMPT_NONE = 0;
const VRR_PROMPT_CREATEFIRSTCHAR = 1;
const VRR_PROMPT_BIZORDER = 2;
const VRR_PROMPT_GIVEVEHTOCLAN = 3;
const VRR_PROMPT_VEHGIVETOCLAN = 3;
const VRR_PROMPT_HOUSEGIVETOCLAN = 4;
const VRR_PROMPT_BIZGIVETOCLAN = 5;
const VRR_PROMPT_HOUSEBUY = 6;
const VRR_PROMPT_BIZBUY = 7;
// Job Types
const VRR_JOB_NONE = 0;
@@ -59,6 +63,7 @@ const VRR_HOUSEOWNER_JOB = 2; // Owned by a job
const VRR_HOUSEOWNER_CLAN = 3; // Owned by a clan
const VRR_HOUSEOWNER_FACTION = 4; // Owned by a faction
const VRR_HOUSEOWNER_PUBLIC = 5; // Is a public house. Technically not owned. This probably won't be used.
const VRR_HOUSEOWNER_BIZ = 6; // Owned by a business. Used for apartment buildings where rent goes to business.
// Gate Owner Types
const VRR_GATEOWNER_NONE = 0; // Not owned
@@ -205,8 +210,8 @@ const VRR_ITEM_USETYPE_ARMOUR = 28; //
const VRR_ITEM_USETYPE_HEALTH = 29; //
const VRR_ITEM_USETYPE_AED = 30; //
const VRR_ITEM_USETYPE_WALKIETALKIE = 31; //
const VRR_ITEM_USETYPE_BOOMBOX = 32; //
const VRR_ITEM_USETYPE_EARBUDS = 33; //
const VRR_ITEM_USETYPE_AREARADIO = 32; //
const VRR_ITEM_USETYPE_PERSONALRADIO = 33; //
const VRR_ITEM_USETYPE_BADGE = 34; //
const VRR_ITEM_USETYPE_DRINK = 35; // Drinkable item. Action output shows "Player_Name drinks some (drink name)"
const VRR_ITEM_USETYPE_EXTINGUISHER = 36; // Extinguisher item. Allows putting out fires
@@ -227,6 +232,7 @@ const VRR_ITEM_USETYPE_PLANT = 50; // Plantable item. Pot plants,
const VRR_ITEM_USETYPE_MEGAPHONE = 51; // Megaphone item. Allows shouting over greater distances. Also called a bullhorn
const VRR_ITEM_USETYPE_INJECTDRUG = 52; // Injectable drug. Action output shows "Player_Name injects some (drug)"
const VRR_ITEM_USETYPE_ALCOHOL = 53; // Alcohol. Applies an intoxication/drunkness effect
const VRR_ITEM_USETYPE_LOTTOTICKET = 54; // Lotto ticket. Allows a character to enter the lottery
// Item Drop Types
const VRR_ITEM_DROPTYPE_NONE = 0; // Can't be dropped

View File

@@ -7,56 +7,64 @@
// TYPE: Server (JavaScript)
// ===========================================================================
let scriptVersion = "1.0";
let scriptVersion = "1.1";
let serverStartTime = 0;
let logLevel = LOG_INFO|LOG_DEBUG|LOG_VERBOSE|LOG_WARN|LOG_ERROR;
let logLevel = LOG_INFO|LOG_DEBUG|LOG_VERBOSE; // LOG_ERROR|LOG_WARN;
// ===========================================================================
/**
* @typedef {Object} ServerData
* @property {Array.<VehicleData>} vehicles
* @property {Array.<ClientData>} clients
* @property {Array.<BusinessData>} businesses
* @property {Array.<HouseData>} houses
* @property {Array.<HouseData>} commands
* @property {Array.<ItemData>} items
* @property {Array.<ItemTypeData>} itemTypes
* @property {Array.<ClanData>} clans
* @property {Array} localeStrings
* @property {Array.<NPCData>} npcs
* @property {Array.<RaceData>} races
* @property {Array.<JobData>} jobs
* @property {Array.<Gates>} gates
* @property {Array} groundItemCache
* @property {Array} groundPlantCache
* @property {Array} purchasingVehicleCache
* @property {Array} rentingVehicleCache
*/
let serverData = {
vehicles: [],
clients: new Array(128),
businesses: [],
houses: [],
commands: {},
groundItemCache: [],
groundPlantCache: [],
items: [],
itemTypes: [],
clans: [],
antiCheat: {
//whiteListedGameScripts: [],
//blackListedGameScripts: [],
},
localeStrings: {},
cachedTranslations: [],
cachedTranslationFrom: [],
triggers: [],
//triggers: [],
npcs: [],
locales: [],
accents: [],
races: [],
jobs: [],
gates: [],
groundItemCache: [],
groundPlantCache: [],
purchasingVehicleCache: [],
rentingVehicleCache: [],
};
// ===========================================================================
// Pre-cache allowed skins
let allowedSkins = getAllowedSkins(getGame());
// ===========================================================================
function initServerData() {
}
// ===========================================================================
/**
*
* @return {ServerData}
*
*/
function getServerData() {
return serverData;
}
// ===========================================================================
function getModNatives() {
return modNatives;
}
// ===========================================================================

View File

@@ -15,8 +15,60 @@ let persistentDatabaseConnection = null;
function initDatabaseScript() {
logToConsole(LOG_INFO, "[VRR.Database]: Initializing database script ...");
databaseConfig = loadDatabaseConfiguration();
logToConsole(LOG_INFO, "[VRR.Database]: Database script initialized successfully!");
}
// ===========================================================================
function createDatabaseInsertQuery(tableName, data) {
let fields = [];
let values = [];
for(let i in data) {
if(data[i][1] != "undefined" && data[i][1] != NaN && data[i][0] != 'NaN') {
if(data[i][1] != "undefined" && data[i][1] != NaN && data[i][1] != 'NaN') {
fields.push(data[i][0]);
if(typeof data[i][1] == "string") {
if(data[i][1] == "{UNIXTIMESTAMP}") {
values.push("UNIX_TIMESTAMP()");
} else {
values.push(`'${data[i][1]}'`);
}
} else {
values.push(data[i][1]);
}
}
}
}
let queryString = `INSERT INTO ${tableName} (${fields.join(", ")}) VALUES (${values.join(", ")})`;
return queryString;
}
// ===========================================================================
function createDatabaseUpdateQuery(tableName, data, whereClause) {
let values = [];
for(let i in data) {
if(data[i][0] != "undefined" && data[i][0] != NaN && data[i][0] != 'NaN') {
if(data[i][1] != "undefined" && data[i][1] != NaN && data[i][1] != 'NaN') {
if(typeof data[i][1] == "string") {
if(data[i][1] == "{UNIXTIMESTAMP}") {
values.push(`${data[i][0]}=UNIX_TIMESTAMP()`);
} else {
values.push(`${data[i][0]}='${data[i][1]}'`);
}
} else {
values.push(`${data[i][0]}=${data[i][1]}`);
}
}
}
}
let queryString = `UPDATE ${tableName} SET ${values.join(", ")} WHERE ${whereClause}`;
return queryString;
}
// ===========================================================================

View File

@@ -263,7 +263,7 @@ function simulateCommandForPlayerCommand(command, params, client) {
}
getCommand(toLowerCase(tempCommand)).handlerFunction(tempCommand, tempParams, targetClient);
messagePlayerSuccess(client, `The command string {ALTCOLOUR}/${tempCommand} ${tempParams}{MAINCOLOUR} has been simulated for {ALTCOLOUR}${targetgetPlayerName(client)}`);
messagePlayerSuccess(client, `The command string {ALTCOLOUR}/${tempCommand} ${tempParams}{MAINCOLOUR} has been simulated for {ALTCOLOUR}${getPlayerName(targetClient)}`);
return true;
}
@@ -324,8 +324,8 @@ function executeServerCodeCommand(command, params, client) {
messagePlayerSuccess(client, "Server code executed!");
messagePlayerNormal(client, `Code: ${params}`, COLOUR_YELLOW);
messagePlayerNormal(client, `Returns: ${returnValue}`, COLOUR_YELLOW);
console.log(returnValue);
messagePlayerNormal(client, `Returns: ${returnValue} (${typeof returnValue})`, COLOUR_YELLOW);
logToConsole(LOG_INFO, `Server code executed by ${getPlayerDisplayForConsole(client)}: ${params}`);
return true;
}
@@ -337,6 +337,7 @@ function executeClientCodeCommand(command, params, client) {
return false;
}
let splitParams = params.split(" ");
let targetClient = getPlayerFromParams(getParam(params, " ", 1));
let targetCode = splitParams.slice(1).join(" ");
@@ -350,10 +351,10 @@ function executeClientCodeCommand(command, params, client) {
return false;
}
sendRunCodeToClient(client, targetClient, targetCode, client.index);
sendRunCodeToClient(targetClient, targetCode, client);
messagePlayerSuccess(client, "Executing client code for " + toString(targetgetPlayerName(client)) + "!");
messagePlayerNormal(client, "Code: " + targetCode);
messagePlayerSuccess(client, `Executing client code for ${getPlayerName(targetClient)}`);
messagePlayerNormal(client, `Code: ${targetCode}`);
return true;
}
@@ -380,7 +381,7 @@ function setPlayerTesterStatusCommand(command, params, client) {
let enabled = hasBitFlag(getPlayerData(targetClient).accountData.flags.moderation, getModerationFlagValue("IsTester"));
messageAdmins(`{ALTCOLOUR}${client.name} ${getBoolRedGreenInlineColour(enabled)}${toUpperCase(getEnabledDisabledFromBool(enabled))} {ALTCOLOUR}${targetClient.name}'s {MAINCOLOUR}tester status`)
messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} ${getBoolRedGreenInlineColour(enabled)}${toUpperCase(getEnabledDisabledFromBool(enabled))} {ALTCOLOUR}${getPlayerName(targetClient)}'s {MAINCOLOUR}tester status`)
return true;
}
@@ -399,7 +400,7 @@ function testPromptGUICommand(command, params, client) {
return false;
}
showPlayerPromptGUI(targetClient, "Testing the two button prompt GUI", "Testing", "Yes", "No")
showPlayerPromptGUI(targetClient, "Testing the two button prompt GUI", "Testing", getLocaleString(client, "Yes"), getLocaleString(client, "No"))
return true;
}
@@ -444,16 +445,23 @@ function testErrorGUICommand(command, params, client) {
// ===========================================================================
function saveServerDataCommand(command, params, client) {
messageAdmins(`{clanOrange}Vortrex has forced a manual save of all data. Initiating ...`);
messageAdmins(`{adminOrange}Vortrex{MAINCOLOUR} has forced a manual save of all data. Initiating ...`);
saveServerDataToDatabase();
messageAdmins(`{clanOrange}All server data saved to database successfully!`);
messageAdmins(`{MAINCOLOUR}All server data saved to database successfully!`);
return true;
}
// ===========================================================================
function testEmailCommand(command, params, client) {
sendEmail(params, "Player", "Test email", "Just testing the SMTP module for the server!");
try {
messagePlayerAlert(client, `Sending test email to ${params}`);
sendEmail(params, "Player", "Test email", "Just testing the SMTP module for the server!");
} catch(error) {
messagePlayerError(client, "The email could not be sent! Error: ${error}");
return false;
}
return true;
}
@@ -461,34 +469,32 @@ function testEmailCommand(command, params, client) {
function restartGameModeCommand(command, params, client) {
messagePlayerNormal(null, `The server game mode is restarting!`, getColourByName("orange"));
consoleCommand("/refresh");
thisResource.restart();
return true;
}
// ===========================================================================
function clientRunCodeFail(client, returnTo, code) {
function clientRunCodeFail(client, returnTo, error) {
let returnClient = getClientFromIndex(returnTo);
if(!returnClient) {
return false;
}
messagePlayerError(returnClient, `Client code failed to execute for ${getPlayerName(client)}!`);
messagePlayerNormal(returnClient, `Code: ${code}`, getColourByName("yellow"));
messagePlayerError(returnClient, `(${getPlayerName(client)}). Error: ${error}`);
}
// ===========================================================================
function clientRunCodeSuccess(client, returnTo, returnVal, code) {
function clientRunCodeSuccess(client, returnTo, returnVal) {
let returnClient = getClientFromIndex(returnTo);
if(!returnClient) {
return false;
}
messagePlayerSuccess(returnClient, `Client code executed for ${getPlayerName(client)}!`);
messagePlayerNormal(returnClient, `Code: ${code}`, getColourByName("yellow"));
messagePlayerNormal(returnClient, `Returns: ${returnVal}`, getColourByName("yellow"));
//messagePlayerSuccess(returnClient, `Client code executed for ${getPlayerName(client)}!`);
//messagePlayerNormal(returnClient, `Code: ${code}`, getColourByName("yellow"));
messagePlayerNormal(returnClient, `(${getPlayerName(client)}) Code returns: ${returnVal}`, getColourByName("white"));
}
// ===========================================================================
@@ -667,7 +673,44 @@ function resetAllServerAmbienceElementsCommand(command, params, client) {
function reloadEconomyConfigurationCommand(command, params, client) {
getGlobalConfig().economy = loadEconomyConfig();
messageAdmins(`${client.name} {MAINCOLOUR}has reloaded the economy settings`);
messageAdmins(`{adminOrange}${getPlayerName(client)} {MAINCOLOUR}has reloaded the economy settings`);
}
// ===========================================================================
function showLocalePickerTestCommand(command, params, client) {
showLocaleChooserForPlayer(client);
}
// ===========================================================================
function executeDatabaseQueryCommand(command, params, client) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
return false;
}
if(!targetClient) {
messagePlayerError(client, "That player was not found!");
return false;
}
if(targetCode == "") {
messagePlayerError(client, "You didn't enter any code!");
return false;
}
let success = quickDatabaseQuery(params);
if(!success) {
messagePlayerAlert(client, `Database query failed to execute: {ALTCOLOUR}${query}`);
} else if(typeof success != "boolean") {
messagePlayeSuccess(client, `Database query successful: {ALTCOLOUR}${query}`);
messagePlayerInfo(client, `Returns: ${success}`);
} else {
messagePlayerSuccess(client, `Database query successful: {ALTCOLOUR}${query}`);
}
return true;
}
// ===========================================================================

View File

@@ -89,7 +89,11 @@ function getDiscordUserData(discordUserId) {
// ===========================================================================
function messageDiscordChatChannel(messageString) {
if(getServerConfig().devServer) {
if(getServerConfig().devServer == true) {
return false;
}
if(!getGlobalConfig().discord.sendChat) {
return false;
}
@@ -108,6 +112,10 @@ function messageDiscordEventChannel(messageString) {
return false;
}
if(!getGlobalConfig().discord.sendEvents) {
return false;
}
if(!getServerConfig().discord.sendEvents) {
return false;
}
@@ -123,6 +131,10 @@ function messageDiscordAdminChannel(messageString) {
return false;
}
if(!getGlobalConfig().discord.sendAdmin) {
return false;
}
if(!getServerConfig().discord.sendAdmin) {
return false;
}

View File

@@ -111,7 +111,7 @@ function forcePlayerPayDayCommand(command, params, client) {
return false;
}
messageAdmins(`${client.name} gave ${targetClient.name} an instant payday`);
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} gave {ALTCOLOUR}${getPlayerName(targetClient)}{MAINCOLOUR} an instant payday`);
playerPayDay(targetClient);
}
@@ -132,7 +132,7 @@ function setPayDayBonusMultiplier(command, params, client) {
getGlobalConfig().economy.grossIncomeMultiplier = newMultiplier;
announceAdminAction(`PaydayBonusSet`, `{adminRed}${client.name}{MAINCOLOUR}`, `{ALTCOLOUR}${newMultiplier*100}%{MAINCOLOUR}`);
announceAdminAction(`PaydayBonusSet`, `{adminOrange}${getPlayerName(client)}{MAINCOLOUR}`, `{ALTCOLOUR}${newMultiplier*100}%{MAINCOLOUR}`);
}
// ===========================================================================
@@ -147,7 +147,7 @@ function taxInfoCommand(command, params, client) {
function wealthInfoCommand(command, params, client) {
let wealth = calculateWealth(client);
messagePlayerInfo(client, `Your wealth is: $${wealth}. Use {ALTCOLOUR}/help wealth {MAINCOLOUR}for more information.`);
messagePlayerInfo(client, `Your wealth is: {ALTCOLOUR}$${wealth}{MAINCOLOUR}. Use {ALTCOLOUR}/help wealth {MAINCOLOUR}for more information.`);
}
// ===========================================================================

View File

@@ -8,12 +8,7 @@
// ===========================================================================
function initEmailScript() {
if(!checkForSMTPModule()) {
return false;
}
logToConsole(LOG_INFO, "[VRR.Email]: Initializing email script ...");
emailConfig = loadEmailConfiguration();
logToConsole(LOG_INFO, "[VRR.Email]: Email script initialized successfully!");
}
@@ -40,15 +35,8 @@ function sendEmail(toEmail, toName, subject, body) {
// ===========================================================================
function loadEmailConfiguration() {
let emailConfigFile = loadTextFile("config/email.json");
return JSON.parse(emailConfigFile);
}
// ===========================================================================
function getEmailConfig() {
return emailConfig;
return getGlobalConfig().email;
}
// ===========================================================================

View File

@@ -15,35 +15,7 @@ function initEventScript() {
// ===========================================================================
function addAllEventHandlers() {
addEventHandler("onResourceStart", onResourceStart);
addEventHandler("onResourceStop", onResourceStop);
addEventHandler("onServerStop", onResourceStop);
addEventHandler("onProcess", onProcess);
addEventHandler("onEntityProcess", onEntityProcess);
addEventHandler("onPlayerConnect", onPlayerConnect);
addEventHandler("onPlayerJoin", onPlayerJoin);
addEventHandler("onPlayerJoined", onPlayerJoined);
addEventHandler("onPlayerChat", onPlayerChat);
addEventHandler("onPlayerQuit", onPlayerQuit);
addEventHandler("onElementStreamIn", onElementStreamIn);
addEventHandler("onElementStreamOut", onElementStreamOut);
addEventHandler("onPedSpawn", onPedSpawn);
addEventHandler("onPedEnterVehicle", onPedEnteringVehicle);
addEventHandler("onPedExitVehicle", onPedExitingVehicle);
addEventHandler("onPedEnteringVehicle", onPedEnteringVehicle);
addEventHandler("onPedExitingVehicle", onPedExitingVehicle);
//addEventHandler("OnPlayerCommand", onPlayerCommand);
}
// ===========================================================================
function onPlayerConnect(event, ipAddress, port) {
function onInitialConnectionToServer(ipAddress, port) {
logToConsole(LOG_INFO, `[VRR.Event] Client connecting (IP: ${ipAddress})`);
//if(isIpAddressBanned(ipAddress)) {
// messagePlayerError(client, "You are banned from this server!");
@@ -53,26 +25,33 @@ function onPlayerConnect(event, ipAddress, port) {
// ===========================================================================
function onPlayerJoin(event, client) {
logToConsole(LOG_INFO, `[VRR.Event] Client ${client.name}[${client.index}] joining from ${client.ip}`);
function onPlayerJoin(client) {
logToConsole(LOG_INFO, `[VRR.Event] Client ${getPlayerName(client)}[${getPlayerId(client)}] joining from ${getPlayerIP(client)}`);
if(isFadeCameraSupported()) {
fadeCamera(client, true, 1.0);
}
messageDiscordEventChannel(`👋 ${client.name} is connecting to the server ...`);
let messageText = `👋 ${getPlayerName(client)} is connecting to the server ...`;
messageDiscordEventChannel(messageText);
let clients = getClients();
for(let i in clients) {
messagePlayerNormal(clients[i], getLocaleString(clients[i], "PlayerConnecting", getPlayerName(client)));
}
//messageDiscordEventChannel(`👋 ${getPlayerDisplayForConsole(client)} has joined the server.`);
}
// ===========================================================================
function onPlayerJoined(event, client) {
function onPlayerJoined(client) {
}
// ===========================================================================
function onElementStreamIn(event, element, client) {
function onElementStreamIn(element, client) {
//if(getPlayerDimension(client) != getElementDimension(element)) {
// event.preventDefault();
//}
@@ -87,29 +66,33 @@ function onElementStreamIn(event, element, client) {
// ===========================================================================
function onElementStreamOut(event, element, client) {
function onElementStreamOut(element, client) {
}
// ===========================================================================
function onPlayerQuit(event, client, quitReasonId) {
function onPlayerQuit(client, quitReasonId) {
logToConsole(LOG_INFO, `👋 Client ${getPlayerDisplayForConsole(client)} disconnected (${disconnectReasons[quitReasonId]}[${quitReasonId}])`);
updateConnectionLogOnQuit(client, quitReasonId);
if(isPlayerLoggedIn(client)) {
let reasonText = disconnectReasons[quitReasonId];
if(getPlayerData(client).customDisconnectReason != "") {
reasonText = getPlayerData(client).customDisconnectReason;
}
messagePlayerNormal(null, `👋 ${getPlayerName(client)} has left the server (${reasonText})`, getColourByName("softYellow"));
messageDiscordEventChannel(`👋 ${client.name} has left the server (${reasonText})`);
let reasonText = disconnectReasons[quitReasonId];
if(getPlayerData(client).customDisconnectReason != "" && getPlayerData(client).customDisconnectReason != undefined && getPlayerData(client).customDisconnectReason != false && getPlayerData(client).customDisconnectReason != null) {
reasonText = getPlayerData(client).customDisconnectReason;
}
messageDiscordEventChannel(`👋 ${getPlayerName(client)} has left the server (${reasonText})`);
getClients().forEach(forClient => {
let reasonText = getGroupedLocaleString(forClient, "DisconnectReasons", quitReasonId);
messagePlayerNormal(forClient, getLocaleString(forClient, "PlayerLeftServer", getPlayerName(client), reasonText));
});
//messagePlayerNormal(null, `👋 ${getPlayerName(client)} has left the server (${reasonText})`, getColourByName("softYellow"));
if(isPlayerLoggedIn(client)) {
savePlayerToDatabase(client);
resetClientStuff(client);
getServerData().clients[client.index] = null;
} else {
messageDiscordEventChannel(`👋 ${client.name} has left the server (${disconnectReasons[quitReasonId]}[${quitReasonId}])`);
getServerData().clients[getPlayerId(client)] = null;
}
clearTemporaryVehicles();
@@ -118,14 +101,14 @@ function onPlayerQuit(event, client, quitReasonId) {
// ===========================================================================
async function onPlayerChat(event, client, messageText) {
async function onPlayerChat(client, messageText) {
processPlayerChat(client, messageText);
event.preventDefault();
}
// ===========================================================================
function onProcess(event, deltaTime) {
function onProcess(deltaTime = 0) {
updateServerGameTime();
//checkPlayerSpawning();
//checkPlayerPedState();
@@ -136,12 +119,12 @@ function onProcess(event, deltaTime) {
// ===========================================================================
function onEntityProcess(event, entity) {
function onEntityProcess(entity) {
}
// ===========================================================================
function onPedEnteringVehicle(event, ped, vehicle, seat) {
function onPedEnteringVehicle(ped, vehicle, seat) {
if(ped.isType(ELEMENT_PLAYER)) {
let client = getClientFromPlayerElement(ped);
getPlayerData(client).pedState = VRR_PEDSTATE_ENTERINGVEHICLE;
@@ -161,8 +144,8 @@ function onPedEnteringVehicle(event, ped, vehicle, seat) {
messagePlayerNormal(client, `🔒 This ${getVehicleName(vehicle)} is locked and you don't have the keys to unlock it`);
}
getPlayerData(client).enteringVehicle = null;
makePlayerStopAnimation(client);
//getPlayerData(client).enteringVehicle = null;
//makePlayerStopAnimation(client);
return false;
}
@@ -172,7 +155,7 @@ function onPedEnteringVehicle(event, ped, vehicle, seat) {
// ===========================================================================
function onPedExitingVehicle(event, ped, vehicle) {
function onPedExitingVehicle(ped, vehicle) {
if(!getVehicleData(vehicle)) {
return false;
}
@@ -191,40 +174,28 @@ function onPedExitingVehicle(event, ped, vehicle) {
// ===========================================================================
function onResourceStart(event, resource) {
logToConsole(LOG_WARN, `[VRR.Event] ${resource.name} started!`);
function onResourceStart(resource) {
logToConsole(LOG_WARN, `[VRR.Event] Resource ${resource.name} started!`);
if(resource != thisResource) {
messageAdmins(`{MAINCOLOUR}Resource {ALTCOLOUR}${resource.name} {MAINCOLOUR}started!`);
messageAdmins(`{MAINCOLOUR}Resource {ALTCOLOUR}${resource.name}{MAINCOLOUR} started!`);
}
}
// ===========================================================================
function onResourceStop(event, resource) {
logToConsole(LOG_WARN, `[VRR.Event] ${resource.name} stopped!`);
function onResourceStop(resource) {
logToConsole(LOG_WARN, `[VRR.Event] Resource ${resource.name} stopped!`);
if(resource != thisResource) {
messageAdmins(`{MAINCOLOUR}Resource {ALTCOLOUR}${resource.name} {MAINCOLOUR}stopped!`);
messageAdmins(`{MAINCOLOUR}Resource {ALTCOLOUR}${resource.name}{MAINCOLOUR} stopped!`);
}
if(resource == thisResource) {
saveServerDataToDatabase();
clearArray(getServerData().vehicles);
clearArray(getServerData().clients);
clearArray(getServerData().businesses);
clearArray(getServerData().houses);
clearArray(getServerData().factions);
clearArray(getServerData().jobs);
clearArray(getServerData().clans);
clearArray(getServerData().items);
clearArray(getServerData().itemTypes);
clearArray(getServerData().groundItemCache);
clearArray(getServerData().groundPlantCache);
kickAllClients();
saveServerDataToDatabase();
collectAllGarbage();
}
collectAllGarbage();
}
// ===========================================================================
@@ -395,7 +366,7 @@ function onPlayerDeath(client, position) {
setTimeout(function() {
if(getPlayerCurrentSubAccount(client).inJail) {
let closestJail = getClosestPoliceStation(getPlayerPosition(client));
client.despawnPlayer();
despawnPlayer(client);
getPlayerCurrentSubAccount(client).interior = closestJail.interior;
getPlayerCurrentSubAccount(client).dimension = closestJail.dimension;
@@ -417,7 +388,7 @@ function onPlayerDeath(client, position) {
setPlayerControlState(client, true);
} else {
let closestHospital = getClosestHospital(getPlayerPosition(client));
client.despawnPlayer();
despawnPlayer(client);
getPlayerCurrentSubAccount(client).interior = closestHospital.interior;
getPlayerCurrentSubAccount(client).dimension = closestHospital.dimension;
@@ -441,6 +412,17 @@ function onPlayerDeath(client, position) {
}
}, 2000);
}, 1000);
let queryData = [
["log_death_server", getServerId()]
["log_death_who_died", getPlayerCurrentSubAccount(client).databaseId],
["log_death_when_died", "{UNIXTIMESTAMP}"],
["log_death_pos_x", position.x],
["log_death_pos_y", position.y],
["log_death_pos_z", position.x],
];
let queryString = createDatabaseInsertQuery("log_death", data);
addToQueryQueue(queryString);
}
// ===========================================================================
@@ -467,27 +449,27 @@ function onPlayerSpawn(client) {
logToConsole(LOG_DEBUG, `[VRR.Event] Checking ${getPlayerDisplayForConsole(client)}'s player data`);
if(!getPlayerData(client)) {
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)}'s player data is invalid. Kicking them from server.`);
client.disconnect();
disconnectPlayer(client);
return false;
}
logToConsole(LOG_DEBUG, `[VRR.Event] Checking ${getPlayerDisplayForConsole(client)}'s login status`);
if(!isPlayerLoggedIn(client)) {
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)} is NOT logged in. Despawning their player.`);
client.disconnect();
disconnectPlayer(client);
return false;
}
logToConsole(LOG_DEBUG, `[VRR.Event] Checking ${getPlayerDisplayForConsole(client)}'s selected character status`);
if(getPlayerData(client).currentSubAccount == -1) {
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)} has NOT selected a character. Despawning their player.`);
client.disconnect();
disconnectPlayer(client);
return false;
}
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)}'s player data is valid. Continuing spawn processing ...`);
if(getServerGame() == VRR_GAME_GTA_IV) {
if(getGame() == VRR_GAME_GTA_IV) {
logToConsole(LOG_DEBUG, `[VRR.Event] Setting ${getPlayerDisplayForConsole(client)}'s ped body parts and props`);
setEntityData(getPlayerPed(client), "vrr.bodyParts", getPlayerCurrentSubAccount(client).bodyParts, true);
setEntityData(getPlayerPed(client), "vrr.bodyProps", getPlayerCurrentSubAccount(client).bodyProps, true);
@@ -545,7 +527,7 @@ function onPlayerSpawn(client) {
updatePlayerSnowState(client);
}
if(areServerElementsSupported() && getServerGame() == VRR_GAME_GTA_SA) {
if(areServerElementsSupported() && getGame() == VRR_GAME_GTA_SA) {
logToConsole(LOG_DEBUG, `[VRR.Event] Setting player walk and fightstyle for ${getPlayerDisplayForConsole(client)}`);
setEntityData(getPlayerPed(client), "vrr.walkStyle", getPlayerCurrentSubAccount(client).walkStyle, true);
@@ -572,8 +554,6 @@ function onPlayerSpawn(client) {
sendPlayerEnterPropertyKey(client, keyId.key);
}
sendPlayerLocaleStrings(client);
//if(isGTAIV()) {
// setEntityData(getPlayerPed(client), "vrr.bodyPartHair", getPlayerCurrentSubAccount(client).bodyParts.hair, true);
// setEntityData(getPlayerPed(client), "vrr.bodyPartHead", getPlayerCurrentSubAccount(client).bodyParts.head, true);
@@ -611,6 +591,9 @@ function onPlayerSpawn(client) {
logToConsole(LOG_DEBUG, `[VRR.Event] Updating all player name tags`);
updateAllPlayerNameTags();
logToConsole(LOG_DEBUG, `[VRR.Event] Sending player nametag distance to ${getPlayerDisplayForConsole(client)}`);
sendNameTagDistanceToClient(client, getServerConfig().nameTagDistance);
if(!areServerElementsSupported()) {
sendAllBusinessesToPlayer(client);
sendAllHousesToPlayer(client);
@@ -622,7 +605,7 @@ function onPlayerSpawn(client) {
getPlayerData(client).payDayTickStart = sdl.ticks;
messageDiscordEventChannel(`🧍 ${client.name} spawned as ${getCharacterFullName(client)}`);
messageDiscordEventChannel(`🧍 ${getPlayerName(client)} spawned as ${getCharacterFullName(client)}`);
}
// ===========================================================================

View File

@@ -7,8 +7,6 @@
// TYPE: Server (JavaScript)
// ===========================================================================
// ===========================================================================
function initFishingScript() {
logToConsole(LOG_INFO, "[VRR.Fishing]: Initializing fishing script ...");
logToConsole(LOG_INFO, "[VRR.Fishing]: Fishing script initialized successfully!");

View File

@@ -7,6 +7,13 @@
// TYPE: Server (JavaScript)
// ===========================================================================
function initGateScript() {
logToConsole(LOG_INFO, `[VRR.Gate]: Initializing gate script ...`);
logToConsole(LOG_INFO, `[VRR.Gate]: Gate script initialized successfully!`);
}
// ===========================================================================
function doesPlayerHaveGateKeys(client, vehicle) {
let gateData = getGateData(vehicle);
@@ -91,7 +98,7 @@ function getGateData(gateId) {
function getClosestGate(position) {
let closest = 0;
for(let i in getServerData().gates[getServerGame()]) {
for(let i in getServerData().gates[getGame()]) {
if(getDistance(getServerData().gates[i].position, position) < getDistance(getServerData().gates[closest].position, position)) {
closest = i;
}
@@ -109,7 +116,7 @@ function triggerGateCommand(command, params, client) {
messagePlayerError(client, getLocaleString(client, "InvalidGate"));
}
if(!canPlayerUseGate(client, closestGate)) {
if(!doesPlayerHaveGateKeys(client, closestGate)) {
messagePlayerError(client, getLocaleString(client, "NoGateAccess"));
return false;
}
@@ -117,4 +124,103 @@ function triggerGateCommand(command, params, client) {
triggerGate(getGateData(closestGate).scriptName);
}
// ===========================================================================
function saveAllGatesToDatabase() {
if(getServerConfig().devServer) {
return false;
}
for(let i in getServerData().gates) {
saveGateToDatabase(i);
}
}
// ===========================================================================
function saveGateToDatabase(gateId) {
if(getGateData(gateId) == null) {
// Invalid gate data
return false;
}
let tempGateData = getGateData(gateId);
if(tempGateData.databaseId == -1) {
// Temp gate, no need to save
return false;
}
if(!tempGateData.needsSaved) {
// Gate hasn't changed. No need to save.
return false;
}
logToConsole(LOG_VERBOSE, `[VRR.Gate]: Saving gate ${tempGateData.databaseId} to database ...`);
let dbConnection = connectToDatabase();
if(dbConnection) {
let safeGateName = escapeDatabaseString(tempGateData.name);
let safeGateScriptName = escapeDatabaseString(tempGateData.scriptName);
let data = [
["gate_server", getServerId()],
["gate_name", safeGateName],
["gate_script_name", safeGateScriptName],
["gate_owner_type", toInteger(tempGateData.ownerType)],
["gate_owner_id", toInteger(tempGateData.ownerId)],
["gate_pos_x", toFloat(tempGateData.position.x)],
["gate_pos_y", toFloat(tempGateData.position.y)],
["gate_pos_z", toFloat(tempGateData.position.z)],
["gate_radius", toFloat(tempGateData.radius)],
];
let dbQuery = null;
if(tempGateData.databaseId == 0) {
let queryString = createDatabaseInsertQuery("gate_main", data);
dbQuery = queryDatabase(dbConnection, queryString);
tempGateData.databaseId = getDatabaseInsertId(dbConnection);
tempGateData.needsSaved = false;
} else {
let queryString = createDatabaseUpdateQuery("gate_main", data, `gate_id=${tempGateData.databaseId}`);
dbQuery = queryDatabase(dbConnection, queryString);
tempGateData.needsSaved = false;
}
freeDatabaseQuery(dbQuery);
disconnectFromDatabase(dbConnection);
return true;
}
logToConsole(LOG_VERBOSE, `[VRR.Gate]: Saved gate ${gateDataId} to database!`);
return true;
}
// ===========================================================================
function loadGatesFromDatabase() {
logToConsole(LOG_INFO, "[VRR.Gate]: Loading gates from database ...");
let tempGates = [];
let dbConnection = connectToDatabase();
let dbAssoc;
if(dbConnection) {
let dbQuery = queryDatabase(dbConnection, `SELECT * FROM gate_main WHERE gate_server = ${getServerId()}`);
if(dbQuery) {
if(dbQuery.numRows > 0) {
while(dbAssoc = fetchQueryAssoc(dbQuery)) {
let tempGateData = new GateData(dbAssoc);
tempGates.push(tempGateData);
logToConsole(LOG_DEBUG, `[VRR.Gate]: Gate '${tempGateData.name}' loaded from database successfully!`);
}
}
freeDatabaseQuery(dbQuery);
}
disconnectFromDatabase(dbConnection);
}
logToConsole(LOG_INFO, `[VRR.Gate]: ${tempGates.length} gates loaded from database successfully!`);
return tempGates;
}
// ===========================================================================

View File

@@ -25,7 +25,7 @@ function playerPromptAnswerNo(client) {
case VRR_PROMPT_CREATEFIRSTCHAR:
logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)} chose not to create a first character. Kicking them from the server ...`);
showPlayerErrorGUI(client, "You don't have a character to play. Goodbye!", "No Characters");
setTimeout(function() { client.disconnect(); }, 5000);
setTimeout(function() { disconnectPlayer(client); }, 5000);
break;
case VRR_PROMPT_BIZORDER:
@@ -58,11 +58,12 @@ function playerPromptAnswerYes(client) {
logToConsole(LOG_DEBUG, `[VRR.GUI] ${getPlayerDisplayForConsole(client)} answered YES to their prompt (${getPlayerData(client).promptType})`);
switch(getPlayerData(client).promptType) {
case VRR_PROMPT_CREATEFIRSTCHAR:
case VRR_PROMPT_CREATEFIRSTCHAR: {
showPlayerNewCharacterGUI(client);
break;
}
case VRR_PROMPT_BIZORDER:
case VRR_PROMPT_BIZORDER: {
if(getPlayerData(client).businessOrderAmount > 0) {
if(getBusinessData(getPlayerData(client).businessOrderBusiness).till < getPlayerData(client).businessOrderCost) {
logToConsole(LOG_DEBUG, `[VRR.GUI] ${getPlayerDisplayForConsole(client)} failed to order ${getPlayerData(client).businessOrderAmount} ${getItemTypeData(getPlayerData(client).businessOrderItem).name} at ${getPlayerData(client).businessOrderCost/getPlayerData(client).businessOrderAmount} each for business ${getBusinessData(getPlayerData(client).businessOrderBusiness).name} (Reason: Not enough money in business till)`);
@@ -82,14 +83,14 @@ function playerPromptAnswerYes(client) {
getPlayerData(client).businessOrderBusiness = false;
getPlayerData(client).businessOrderItem = -1;
getPlayerData(client).businessOrderValue = -1;
}
} else {
showPlayerErrorGUI(client, ``, `Business Order Canceled`);
}
break;
}
case VRR_PROMPT_GIVEVEHTOCLAN:
case VRR_PROMPT_GIVEVEHTOCLAN: {
if(!isPlayerInAnyVehicle(client)) {
messagePlayerError(client, getLocaleString(client, "MustBeInVehicle"));
return false;
@@ -112,12 +113,117 @@ function playerPromptAnswerYes(client) {
getVehicleData(getPlayerVehicle(client)).ownerType = VRR_VEHOWNER_CLAN;
getVehicleData(getPlayerVehicle(client)).ownerId = getPlayerCurrentSubAccount(client).clan;
messagePlayerSuccess(client, getLocaleString(client, "GaveVehicleToClan"));
messagePlayerSuccess(client, getLocaleString(client, "GaveVehicleToClan", getVehicleName(getPlayerVehicle(client))));
//messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} {MAINCOLOUR}set their {vehiclePurple}${getVehicleName(vehicle)} {MAINCOLOUR}owner to the {clanOrange}${getClanData(clanId).name} {MAINCOLOUR}clan`);
break;
}
default:
case VRR_PROMPT_GIVEHOUSETOCLAN: {
let houseId = getPlayerHouse(client);
if(!houseId) {
messagePlayerError(client, getLocaleString(client, "InvalidHouse"));
return false;
}
if(getHouseData(houseId).ownerType != VRR_VEHOWNER_PLAYER) {
messagePlayerError(client, getLocaleString(client, "MustOwnHouse"));
return false;
}
if(getHouseData(houseId).ownerId != getPlayerCurrentSubAccount(client).databaseId) {
messagePlayerError(client, getLocaleString(client, "MustOwnHouse"));
return false;
}
getHouseData(houseId).ownerType = VRR_HOUSEOWNER_CLAN;
getHouseData(houseId).ownerId = getPlayerCurrentSubAccount(client).clan;
messagePlayerSuccess(client, getLocaleString(client, "GaveHouseToClan"));
//messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} {MAINCOLOUR}set their {vehiclePurple}${getVehicleName(vehicle)} {MAINCOLOUR}owner to the {clanOrange}${getClanData(clanId).name} {MAINCOLOUR}clan`);
break;
}
case VRR_PROMPT_GIVEBIZTOCLAN: {
let businessId = getPlayerBusiness(client);
if(!businessId) {
messagePlayerError(client, getLocaleString(client, "InvalidBusiness"));
return false;
}
if(getBusinessData(businessId).ownerType != VRR_VEHOWNER_PLAYER) {
messagePlayerError(client, getLocaleString(client, "MustOwnBusiness"));
return false;
}
if(getBusinessData(businessId).ownerId != getPlayerCurrentSubAccount(client).databaseId) {
messagePlayerError(client, getLocaleString(client, "MustOwnBusiness"));
return false;
}
getBusinessData(businessId).ownerType = VRR_BIZOWNER_CLAN;
getBusinessData(businessId).ownerId = getPlayerCurrentSubAccount(client).clan;
messagePlayerSuccess(client, getLocaleString(client, "GaveBusinessToClan"));
//messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} {MAINCOLOUR}set their {vehiclePurple}${getVehicleName(vehicle)} {MAINCOLOUR}owner to the {clanOrange}${getClanData(clanId).name} {MAINCOLOUR}clan`);
break;
}
case VRR_PROMPT_BUYHOUSE: {
let houseId = getPlayerHouse(client);
if(!houseId) {
messagePlayerError(client, getLocaleString(client, "InvalidHouse"));
return false;
}
if(getHouseData(houseId).buyPrice <= 0) {
messagePlayerError(client, getLocaleString(client, "HouseNotForSale"));
return false;
}
if(getPlayerCurrentSubAccount(client).cash < getHouseData(houseId).buyPrice) {
messagePlayerError(client, getLocaleString(client, "HousePurchaseNotEnoughMoney"));
return false;
}
getHouseData(houseId).ownerType = VRR_HOUSEOWNER_PLAYER;
getHouseData(houseId).ownerId = getPlayerCurrentSubAccount(client).databaseId;
getHouseData(houseId).buyPrice = 0;
getHouseData(houseId).needsSaved = true;
updateHousePickupLabelData(houseId);
messagePlayerSuccess(client, `You are now the owner of {houseGreen}${getHouseData(houseId).description}`);
break;
}
case VRR_PROMPT_BUYBIZ: {
let businessId = getPlayerBusiness(client);
if(!businessId) {
messagePlayerError(client, getLocaleString(client, "InvalidBusiness"));
return false;
}
if(getBusinessData(businessId).buyPrice <= 0) {
messagePlayerError(client, getLocaleString(client, "BusinessNotForSale"));
return false;
}
if(getPlayerCurrentSubAccount(client).cash < getBusinessData(businessId).buyPrice) {
messagePlayerError(client, getLocaleString(client, "HousePurchaseNotEnoughMoney"));
return false;
}
getBusinessData(businessId).ownerType = VRR_BIZOWNER_PLAYER;
getBusinessData(businessId).ownerId = getPlayerCurrentSubAccount(client).databaseId;
getBusinessData(businessId).buyPrice = 0;
getBusinessData(businessId).needsSaved = true;
updateBusinessPickupLabelData(businessId);
messagePlayerSuccess(client, `You are now the owner of {businessBlue}${getBusinessData(businessId).name}`);
break;
}
default: {
submitBugReport(client, `[AUTOMATED REPORT] Unknown prompt type: ${getPlayerData(client).promptType}`);
break;
}
}
getPlayerData(client).promptType = VRR_PROMPT_NONE;

View File

@@ -16,7 +16,7 @@ function initHelpScript() {
let randomTips = [
`{MAINCOLOUR}Look for yellow dots on your map for job locations.`,
`{MAINCOLOUR}You can set custom key binds. Use {ALTCOLOUR}/help keys {MAINCOLOUR} for details.`,
`{MAINCOLOUR}You can set custom key binds. Use {ALTCOLOUR}/info keys {MAINCOLOUR} for details.`,
`{MAINCOLOUR}Use /notips if you don't want to see tips and extra information`,
`{MAINCOLOUR}You can edit your keybinds using {ALTCOLOUR}/bindkey and /unbindkey`,
`{MAINCOLOUR}Press to see your inventory, and use number keys to select an item`,
@@ -40,8 +40,8 @@ let randomTips = [
//`{MAINCOLOUR}You can change your quick item display. Choices are GTAV-style pie menu or Minecraft-style hotbar`,
//`{MAINCOLOUR}Hold [#0066FF]E {MAINCOLOUR}to hail a nearby taxi if you need a ride.`,
//`{MAINCOLOUR}Press [#0066FF]G {MAINCOLOUR}to enter a vehicle as passenger.`,
//`{MAINCOLOUR}Banks can provide loans. Use {ALTCOLOUR}/help loans {MAINCOLOUR} for more details.`,
`{MAINCOLOUR}Want to make a clan? Use {ALTCOLOUR}/help clans {MAINCOLOUR} for details.`,
//`{MAINCOLOUR}Banks can provide loans. Use {ALTCOLOUR}/info loans {MAINCOLOUR} for more details.`,
`{MAINCOLOUR}Want to make a clan? Use {ALTCOLOUR}/info clans {MAINCOLOUR} for details.`,
`{MAINCOLOUR}Legal weapons can be purchased at any ammunation.`,
];
@@ -184,8 +184,8 @@ function helpCommand(command, params, client) {
// ===========================================================================
function showMainHelpMessage(client) {
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderHelpMainList")));
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Use /help <category> for commands and info. Example: {ALTCOLOUR}/help vehicle`);
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HelpMainListHeader")));
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Use /info <category> for commands and info. Example: {ALTCOLOUR}/info vehicle`);
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Help Categories: [#A9A9A9]account, command, vehicle, job, chat, rules, website, animation`);
messagePlayerNormal(client, `{clanOrange}• [#A9A9A9]skin, mechanic, dealership, discord, colour, keybind`);
}
@@ -205,10 +205,10 @@ function showAccountHelpMessage(client) {
function showVehicleHelpMessage(client) {
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderVehicleHelp")));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "VehicleHelp", 0, `{ALTCOLOUR}/help dealership{MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "VehicleHelp", 0, `{ALTCOLOUR}/info dealership{MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "VehicleHelp", 1, `{ALTCOLOUR}/lock, /engine, /lights, /trunk, /rentveh, /buyveh, /rentprice, /buyprice{MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "VehicleHelp", 2));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "VehicleHelp", 3, `{ALTCOLOUR}/help mechanic{MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "VehicleHelp", 3, `{ALTCOLOUR}/info mechanic{MAINCOLOUR}`));
}
// ===========================================================================
@@ -249,7 +249,7 @@ function showRulesHelpMessage(client) {
messagePlayerHelpContent(client, getGroupedLocaleString(client, "RulesHelp", 1));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "RulesHelp", 2));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "RulesHelp", 3));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "RulesHelp", 4), `{ALTCOLOUR}/help language {MAINCOLOUR}`);
messagePlayerHelpContent(client, getGroupedLocaleString(client, "RulesHelp", 4), `{ALTCOLOUR}/info language {MAINCOLOUR}`);
}
// ===========================================================================
@@ -280,7 +280,7 @@ function showAnimationHelpMessage(client) {
function showClothesHelpMessage(client) {
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderSkinHelp")));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "SkinHelp", 0, `{ALTCOLOUR}/buy {MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "SkinHelp", 1, `{ALTCOLOUR}/help items {MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "SkinHelp", 1, `{ALTCOLOUR}/info items {MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "SkinHelp", 2));
}
@@ -380,7 +380,7 @@ function showCommandHelpMessage(client, commandName) {
*
*/
function helpGetCarCommand(command, params, client) {
messagePlayerAlert(client, getLocaleString(client, "CarCommandHelp", `{ALTCOLOUR}/help vehicle{MAINCOLOUR}`));
messagePlayerAlert(client, getLocaleString(client, "CarCommandHelp", `{ALTCOLOUR}/info vehicle{MAINCOLOUR}`));
}
// ===========================================================================
@@ -395,7 +395,7 @@ function helpGetCarCommand(command, params, client) {
*
*/
function helpGetSkinCommand(command, params, client) {
messagePlayerAlert(client, getLocaleString(client, "SkinCommandHelp", `{ALTCOLOUR}/help skin{MAINCOLOUR}`));
messagePlayerAlert(client, getLocaleString(client, "SkinCommandHelp", `{ALTCOLOUR}/info skin{MAINCOLOUR}`));
messagePlayerAlert(client, ``);
}

View File

@@ -9,19 +9,6 @@
function initHouseScript() {
logToConsole(LOG_INFO, "[VRR.House]: Initializing house script ...");
if(!getServerConfig().devServer) {
getServerData().houses = loadHousesFromDatabase();
}
if(getServerConfig().createHousePickups) {
createAllHousePickups();
}
if(getServerConfig().createHouseBlips) {
createAllHouseBlips();
}
setAllHouseIndexes();
logToConsole(LOG_INFO, "[VRR.House]: House script initialized successfully!");
return true;
}
@@ -35,11 +22,15 @@ function loadHousesFromDatabase() {
let dbAssoc;
if(dbConnection) {
dbAssoc = await fetchQueryAssoc(dbConnection, `SELECT * FROM house_main WHERE house_server = ${getServerId()}`);
for(let i in dbAssoc) {
let tempHouseData = new HouseData(dbAssoc[i]);
tempHouses.push(tempHouseData);
logToConsole(LOG_VERBOSE, `[VRR.House]: House '${tempHouseData.description}' (ID ${tempHouseData.databaseId}) loaded!`);
let dbQuery = queryDatabase(dbConnection, `SELECT * FROM house_main WHERE house_server = ${getServerId()}`);
if(dbQuery) {
if(dbQuery.numRows > 0) {
while(dbAssoc = fetchQueryAssoc(dbQuery)) {
let tempHouseData = new HouseData(dbAssoc);
tempHouses.push(tempHouseData);
logToConsole(LOG_VERBOSE, `[VRR.House]: House '${tempHouseData.description}' (ID ${tempHouseData.databaseId}) loaded!`);
}
}
freeDatabaseQuery(dbQuery);
}
disconnectFromDatabase(dbConnection);
@@ -60,70 +51,13 @@ function loadHousesFromDatabase() {
*
*/
function createHouseCommand(command, params, client) {
let entranceLocation = new HouseLocationData(false);
entranceLocation.entrancePosition = getPlayerPosition(client);
entranceLocation.entranceRotation = 0.0;
entranceLocation.entrancePickupModel = getGameConfig().pickupModels[getServerGame()].House;
entranceLocation.entranceBlipModel = getGameConfig().blipSprites[getServerGame()].House;
entranceLocation.entranceInterior = 0;
entranceLocation.entranceDimension = 0;
entranceLocation.exitPosition = toVector3(0.0, 0.0, 0.0);
entranceLocation.exitRotation = 0.0;
entranceLocation.exitPickupModel = getGameConfig().pickupModels[getServerGame()].Exit;
entranceLocation.exitBlipModel = -1;
entranceLocation.exitInterior = 0;
entranceLocation.exitDimension = 0;
let tempHouseData = createHouse(params, entranceLocation);
let houseId = getServerData().houses.push(tempHouseData);
saveHouseToDatabase(houseId-1);
setAllHouseIndexes();
createHouseEntrancePickup(houseId-1);
createHouseExitPickup(houseId-1);
createHouseEntranceBlip(houseId-1);
createHouseExitBlip(houseId-1);
//getHouseData(houseId).needsSaved = true;
let messageText = `{ALTCOLOUR}${getPlayerName(client)} {MAINCOLOUR}created house {houseGreen}${tempHouseData.description}`;
logToConsole(LOG_INFO, messageText);
messageAdmins(messageText);
}
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function lockUnlockHouseCommand(command, params, client) {
let houseId = getPlayerHouse(client);
if(!getHouseData(houseId)) {
messagePlayerError(client, getLocaleString(client, "InvalidHouse"));
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
return false;
}
getHouseData(houseId).locked = !getHouseData(houseId).locked;
//for(let i in getHouseData(houseId).locations) {
// if(getHouseData(houseId).locations[i].type == VRR_HOUSE_LOC_DOOR) {
// setEntityData(getHouseData(houseId).locations[i].entrancePickup, "vrr.label.locked", getHouseData(houseId).locked, true);
// }
//}
setEntityData(getHouseData(houseId).entrancePickup, "vrr.label.locked", getHouseData(houseId).locked, true);
getHouseData(houseId).needsSaved = true;
messagePlayerSuccess(client, `House {houseGreen}${getHouseData(houseId).description} {MAINCOLOUR}${getLockedUnlockedFromBool((getHouseData(houseId).locked))}!`);
createHouse(params, getPlayerPosition(client), toVector3(0.0, 0.0, 0.0), getGameConfig().pickupModels[getGame()].House, -1, getPlayerInterior(client), getPlayerDimension(client), getPlayerData(client).interiorCutscene);
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} created house: {houseGreen}${params}`);
}
// ===========================================================================
@@ -177,17 +111,11 @@ function setHouseDescriptionCommand(command, params, client) {
let oldDescription = getHouseData(houseId).description;
getHouseData(houseId).description = newHouseDescription;
//for(let i in getHouseData(houseId).locations) {
// if(getHouseData(houseId).locations[i].type == VRR_HOUSE_LOC_DOOR) {
// setEntityData(getHouseData(houseId).entrancePickup, "vrr.label.name", getHouseData(houseId).description, true);
// }
//}
setEntityData(getHouseData(houseId).entrancePickup, "vrr.label.name", getHouseData(houseId).description, true);
getHouseData(houseId).needsSaved = true;
messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} {MAINCOLOUR}renamed house {houseGreen}${oldDescription} {MAINCOLOUR}to {houseGreen}${getHouseData(houseId).description}`);
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} renamed house {houseGreen}${oldDescription}{MAINCOLOUR} to {houseGreen}${getHouseData(houseId).description}`);
}
// ===========================================================================
@@ -225,8 +153,39 @@ function setHouseOwnerCommand(command, params, client) {
getHouseData(houseId).needsSaved = true;
getHouseData(houseId).ownerType = VRR_HOUSEOWNER_PLAYER;
getHouseData(houseId).ownerId = getServerData().clients[newHouseOwner.index].accountData.databaseId;
messagePlayerSuccess(`{MAINCOLOUR}You gave house {houseGreen}${getHouseData(houseId).description} {MAINCOLOUR}to {ALTCOLOUR}${newHouseOwner.name}`);
getHouseData(houseId).ownerId = getPlayerCurrentSubAccount(newHouseOwner).databaseId;
messagePlayerSuccess(`{MAINCOLOUR}You gave house {houseGreen}${getHouseData(houseId).description}{MAINCOLOUR} to {ALTCOLOUR}${newHouseOwner.name}`);
}
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function removeHouseOwnerCommand(command, params, client) {
let houseId = getPlayerHouse(client);
if(!getHouseData(houseId)) {
messagePlayerError(client, getLocaleString(client, "InvalidHouse"));
return false;
}
if(!doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageHouses"))) {
if(getHouseData(houseId).ownerType == VRR_HOUSEOWNER_PLAYER && getHouseData(houseId).ownerId == getPlayerCurrentSubAccount(client).databaseId) {
messagePlayerError(client, getLocaleString(client, "CantModifyHouse"));
return false;
}
}
getHouseData(houseId).ownerType = VRR_HOUSEOWNER_NONE;
getHouseData(houseId).ownerId = -1;
getHouseData(houseId).needsSaved = true;
messagePlayerSuccess(client, `{MAINCOLOUR}You removed house {houseGreen}${getHouseData(houseId).description}'s{MAINCOLOUR} owner`);
}
// ===========================================================================
@@ -255,18 +214,20 @@ function setHouseClanCommand(command, params, client) {
return false;
}
if(!doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageHouses"))) {
if(getHouseData(houseId).ownerType == VRR_HOUSEOWNER_PLAYER && getHouseData(houseId).ownerId == getPlayerCurrentSubAccount(client).databaseId) {
messagePlayerError(client, getLocaleString(client, "CantModifyHouse"));
return false;
}
if(getHouseData(houseId).ownerType != VRR_VEHOWNER_PLAYER) {
messagePlayerError(client, getLocaleString(client, "MustOwnHouse"));
return false;
}
getHouseData(houseId).needsSaved = true;
if(getHouseData(houseId).ownerId != getPlayerCurrentSubAccount(client).databaseId) {
messagePlayerError(client, getLocaleString(client, "MustOwnHouse"));
return false;
}
getHouseData(houseId).ownerType = VRR_HOUSEOWNER_CLAN;
getHouseData(houseId).ownerId = getClanData(clanId).databaseId;
messagePlayerSuccess(`{MAINCOLOUR}You gave house {houseGreen}${getHouseData(houseId).description} {MAINCOLOUR} to the {clanOrange}${getClanData(clanId).name} {MAINCOLOUR}clan!`);
showPlayerPrompt(client, getLocaleString(client, "SetHouseClanConfirmMessage"), getLocaleString(client, "SetHouseClanConfirmTitle"), getLocaleString(client, "Yes"), getLocaleString(client, "No"));
getPlayerData(client).promptType = VRR_PROMPT_HOUSEGIVETOCLAN;
//messagePlayerSuccess(`{MAINCOLOUR}You gave house {houseGreen}${getHouseData(houseId).description}{MAINCOLOUR} to the {clanOrange}${getClanData(clanId).name} {MAINCOLOUR}clan!`);
}
// ===========================================================================
@@ -295,23 +256,6 @@ function setHouseClanCommand(command, params, client) {
return false;
}
let clanRankId = getClanRankFromParams(clanId, params);
if(!getClanRankData(clanId, clanRankId)) {
messagePlayerError(client, getLocaleString(client, "ClanRankInvalid"));
return false;
}
if(doesPlayerHaveClanPermission(client, getClanFlagValue("ManageHouses"))) {
messagePlayerError(client, getLocaleString(client, "CantModifyHouse"));
return false;
}
if(getClanRankData(clanId, clanRankId).level > getPlayerCurrentSubAccount(client).clanRank) {
messagePlayerError(client, "That rank is above your level!");
return false;
}
getHouseData(houseId).clanRank = getClanRankData(clanId, clanRankId).level;
getHouseData(houseId).needsSaved = true;
messagePlayerSuccess(`{MAINCOLOUR}You set house {houseGreen}${getHouseData(houseId).description}{MAINCOLOUR}'s clan rank to {clanOrange}${getClanRankData(clanId, clanRankId).name} {MAINCOLOUR}(level ${getClanRankData(clanId, clanRankId).level}) and above!`);
@@ -341,9 +285,9 @@ function setHousePickupCommand(command, params, client) {
if(toLowerCase(typeParam) == "None") {
getHouseData(houseId).entrancePickupModel = -1;
} else {
if(isNull(getGameConfig().pickupModels[getServerGame()][typeParam])) {
if(isNull(getGameConfig().pickupModels[getGame()][typeParam])) {
messagePlayerError(client, "Invalid pickup type! Use a pickup type name or a model ID");
let pickupTypes = Object.keys(getGameConfig().pickupModels[getServerGame()]);
let pickupTypes = Object.keys(getGameConfig().pickupModels[getGame()]);
let chunkedList = splitArrayIntoChunks(pickupTypes, 10);
messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderPickupTypes")));
@@ -353,7 +297,7 @@ function setHousePickupCommand(command, params, client) {
return false;
}
getHouseData(houseId).entrancePickupModel = getGameConfig().pickupModels[getServerGame()][typeParam];
getHouseData(houseId).entrancePickupModel = getGameConfig().pickupModels[getGame()][typeParam];
}
} else {
getHouseData(houseId).entrancePickupModel = toInteger(typeParam);
@@ -364,7 +308,7 @@ function setHousePickupCommand(command, params, client) {
getHouseData(houseId).needsSaved = true;
messageAdmins(`{ALTCOLOUR}${client.name} {MAINCOLOUR}set house {houseGreen}${getHouseData(houseId).description} {MAINCOLOUR}pickup display to {ALTCOLOUR}${toLowerCase(typeParam)}`);
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} set house {houseGreen}${getHouseData(houseId).description}{MAINCOLOUR} pickup display to {ALTCOLOUR}${toLowerCase(typeParam)}`);
}
// ===========================================================================
@@ -387,6 +331,11 @@ function setHouseInteriorTypeCommand(command, params, client) {
return false;
}
if(typeof getGameConfig().interiors[getGame()] == "undefined") {
messagePlayerError(client, `There are no interiors available for this game!`);
return false;
}
if(isNaN(typeParam)) {
let tempHouseLocation = new HouseLocationData(false);
@@ -395,13 +344,13 @@ function setHouseInteriorTypeCommand(command, params, client) {
tempHouseLocation.exitInterior = -1;
getHouseData(houseId).exitPickupModel = -1;
getHouseData(houseId).hasInterior = false;
messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} {MAINCOLOUR}removed house {houseGreen}${getHouseData(houseId).description} {MAINCOLOUR}interior`);
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} removed house {houseGreen}${getHouseData(houseId).description}{MAINCOLOUR} interior`);
return false;
}
if(isNull(getGameConfig().interiors[getServerGame()][typeParam])) {
if(isNull(getGameConfig().interiors[getGame()][typeParam])) {
messagePlayerError(client, "Invalid interior type! Use an interior type name");
let interiorTypesList = Object.keys(getGameConfig().interiors[getServerGame()]);
let interiorTypesList = Object.keys(getGameConfig().interiors[getGame()]);
let chunkedList = splitArrayIntoChunks(interiorTypesList, 10);
messagePlayerNormal(client, makeChatBoxSectionHeader("InteriorTypes"));
@@ -411,10 +360,10 @@ function setHouseInteriorTypeCommand(command, params, client) {
return false;
}
getHouseData(houseId).exitPosition = getGameConfig().interiors[getServerGame()][typeParam][0];
getHouseData(houseId).exitInterior = getGameConfig().interiors[getServerGame()][typeParam][1];
getHouseData(houseId).exitPosition = getGameConfig().interiors[getGame()][typeParam][0];
getHouseData(houseId).exitInterior = getGameConfig().interiors[getGame()][typeParam][1];
getHouseData(houseId).exitDimension = getHouseData(houseId).databaseId+getGlobalConfig().houseDimensionStart;
getHouseData(houseId).exitPickupModel = getGameConfig().pickupModels[getServerGame()].Exit;
getHouseData(houseId).exitPickupModel = getGameConfig().pickupModels[getGame()].Exit;
getHouseData(houseId).hasInterior = true;
}
@@ -425,7 +374,7 @@ function setHouseInteriorTypeCommand(command, params, client) {
getHouseData(houseId).needsSaved = true;
messageAdmins(`{ALTCOLOUR}${client.name} {MAINCOLOUR}set house {houseGreen}${getHouseData(houseId).description} {MAINCOLOUR}interior type to {ALTCOLOUR}${toLowerCase(typeParam)}`);
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} set house {houseGreen}${getHouseData(houseId).description}{MAINCOLOUR} interior type to {ALTCOLOUR}${toLowerCase(typeParam)}`);
}
// ===========================================================================
@@ -452,8 +401,8 @@ function setHouseBlipCommand(command, params, client) {
if(toLowerCase(typeParam) == "None") {
getHouseData(houseId).entranceBlipModel = -1;
} else {
if(isNull(getGameConfig().blipSprites[getServerGame()][typeParam])) {
let blipTypes = Object.keys(getGameConfig().blipSprites[getServerGame()]);
if(isNull(getGameConfig().blipSprites[getGame()][typeParam])) {
let blipTypes = Object.keys(getGameConfig().blipSprites[getGame()]);
let chunkedList = splitArrayIntoChunks(blipTypes, 10);
messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderBlipTypes")));
@@ -463,7 +412,7 @@ function setHouseBlipCommand(command, params, client) {
return false;
}
getHouseData(houseId).entranceBlipModel = getGameConfig().blipSprites[getServerGame()][typeParam];
getHouseData(houseId).entranceBlipModel = getGameConfig().blipSprites[getGame()][typeParam];
}
} else {
getHouseData(houseId).entranceBlipModel = toInteger(typeParam);
@@ -476,7 +425,7 @@ function setHouseBlipCommand(command, params, client) {
resetHouseBlips(houseId);
getHouseData(houseId).needsSaved = true;
messageAdmins(`{ALTCOLOUR}${client.name} {MAINCOLOUR}set house {houseGreen}${getHouseData(houseId).description} {MAINCOLOUR}blip display to {ALTCOLOUR}${toLowerCase(typeParam)}`);
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} set house {houseGreen}${getHouseData(houseId).description}{MAINCOLOUR} blip display to {ALTCOLOUR}${toLowerCase(typeParam)}`);
}
// ===========================================================================
@@ -494,7 +443,7 @@ function moveHouseEntranceCommand(command, params, client) {
let houseId = getPlayerHouse(client);
if(!getHouseData(houseId)) {
messagePlayer(client, getLocaleString(client, "InvalidHouse"));
messagePlayerError(client, getLocaleString(client, "InvalidHouse"));
return false;
}
@@ -512,7 +461,7 @@ function moveHouseEntranceCommand(command, params, client) {
getHouseData(houseId).needsSaved = true;
messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} {MAINCOLOUR}moved house {houseGreen}${getHouseData(houseId).description} {MAINCOLOUR}entrance to their position`);
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} moved house {houseGreen}${getHouseData(houseId).description}{MAINCOLOUR} entrance to their position`);
}
// ===========================================================================
@@ -527,10 +476,10 @@ function moveHouseEntranceCommand(command, params, client) {
*
*/
function moveHouseExitCommand(command, params, client) {
let houseId = getPlayerHouse(client);
let houseId = getClosestHouseEntrance(getPlayerPosition(client), getPlayerDimension(client));
if(!getHouseData(houseId)) {
messagePlayer(client, getLocaleString(client, "InvalidHouse"));
messagePlayerError(client, getLocaleString(client, "InvalidHouse"));
return false;
}
@@ -552,7 +501,7 @@ function moveHouseExitCommand(command, params, client) {
getHouseData(houseId).needsSaved = true;
messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} {MAINCOLOUR}moved house {houseGreen}${getHouseData(houseId).description} {MAINCOLOUR}exit to their position`);
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} moved house {houseGreen}${getHouseData(houseId).description}{MAINCOLOUR} exit to their position`);
}
// ===========================================================================
@@ -574,7 +523,7 @@ function deleteHouseCommand(command, params, client) {
return false;
}
messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} {MAINCOLOUR}deleted house {houseGreen}${getHouseData(houseId).description}`);
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} deleted house {houseGreen}${getHouseData(houseId).description}`);
deleteHouse(houseId, getPlayerData(client).accountData.databaseId);
}
@@ -622,10 +571,8 @@ function deleteHouse(houseId, whoDeleted = 0) {
* @return {bool} Whether or not the player was successfully removed from the house
*
*/
function removePlayerFromHouses(client) {
if(isPlayerInAnyHouse(client)) {
exitHouse(client);
}
function removePlayerFromHouse(client) {
exitHouse(client);
}
// ===========================================================================
@@ -638,25 +585,37 @@ function removePlayerFromHouses(client) {
* @return {bool} Whether or not the player was successfully removed from the house
*
*/
function createHouse(description, entranceLocation) {
function createHouse(description, entrancePosition, exitPosition, entrancePickupModel = -1, entranceBlipModel = -1, entranceInterior = 0, entranceDimension = 0, entranceCutscene = -1) {
let tempHouseData = new HouseData(false);
tempHouseData.description = description;
tempHouseData.entrancePosition = entranceLocation.entrancePosition;
tempHouseData.entranceRotation = entranceLocation.entranceRotation;
tempHouseData.entrancePickupModel = entranceLocation.entrancePickupModel;
tempHouseData.entranceBlipModel = entranceLocation.entranceBlipModel;
tempHouseData.entranceInterior = entranceLocation.entranceInterior;
tempHouseData.entranceDimension = entranceLocation.entranceDimension;
tempHouseData.entrancePosition = entrancePosition;
tempHouseData.entranceRotation = 0.0;
tempHouseData.entrancePickupModel = entrancePickupModel;
tempHouseData.entranceBlipModel = entranceBlipModel;
tempHouseData.entranceInterior = entranceInterior;
tempHouseData.entranceDimension = entranceDimension;
tempHouseData.entranceCutscene = entranceCutscene;
tempHouseData.exitPosition = entranceLocation.exitPosition;
tempHouseData.exitRotation = entranceLocation.exitRotation;
tempHouseData.exitPickupModel = entranceLocation.exitPickupModel;
tempHouseData.exitBlipModel = entranceLocation.exitBlipModel;
tempHouseData.exitInterior = entranceLocation.exitInterior;
tempHouseData.entranceDimension = entranceLocation.entranceDimension;
tempHouseData.exitPosition = exitPosition;
tempHouseData.exitRotation = 0.0;
tempHouseData.exitPickupModel = 0;
tempHouseData.exitBlipModel = -1;
tempHouseData.exitInterior = 0;
tempHouseData.exitDimension = 0;
tempHouseData.exitCutscene = -1;
return tempHouseData;
tempHouseData.needsSaved = true;
let houseId = getServerData().houses.push(tempHouseData);
saveHouseToDatabase(houseId-1);
setHouseDataIndexes();
createHousePickups(houseId-1);
createHouseBlips(houseId-1);
return houseId-1;
}
// ===========================================================================
@@ -700,14 +659,21 @@ function getClosestHouseExit(position, dimension) {
// ===========================================================================
function getPlayerHouse(client) {
let closestEntrance = getClosestHouseEntrance(getPlayerPosition(client), getPlayerDimension(client));
if(getDistance(getPlayerPosition(client), getHouseData(closestEntrance).entrancePosition) <= getGlobalConfig().enterPropertyDistance) {
return getHouseData(closestEntrance).index
}
if(getPlayerDimension(client) == getGameConfig().mainWorldDimension[getGame()]) {
let closestEntrance = getClosestHouseEntrance(getPlayerPosition(client), getPlayerDimension(client));
if(getDistance(getPlayerPosition(client), getHouseData(closestEntrance).entrancePosition) <= getGlobalConfig().enterPropertyDistance) {
return getHouseData(closestEntrance).index;
}
} else {
let closestEntrance = getClosestHouseEntrance(getPlayerPosition(client), getPlayerDimension(client));
if(getDistance(getPlayerPosition(client), getHouseData(closestEntrance).entrancePosition) <= getGlobalConfig().enterPropertyDistance) {
return getHouseData(closestEntrance).index;
}
for(let i in getServerData().houses) {
if(getServerData().houses[i].exitDimension == getPlayerDimension(client)) {
return i;
for(let i in getServerData().houses) {
if(getServerData().houses[i].hasInterior && getServerData().houses[i].exitDimension == getPlayerDimension(client)) {
return i;
}
}
}
@@ -716,7 +682,7 @@ function getPlayerHouse(client) {
// ===========================================================================
function saveHousesToDatabase() {
function saveAllHousesToDatabase() {
if(getServerConfig().devServer) {
return false;
}
@@ -735,12 +701,14 @@ function saveHousesToDatabase() {
function saveHouseToDatabase(houseId) {
let tempHouseData = getServerData().houses[houseId];
if(!tempHouseData.needsSaved) {
return false;
}
logToConsole(LOG_VERBOSE, `[VRR.House]: Saving house '${tempHouseData.databaseId}' to database ...`);
let dbConnection = connectToDatabase();
if(dbConnection) {
let safeHouseDescription = escapeDatabaseString(dbConnection, tempHouseData.description);
let safeExitCutscene = escapeDatabaseString(dbConnection, tempHouseData.exitCutscene);
let safeEntranceCutscene = escapeDatabaseString(dbConnection, tempHouseData.entranceCutscene);
let data = [
["house_server", getServerId()],
@@ -757,7 +725,7 @@ function saveHouseToDatabase(houseId) {
["house_entrance_vw", tempHouseData.entranceDimension],
["house_entrance_pickup", tempHouseData.entrancePickupModel],
["house_entrance_blip", tempHouseData.entranceBlipModel],
["house_entrance_cutscene", safeEntranceCutscene],
["house_entrance_cutscene", tempHouseData.entranceCutscene],
["house_exit_pos_x", tempHouseData.exitPosition.x],
["house_exit_pos_y", tempHouseData.exitPosition.y],
["house_exit_pos_z", tempHouseData.exitPosition.z],
@@ -766,12 +734,12 @@ function saveHouseToDatabase(houseId) {
["house_exit_vw", tempHouseData.exitDimension],
["house_exit_pickup", tempHouseData.exitPickupModel],
["house_exit_blip", tempHouseData.exitBlipModel],
["house_exit_cutscene", safeExitCutscene],
["house_exit_cutscene", tempHouseData.exitCutscene],
["house_buy_price", tempHouseData.buyPrice],
["house_rent_price", tempHouseData.rentPrice],
["house_has_interior", boolToInt(tempHouseData.hasInterior)],
["house_interior_lights", boolToInt(tempHouseData.interiorLights)],
["house_custom_interior", boolToInt(tempHouseData.customInterior)],
];
let dbQuery = null;
@@ -800,6 +768,10 @@ function saveHouseToDatabase(houseId) {
function saveHouseLocationToDatabase(houseId, locationId) {
let tempHouseLocationData = getServerData().houses[houseId].locations[locationId];
if(!tempHouseLocationData.needsSaved) {
return false;
}
logToConsole(LOG_VERBOSE, `[VRR.House]: Saving house location '${locationId}' for house '${getHouseData(houseId).databaseId}' to database ...`);
let dbConnection = connectToDatabase();
if(dbConnection) {
@@ -869,31 +841,43 @@ function createAllHouseBlips() {
// ===========================================================================
function createHouseEntrancePickup(houseId) {
if(!areServerElementsSupported()) {
return false;
}
if(!getServerConfig().createHousePickups) {
return false;
}
if(getHouseData(houseId).entrancePickupModel != -1) {
let pickupModelId = getGameConfig().pickupModels[getServerGame()].House;
if(!getHouseData(houseId)) {
return false;
}
if(getServerData().houses[houseId].entrancePickupModel != 0) {
pickupModelId = getHouseData(houseId).entrancePickupModel;
}
let houseData = getHouseData(houseId);
if(areServerElementsSupported()) {
let entrancePickup = createGamePickup(pickupModelId, getHouseData(houseId).entrancePosition, getGameConfig().pickupTypes[getServerGame()].house);
if(entrancePickup != null) {
setElementOnAllDimensions(entrancePickup, false);
setElementDimension(entrancePickup, getHouseData(houseId).entranceDimension);
setElementStreamInDistance(entrancePickup, getGlobalConfig().housePickupStreamInDistance);
setElementStreamOutDistance(entrancePickup, getGlobalConfig().housePickupStreamOutDistance);
setElementTransient(entrancePickup, false);
addToWorld(entrancePickup);
//if(houseData.hasInterior) {
// return false;
//}
getHouseData(houseId).entrancePickup = entrancePickup;
updateHousePickupLabelData(houseId);
}
}
if(houseData.entrancePickupModel == -1) {
return false;
}
let pickupModelId = getGameConfig().pickupModels[getGame()].House;
if(getServerData().houses[houseId].entrancePickupModel != 0) {
pickupModelId = getHouseData(houseId).entrancePickupModel;
}
let entrancePickup = createGamePickup(pickupModelId, getHouseData(houseId).entrancePosition, getGameConfig().pickupTypes[getGame()].house);
if(entrancePickup != null) {
setElementOnAllDimensions(entrancePickup, false);
setElementDimension(entrancePickup, getHouseData(houseId).entranceDimension);
setElementStreamInDistance(entrancePickup, getGlobalConfig().housePickupStreamInDistance);
setElementStreamOutDistance(entrancePickup, getGlobalConfig().housePickupStreamOutDistance);
setElementTransient(entrancePickup, false);
getHouseData(houseId).entrancePickup = entrancePickup;
updateHousePickupLabelData(houseId);
}
}
@@ -901,100 +885,150 @@ function createHouseEntrancePickup(houseId) {
// ===========================================================================
function createHouseEntranceBlip(houseId) {
if(!areServerElementsSupported()) {
return false;
}
if(!getServerConfig().createHouseBlips) {
return false;
}
if(getHouseData(houseId).entranceBlipModel != -1) {
let blipModelId = getGameConfig().blipSprites[getServerGame()].House;
if(!getHouseData(houseId)) {
return false;
}
if(getServerData().houses[houseId].entranceBlipModel != 0) {
blipModelId = getHouseData(houseId).entranceBlipModel;
let houseData = getHouseData(houseId);
//if(houseData.hasInterior) {
// return false;
//}
if(houseData.entranceBlipModel == -1) {
return false;
}
let blipModelId = getGameConfig().blipSprites[getGame()].House;
if(getServerData().houses[houseId].entranceBlipModel != 0) {
blipModelId = getHouseData(houseId).entranceBlipModel;
}
let entranceBlip = createGameBlip(houseData.entrancePosition, blipModelId, getColourByName("houseGreen"));
if(entranceBlip != null) {
if(houseData.exitDimension != -1) {
setElementDimension(entranceBlip, houseData.entranceDimension);
setElementOnAllDimensions(entranceBlip, false);
} else {
setElementOnAllDimensions(entranceBlip, true);
}
if(areServerElementsSupported()) {
let entranceBlip = createGameBlip(getHouseData(houseId).entrancePosition, blipModelId, 1, getColourByName("houseGreen"));
if(entranceBlip != null) {
setElementDimension(entranceBlip, getHouseData(houseId).entranceDimension);
setElementOnAllDimensions(entranceBlip, false);
setElementStreamInDistance(entranceBlip, getGlobalConfig().houseBlipStreamInDistance);
setElementStreamOutDistance(entranceBlip, getGlobalConfig().houseBlipStreamOutDistance);
setElementTransient(entranceBlip, false);
setEntityData(entranceBlip, "vrr.owner.type", VRR_BLIP_HOUSE_ENTRANCE, false);
setEntityData(entranceBlip, "vrr.owner.id", houseId, false);
addToWorld(entranceBlip);
getHouseData(houseId).entranceBlip = entranceBlip;
}
if(getGlobalConfig().houseBlipStreamInDistance == -1 || getGlobalConfig().houseBlipStreamOutDistance == -1) {
entranceBlip.netFlags.distanceStreaming = false;
} else {
setElementStreamInDistance(entranceBlip, getGlobalConfig().houseBlipStreamInDistance);
setElementStreamOutDistance(entranceBlip, getGlobalConfig().houseBlipStreamOutDistance);
}
setEntityData(entranceBlip, "vrr.owner.type", VRR_BLIP_HOUSE_ENTRANCE, false);
setEntityData(entranceBlip, "vrr.owner.id", houseId, false);
houseData.entranceBlip = entranceBlip;
}
}
// ===========================================================================
function createHouseExitPickup(houseId) {
if(!areServerElementsSupported()) {
return false;
}
if(!getServerConfig().createHousePickups) {
return false;
}
if(getHouseData(houseId).hasInterior) {
if(getHouseData(houseId).exitPickupModel != -1) {
let pickupModelId = getGameConfig().pickupModels[getServerGame()].Exit;
if(!getHouseData(houseId)) {
return false;
}
if(getServerData().houses[houseId].exitPickupModel != 0) {
pickupModelId = getHouseData(houseId).exitPickupModel;
}
let houseData = getHouseData(houseId);
if(areServerElementsSupported()) {
let exitPickup = createGamePickup(pickupModelId, getHouseData(houseId).exitPosition, getGameConfig().pickupTypes[getServerGame()].house);
if(exitPickup != null) {
setElementDimension(exitPickup, getHouseData(houseId).exitDimension);
setElementOnAllDimensions(exitPickup, false);
setElementStreamInDistance(exitPickup, getGlobalConfig().housePickupStreamInDistance);
setElementStreamOutDistance(exitPickup, getGlobalConfig().housePickupStreamOutDistance);
setElementTransient(exitPickup, false);
addToWorld(exitPickup);
//if(houseData.hasInterior) {
// return false;
//}
getHouseData(houseId).exitPickup = exitPickup;
updateHousePickupLabelData(houseId);
}
}
updateHousePickupLabelData(houseId);
}
if(houseData.exitPickupModel == -1) {
return false;
}
let pickupModelId = getGameConfig().pickupModels[getGame()].Exit;
if(getServerData().houses[houseId].exitPickupModel != 0) {
pickupModelId = houseData.exitPickupModel;
}
let exitPickup = createGamePickup(pickupModelId, houseData.exitPosition, getGameConfig().pickupTypes[getGame()].house);
if(exitPickup != null) {
setElementDimension(exitPickup, houseData.exitDimension);
setElementOnAllDimensions(exitPickup, false);
setElementStreamInDistance(exitPickup, getGlobalConfig().housePickupStreamInDistance);
setElementStreamOutDistance(exitPickup, getGlobalConfig().housePickupStreamOutDistance);
setElementTransient(exitPickup, false);
getHouseData(houseId).exitPickup = exitPickup;
updateHousePickupLabelData(houseId);
}
}
// ===========================================================================
function createHouseExitBlip(houseId) {
if(!areServerElementsSupported()) {
return false;
}
if(!getServerConfig().createHouseBlips) {
return false;
}
if(getHouseData(houseId).hasInterior) {
if(getHouseData(houseId).exitBlipModel != -1) {
let blipModelId = getGameConfig().blipSprites[getServerGame()].House;
if(!getHouseData(houseId)) {
return false;
}
if(getServerData().houses[houseId].exitBlipModel != 0) {
blipModelId = getHouseData(houseId).exitBlipModel;
}
let houseData = getHouseData(houseId);
if(areServerElementsSupported()) {
let exitBlip = createGameBlip(blipModelId, getHouseData(houseId).exitPosition, 1, getColourByName("houseGreen"));
if(exitBlip != null) {
setElementDimension(exitBlip, getHouseData(houseId).entranceDimension);
setElementOnAllDimensions(exitBlip, false);
setElementStreamInDistance(exitBlip, getGlobalConfig().houseBlipStreamInDistance);
setElementStreamOutDistance(exitBlip, getGlobalConfig().houseBlipStreamOutDistance);
setElementTransient(exitBlip, false);
setEntityData(exitBlip, "vrr.owner.type", VRR_BLIP_HOUSE_EXIT, false);
setEntityData(exitBlip, "vrr.owner.id", houseId, false);
addToWorld(exitBlip);
//if(houseData.hasInterior) {
// return false;
//}
getHouseData(houseId).exitBlip = exitBlip;
}
}
if(houseData.exitBlipModel == -1) {
return false;
}
let blipModelId = getGameConfig().blipSprites[getGame()].Exit;
if(getServerData().houses[houseId].exitBlipModel != 0) {
blipModelId = houseData.exitBlipModel;
}
let exitBlip = createGameBlip(houseData.exitPosition, blipModelId, 1, getColourByName("houseGreen"));
if(exitBlip != null) {
if(houseData.exitDimension != -1) {
setElementDimension(exitBlip, houseData.exitDimension);
setElementOnAllDimensions(exitBlip, false);
} else {
setElementOnAllDimensions(entranceBlip, true);
}
if(getGlobalConfig().houseBlipStreamInDistance == -1 || getGlobalConfig().houseBlipStreamOutDistance == -1) {
exitBlip.netFlags.distanceStreaming = false;
} else {
setElementStreamInDistance(exitBlip, getGlobalConfig().houseBlipStreamInDistance);
setElementStreamOutDistance(exitBlip, getGlobalConfig().houseBlipStreamOutDistance);
}
setElementTransient(exitBlip, false);
setEntityData(exitBlip, "vrr.owner.type", VRR_BLIP_HOUSE_EXIT, false);
setEntityData(exitBlip, "vrr.owner.id", houseId, false);
getHouseData(houseId).exitBlip = exitBlip;
}
}
@@ -1008,15 +1042,18 @@ function getHouseOwnerTypeText(ownerType) {
case VRR_HOUSEOWNER_PLAYER:
return "player";
case VRR_BIZOWNER_NONE:
case VRR_HOUSEOWNER_NONE:
return "not owned";
case VRR_BIZOWNER_PUBLIC:
case VRR_HOUSEOWNER_PUBLIC:
return "not owned";
case VRR_BIZOWNER_JOB:
case VRR_HOUSEOWNER_JOB:
return "job";
case VRR_HOUSEOWNER_BIZ:
return "business";
default:
return "unknown";
}
@@ -1045,14 +1082,16 @@ function getHouseInfoCommand(command, params, client) {
return false;
}
let houseData = getHouseData(houseId);
let ownerName = "Unknown";
switch(getHouseData(houseId).ownerType) {
case VRR_HOUSEOWNER_CLAN:
ownerName = getClanData(getHouseData(houseId).ownerId).name;
ownerName = getClanData(houseData).name;
break;
case VRR_HOUSEOWNER_PLAYER:
let subAccountData = loadSubAccountFromId(getHouseData(houseId).ownerId);
let subAccountData = loadSubAccountFromId(houseData.ownerId);
ownerName = `${subAccountData.firstName} ${subAccountData.lastName} [${subAccountData.databaseId}]`;
break;
@@ -1064,12 +1103,38 @@ function getHouseInfoCommand(command, params, client) {
ownerName = "Public";
break;
case VRR_HOUSEOWNER_BIZ:
ownerName = getBusinessDataFromDatabaseId(houseData.ownerId).name;
break;
case VRR_HOUSEOWNER_JOB:
ownerName = getJobData(getHouseData(houseId).ownerId).name;
ownerName = getJobData(houseData.ownerId).name;
break;
}
messagePlayerNormal(client, `🏠 {houseGreen}[House Info] {MAINCOLOUR}Description: {ALTCOLOUR}${getHouseData(houseId).description}, {MAINCOLOUR}Owner: {ALTCOLOUR}${ownerName} (${getHouseOwnerTypeText(getHouseData(houseId).ownerType)}), {MAINCOLOUR}Locked: {ALTCOLOUR}${getYesNoFromBool(intToBool(getHouseData(houseId).locked))}, {MAINCOLOUR}ID: {ALTCOLOUR}${houseId}/${getHouseData(houseId).databaseId}`);
let tempStats = [
[`Name`, `${houseData.description}`],
[`ID`, `${houseData.index}/${houseData.databaseId}`],
[`Owner`, `${ownerName} (${getHouseOwnerTypeText(houseData.ownerType)})`],
[`Locked`, `${getLockedUnlockedFromBool(houseData.locked)}`],
[`BuyPrice`, `${houseData.buyPrice}`],
[`RentPrice`, `${houseData.rentPrice}`],
[`HasInterior`, `${getYesNoFromBool(houseData.hasInterior)}`],
[`CustomInterior`, `${getYesNoFromBool(houseData.customInterior)}`],
[`InteriorLights`, `${getOnOffFromBool(houseData.interiorLights)}`],
[`RadioStation`, `${houseData.streamingRadioStation}`],
];
let stats = tempStats.map(stat => `{MAINCOLOUR}${stat[0]}: {ALTCOLOUR}${stat[1]}{MAINCOLOUR}`);
messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderHouseInfo", houseData.description)));
let chunkedList = splitArrayIntoChunks(stats, 6);
for(let i in chunkedList) {
messagePlayerInfo(client, chunkedList[i].join(", "));
}
//messagePlayerNormal(client, `🏠 {houseGreen}[House Info]{MAINCOLOUR} Description: {ALTCOLOUR}${getHouseData(houseId).description}, {MAINCOLOUR}Owner: {ALTCOLOUR}${ownerName} (${getHouseOwnerTypeText(getHouseData(houseId).ownerType)}), {MAINCOLOUR}Locked: {ALTCOLOUR}${getYesNoFromBool(intToBool(getHouseData(houseId).locked))}, {MAINCOLOUR}ID: {ALTCOLOUR}${houseId}/${getHouseData(houseId).databaseId}`);
}
// ===========================================================================
@@ -1105,8 +1170,9 @@ function setHouseBuyPriceCommand(command, params, client) {
}
getHouseData(houseId).buyPrice = amount;
setEntityData(getHouseData(houseId).entrancePickup, "vrr.label.price", getHouseData(houseId).buyPrice, true);
messagePlayerSuccess(client, `{MAINCOLOUR}You set house {houseGreen}${getHouseData(houseId).description}'s {MAINCOLOUR}for-sale price to {ALTCOLOUR}$${makeLargeNumberReadable(amount)}`);
getHouseData(houseId).needsSaved = true;
updateHousePickupLabelData(houseId);
messagePlayerSuccess(client, `{MAINCOLOUR}You set house {houseGreen}${getHouseData(houseId).description}'s{MAINCOLOUR} for-sale price to {ALTCOLOUR}$${makeLargeNumberReadable(amount)}`);
}
// ===========================================================================
@@ -1142,8 +1208,9 @@ function setHouseRentPriceCommand(command, params, client) {
}
getHouseData(houseId).rentPrice = amount;
setEntityData(getHouseData(houseId).entrancePickup, "vrr.label.price", `Rent: ${getHouseData(houseId).rentPrice}`, true);
messagePlayerSuccess(client, `{MAINCOLOUR}You set house {houseGreen}${getHouseData(houseId).description}'s {MAINCOLOUR}rent price to {ALTCOLOUR}$${makeLargeNumberReadable(amount)}`);
getHouseData(houseId).needsSaved = true;
updateHousePickupLabelData(houseId);
messagePlayerSuccess(client, `{MAINCOLOUR}You set house {houseGreen}${getHouseData(houseId).description}'s{MAINCOLOUR} rent price to {ALTCOLOUR}$${makeLargeNumberReadable(amount)}`);
}
// ===========================================================================
@@ -1175,19 +1242,8 @@ function buyHouseCommand(command, params, client) {
return false;
}
getHouseData(houseId).ownerType = VRR_BIZOWNER_PLAYER;
getHouseData(houseId).ownerId = getPlayerCurrentSubAccount(client).databaseId;
getHouseData(houseId).buyPrice = 0;
updateHousePickupLabelData(houseId);
messagePlayerSuccess(client, `You are now the owner of {houseGreen}${getHouseData(houseId).description}`);
}
// ===========================================================================
function isPlayerInAnyHouse(client) {
return doesEntityDataExist(client, "vrr.inHouse");
showPlayerPrompt(client, getLocaleString(client, "BuyHouseConfirmMessage"), getLocaleString(client, "BuyHouseConfirmTitle"), getLocaleString(client, "Yes"), getLocaleString(client, "No"));
getPlayerData(client).promptType = VRR_PROMPT_HOUSEBUY;
}
// ===========================================================================
@@ -1278,8 +1334,8 @@ function deleteHouseExitBlip(houseId) {
function reloadAllHousesCommand(command, params, client) {
let clients = getClients();
for(let i in clients) {
if(isPlayerInAnyHouse(clients[i])) {
removePlayerFromHouses(clients[i]);
if(getPlayerHouse(clients[i]) != -1) {
removePlayerFromHouse(clients[i]);
}
}
@@ -1295,7 +1351,7 @@ function reloadAllHousesCommand(command, params, client) {
createAllHousePickups();
createAllHouseBlips();
announceAdminAction(`HousesReloaded`);
announceAdminAction(`AllHousesReloaded`);
}
// ===========================================================================
@@ -1307,12 +1363,11 @@ function exitHouse(client) {
setPlayerDimension(client, getServerData().house[houseId].entranceDimension);
setPlayerPosition(client, getServerData().house[houseId].entrancePosition);
}
removeEntityData(client, "vrr.inHouse");
}
// ===========================================================================
function setAllHouseIndexes() {
function setHouseDataIndexes() {
for(let i in getServerData().houses) {
getServerData().houses[i].index = i;
@@ -1517,7 +1572,7 @@ function updateHousePickupLabelData(houseId) {
setEntityData(houseData.entrancePickup, "vrr.owner.type", VRR_PICKUP_HOUSE_ENTRANCE, false);
setEntityData(houseData.entrancePickup, "vrr.owner.id", houseId, false);
setEntityData(houseData.entrancePickup, "vrr.label.type", VRR_LABEL_HOUSE, true);
//setEntityData(houseData.entrancePickup, "vrr.label.name", houseData.description, true);
setEntityData(houseData.entrancePickup, "vrr.label.name", houseData.description, true);
setEntityData(houseData.entrancePickup, "vrr.label.locked", houseData.locked, true);
if(houseData.buyPrice > 0) {
setEntityData(houseData.entrancePickup, "vrr.label.price", houseData.buyPrice, true);
@@ -1537,4 +1592,36 @@ function updateHousePickupLabelData(houseId) {
}
}
// ===========================================================================
function deleteAllHouseBlips() {
for(let i in getServerData().houses) {
deleteHouseEntranceBlip(i);
deleteHouseExitBlip(i);
}
}
// ===========================================================================
function deleteAllHousePickups() {
for(let i in getServerData().houses) {
deleteHouseEntrancePickup(i);
deleteHouseExitPickup(i);
}
}
// ===========================================================================
function createHouseBlips(houseId) {
createHouseEntranceBlip(houseId);
createHouseExitBlip(houseId);
}
// ===========================================================================
function createHousePickups(houseId) {
createHouseEntrancePickup(houseId);
createHouseExitPickup(houseId);
}
// ===========================================================================

View File

@@ -38,6 +38,7 @@ 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");

View File

@@ -9,16 +9,6 @@
function initItemScript() {
logToConsole(LOG_INFO, "[VRR.Item]: Initializing item script ...");
getServerData().itemTypes = loadItemTypesFromDatabase();
if(!getServerConfig().devServer) {
getServerData().items = loadItemsFromDatabase();
}
setItemTypeDataIndexes();
setItemDataIndexes();
cacheAllGroundItems();
createAllGroundItemObjects();
logToConsole(LOG_INFO, "[VRR.Item]: Item script initialized successfully!");
return true;
}
@@ -295,13 +285,13 @@ function pickupItemCommand(command, params, client) {
let itemId = getClosestItemOnGround(getPlayerPosition(client));
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.`);
submitBugReport(client, `(AUTOMATED REPORT) Pickup Item: Getting item data for item ${itemId} on ground returned false.`);
return false;
}
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.`);
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;
}
@@ -717,25 +707,26 @@ function setItemTypeUseValueCommand(command, params, client) {
// ===========================================================================
function playerUseItem(client, hotBarSlot) {
let closestPlayer;
let tempUseValue;
let vehicle;
let fuelPump;
let itemIndex = getPlayerData(client).hotBarItems[hotBarSlot];
if(itemIndex == -1) {
return false;
}
if(!getItemData(itemIndex)) {
submitBugReport(client, `[AUTOMATED REPORT] Tried to use invalid item (index ${itemIndex} in player slot ${hotBarSlot})`);
cachePlayerHotBarItems(client);
return false;
}
switch(getItemTypeData(getItemData(itemIndex).itemTypeIndex).useType) {
case VRR_ITEM_USETYPE_SKIN:
case VRR_ITEM_USETYPE_SKIN: {
getPlayerData(client).itemActionItem = itemIndex;
forcePlayerIntoSkinSelect(client);
break;
}
case VRR_ITEM_USETYPE_WEAPON:
case VRR_ITEM_USETYPE_WEAPON: {
for(let i in getPlayerData(client).hotBarItems) {
if(getPlayerData(client).hotBarItems[i] != -1) {
if(getItemData(getPlayerData(client).hotBarItems[i]) != false) {
@@ -753,16 +744,19 @@ function playerUseItem(client, hotBarSlot) {
}
messagePlayerError(client, `You don't have any ammo to load into your ${getItemTypeData(getItemData(itemIndex).itemTypeIndex).name}!`);
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`}`);
break;
}
case VRR_ITEM_USETYPE_STORAGE:
case VRR_ITEM_USETYPE_STORAGE: {
showItemInventoryToPlayer(client, itemIndex);
break;
}
case VRR_ITEM_USETYPE_FOOD:
case VRR_ITEM_USETYPE_FOOD: {
meActionToNearbyPlayers(client, `eats some of their ${getItemName(itemIndex)}`);
givePlayerHealth(client, getItemTypeData(getItemData(itemIndex).itemTypeIndex).useValue);
getItemData(itemIndex).value = getItemData(itemIndex).value - getItemTypeData(getItemData(itemIndex).itemTypeIndex).useValue;
@@ -771,8 +765,9 @@ function playerUseItem(client, hotBarSlot) {
switchPlayerActiveHotBarSlot(client, -1);
}
break;
}
case VRR_ITEM_USETYPE_DRINK:
case VRR_ITEM_USETYPE_DRINK: {
meActionToNearbyPlayers(client, `drinks some of their ${getItemName(itemIndex)}`);
givePlayerHealth(client, getItemTypeData(getItemData(itemIndex).itemTypeIndex).useValue);
getItemData(itemIndex).value = getItemData(itemIndex).value - getItemTypeData(getItemData(itemIndex).itemTypeIndex).useValue;
@@ -781,16 +776,18 @@ function playerUseItem(client, hotBarSlot) {
switchPlayerActiveHotBarSlot(client, -1);
}
break;
}
case VRR_ITEM_USETYPE_ARMOUR:
case VRR_ITEM_USETYPE_ARMOUR: {
meActionToNearbyPlayers(client, `puts on a ${getItemName(itemIndex)}`);
givePlayerArmour(client, getItemData(itemIndex).useValue);
deleteItem(itemIndex);
switchPlayerActiveHotBarSlot(client, -1);
break;
}
case VRR_ITEM_USETYPE_ROPE:
closestPlayer = getClosestPlayer(getPlayerPosition(client), getPlayerPed(client));
case VRR_ITEM_USETYPE_ROPE: {
let closestPlayer = getClosestPlayer(getPlayerPosition(client), client);
if(!getPlayerData(closestPlayer)) {
messagePlayerError(client, "There isn't anyone close enough to tie up!");
@@ -820,9 +817,10 @@ function playerUseItem(client, hotBarSlot) {
meActionToNearbyPlayers(client, `takes their rope and ties ${getCharacterFullName(closestPlayer)}'s hands and feet together.`);
}
break;
}
case VRR_ITEM_USETYPE_HANDCUFF:
closestPlayer = getClosestPlayer(getPlayerPosition(client), client);
case VRR_ITEM_USETYPE_HANDCUFF: {
let closestPlayer = getClosestPlayer(getPlayerPosition(client), client);
if(!getPlayerData(closestPlayer)) {
messagePlayerError(client, "There isn't anyone close enough to handcuff!");
@@ -847,13 +845,15 @@ function playerUseItem(client, hotBarSlot) {
meActionToNearbyPlayers(client, `takes their cuffs and places them on ${getCharacterFullName(closestPlayer)}`);
}
break;
}
case VRR_ITEM_USETYPE_NONE:
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:
vehicle = getClosestVehicle(getPlayerPosition(client));
case VRR_ITEM_USETYPE_VEHREPAIR: {
let vehicle = getClosestVehicle(getPlayerPosition(client));
if(getDistance(getPlayerPosition(client), getVehiclePosition(vehicle)) <= getGlobalConfig().vehicleRepairDistance) {
meActionToNearbyPlayers(client, `takes their repair kit and fixes the vehicle`);
repairVehicle(vehicle);
@@ -864,25 +864,28 @@ function playerUseItem(client, hotBarSlot) {
}
}
break;
}
case VRR_ITEM_USETYPE_VEHUPGRADE_PART:
vehicle = getClosestVehicle(getPlayerPosition(client));
case VRR_ITEM_USETYPE_VEHUPGRADE_PART: {
let vehicle = getClosestVehicle(getPlayerPosition(client));
if(getDistance(getPlayerPosition(client), getVehiclePosition(vehicle)) <= getGlobalConfig().vehicleRepairDistance) {
meActionToNearbyPlayers(client, `takes their upgrade kit and adds a ${getItemName(itemIndex)} to the vehicle.`);
addVehicleUpgrade(vehicle, getItemData(itemIndex).useId);
}
break;
}
case VRR_ITEM_USETYPE_VEHLIVERY:
vehicle = getClosestVehicle(getPlayerPosition(client));
case VRR_ITEM_USETYPE_VEHLIVERY: {
let vehicle = getClosestVehicle(getPlayerPosition(client));
if(getDistance(getPlayerPosition(client), getVehiclePosition(vehicle)) <= getGlobalConfig().vehicleRepairDistance) {
meActionToNearbyPlayers(client, `takes their decal kit and adds some decals to the vehicle.`);
setVehicleLivery(vehicle, getItemData(itemIndex).value);
}
break;
}
case VRR_ITEM_USETYPE_VEHCOLOUR:
vehicle = getClosestVehicle(getPlayerPosition(client));
case VRR_ITEM_USETYPE_VEHCOLOUR: {
let vehicle = getClosestVehicle(getPlayerPosition(client));
if(getDistance(getPlayerPosition(client), getVehiclePosition(vehicle)) <= getGlobalConfig().vehicleRepairDistance) {
if(getItemData(itemIndex).useId == 1) {
meActionToNearbyPlayers(client, `takes their vehicle colour kit and changes the primary colour of the vehicle.`);
@@ -895,10 +898,11 @@ function playerUseItem(client, hotBarSlot) {
}
}
break;
}
case VRR_ITEM_USETYPE_FUELCAN:
vehicle = getClosestVehicle(getPlayerPosition(client));
fuelPump = getClosestFuelPump(getPlayerPosition(client));
case VRR_ITEM_USETYPE_FUELCAN: {
let vehicle = getClosestVehicle(getPlayerPosition(client));
let fuelPump = getClosestFuelPump(getPlayerPosition(client));
if(getDistance(getPlayerPosition(client), getVehiclePosition(vehicle)) <= getDistance(getPlayerPosition(client), getFuelPumpData(fuelPump).position)) {
if(getDistance(getPlayerPosition(client), getVehiclePosition(vehicle)) <= getGlobalConfig().vehicleRepairDistance) {
meActionToNearbyPlayers(client, `takes their fuel can and refills the vehicle`);
@@ -927,14 +931,16 @@ function playerUseItem(client, hotBarSlot) {
}
}
break;
}
case VRR_ITEM_USETYPE_WALKIETALKIE:
case VRR_ITEM_USETYPE_WALKIETALKIE: {
getItemData(itemIndex).enabled = !getItemData(itemIndex).enabled;
//messagePlayerAlert(client, `You turned ${getBoolRedGreenInlineColour(getItemData(itemIndex).enabled)}${toUpperCase(getOnOffFromBool(getItemData(itemIndex).enabled))} {MAINCOLOUR}your walkie talkie in slot ${getPlayerData(client).activeHotBarSlot+1} {ALTCOLOUR}${getItemValueDisplayForItem(itemIndex)}`);
meActionToNearbyPlayers(client, `turns ${toLowerCase(getOnOffFromBool(getItemData(itemIndex).enabled))} their walkie-talkie`);
break;
}
case VRR_ITEM_USETYPE_PHONE:
case VRR_ITEM_USETYPE_PHONE: {
if(getItemData(itemIndex).value == 0) {
let phoneNumber = generateRandomPhoneNumber();
getItemData(itemIndex).value = phoneNumber;
@@ -950,8 +956,9 @@ function playerUseItem(client, hotBarSlot) {
}
}
break;
}
case VRR_ITEM_USETYPE_SMOKEDRUG:
case VRR_ITEM_USETYPE_SMOKEDRUG: {
meActionToNearbyPlayers(client, `smokes some ${getItemName(itemIndex)}`);
getPlayerData(client).incomingDamageMultiplier = getPlayerData(client).incomingDamageMultiplier-(getItemTypeData(getItemData(itemIndex).itemTypeIndex).useValue/100);
if(getPlayerData(client).incomingDamageMultiplier < 0.25) {
@@ -960,8 +967,9 @@ function playerUseItem(client, hotBarSlot) {
deleteItem(itemIndex);
switchPlayerActiveHotBarSlot(client, -1);
break;
}
case VRR_ITEM_USETYPE_SNORTDRUG:
case VRR_ITEM_USETYPE_SNORTDRUG: {
meActionToNearbyPlayers(client, `snorts some ${getItemName(itemIndex)}`);
getPlayerData(client).incomingDamageMultiplier = getPlayerData(client).incomingDamageMultiplier-(getItemTypeData(getItemData(itemIndex).itemTypeIndex).useValue/100);
if(getPlayerData(client).incomingDamageMultiplier < 0.25) {
@@ -970,8 +978,9 @@ function playerUseItem(client, hotBarSlot) {
deleteItem(itemIndex);
switchPlayerActiveHotBarSlot(client, -1);
break;
}
case VRR_ITEM_USETYPE_INJECTDRUG:
case VRR_ITEM_USETYPE_INJECTDRUG: {
meActionToNearbyPlayers(client, `shoots up some ${getItemName(itemIndex)}`);
getPlayerData(client).incomingDamageMultiplier = getPlayerData(client).incomingDamageMultiplier-(getItemTypeData(getItemData(itemIndex).itemTypeIndex).useValue/100);
if(getPlayerData(client).incomingDamageMultiplier < 0.25) {
@@ -980,8 +989,9 @@ function playerUseItem(client, hotBarSlot) {
deleteItem(itemIndex);
switchPlayerActiveHotBarSlot(client, -1);
break;
}
case VRR_ITEM_USETYPE_PLANT:
case VRR_ITEM_USETYPE_PLANT: {
meActionToNearbyPlayers(client, `bends down and plants a ${getItemName(itemIndex)} in the ground`);
createGroundPlant(itemIndex);
if(getItemData(itemIndex).value == 0) {
@@ -989,27 +999,64 @@ function playerUseItem(client, hotBarSlot) {
switchPlayerActiveHotBarSlot(client, -1);
}
break;
}
case VRR_ITEM_USETYPE_BADGE:
case VRR_ITEM_USETYPE_BADGE: {
meActionToNearbyPlayers(client, `shows their badge to everyone nearby.`);
let clients = getClients();
for(let i in clients) {
if(getDistance(getPlayerPosition(client), getPlayerPosition(clients[i])) <= 7) {
messagePlayerInfo(client, `{clanOrange}== {jobYellow}Badge {clanOrange}====================================`);
messagePlayerNormal(client, `{clanOrange}Name: {MAINCOLOUR}${getCharacterFullName(client)}`);
messagePlayerNormal(client, `{clanOrange}Type: {MAINCOLOUR}${getJobData(getPlayerJob(client)).name}`);
messagePlayerNormal(client, `{clanOrange}Rank: {MAINCOLOUR}${getJobRankName(getPlayerJob(client), getPlayerJobRank(client))}`);
makeChatBoxSectionHeader(clients[i], getLocaleString(client, "Badge", getCharacterFullName(client)));
messagePlayerNormal(client, `{clanOrange}Type:{MAINCOLOUR} ${getJobData(getPlayerJob(client)).name}`);
messagePlayerNormal(client, `{clanOrange}ID:{MAINCOLOUR} ${addPrefixNumberFill(getPlayerCurrentSubAccount(client).databaseId, 5)}`);
messagePlayerNormal(client, `{clanOrange}Rank:{MAINCOLOUR} ${getJobRankName(getPlayerJob(client), getPlayerJobRank(client))}`);
}
}
break;
}
case VRR_ITEM_USETYPE_AMMO_CLIP:
case VRR_ITEM_USETYPE_AMMO_CLIP: {
messagePlayerError(client, `Equip a compatible weapon and press R to use an ammo clip/magazine`);
break;
}
default:
case VRR_ITEM_USETYPE_HEALTH: {
let closestPlayer = getClosestPlayer(getPlayerPosition(client), client);
if(!getPlayerData(closestPlayer)) {
messagePlayerError(client, "There isn't anyone close enough to heal!");
return false;
}
if(getDistance(getPlayerPosition(closestPlayer), getPlayerPosition(client)) > getGlobalConfig().firstAidKitPlayerDistance) {
messagePlayerError(client, "There isn't anyone close enough to heal!");
return false;
}
break;
}
case VRR_ITEM_USETYPE_LOTTOTICKET: {
break;
}
case VRR_ITEM_USETYPE_AREARADIO: {
let state = getItemData(itemIndex)
meActionToNearbyPlayers(client, `turns ${getOnOffFromBool(state)} the boombox radio`);
messagePlayerAlert(client, `Use /radiostation to set the radio station and drop it on the ground to play`);
break;
}
case VRR_ITEM_USETYPE_PERSONALRADIO: {
meActionToNearbyPlayers(client, `turns ${getOnOffFromBool(state)} the boombox radio`);
messagePlayerAlert(client, `Use /radiostation to set the radio station`);
break;
}
default: {
messagePlayerError(client, `The ${getItemName(itemIndex)} doesn't do anything when you try to use it.`);
break;
}
}
if(getItemData(itemIndex) != false) {
@@ -1028,10 +1075,10 @@ function playerDropItem(client, hotBarSlot) {
meActionToNearbyPlayers(client, `drops ${getProperDeterminerForName(getItemName(itemId))} ${getItemName(itemId)} on the ground`);
resyncWeaponItemAmmo(client);
clearPlayerWeapons(client);
getPlayerData(client).hotBarItems[hotBarSlot] = -1;
updatePlayerHotBar(client);
clearPlayerWeapons(client);
getItemData(itemId).ownerType = VRR_ITEM_OWNER_GROUND;
getItemData(itemId).ownerId = 0;
@@ -1297,7 +1344,7 @@ function getClosestItemOnGround(position) {
// ===========================================================================
function setItemDataIndexes() {
function setAllItemDataIndexes() {
for(let i in getServerData().items) {
if(getServerData().items[i]) {
getServerData().items[i].index = i;
@@ -1308,7 +1355,7 @@ function setItemDataIndexes() {
// ===========================================================================
function setItemTypeDataIndexes() {
function setAllItemTypeDataIndexes() {
for(let i in getServerData().itemTypes) {
if(getServerData().itemTypes[i]) {
getServerData().itemTypes[i].index = i;
@@ -1326,13 +1373,9 @@ function setItemTypeDataIndexes() {
// ===========================================================================
function cacheAllGroundItems() {
getServerData().groundItemCache = [];
for(let i in getServerData().items) {
if(getServerData().items[i].ownerType == VRR_ITEM_OWNER_GROUND) {
getServerData().groundItemCache.push(i);
}
}
clearArray(getServerData().groundItemCache);
getServerData().groundItemCache = getServerData().items.filter(item => item.ownerType == VRR_ITEM_OWNER_GROUND);
//getServerData().groundPlantCache = getServerData().items.filter(item => item.ownerType == VRR_ITEM_OWNER_PLANT);
}
// ===========================================================================
@@ -1368,19 +1411,11 @@ function cachePlayerHotBarItems(client) {
return false;
}
for(let i = 0 ; i < 9 ; i++) {
getPlayerData(client).hotBarItems[i] = -1;
}
clearArray(getPlayerData(client).hotBarItems);
getPlayerData(client).hotBarItems = getServerData().items.filter(item => item.ownerType == VRR_ITEM_OWNER_PLAYER && item.ownerId == getPlayerCurrentSubAccount(client).databaseId);
for(let i in getServerData().items) {
if(getItemData(i).ownerType == VRR_ITEM_OWNER_PLAYER) {
if(getItemData(i).ownerId == getPlayerCurrentSubAccount(client).databaseId) {
let firstSlot = getPlayerFirstEmptyHotBarSlot(client);
if(firstSlot != -1) {
getPlayerData(client).hotBarItems[firstSlot] = i;
}
}
}
if(getPlayerData(client).hotBarItems.length < getGlobalConfig().maxPlayerItemSlots) {
getPlayerData(client).hotBarItems.concat(Array(getGlobalConfig().maxPlayerItemSlots-getPlayerData(client).hotBarItems.length).fill(-1));
}
}
@@ -1460,7 +1495,7 @@ function deleteItem(itemId) {
quickDatabaseQuery(`DELETE FROM item_main WHERE item_id = ${getItemData(itemId).databaseId}`);
}
getServerData().items[itemId] = false;
setItemDataIndexes();
setAllItemDataIndexes();
}
// ===========================================================================
@@ -1469,12 +1504,12 @@ function getBestNewOwnerToPutItem(client) {
let closestDistance = 100.0;
let position = getPlayerPosition(client);
let possibleHouse = (isPlayerInAnyHouse(client)) ? getPlayerHouse(client) : getClosestHouseEntrance(getPlayerPosition(client));
let possibleHouse = getPlayerHouse(client);
if(getHouseData(possibleHouse)) {
return [VRR_ITEM_OWNER_HOUSE, possibleHouse];
}
let possibleBusiness = (isPlayerInAnyBusiness(client)) ? getPlayerBusiness(client) : getClosestBusinessEntrance(getPlayerPosition(client));
let possibleBusiness = getPlayerBusiness(client);
if(getBusinessData(possibleBusiness)) {
return [VRR_ITEM_OWNER_BIZSTORAGE, possibleBusiness];
}
@@ -1496,7 +1531,7 @@ function getBestItemToTake(client, slot) {
let ownerType = VRR_ITEM_OWNER_NONE;
let ownerId = 0;
let possibleHouse = (isPlayerInAnyHouse(client)) ? getPlayerHouse(client) : getClosestHouseEntrance(getPlayerPosition(client));
let possibleHouse = getPlayerHouse(client);
if(getHouseData(possibleHouse)) {
if(typeof getHouseData(possibleHouse).itemCache[slot] != "undefined") {
itemId = getHouseData(possibleHouse).itemCache[slot];
@@ -1505,7 +1540,7 @@ function getBestItemToTake(client, slot) {
}
}
let possibleBusiness = (isPlayerInAnyBusiness(client)) ? getPlayerBusiness(client) : getClosestBusinessEntrance(getPlayerPosition(client));
let possibleBusiness = getPlayerBusiness(client);
if(getBusinessData(possibleBusiness)) {
if(typeof getBusinessData(possibleBusiness).floorItemCache[slot] != "undefined") {
itemId = getBusinessData(possibleBusiness).floorItemCache[slot];
@@ -1540,7 +1575,18 @@ function getBestItemToTake(client, slot) {
*
*/
function listPlayerInventoryCommand(command, params, client) {
showPlayerInventoryToPlayer(client, client);
let targetClient = client;
if(doesPlayerHaveStaffPermission(client, getStaffFlagValue("BasicModeration"))) {
if(!areParamsEmpty(client)) {
if(targetClient == false) {
sendMessageToPlayer(client, getLocaleString(client, "InvalidPlayer"));
return false;
}
targetClient = getPlayerFromParams(params);
}
}
showPlayerInventoryToPlayer(client, targetClient);
//showPlayerInventoryToPlayer(client, client);
}
// ===========================================================================
@@ -1555,7 +1601,7 @@ function listPlayerInventoryCommand(command, params, client) {
*
*/
function listBusinessStorageInventoryCommand(command, params, client) {
let businessId = (isPlayerInAnyBusiness(client)) ? getPlayerBusiness(client) : getClosestBusinessEntrance(getPlayerPosition(client));
let businessId = getPlayerBusiness(client);
if(!getBusinessData(businessId)) {
messagePlayerError(client, getLocaleString(client, "InvalidBusiness"));
@@ -1582,7 +1628,7 @@ function listBusinessStorageInventoryCommand(command, params, client) {
*
*/
function listBusinessFloorInventoryCommand(command, params, client) {
let businessId = (isPlayerInAnyBusiness(client)) ? getPlayerBusiness(client) : getClosestBusinessEntrance(getPlayerPosition(client));
let businessId = getPlayerBusiness(client);
if(!getBusinessData(businessId)) {
messagePlayerError(client, getLocaleString(client, "InvalidBusiness"));
@@ -1609,7 +1655,7 @@ function listBusinessFloorInventoryCommand(command, params, client) {
*
*/
function listHouseInventoryCommand(command, params, client) {
let houseId = (isPlayerInAnyHouse(client)) ? getPlayerHouse(client) : getClosestHouseEntrance(getPlayerPosition(client));
let houseId = getPlayerHouse(client);
if(!getHouseData(houseId)) {
messagePlayerError(client, getLocaleString(client, "InvalidHouse"));
@@ -1676,7 +1722,7 @@ function getItemTypeData(itemTypeId) {
// ===========================================================================
function saveItemsToDatabase() {
function saveAllItemsToDatabase() {
if(getServerConfig().devServer) {
return false;
}
@@ -1688,7 +1734,7 @@ function saveItemsToDatabase() {
// ===========================================================================
function saveItemTypesToDatabase() {
function saveAllItemTypesToDatabase() {
if(getServerConfig().devServer) {
return false;
}
@@ -2240,7 +2286,7 @@ function showPlayerInventoryToPlayer(client, targetClient) {
if(client == targetClient) {
messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderSelfItemList")));
} else {
messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderPlayerItemList")));
messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderPlayerItemList", getCharacterFullName(targetClient))));
}
let chunkedList = splitArrayIntoChunks(itemDisplay, 5);
@@ -2317,7 +2363,6 @@ function createGroundPlant(itemId) {
createGroundItem(getItemTypeData(itemId).useId, 1, position, dimension);
groundPlantCache.push(itemId);
groundItemCache.push(itemId);
}
// ===========================================================================

File diff suppressed because it is too large Load Diff

View File

@@ -10,7 +10,6 @@
function initKeyBindScript() {
logToConsole(LOG_INFO, "[VRR.KeyBind]: Initializing key bind script ...");
getGlobalConfig().keyBind = loadKeyBindConfiguration();
logToConsole(LOG_INFO, "[VRR.KeyBind]: Key bind script initialized!");
}
@@ -19,16 +18,19 @@ function initKeyBindScript() {
function addKeyBindCommand(command, params, client) {
let splitParams = params.split(" ");
let keys = getKeysInComboName(getParam(params, " ", 1));
let keyId = getKeyIdFromParams(getParam(params, " ", 1));
let tempCommand = getParam(params, " ", 2);
let tempParams = (splitParams.length > 2) ? splitParams.slice(2).join(" ") : "";
if(keys.indexOf(false) != -1) {
messagePlayerError(client, "One of the key names you input is invalid!");
messagePlayerTip(client, "Use simple key names, letters, or numbers. Don't add spaces. Must be lowercase.");
messagePlayerTip(client, "No actual symbols, use a name for those if needed like ampersand, hashtag, tilde, etc");
if(!keyId) {
messagePlayerError(client, "The key ID or name you input is invalid!");
messagePlayerTip(client, "Use simple key names, letters, or numbers. Don't add spaces.");
messagePlayerInfo(client, `Examples: {ALTCOLOUR}1, 2, a, b, numplus, num1, f1, f2, pageup, delete, insert, rightshift, leftctrl`);
messagePlayerInfo(client, `For combos, use a plus sign between the keys. No spaces! Example: {ALTCOLOUR}rightctrl+num3{MAINCOLOUR}`);
return false;
}
if(!keyId) {
messagePlayerError(client, "That key name/id is invalid!");
return false;
}
@@ -38,12 +40,14 @@ function addKeyBindCommand(command, params, client) {
}
addPlayerKeyBind(client, keyId, tempCommand, tempParams);
messagePlayerSuccess(client, `You binded the {ALTCOLOUR}${toUpperCase(keys.join(" + "))} {MAINCOLOUR}keys to command: {ALTCOLOUR}/${tempCommand} ${tempParams}`);
messagePlayerSuccess(client, `You binded the {ALTCOLOUR}${toUpperCase(getKeyNameFromId(keyId))} {MAINCOLOUR}key to command: {ALTCOLOUR}/${tempCommand} ${tempParams}`);
}
// ===========================================================================
function removeKeyBindCommand(command, params, client) {
let splitParams = params.split(" ");
let keyId = getKeyIdFromParams(getParam(params, " ", 1));
if(!keyId) {
@@ -70,8 +74,6 @@ function addPlayerKeyBind(client, keys, command, params, tempKey = false) {
keyBindData.databaseId = -1;
}
keyBindData.needsSaved = true;
getPlayerData(client).keyBinds.push(keyBindData);
sendAddAccountKeyBindToClient(client, keys, (keys.length > 1) ? VRR_KEYSTATE_COMBO : VRR_KEYSTATE_UP);
@@ -91,11 +93,12 @@ function removePlayerKeyBind(client, keyId) {
quickDatabaseQuery(`DELETE FROM acct_hotkey WHERE acct_hotkey_acct = ${getPlayerData(client).accountData.databaseId} AND acct_hotkey_key = ${keyId}`);
}
for(let i in getPlayerData(client).keyBinds) {
if(getPlayerData(client).keyBinds[i].key == keyId) {
getPlayerData(client).keyBinds.splice(i, 1);
}
}
//for(let i in getPlayerData(client).keyBinds) {
// if(getPlayerData(client).keyBinds[i].key == keyId) {
// getPlayerData(client).keyBinds.splice(i, 1);
// }
//}
getPlayerData(client).keyBinds = getPlayerData(client).keyBinds.filter(keyBind => keyBind.key != keyId);
sendRemoveAccountKeyBindToClient(client, keyId);
if(!doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForCommand(client, "enter")) {
@@ -195,13 +198,6 @@ function sendAccountKeyBindsToClient(client) {
// ===========================================================================
function loadKeyBindConfiguration() {
let keyBindConfigFile = loadTextFile("config/keybind.json");
return JSON.parse(keyBindConfigFile);
}
// ===========================================================================
function showKeyBindListCommand(command, params, client) {
let keybindList = getPlayerData(client).keyBinds.map(function(x) { return `{ALTCOLOUR}${toUpperCase(getKeyNameFromId(x.key))}: {MAINCOLOUR}${x.commandString}`; });
@@ -214,29 +210,4 @@ function showKeyBindListCommand(command, params, client) {
}
}
// ===========================================================================
function getKeyNamesInComboName(comboName) {
if(comboName.indexOf("+") != -1) {
return comboName.split("+");
} else {
return [comboName];
}
}
// ===========================================================================
function getKeysInComboName(comboName) {
let keyNames = getKeyNamesInComboName(comboName);
let keys = [];
for(let i in keyNames) {
if(getKeyIdFromParams(keyNames[i])) {
keys.push(getKeyIdFromParams(keyNames[i]));
} else {
keys.push(false);
}
}
return keys
}
// ===========================================================================

View File

@@ -7,22 +7,8 @@
// TYPE: Server (JavaScript)
// ===========================================================================
let translateURL = "http://api.mymemory.translated.net/get?de={3}&q={0}&langpair={1}|{2}";
// ===========================================================================
function initLocaleScript() {
logToConsole(LOG_INFO, "[VRR.Locale]: Initializing locale script ...");
getServerData().localeStrings = loadAllLocaleStrings();
// Translation Cache
getServerData().cachedTranslations = new Array(getGlobalConfig().locale.locales.length);
getServerData().cachedTranslationFrom = new Array(getGlobalConfig().locale.locales.length);
getServerData().cachedTranslationFrom.fill([]);
getServerData().cachedTranslations.fill(getServerData().cachedTranslationFrom);
getGlobalConfig().locale.defaultLanguageId = getLocaleFromParams(getGlobalConfig().locale.defaultLanguageId);
logToConsole(LOG_INFO, "[VRR.Locale]: Locale script initialized!");
}
@@ -30,8 +16,10 @@ function initLocaleScript() {
function getLocaleString(client, stringName, ...args) {
let tempString = getRawLocaleString(stringName, getPlayerData(client).locale);
if(tempString == "") {
if(tempString == "" || tempString == null || typeof tempString == "undefined") {
logToConsole(LOG_WARN, `[VRR.Locale] Locale string missing for ${stringName} on language ${getLocaleData(getPlayerData(client).locale).englishName}`);
submitBugReport(client, `(AUTOMATED REPORT) Locale string "${stringName}" is missing for "${getPlayerLocaleName(client)}"`);
return "";
}
for(let i = 1; i <= args.length; i++) {
@@ -45,7 +33,8 @@ function getLocaleString(client, stringName, ...args) {
function getLanguageLocaleString(localeId, stringName, ...args) {
let tempString = getRawLocaleString(stringName, localeId);
if(tempString == "") {
if(tempString == "" || tempString == null || typeof tempString == "undefined") {
logToConsole(LOG_WARN, `[VRR.Locale] Locale string missing for ${stringName} on language ${getLocaleData(getPlayerData(client).locale).englishName}`);
submitBugReport(client, `(AUTOMATED REPORT) Locale string "${stringName}" is missing for "${getPlayerLocaleName(client)}"`);
}
@@ -163,7 +152,7 @@ function setLocaleCommand(command, params, client) {
getPlayerData(client).accountData.locale = localeId;
getPlayerData(client).locale = localeId;
messagePlayerSuccess(client, getLocaleString(client, "LocaleChanged1", getLocaleString(client, "LocaleNativeName")));
sendPlayerLocaleStrings(client);
sendPlayerLocaleId(client, localeId);
}
// ===========================================================================
@@ -188,9 +177,7 @@ function reloadLocaleConfigurationCommand(command, params, client) {
getServerData().cachedTranslationFrom.fill([]);
getServerData().cachedTranslations.fill(getServerData().cachedTranslationFrom);
getGlobalConfig().locale.defaultLanguageId = getLocaleFromParams(getGlobalConfig().locale.defaultLanguage);
messageAdmins(`${client.name}{MAINCOLOUR} has reloaded the locale settings and texts`);
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} has reloaded the locale settings and texts`);
}
// ===========================================================================
@@ -209,7 +196,7 @@ async function translateMessage(messageText, translateFrom = getGlobalConfig().l
}
}
let thisTranslationURL = translateURL.format(encodeURI(messageText), toUpperCase(getGlobalConfig().locale.locales[translateFrom].isoCode), toUpperCase(getGlobalConfig().locale.locales[translateTo].isoCode), getGlobalConfig().locale.apiEmail);
let thisTranslationURL = getGlobalConfig().locale.translateURL.format(encodeURI(messageText), toUpperCase(getGlobalConfig().locale.locales[translateFrom].isoCode), toUpperCase(getGlobalConfig().locale.locales[translateTo].isoCode), getGlobalConfig().locale.apiEmail);
httpGet(
thisTranslationURL,
"",

View File

@@ -17,11 +17,13 @@ function initMessagingScript() {
function announceAdminAction(localeString, ...args) {
let clients = getClients();
for(let i in clients) {
let messageText = getLocaleString.apply(null, [clients[i], localeString, args]);
let argsArray = [clients[i], localeString];
argsArray = argsArray.concat(args);
let messageText = getLocaleString.apply(null, argsArray);
messagePlayerNormal(clients[i], `⚠️ ${messageText}`, getColourByName("orange"));
}
messageDiscordEventChannel(getLanguageLocaleString.apply(null, [0, localeString, args]));
messageDiscordEventChannel(getLanguageLocaleString.apply(null, [0, localeString].concat(args)));
}
// ===========================================================================
@@ -56,7 +58,7 @@ function messagePlayerNormal(client, messageText, colour = COLOUR_WHITE) {
function messageAdmins(messageText, colour = getColourByName("softRed")) {
//
//console.warn(`🛡️ ${plainMessage}`);
//logToConsole(LOG_WARN, `🛡️ ${plainMessage}`);
let clients = getClients();
for(let i in clients) {

View File

@@ -296,7 +296,7 @@ function getPlayerInfoCommand(command, params, client) {
}
}
messagePlayerNormal(client, `{clanOrange}== {jobYellow}Player Info {clanOrange}==============================`);
messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderPlayerInfo")));
let clan = (getPlayerCurrentSubAccount(targetClient).clan != 0) ? `{ALTCOLOUR}${getClanData(getClanIdFromDatabaseId(getPlayerCurrentSubAccount(targetClient).clan)).name}[${getPlayerCurrentSubAccount(targetClient).clan}] (Rank: ${getClanRankData(getPlayerCurrentSubAccount(targetClient).clan, getPlayerCurrentSubAccount(targetClient).clanRank).name}[Level: ${getClanRankData(getPlayerCurrentSubAccount(targetClient).clan, getPlayerCurrentSubAccount(targetClient).clanRank).level}, DBID: ${getClanRankData(getPlayerCurrentSubAccount(targetClient).clan, getPlayerCurrentSubAccount(targetClient).clanRank).databaseId}` : `(None)`;
let job = (getPlayerCurrentSubAccount(targetClient).job != 0) ? `{ALTCOLOUR}${getJobData(getJobIdFromDatabaseId(getPlayerCurrentSubAccount(targetClient).job)).name}[${getPlayerCurrentSubAccount(targetClient).job}] (Rank: ${getPlayerCurrentSubAccount(targetClient).jobRank})` : `(None)`;
@@ -304,8 +304,8 @@ function getPlayerInfoCommand(command, params, client) {
let stats = [
`{MAINCOLOUR}Account: {ALTCOLOUR}${getPlayerData(targetClient).accountData.name}[${getPlayerData(targetClient).accountData.databaseId}]`,
`{MAINCOLOUR}Character: {ALTCOLOUR}${getCharacterFullName(targetClient)}[${getPlayerCurrentSubAccount(targetClient).databaseId}]`,
`{MAINCOLOUR}Connected: {ALTCOLOUR}${getTimeDifferenceDisplay(Math.ceil(sdl.tick/1000), getPlayerData(targetClient).connectTime)} ago`,
`{MAINCOLOUR}Registered: ${getPlayerData(targetClient).accountData}`,
`{MAINCOLOUR}Connected: {ALTCOLOUR}${getTimeDifferenceDisplay(getCurrentUnixTimestamp(), getPlayerData(targetClient).connectTime)} ago`,
`{MAINCOLOUR}Registered: ${getPlayerData(targetClient).accountData.registerDate}`,
`{MAINCOLOUR}Game Version: {ALTCOLOUR}${targetClient.gameVersion}`,
`{MAINCOLOUR}Client Version: {ALTCOLOUR}${getPlayerData(targetClient).clientVersion}`,
`{MAINCOLOUR}Skin: {ALTCOLOUR}${getSkinNameFromModel(getPlayerCurrentSubAccount(targetClient).skin)}[${getPlayerCurrentSubAccount(targetClient).skin}]`,
@@ -322,6 +322,10 @@ function getPlayerInfoCommand(command, params, client) {
// ===========================================================================
function playerChangeAFKState(client, afkState) {
if(!getPlayerData(client)) {
return false;
}
getPlayerData(client).afk = afkState;
updateAllPlayerNameTags();
}
@@ -348,23 +352,26 @@ function checkPlayerSpawning() {
// ===========================================================================
function showPlayerPrompt(client, promptType, promptMessage, promptTitle) {
if(promptType == VRR_PROMPT_NONE) {
return false;
}
getPlayerData(client).promptType = promptType;
function showPlayerPrompt(client, promptMessage, promptTitle, yesButtonText, noButtonText) {
if(canPlayerUseGUI(client)) {
showPlayerPromptGUI(client, promptMessage, promptTitle);
showPlayerPromptGUI(client, promptMessage, promptTitle, yesButtonText, noButtonText);
} else {
messagePlayerNormal(client, `${promptMessage}`);
messagePlayerInfo(client, `{MAINCOLOUR}Use {ALTCOLOUR}/yes or {ALTCOLOUR}/no`);
messagePlayerInfo(client, getLocaleString(client, "PromptResponseTip", `{ALTCOLOUR}/yes{MAINCOLOUR}`, `{ALTCOLOUR}/no{MAINCOLOUR}`));
}
}
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function updateServerGameTime() {
if(isTimeSupported()) {
game.time.hour = getServerConfig().hour;
@@ -374,6 +381,15 @@ function updateServerGameTime() {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function listOnlineAdminsCommand(command, params, client) {
//== Admins ===================================
messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderAdminsList")));
@@ -398,6 +414,15 @@ function listOnlineAdminsCommand(command, params, client) {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function gpsCommand(command, params, client) {
messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderBusinessList")));
@@ -407,17 +432,18 @@ function gpsCommand(command, params, client) {
switch(toLowerCase(params)) {
case "police":
blipColour = "businessBlue"
case "policestation":
blipColour = "mediumGrey"
locationType = VRR_GPS_TYPE_POLICE;
break;
case "hospital":
blipColour = "businessBlue"
blipColour = "mediumGrey"
locationType = VRR_GPS_TYPE_HOSPITAL;
break;
case "job":
blipColour = "businessBlue"
blipColour = "mediumGrey"
locationType = VRR_GPS_TYPE_JOB;
break;
@@ -425,7 +451,7 @@ function gpsCommand(command, params, client) {
case "skins":
case "clothes":
case "player":
blipColour = "businessBlue"
blipColour = "mediumGrey"
locationType = VRR_GPS_TYPE_BUSINESS;
useType = VRR_ITEM_USETYPE_SKIN;
break;
@@ -436,20 +462,20 @@ function gpsCommand(command, params, client) {
case "weapons":
case "wep":
case "weps":
blipColour = "businessBlue"
blipColour = "mediumGrey"
locationType = VRR_GPS_TYPE_BUSINESS;
useType = VRR_ITEM_USETYPE_WEAPON;
break;
case "food":
case "eat":
blipColour = "businessBlue"
blipColour = "mediumGrey"
locationType = VRR_GPS_TYPE_BUSINESS;
useType = VRR_ITEM_USETYPE_FOOD;
break;
case "drink":
blipColour = "businessBlue"
blipColour = "mediumGrey"
locationType = VRR_GPS_TYPE_BUSINESS;
useType = VRR_ITEM_USETYPE_DRINK;
break;
@@ -457,7 +483,7 @@ function gpsCommand(command, params, client) {
case "alcohol":
case "booze":
case "bar":
blipColour = "businessBlue"
blipColour = "mediumGrey"
locationType = VRR_GPS_TYPE_BUSINESS;
useType = VRR_ITEM_USETYPE_ALCOHOL;
break;
@@ -467,7 +493,7 @@ function gpsCommand(command, params, client) {
case "vehrepair":
case "spray":
case "fix":
blipColour = "businessBlue"
blipColour = "mediumGrey"
locationType = VRR_GPS_TYPE_BUSINESS;
useType = VRR_ITEM_USETYPE_VEHREPAIR;
break;
@@ -476,7 +502,7 @@ function gpsCommand(command, params, client) {
case "vehcolour":
case "carcolour":
case "colour":
blipColour = "businessBlue"
blipColour = "mediumGrey"
locationType = VRR_GPS_TYPE_BUSINESS;
useType = VRR_ITEM_USETYPE_VEHCOLOUR;
break;
@@ -485,12 +511,12 @@ function gpsCommand(command, params, client) {
let itemTypeId = getItemTypeFromParams(params);
if(getItemTypeData(itemTypeId) != false) {
locationType = VRR_GPS_TYPE_BUSINESS;
blipColour = "businessBlue";
blipColour = "mediumGrey";
useType = getItemTypeData(itemTypeId).useType;
} else {
let gameLocationId = getGameLocationFromParams(params);
if(gameLocationId != false) {
position = getGameConfig().locations[getServerGame()][gameLocationId][1]
position = getGameConfig().locations[getGame()][gameLocationId][1]
}
}
}
@@ -528,6 +554,15 @@ function gpsCommand(command, params, client) {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function stuckPlayerCommand(command, params, client) {
if((getCurrentUnixTimestamp()-getPlayerData(client).lastStuckCommand) < getGlobalConfig().stuckCommandInterval) {
messagePlayerError(client, "CantUseCommandYet");
@@ -539,7 +574,7 @@ function stuckPlayerCommand(command, params, client) {
messagePlayerAlert(client, getLocaleString(client, "FixingStuck"));
if(getGameConfig().skinChangePosition[getServerGame()].length > 0) {
if(getGameConfig().skinChangePosition[getGame()].length > 0) {
if(getPlayerData(client).returnToPosition != null && getPlayerData(client).returnToType == VRR_RETURNTO_TYPE_SKINSELECT) {
messagePlayerAlert(client, "You canceled the skin change.");
restorePlayerCamera(client);
@@ -598,6 +633,15 @@ function stuckPlayerCommand(command, params, client) {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function playerPedSpeakCommand(command, params, client) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
@@ -607,4 +651,188 @@ function playerPedSpeakCommand(command, params, client) {
makePlayerPedSpeak(client, params);
}
// ===========================================================================
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function lockCommand(command, params, client) {
if(isPlayerInAnyVehicle(client)) {
let vehicle = getPlayerVehicle(client);
if(!getVehicleData(vehicle)) {
messagePlayerError(client, getLocaleString(client, "RandomVehicleCommandsDisabled"));
return false;
}
if(!isPlayerInFrontVehicleSeat(client)) {
messagePlayerError(client, getLocaleString(client, "MustBeInVehicleFrontSeat"));
return false;
}
getVehicleData(vehicle).locked = !getVehicleData(vehicle).locked;
setVehicleLocked(vehicle, getVehicleData(vehicle).locked);
getVehicleData(vehicle).needsSaved = true;
meActionToNearbyPlayers(client, `${toLowerCase(getLockedUnlockedFromBool(getVehicleData(vehicle).locked))} the ${getVehicleName(vehicle)}`);
return true;
} else {
let vehicle = getClosestVehicle(getPlayerPosition(client));
if(getDistance(getPlayerPosition(client), getVehiclePosition(vehicle)) <= getGlobalConfig().vehicleLockDistance) {
if(!getVehicleData(vehicle)) {
messagePlayerError(client, getLocaleString(client, "RandomVehicleCommandsDisabled"));
return false;
}
if(!doesPlayerHaveVehicleKeys(client, vehicle)) {
messagePlayerError(client, getLocaleString(client, "DontHaveVehicleKey"));
return false;
}
getVehicleData(vehicle).locked = !getVehicleData(vehicle).locked;
setVehicleLocked(vehicle, getVehicleData(vehicle).locked);
getVehicleData(vehicle).needsSaved = true;
meActionToNearbyPlayers(client, `${toLowerCase(getLockedUnlockedFromBool(getVehicleData(vehicle).locked))} the ${getVehicleName(vehicle)}`);
return true;
}
let businessId = getPlayerBusiness(client);
if(businessId != -1) {
if(!canPlayerManageBusiness(client, businessId)) {
messagePlayerError(client, getLocaleString(client, "CantModifyBusiness"));
return false;
}
getBusinessData(businessId).locked = !getBusinessData(businessId).locked;
updateBusinessPickupLabelData(businessId);
getBusinessData(businessId).needsSaved = true;
messagePlayerSuccess(client, `${getLockedUnlockedEmojiFromBool((getBusinessData(businessId).locked))} Business {businessBlue}${getBusinessData(businessId).name} {MAINCOLOUR}${getLockedUnlockedFromBool((getBusinessData(businessId).locked))}!`);
return true;
}
let houseId = getPlayerHouse(client);
if(houseId != -1) {
if(!canPlayerManageHouse(client, houseId)) {
messagePlayerError(client, getLocaleString(client, "CantModifyHouse"));
return false;
}
getHouseData(houseId).locked = !getHouseData(houseId).locked;
updateHousePickupLabelData(houseId);
getHouseData(houseId).needsSaved = true;
messagePlayerSuccess(client, `House {houseGreen}${getHouseData(houseId).description} {MAINCOLOUR}${getLockedUnlockedFromBool((getHouseData(houseId).locked))}!`);
return true;
}
}
}
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function lightsCommand(command, params, client) {
if(isPlayerInAnyVehicle(client)) {
let vehicle = getPlayerVehicle(client);
if(!getVehicleData(vehicle)) {
messagePlayerError(client, getLocaleString(client, "RandomVehicleCommandsDisabled"));
return false;
}
if(!isPlayerInFrontVehicleSeat(client)) {
messagePlayerError(client, getLocaleString(client, "MustBeInVehicleFrontSeat"));
return false;
}
getVehicleData(vehicle).lights = !getVehicleData(vehicle).lights;
setVehicleLights(vehicle, getVehicleData(vehicle).lights)
getVehicleData(vehicle).needsSaved = true;
meActionToNearbyPlayers(client, `turned ${toLowerCase(getOnOffFromBool(getVehicleData(vehicle).lights))} the ${getVehicleName(vehicle)}'s lights`);
} else {
/*
let vehicle = getClosestVehicle(getPlayerPosition(client));
if(vehicle != false) {
if(getDistance(getPlayerPosition(client), getVehiclePosition(vehicle)) <= getGlobalConfig().vehicleLockDistance) {
return false;
}
if(!getVehicleData(vehicle)) {
messagePlayerError(client, getLocaleString(client, "RandomVehicleCommandsDisabled"));
return false;
}
if(!doesPlayerHaveVehicleKeys(client, vehicle)) {
messagePlayerError(client, getLocaleString(client, "DontHaveVehicleKey"));
return false;
}
getVehicleData(vehicle).lights = !getVehicleData(vehicle).lights;
setVehicleLights(vehicle, getVehicleData(vehicle).lights);
getVehicleData(vehicle).needsSaved = true;
meActionToNearbyPlayers(client, `${toLowerCase(getLockedUnlockedFromBool(getVehicleData(vehicle).locked))} the ${getVehicleName(vehicle)}`);
return true;
}
*/
let businessId = getPlayerBusiness(client);
if(businessId != -1) {
if(!canPlayerManageBusiness(client, businessId)) {
messagePlayerError(client, getLocaleString(client, "CantModifyBusiness"));
return false;
}
getBusinessData(businessId).interiorLights = !getBusinessData(businessId).interiorLights;
getBusinessData(businessId).needsSaved = true;
let clients = getClients();
for(let i in clients) {
if(getPlayerBusiness(client) == getPlayerBusiness(clients[i]) && getPlayerDimension(clients[i]) == getBusinessData(businessId).exitDimension) {
updateInteriorLightsForPlayer(clients[i], getBusinessData(businessId).interiorLights);
}
}
meActionToNearbyPlayers(client, `turned ${toLowerCase(getOnOffFromBool((getBusinessData(businessId).interiorLights)))} on the business lights`);
return true;
}
let houseId = getPlayerHouse(client);
if(houseId != -1) {
if(!canPlayerManageHouse(client, houseId)) {
messagePlayerError(client, getLocaleString(client, "CantModifyHouse"));
return false;
}
getHouseData(houseId).interiorLights = !getHouseData(houseId).interiorLights;
getHouseData(houseId).needsSaved = true;
let clients = getClients();
for(let i in clients) {
if(getPlayerHouse(client) == getPlayerHouse(clients[i]) && getPlayerDimension(clients[i]) == getHouseData(houseId).exitDimension) {
updateInteriorLightsForPlayer(clients[i], getHouseData(houseId).interiorLights);
}
}
meActionToNearbyPlayers(client, `turned ${toLowerCase(getOnOffFromBool((getHouseData(houseId).interiorLights)))} on the house lights`);
return true;
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -22,6 +22,23 @@ let builtInCommands = [
// ===========================================================================
let disconnectReasons = [
"Lost Connection",
"Disconnected",
"Unsupported Client",
"Wrong Game",
"Incorrect Password",
"Unsupported Executable",
"Disconnected",
"Banned",
"Failed",
"Invalid Name",
"Crashed",
"Modified Game"
];
// ===========================================================================
function getPlayerPosition(client) {
if(!areServerElementsSupported()) {
return getPlayerData(client).syncPosition;
@@ -92,7 +109,7 @@ function getPlayerInterior(client) {
// ===========================================================================
function setPlayerDimension(client, dimension) {
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s dimension to ${dimension}`);
logToConsole(LOG_VERBOSE, `Setting ${getPlayerDisplayForConsole(client)}'s dimension to ${dimension}`);
if(!areServerElementsSupported()) {
getPlayerData(client).syncDimension = dimension;
} else {
@@ -105,7 +122,7 @@ function setPlayerDimension(client, dimension) {
// ===========================================================================
function setPlayerInterior(client, interior) {
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s interior to ${interior}`);
logToConsole(LOG_VERBOSE, `Setting ${getPlayerDisplayForConsole(client)}'s interior to ${interior}`);
sendPlayerSetInterior(client, interior);
if(isPlayerLoggedIn(client) && isPlayerSpawned(client)) {
getPlayerCurrentSubAccount(client).interior = interior;
@@ -261,7 +278,7 @@ function setPlayerHealth(client, health) {
// ===========================================================================
function getPlayerHealth(client) {
return getServerData(client).health;
return getPlayerData(client).health;
}
// ===========================================================================
@@ -331,7 +348,7 @@ function takePlayerCash(client, amount) {
function disconnectPlayer(client) {
logToConsole(LOG_DEBUG, `Disconnecting (kicking) ${getPlayerDisplayForConsole(client)}`);
client.disconnect();
disconnectPlayer(client);
return false;
}
@@ -377,11 +394,12 @@ function getElementDimension(element) {
// ===========================================================================
function setElementDimension(element, dimension) {
if(typeof element.dimension != "undefined") {
element.dimension = dimension;
return true;
}
return false;
if(typeof element.dimension != "undefined") {
logToConsole(LOG_VERBOSE, `Setting element ${element} (${element.id}) dimension to ${dimension}`);
element.dimension = dimension;
return true;
}
return false;
}
// ===========================================================================
@@ -420,14 +438,20 @@ function givePlayerArmour(client, amount) {
// ===========================================================================
function getServerGame() {
return getGame();
function consolePrint(text) {
console.log(text);
}
// ===========================================================================
function consolePrint(text) {
console.log(text);
function consoleWarn(text) {
console.warn(text);
}
// ===========================================================================
function consoleError(text) {
console.error(text);
}
// ===========================================================================
@@ -495,7 +519,7 @@ function destroyGameElement(element) {
// ===========================================================================
function isMeleeWeapon(weaponId, gameId = getServerGame()) {
function isMeleeWeapon(weaponId, gameId = getGame()) {
return (getGameConfig().meleeWeapons[gameId].indexOf(weaponId) != -1);
}
@@ -508,6 +532,9 @@ function getPlayerLastVehicle(client) {
// ===========================================================================
function isVehicleObject(vehicle) {
if(vehicle == null || vehicle == undefined) {
return false;
}
return (vehicle.type == ELEMENT_VEHICLE);
}
@@ -520,7 +547,8 @@ function repairVehicle(vehicle) {
// ===========================================================================
function setVehicleLights(vehicle, lights) {
vehicle.lights = lights;
setEntityData(vehicle, "vrr.lights", lights, true);
sendNetworkEventToPlayer("vrr.veh.lights", null, vehicle.id, lights);
}
// ===========================================================================
@@ -593,7 +621,7 @@ function createGameVehicle(modelIndex, position, heading, toClient = null) {
function createGameCivilian(modelIndex, position, heading, toClient = null) {
if(areServerElementsSupported()) {
let civilian = game.createCivilian(getGameConfig().skins[getGame()][modelIndex][0], 0);
let civilian = game.createCivilian(getGameConfig().skins[getGame()][modelIndex][1], 0);
if(!isNull(civilian)) {
civilian.position = position;
civilian.heading = heading;
@@ -608,7 +636,7 @@ function createGameCivilian(modelIndex, position, heading, toClient = null) {
// ===========================================================================
function getIsland(position) {
if(getServerGame() == VRR_GAME_GTA_III) {
if(getGame() == VRR_GAME_GTA_III) {
if(position.x > 616) {
return VRR_ISLAND_PORTLAND;
} else if(position.x < -283) {
@@ -644,6 +672,14 @@ function setGameTime(hour, minute, minuteDuration = 1000) {
// ===========================================================================
function setGameWeather(weather) {
if(isWeatherSupported()) {
mp.world.weather = weather;
}
}
// ===========================================================================
function setPlayerFightStyle(client, fightStyleId) {
if(!isPlayerSpawned(client)) {
return false;
@@ -653,7 +689,7 @@ function setPlayerFightStyle(client, fightStyleId) {
return false;
}
setEntityData(getPlayerElement(client), "vrr.fightStyle", [getGameConfig().fightStyles[getServerGame()][fightStyleId][1][0], getGameConfig().fightStyles[getServerGame()][fightStyleId][1][1]]);
setEntityData(getPlayerElement(client), "vrr.fightStyle", [getGameConfig().fightStyles[getGame()][fightStyleId][1][0], getGameConfig().fightStyles[getGame()][fightStyleId][1][1]]);
forcePlayerToSyncElementProperties(null, getPlayerElement(client));
}
@@ -739,7 +775,7 @@ function givePlayerWeaponAmmo(client, ammo) {
function getPlayerWeapon(client) {
if(areServerElementsSupported(client)) {
return getPlayerPed(client).weapon;;
return getPlayerPed(client).weapon;
} else {
return getPlayerData(client).syncWeapon;
}
@@ -748,26 +784,26 @@ function getPlayerWeapon(client) {
// ===========================================================================
function connectToDatabase() {
if(databaseConfig.usePersistentConnection) {
if(getDatabaseConfig().usePersistentConnection) {
if(persistentDatabaseConnection == null) {
logToConsole(LOG_DEBUG, "[VRR.Database] Initializing database connection ...");
persistentDatabaseConnection = module.mysql.connect(databaseConfig.host, databaseConfig.user, databaseConfig.pass, databaseConfig.name, databaseConfig.port);
logToConsole(LOG_DEBUG, `[VRR.Database] Initializing database connection ...`);
persistentDatabaseConnection = module.mysql.connect(getDatabaseConfig().host, getDatabaseConfig().user, getDatabaseConfig().pass, getDatabaseConfig().name, getDatabaseConfig().port);
if(persistentDatabaseConnection.error) {
console.warn("[VRR.Database] Database connection error: " + toString(persistentDatabaseConnection.error));
logToConsole(LOG_ERROR, `[VRR.Database] Database connection error: ${persistentDatabaseConnection.error}`);
persistentDatabaseConnection = null;
return false;
}
logToConsole(LOG_DEBUG, "[VRR.Database] Database connection successful!");
logToConsole(LOG_DEBUG, `[VRR.Database] Database connection successful!`);
return persistentDatabaseConnection;
} else {
logToConsole(LOG_DEBUG, "[VRR.Database] Using existing database connection.");
logToConsole(LOG_DEBUG, `[VRR.Database] Using existing database connection.`);
return persistentDatabaseConnection;
}
} else {
let databaseConnection = module.mysql.connect(databaseConfig.host, databaseConfig.user, databaseConfig.pass, databaseConfig.name, databaseConfig.port);
let databaseConnection = module.mysql.connect(getDatabaseConfig().host, getDatabaseConfig().user, getDatabaseConfig().pass, getDatabaseConfig().name, getDatabaseConfig().port);
if(databaseConnection.error) {
console.warn("[VRR.Database] Database connection error: " + toString(persistentDatabaseConnection.error));
logToConsole(LOG_ERROR, `[VRR.Database] Database connection error: ${persistentDatabaseConnection.error}`);
return false;
} else {
return databaseConnection;
@@ -778,7 +814,7 @@ function connectToDatabase() {
// ===========================================================================
function disconnectFromDatabase(dbConnection) {
if(!databaseConfig.usePersistentConnection) {
if(!getDatabaseConfig().usePersistentConnection) {
try {
dbConnection.close();
logToConsole(LOG_DEBUG, `[VRR.Database] Database connection closed successfully`);
@@ -791,9 +827,16 @@ function disconnectFromDatabase(dbConnection) {
// ===========================================================================
function queryDatabase(dbConnection, queryString) {
function queryDatabase(dbConnection, queryString, useThread = false) {
logToConsole(LOG_DEBUG, `[VRR.Database] Query string: ${queryString}`);
return dbConnection.query(queryString);
if(useThread == true) {
Promise.resolve().then(() => {
let queryResult = dbConnection.query(queryString);
return queryResult;
});
} else {
return dbConnection.query(queryString);
}
}
// ===========================================================================
@@ -838,14 +881,8 @@ function freeDatabaseQuery(dbQuery) {
// ===========================================================================
async function fetchQueryAssoc(dbQuery) {
let queryAssoc = new Promise(function() {
let result = dbConnection.query(queryString);
let tempAassoc = result.fetchAssoc();
result.free();
resolve(tempAassoc);
});
return queryAssoc;
function fetchQueryAssoc(dbQuery) {
return dbQuery.fetchAssoc();
}
// ===========================================================================
@@ -883,102 +920,6 @@ function quickDatabaseQuery(queryString) {
// ===========================================================================
function executeDatabaseQueryCommand(command, params, client) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
return false;
}
if(!targetClient) {
messagePlayerError(client, "That player was not found!");
return false;
}
if(targetCode == "") {
messagePlayerError(client, "You didn't enter any code!");
return false;
}
let success = quickDatabaseQuery(params);
if(!success) {
messagePlayerAlert(client, `Database query failed to execute: {ALTCOLOUR}${query}`);
} else if(typeof success != "boolean") {
messagePlayeSuccess(client, `Database query successful: {ALTCOLOUR}${query}`);
messagePlayerInfo(client, `Returns: ${success}`);
} else {
messagePlayerSuccess(client, `Database query successful: {ALTCOLOUR}${query}`);
}
return true;
}
// ===========================================================================
function setConstantsAsGlobalVariablesInDatabase() {
let dbConnection = connectToDatabase();
let entries = Object.entries(global);
for(let i in entries) {
logToConsole(LOG_DEBUG, `[VRR.Database] Checking entry ${i} (${entries[i]})`);
if(toString(i).slice(0, 3).indexOf("VRR_") != -1) {
logToConsole(LOG_DEBUG, `[VRR.Database] Adding ${i} (${entries[i]}) to database global variables`);
}
}
}
// ===========================================================================
function loadDatabaseConfiguration() {
let databaseConfigFile = loadTextFile("config/database.json");
return JSON.parse(databaseConfigFile);
}
// ===========================================================================
function createDatabaseInsertQuery(tableName, data) {
let fields = [];
let values = [];
for(let i in data) {
if(data[i][1] != "undefined" && data[i][1] != NaN && data[i][0] != 'NaN') {
if(data[i][1] != "undefined" && data[i][1] != NaN && data[i][1] != 'NaN') {
fields.push(data[i][0]);
if(typeof data[i][1] == "string") {
values.push(`'${data[i][1]}'`);
} else {
values.push(data[i][1]);
}
}
}
}
let queryString = `INSERT INTO ${tableName} (${fields.join(", ")}) VALUES (${values.join(", ")})`;
return queryString;
}
// ===========================================================================
function createDatabaseUpdateQuery(tableName, data, whereClause) {
let values = [];
for(let i in data) {
if(data[i][0] != "undefined" && data[i][0] != NaN && data[i][0] != 'NaN') {
if(data[i][1] != "undefined" && data[i][1] != NaN && data[i][1] != 'NaN') {
if(typeof data[i][1] == "string") {
values.push(`${data[i][0]}='${data[i][1]}'`);
} else {
values.push(`${data[i][0]}=${data[i][1]}`);
}
}
}
}
let queryString = `UPDATE ${tableName} SET ${values.join(", ")} WHERE ${whereClause}`;
return queryString;
}
// ===========================================================================
function sendNetworkEventToPlayer(eventName, client, ...args) {
let argsArray = [eventName, client];
argsArray = argsArray.concat(args);
@@ -1041,6 +982,9 @@ function getClosestCivilian(position) {
// ===========================================================================
function getVehiclesInRange(position, range) {
if(getGame() == VRR_GAME_GTA_IV) {
return getServerData().vehicles.reduce((i, j) => (getDistance(position, i.syncPosition) <= getDistance(position, j.syncPosition)) ? i : j);
}
return getElementsByTypeInRange(ELEMENT_VEHICLE, position, range);
}
@@ -1095,7 +1039,7 @@ function getPlayerPing(client) {
// ===========================================================================
function setVehicleHealth(vehicle, health) {
vehicle.health = 1000;
vehicle.health = health;
}
// ===========================================================================
@@ -1150,30 +1094,43 @@ function getPlayerPed(client) {
function setEntityData(entity, dataName, dataValue, syncToClients = true) {
if(entity != null) {
return entity.setData(dataName, dataValue, syncToClients);
if(areServerElementsSupported()) {
return entity.setData(dataName, dataValue, syncToClients);
}
}
return false;
}
// ===========================================================================
function removeEntityData(entity, dataName) {
if(entity != null) {
return entity.removeData(dataName);
if(areServerElementsSupported()) {
return entity.removeData(dataName);
}
}
return null;
return false;
}
// ===========================================================================
function doesEntityDataExist(entity, dataName) {
if(entity != null) {
return (entity.getData(dataName) != null);
if(areServerElementsSupported()) {
return (entity.getData(dataName) != null);
} else {
return false;
}
}
return null;
}
<<<<<<< Updated upstream
=======
// ===========================================================================
function disconnectPlayer(client) {
client.disconnect();
}
// ===========================================================================
function getPlayerId(client) {
@@ -1313,5 +1270,4 @@ function bindServerEventHandler(eventName, bindTo, handlerFunction) {
});
}
>>>>>>> Stashed changes
// ===========================================================================

View File

@@ -2,151 +2,141 @@
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/gtac_roleplay
// ===========================================================================
// FILE: ragemp.js
// DESC: Provides wrapped natives for RageMP
// FILE: connected.js
// DESC: Provides wrapped natives for GTA Connected and Mafia Connected mods
// TYPE: Server (JavaScript)
// ===========================================================================
class DatabaseConnection {
constructor(host, username, password, database, port = 3306) {
this.host = host;
this.port = port;
this.username = username;
this.password = password;
this.connection = database;
this.insertId = 0;
this.error = null;
let handle = mysql.createConnection({
host: this.host,
port: this.port,
username: this.username,
password: this.password,
database: this.database
});
this.connection = handle;
}
query(queryString) {
return new DatabaseQuery(this.connection, queryString);
}
close() {
this.connection.close();
}
}
class DatabaseQuery {
constructor(connection, queryString) {
this.connection = connection;
this.rows = [];
this.fields = [];
this.numRows = 0;
this.connection.query(queryString, function(err, results, fields) {
if(err) {
logToConsole(LOG_DEBUG|LOG_ERROR, err);
return false;
}
this.rows = results;
this.fields = fields;
this.connection.insertId = results.insertId;
this.numRows = results.changedRows;
});
}
fetchAssoc() {
return this.rows;
}
free() {
return;
}
}
// ===========================================================================
const VRR_ELEMENT_NONE = 0;
const VRR_ELEMENT_VEHICLE = 1;
const VRR_ELEMENT_PLAYER = 2;
// ===========================================================================
let builtInCommands = [
"refresh",
"restart",
"stop",
"start",
"reconnect",
"setname",
"connect",
"disconnect",
"say",
"dumpdoc",
];
// ===========================================================================
let disconnectReasons = [
"Lost Connection",
"Disconnected",
"Unsupported Client",
"Wrong Game",
"Incorrect Password",
"Unsupported Executable",
"Disconnected",
"Banned",
"Failed",
"Invalid Name",
"Crashed",
"Modified Game"
];
// ===========================================================================
function getPlayerPosition(client) {
return client.position;
if(!areServerElementsSupported()) {
return getPlayerData(client).syncPosition;
} else {
if(getPlayerPed(client) != null) {
return getPlayerPed(client).position;
}
}
}
// ===========================================================================
function setPlayerPosition(client, position) {
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s position to ${position.x}, ${position.y}, ${position.z}`);
client.position = position;
sendPlayerSetPosition(client, position);
}
// ===========================================================================
function getPlayerHeading(client) {
return client.heading
if(!areServerElementsSupported()) {
return getPlayerData(client).syncHeading;
} else {
if(getPlayerPed(client) != null) {
return getPlayerPed(client).heading;
}
}
}
// ===========================================================================
function setPlayerHeading(client, heading) {
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s heading to ${heading}`);
client.heading = heading;
sendPlayerSetHeading(client, heading);
}
// ===========================================================================
function getPlayerVehicle(client) {
return client.vehicle;
if(!areServerElementsSupported()) {
return getPlayerData().syncVehicle;
} else {
if(getPlayerPed(client).vehicle) {
return getPlayerPed(client).vehicle;
}
}
return false;
}
// ===========================================================================
function getPlayerDimension(client) {
return client.dimension;
if(!areServerElementsSupported()) {
return getPlayerData(client).syncDimension;
} else {
if(getPlayerPed(client) != null) {
return getPlayerPed(client).dimension;
}
}
}
// ===========================================================================
function getPlayerInterior(client) {
return 0;
return getPlayerCurrentSubAccount(client).interior || 0;
}
// ===========================================================================
function setPlayerDimension(client, dimension) {
logToConsole(LOG_VERBOSE, `Setting ${getPlayerDisplayForConsole(client)}'s dimension to ${dimension}`);
client.dimension = dimension;
if(!areServerElementsSupported()) {
getPlayerData(client).syncDimension = dimension;
} else {
if(getPlayerPed(client) != null) {
getPlayerPed(client).dimension = dimension;
}
}
}
// ===========================================================================
function setPlayerInterior(client, interior) {
logToConsole(LOG_VERBOSE, `Setting ${getPlayerDisplayForConsole(client)}'s interior to ${interior}`);
return false;
sendPlayerSetInterior(client, interior);
if(isPlayerLoggedIn(client) && isPlayerSpawned(client)) {
getPlayerCurrentSubAccount(client).interior = interior;
}
}
// ===========================================================================
function isPlayerInAnyVehicle(client) {
return (client.vehicle != null);
if(!areServerElementsSupported()) {
return (getPlayerData().syncVehicle != null);
} else {
return (getPlayerPed(client).vehicle != null);
}
}
// ===========================================================================
@@ -156,7 +146,17 @@ function getPlayerVehicleSeat(client) {
return false;
}
return client.seat;
if(!areServerElementsSupported()) {
return getPlayerData().syncVehicleSeat;
} else {
for(let i = 0 ; i <= 8 ; i++) {
if(getPlayerVehicle(client).getOccupant(i) == getPlayerPed(client)) {
return i;
}
}
}
return false;
}
// ===========================================================================
@@ -180,37 +180,60 @@ function getVehicleHeading(vehicle) {
// ===========================================================================
function setVehicleHeading(vehicle, heading) {
if(getGame() == VRR_GAME_GTA_IV) {
return sendNetworkEventToPlayer("vrr.vehPosition", null, getVehicleForNetworkEvent(vehicle), heading);
}
return vehicle.heading = heading;
}
// ===========================================================================
function getElementTransient(element) {
if(typeof element.transient != "undefined") {
return element.transient;
}
return false;
}
// ===========================================================================
function setElementTransient(element, state) {
if(typeof element.transient != "undefined") {
element.transient = state;
return true;
}
return false;
}
// ===========================================================================
function getVehicleSyncer(vehicle) {
return null;
return getElementSyncer(vehicle);
}
// ===========================================================================
function getVehicleForNetworkEvent(vehicle) {
if(getGame() == VRR_GAME_GTA_IV) {
if(getVehicleData(vehicle).ivNetworkId != -1) {
return getVehicleData(vehicle).ivNetworkId;
}
return -1;
}
return vehicle.id;
}
// ===========================================================================
function deleteGameElement(element) {
element.destroy();
try {
if(element != null) {
destroyElement(element);
return true;
}
} catch(error) {
return false;
}
}
// ===========================================================================
@@ -223,52 +246,70 @@ function isPlayerInFrontVehicleSeat(client) {
function removePlayerFromVehicle(client) {
logToConsole(LOG_DEBUG, `Removing ${getPlayerDisplayForConsole(client)} from their vehicle`);
client.removeFromVehicle();
sendPlayerRemoveFromVehicle(client);
return true;
}
// ===========================================================================
function setPlayerSkin(client, skinIndex) {
client.model = getGameConfig().skins[getGame()][skinIndex][0];
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s skin to ${getGameConfig().skins[getGame()][skinIndex][0]} (Index: ${skinIndex}, Name: ${getGameConfig().skins[getGame()][skinIndex][1]})`);
if(getGame() == VRR_GAME_GTA_IV) {
triggerNetworkEvent("vrr.localPlayerSkin", client, getGameConfig().skins[getGame()][skinIndex][0]);
} else {
getPlayerPed(client).modelIndex = getGameConfig().skins[getGame()][skinIndex][0];
}
}
// ===========================================================================
function getPlayerSkin(client) {
return getSkinIndexFromModel(client.model);
return getSkinIndexFromModel(client.player.modelIndex);
}
// ===========================================================================
function setPlayerHealth(client, health) {
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s health to ${health}`);
client.health = health;
sendPlayerSetHealth(client, health);
getServerData(client).health = health;
}
// ===========================================================================
function getPlayerHealth(client) {
return client.health;
return getPlayerData(client).health;
}
// ===========================================================================
function setPlayerArmour(client, armour) {
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s armour to ${armour}`);
client.armour = armour;
sendPlayerSetArmour(client, armour);
//client.player.armour = armour;
}
// ===========================================================================
function getPlayerArmour(client) {
return client.armour;
if(areServerElementsSupported(client)) {
return getPlayerPed(client).armour;
} else {
return getPlayerData(client).syncArmour;
}
}
// ===========================================================================
function setPlayerCash(client, amount) {
if(client == null) {
return false;
}
if(isNaN(amount)) {
return false;
}
getPlayerCurrentSubAccount(client).cash = toInteger(amount);
updatePlayerCash(client);
}
@@ -305,6 +346,14 @@ function takePlayerCash(client, amount) {
// ===========================================================================
function disconnectPlayer(client) {
logToConsole(LOG_DEBUG, `Disconnecting (kicking) ${getPlayerDisplayForConsole(client)}`);
disconnectPlayer(client);
return false;
}
// ===========================================================================
function getElementSyncer(element) {
return getClients()[element.syncer];
}
@@ -725,14 +774,7 @@ function connectToDatabase() {
return persistentDatabaseConnection;
}
} else {
let databaseConnection = mysql.createConnection({
host: getDatabaseConfig().host,
user: getDatabaseConfig().user,
password: getDatabaseConfig().pass,
database: getDatabaseConfig().name,
port: getDatabaseConfig().port
});
let databaseConnection = module.mysql.connect(getDatabaseConfig().host, getDatabaseConfig().user, getDatabaseConfig().pass, getDatabaseConfig().name, getDatabaseConfig().port);
if(databaseConnection.error) {
logToConsole(LOG_ERROR, `[VRR.Database] Database connection error: ${persistentDatabaseConnection.error}`);
return false;
@@ -778,7 +820,7 @@ function escapeDatabaseString(dbConnection, unsafeString = "") {
}
if(typeof unsafeString == "string") {
return dbConnection.escape(unsafeString);
return dbConnection.escapeString(unsafeString);
}
return unsafeString;
}
@@ -812,12 +854,8 @@ function freeDatabaseQuery(dbQuery) {
// ===========================================================================
function fetchQueryAssoc(queryString) {
let queryResult = dbConnection.query(queryString, function(error, result, fields) {
resolve(result);
});
return queryResult;
function fetchQueryAssoc(dbQuery) {
return dbQuery.fetchAssoc();
}
// ===========================================================================

View File

@@ -8,12 +8,8 @@
// ===========================================================================
function initNPCScript() {
if(!getServerConfig().devServer) {
getServerData().npcs = loadNPCsFromDatabase();
}
setNPCDataIndexes();
spawnNPCs();
logToConsole(LOG_INFO, "[VRR.NPC]: Initializing NPC script ...");
logToConsole(LOG_INFO, "[VRR.NPC]: NPC script initialized successfully!");
}
// ===========================================================================
@@ -46,8 +42,8 @@ function createNPCCommand(client, command, params) {
let position = getPosInFrontOfPos(getPlayerPosition(client), getPlayerHeading(client), 3);
let npcId = createNPC(skinId, position, getPlayerHeading(client));
messageAdmins(`${client.name}{MAINCOLOUR} created a ${getSkinNameFromIndex(getNPCData(npcId).skin)} NPC!`);
let npcId = createNPC(skinId, position, getPlayerHeading(client), getPlayerInterior(client), getPlayerDimension());
messageAdmins(`${getPlayerName(client)}{MAINCOLOUR} created a ${getSkinNameFromIndex(getNPCData(npcId).skin)} NPC!`);
}
// ===========================================================================
@@ -139,7 +135,7 @@ function loadNPCTriggerResponsesFromDatabase(npcTriggerDatabaseId) {
// ===========================================================================
function saveNPCsToDatabase() {
function saveAllNPCsToDatabase() {
if(getServerConfig().devServer) {
return false;
}
@@ -152,6 +148,10 @@ function saveNPCsToDatabase() {
// ===========================================================================
function saveNPCToDatabase(npcDataId) {
if(getServerConfig().devServer) {
return false;
}
if(getNPCData(npcDataId) == null) {
// Invalid NPC data
return false;
@@ -175,11 +175,11 @@ function saveNPCToDatabase(npcDataId) {
if(tempNPCData.ped != false) {
if(!tempNPCData.spawnLocked) {
if(areServerElementsSupported()) {
tempNPCData.spawnPosition = tempNPCData.vehicle.position;
tempNPCData.spawnRotation = tempNPCData.vehicle.heading;
tempNPCData.position = tempNPCData.ped.position;
tempNPCData.heading = tempNPCData.ped.heading;
} else {
tempNPCData.spawnPosition = tempNPCData.syncPosition;
tempNPCData.spawnRotation = tempNPCData.syncHeading;
tempNPCData.position = tempNPCData.syncPosition;
tempNPCData.heading = tempNPCData.syncHeading;
}
}
}
@@ -273,7 +273,7 @@ function spawnNPC(npcIndex) {
// ===========================================================================
function spawnNPCs() {
function spawnAllNPCs() {
for(let i in getServerData().npcs) {
spawnNPC(npcIndex);
}
@@ -297,7 +297,7 @@ function deleteNPCCommand(command, params, client) {
let npcName = getNPCData(closestNPC).name;
deleteNPC(closestNPC);
messageAdmins(`${client.name}{MAINCOLOUR} deleted NPC {npcPink}${npcName}`);
messageAdmins(`${getPlayerName(client)}{MAINCOLOUR} deleted NPC {npcPink}${npcName}`);
}
// ===========================================================================
@@ -365,17 +365,19 @@ function getClosestNPC(position) {
// ===========================================================================
function createNPC(skinIndex, position, heading) {
function createNPC(skinIndex, position, heading, interior, dimension) {
let tempNPCData = new NPCData(false);
tempNPCData.position = position;
tempNPCData.heading = heading;
tempNPCData.skin = skinIndex;
tempNPCData.interior = interior;
tempNPCData.dimension = dimension;
tempNPCData.animationName = "";
let npcIndex = getServerData().npcs.push(tempNPCData);
setNPCDataIndexes();
spawnNPC(npcIndex-1);
setNPCDataIndexes();
return npcIndex-1;
}

View File

@@ -8,11 +8,8 @@
// ===========================================================================
function initRaceScript() {
if(!getServerConfig().devServer) {
getServerData().races = loadRacesFromDatabase();
}
setRaceDataIndexes();
logToConsole(LOG_INFO, "[VRR.Race]: Initializing race script ...");
logToConsole(LOG_INFO, "[VRR.Race]: Race script initialized successfully!");
}
// ===========================================================================
@@ -28,4 +25,56 @@ function getRaceData(raceId) {
return false;
}
// ===========================================================================
function setAllRaceDataIndexes() {
for(let i in getServerData().races) {
getServerData().races[i].index = i;
}
}
// ===========================================================================
function loadRacesFromDatabase() {
// To-do
return [];
}
// ===========================================================================
function saveRacesToDatabase() {
if(getServerConfig().devServer) {
return false;
}
for(let i in getServerData().races) {
saveRaceToDatabase(getServerData().races[i]);
}
}
// ===========================================================================
function saveRaceToDatabase(raceData) {
return true;
}
// ===========================================================================
function createRaceCommand(command, params, client) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
return false;
}
let raceId = getRaceFromParams(params);
if(raceId == false) {
messagePlayerError(client, "A race with that name already exists!");
return false;
}
createRace(params);
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} created race {ALTCOLOUR}${params}`);
}
// ===========================================================================

View File

@@ -9,11 +9,6 @@
function initRadioScript() {
logToConsole(LOG_INFO, "[VRR.Radio]: Initializing radio script ...");
if(!getServerConfig().devServer) {
getServerData().radioStations = loadRadioStationsFromDatabase();
}
setRadioStationIndexes();
logToConsole(LOG_INFO, "[VRR.Radio]: Radio script initialized successfully!");
return true;
}
@@ -65,13 +60,16 @@ function playStreamingRadioCommand(command, params, client) {
}
if(isPlayerInAnyVehicle(client)) {
if(!getVehicleData(getPlayerVehicle(client))) {
let vehicle = getPlayerVehicle(client);
if(!getVehicleData(vehicle)) {
messagePlayerError(client, getLocaleString(client, "RandomVehicleCommandsDisabled"));
return false;
}
if(radioStationId == 0) {
getVehicleData(getPlayerVehicle(client)).streamingRadioStation = -1;
getVehicleData(vehicle).streamingRadioStation = -1;
getVehicleData(vehicle).needsSaved = true;
getPlayerData(client).streamingRadioStation = -1;
meActionToNearbyPlayers(client, `turns off their vehicle's radio`);
@@ -84,13 +82,13 @@ function playStreamingRadioCommand(command, params, client) {
return false;
}
getVehicleData(getPlayerVehicle(client)).streamingRadioStation = radioStationId-1;
getVehicleData(vehicle).streamingRadioStation = radioStationId-1;
getPlayerData(client).streamingRadioStation = radioStationId-1;
meActionToNearbyPlayers(client, getLocaleString(client, "ActionVehicleRadioStationChange", getRadioStationData(radioStationId-1).name, getRadioStationData(radioStationId-1).genre));
let clients = getClients();
for(let i in clients) {
if(getPlayerVehicle(client) == getPlayerVehicle(clients[i])) {
if(vehicle == getPlayerVehicle(clients[i])) {
playRadioStreamForPlayer(clients[i], getRadioStationData(radioStationId-1).url, true, getPlayerStreamingRadioVolume(client));
}
}
@@ -99,6 +97,7 @@ function playStreamingRadioCommand(command, params, client) {
let houseId = getEntityData(client, "vrr.inHouse");
if(radioStationId == 0) {
getHouseData(houseId).streamingRadioStation = -1;
getHouseData(houseId).needsSaved = true;
getPlayerData(client).streamingRadioStation = -1;
meActionToNearbyPlayers(client, `turns off the house radio`);
@@ -110,6 +109,7 @@ function playStreamingRadioCommand(command, params, client) {
}
} else {
getHouseData(houseId).streamingRadioStation = radioStationId-1;
getHouseData(houseId).needsSaved = true;
getPlayerData(client).streamingRadioStation = radioStationId-1;
meActionToNearbyPlayers(client, getLocaleString(client, "ActionHouseRadioStationChange", getRadioStationData(radioStationId-1).name, getRadioStationData(radioStationId-1).genre));
@@ -124,6 +124,7 @@ function playStreamingRadioCommand(command, params, client) {
let businessId = getPlayerBusiness(client);
if(radioStationId == 0) {
getBusinessData(businessId).streamingRadioStation = -1;
getBusinessData(businessId).needsSaved = true;
getPlayerData(client).streamingRadioStation = -1;
meActionToNearbyPlayers(client, `turns off the business radio`);
@@ -135,6 +136,7 @@ function playStreamingRadioCommand(command, params, client) {
}
} else {
getBusinessData(businessId).streamingRadioStation = radioStationId-1;
getBusinessData(businessId).needsSaved = true;
getPlayerData(client).streamingRadioStation = radioStationId-1;
meActionToNearbyPlayers(client, getLocaleString(client, "ActionBusinessRadioStationChange", getRadioStationData(radioStationId-1).name, getRadioStationData(radioStationId-1).genre));
@@ -226,7 +228,7 @@ function showRadioStationListCommand(command, params, client) {
// ===========================================================================
function setRadioStationIndexes() {
function setAllRadioStationIndexes() {
for(let i in getServerData().radioStations) {
getServerData().radioStations[i].index = i;
}

View File

@@ -45,7 +45,7 @@ function kickClientCommand(command, params, client) {
//getPlayerData(targetClient).customDisconnectReason = reason;
announceAdminAction(`PlayerKicked`, getPlayerName(targetClient));
targetClient.disconnect();
targetdisconnectPlayer(client);
}
// ===========================================================================
@@ -83,9 +83,9 @@ function setStaffTitleCommand(command, params, client) {
}
getPlayerData(targetClient).accountData.staffTitle = staffTitle;
messageAdmins(`${client.name} {MAINCOLOUR}set ${getPlayerName(targetClient)}'s staff title to ${staffTitle}`);
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} set {ALTCOLOUR}${getPlayerName(targetClient)}'s{MAINCOLOUR} staff title to ${staffTitle}`);
messagePlayerAlert(client, `${getPlayerName(client)} set your staff title to ${staffTitle}`);
targetClient.disconnect();
targetdisconnectPlayer(client);
}
// ===========================================================================
@@ -119,7 +119,7 @@ function muteClientCommand(command, params, client) {
}
}
messageAdmins(`${targetClient.name} {MAINCOLOUR}has been muted by ${client.name}!`);
messageAdmins(`{adminOrange}${getPlayerName(targetClient)}{MAINCOLOUR} has been muted by {adminOrange}${getPlayerName(client)}`);
getPlayerData(targetClient).muted = true;
}
@@ -154,7 +154,7 @@ function unMuteClientCommand(command, params, client) {
}
}
messageAdmins(`${targetClient.name} {MAINCOLOUR}has been un-muted by ${client.name}!`);
messageAdmins(`{adminOrange}${getPlayerName(targetClient)}{MAINCOLOUR} has been un-muted by {adminOrange}${getPlayerName(client)}`);
getPlayerData(targetClient).muted = false;
}
@@ -189,7 +189,7 @@ function freezeClientCommand(command, params, client) {
}
}
messageAdmins(`${targetClient.name} {MAINCOLOUR}has been frozen by ${client.name}!`);
messageAdmins(`{adminOrange}${getPlayerName(targetClient)}{MAINCOLOUR} has been frozen by ${getPlayerName(client)}`);
//setPlayerFrozenState(client, state);
setPlayerControlState(client, false);
}
@@ -225,7 +225,7 @@ function unFreezeClientCommand(command, params, client) {
}
}
messageAdmins(`${targetClient.name} {MAINCOLOUR}has been un-frozen by ${client.name}!`);
messageAdmins(`{adminOrange}${getPlayerName(targetClient)}{MAINCOLOUR} has been un-frozen by ${getPlayerName(client)}`);
//sendPlayerFrozenState(client, false);
setPlayerControlState(client, true);
}
@@ -294,11 +294,11 @@ function getPlayerGeoIPInformationCommand(command, params, client) {
return false;
}
let countryName = module.geoip.getCountryName(getGlobalConfig().geoIPCountryDatabaseFilePath, targetClient.ip);
let subDivisionName = module.geoip.getSubdivisionName(getGlobalConfig().geoIPCityDatabaseFilePath, targetClient.ip);
let cityName = module.geoip.getCityName(getGlobalConfig().geoIPCityDatabaseFilePath, targetClient.ip);
let countryName = module.geoip.getCountryName(getGlobalConfig().geoIPCountryDatabaseFilePath, getPlayerIP(targetClient));
let subDivisionName = module.geoip.getSubdivisionName(getGlobalConfig().geoIPCityDatabaseFilePath, getPlayerIP(targetClient));
let cityName = module.geoip.getCityName(getGlobalConfig().geoIPCityDatabaseFilePath, getPlayerIP(targetClient));
messagePlayerInfo(client, `{ALTCOLOUR}${targetClient.name} {MAINCOLOUR}is from {ALTCOLOUR}${cityName}, ${subDivisionName}, ${countryName}`);
messagePlayerInfo(client, `{ALTCOLOUR}${getPlayerName(targetClient)}{MAINCOLOUR} is from {ALTCOLOUR}${cityName}, ${subDivisionName}, ${countryName}`);
}
// ===========================================================================
@@ -324,7 +324,7 @@ function getPlayerIPInformationCommand(command, params, client) {
return false;
}
messagePlayerInfo(client, `{ALTCOLOUR}${targetClient.name}'s{MAINCOLOUR} IP is ${targetClient.ip}`);
messagePlayerInfo(client, `{ALTCOLOUR}${getPlayerName(targetClient)}'s{MAINCOLOUR} IP is ${getPlayerIP(targetClient)}`);
}
// ===========================================================================
@@ -393,7 +393,7 @@ function getVehicleCommand(command, params, client) {
setElementInterior(vehicle, getPlayerInterior(client));
setElementDimension(vehicle, getPlayerDimension(client));
messageAdmins(`${client.name} {MAINCOLOUR}teleported a {vehiclePurple}${getVehicleName(vehicle)} {ALTCOLOUR}(ID ${vehicle.id}) {MAINCOLOUR}to you`);
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} teleported a {vehiclePurple}${getVehicleName(vehicle)}{ALTCOLOUR} (ID ${vehicle.id}){MAINCOLOUR} to their position`);
}
// ===========================================================================
@@ -494,25 +494,26 @@ function gotoGameLocationCommand(command, params, client) {
let gameLocationId = getGameLocationFromParams(params);
if(!gameLocationId) {
if(gameLocationId == false) {
messagePlayerError(client, "That game location doesn't exist!");
return false;
}
setPlayerVelocity(client, toVector3(0.0, 0.0, 0.0));
setPlayerPosition(client, getGameConfig().locations[getServerGame()][gameLocationId][1]);
setPlayerPosition(client, getGameConfig().locations[getGame()][gameLocationId][1]);
setPlayerHeading(client, getGameConfig().locations[getGame()][gameLocationId][1]);
setPlayerInterior(client, 0);
setPlayerDimension(client, 0);
updateInteriorLightsForPlayer(client, true);
//setTimeout(function() {
// setPlayerPosition(client, getGameConfig().locations[getServerGame()][gameLocationId][1]);
// setPlayerPosition(client, getGameConfig().locations[getGame()][gameLocationId][1]);
// setPlayerInterior(client, 0);
// setPlayerDimension(client, 0);
// updateInteriorLightsForPlayer(client, true);
//}, 500);
messagePlayerSuccess(client, `You teleported to game location {ALTCOLOUR}${getGameConfig().locations[getServerGame()][gameLocationId][0]}`);
messagePlayerSuccess(client, `You teleported to game location {ALTCOLOUR}${getGameConfig().locations[getGame()][gameLocationId][0]}`);
}
// ===========================================================================
@@ -814,7 +815,7 @@ function playerInteriorCommand(command, params, client) {
let interiorId = getParam(params, " ", 2);
setPlayerInterior(targetClient, Number(interiorId));
messageAdmins(`${client.name} {MAINCOLOUR}set ${getPlayerName(targetClient)}'s interior to {ALTCOLOUR}${interiorId}`);
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} set {ALTCOLOUR}${getPlayerName(targetClient)}'s{MAINCOLOUR} interior to {ALTCOLOUR}${interiorId}`);
}
// ===========================================================================
@@ -841,13 +842,13 @@ function playerVirtualWorldCommand(command, params, client) {
}
if(getParamsCount(params, " ") == 1) {
messagePlayerInfo(client, `{ALTCOLOUR}${getPlayerName(targetClient)}'s {MAINCOLOUR}virtual world is {ALTCOLOUR}${getPlayerDimension(targetClient)}`);
messagePlayerInfo(client, `{ALTCOLOUR}${getPlayerName(targetClient)}'s{MAINCOLOUR} virtual world is {ALTCOLOUR}${getPlayerDimension(targetClient)}`);
return false;
}
let dimensionId = getParam(params, " ", 2);
setPlayerDimension(targetClient, Number(dimensionId));
messageAdmins(`${client.name} {MAINCOLOUR}set {ALTCOLOUR}${getPlayerName(targetClient)}'s {MAINCOLOUR}virtual world to {ALTCOLOUR}${dimensionId}`);
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} set {ALTCOLOUR}${getPlayerName(targetClient)}'s{MAINCOLOUR} virtual world to {ALTCOLOUR}${dimensionId}`);
}
// ===========================================================================
@@ -881,21 +882,12 @@ function getPlayerCommand(command, params, client) {
getPlayerData(targetClient).returnToInterior = getPlayerInterior(targetClient);
getPlayerData(targetClient).returnToType = VRR_RETURNTO_TYPE_ADMINGET;
if(isPlayerInAnyHouse(targetClient)) {
getPlayerData(targetClient).returnToHouse = getPlayerHouse(targetClient);
}
if(isPlayerInAnyBusiness(targetClient)) {
getPlayerData(targetClient).returnToBusiness = getPlayerBusiness(targetClient);
}
removePlayerFromVehicle(targetClient);
setPlayerPosition(targetClient, getPosBehindPos(getPlayerPosition(client), getPlayerHeading(client), 2));
setPlayerHeading(targetClient, getPlayerHeading(client));
setPlayerInterior(targetClient, getPlayerInterior(client));
setPlayerDimension(targetClient, getPlayerDimension(client));
messageAdmins(`${client.name} {MAINCOLOUR}teleported {ALTCOLOUR}${getPlayerName(targetClient)} {MAINCOLOUR}to their position.`);
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} teleported {ALTCOLOUR}${getPlayerName(targetClient)}{MAINCOLOUR} to their position.`);
messagePlayerAlert(targetClient, `An admin has teleported you to their location`);
}
@@ -942,7 +934,7 @@ function returnPlayerCommand(command, params, client) {
getPlayerData(targetClient).returnToBusiness = null;
getPlayerData(targetClient).returnToType = VRR_RETURNTO_TYPE_NONE;
messageAdmins(`${client.name} {MAINCOLOUR}returned {ALTCOLOUR}${getPlayerName(targetClient)} {MAINCOLOUR}to their previous position.`);
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} returned {ALTCOLOUR}${getPlayerName(targetClient)}{MAINCOLOUR} to their previous position.`);
messagePlayerAlert(targetClient, `An admin has returned you to your previous location`);
}
@@ -985,7 +977,7 @@ function addPlayerStaffFlagCommand(command, params, client) {
}
givePlayerStaffFlag(targetClient, flagName);
messageAdmins(`${client.name} has {MAINCOLOUR}given {ALTCOLOUR}${getPlayerName(targetClient)} {MAINCOLOUR}the {ALTCOLOUR}${flagName} {MAINCOLOUR}staff flag`);
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} has given {ALTCOLOUR}${getPlayerName(targetClient)}{MAINCOLOUR} the {ALTCOLOUR}${flagName}{MAINCOLOUR} staff flag`);
}
// ===========================================================================
@@ -1027,7 +1019,7 @@ function removePlayerStaffFlagCommand(command, params, client) {
}
takePlayerStaffFlag(targetClient, flagName);
messageAdmins(`${client.name} {MAINCOLOUR}has taken the {ALTCOLOUR}${flagName} {MAINCOLOUR}staff flag from {ALTCOLOUR}${getPlayerName(targetClient)}`);
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} has taken the {ALTCOLOUR}${flagName}{MAINCOLOUR} staff flag from {ALTCOLOUR}${getPlayerName(targetClient)}`);
}
// ===========================================================================
@@ -1063,7 +1055,7 @@ function removePlayerStaffFlagsCommand(command, params, client) {
}
clearPlayerStaffFlags(targetClient);
messageAdmins(`${client.name} {MAINCOLOUR}removed all staff flags from {ALTCOLOUR}${getPlayerName(targetClient)}`);
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} removed all staff flags from {ALTCOLOUR}${getPlayerName(targetClient)}`);
}
// ===========================================================================
@@ -1190,7 +1182,7 @@ function givePlayerMoneyCommand(command, params, client) {
givePlayerCash(targetClient, toInteger(amount));
updatePlayerCash(targetClient);
//messagePlayerSuccess(client, `You gave {ALTCOLOUR}$${amount} {MAINCOLOUR}to {ALTCOLOUR}${getCharacterFullName(targetClient)}`);
messageAdmins(`${client.name} {MAINCOLOUR}gave {ALTCOLOUR}$${amount} {MAINCOLOUR}to {ALTCOLOUR}${getCharacterFullName(targetClient)}`)
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} gave {ALTCOLOUR}$${amount}{MAINCOLOUR} to {ALTCOLOUR}${getCharacterFullName(targetClient)}`)
messagePlayerAlert(targetClient, `An admin gave you {ALTCOLOUR}$${amount}`);
}
@@ -1227,11 +1219,11 @@ function setPlayerAccentCommand(command, params, client) {
if(newAccent == "") {
//messagePlayerSuccess(client, `You removed {ALTCOLOUR}${getCharacterFullName(targetClient)}'s {MAINCOLOUR}accent.`);
messageAdmins(client, `${client.name} removed {ALTCOLOUR}${getCharacterFullName(targetClient)}'s {MAINCOLOUR}accent.`);
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} removed {ALTCOLOUR}${getCharacterFullName(targetClient)}'s{MAINCOLOUR} accent.`);
messagePlayerAlert(client, `An admin removed your accent.`);
} else {
//messagePlayerSuccess(client, `You set {ALTCOLOUR}${getCharacterFullName(targetClient)}'s {MAINCOLOUR}accent to {ALTCOLOUR}${newAccent}`);
messageAdmins(`${client.name} set {ALTCOLOUR}${getCharacterFullName(targetClient)}'s {MAINCOLOUR}accent to {ALTCOLOUR}${newAccent}`)
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} set {ALTCOLOUR}${getCharacterFullName(targetClient)}'s{MAINCOLOUR} accent to {ALTCOLOUR}${newAccent}`)
messagePlayerAlert(client, `An admin set your accent to {ALTCOLOUR}${newAccent}`);
}
}
@@ -1262,7 +1254,7 @@ function forceCharacterNameChangeCommand(command, params, client) {
getPlayerData(targetClient).changingCharacterName = true;
messageAdmins(`${client.name} {MAINCOLOUR}forced {ALTCOLOUR}${getPlayerName(targetClient)} (${getCharacterFullName(targetClient)}) {MAINCOLOUR}to change their character's name.`);
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} forced {ALTCOLOUR}${getPlayerName(targetClient)} (${getCharacterFullName(targetClient)}){MAINCOLOUR} to change their character's name.`);
showPlayerNewCharacterFailedGUI(targetClient, getLocaleString(targetClient, "NonRPName"));
}
@@ -1305,7 +1297,7 @@ function setCharacterNameCommand(command, params, client) {
getPlayerCurrentSubAccount(targetClient).firstName = firstName;
getPlayerCurrentSubAccount(targetClient).lastName = lastName;
messageAdmins(`${getPlayerName(client)} {MAINCOLOUR}forced {ALTCOLOUR}${getPlayerName(targetClient)}'s{MAINCOLOUR} current character name from {ALTCOLOUR}${oldName}{MAINCOLOUR} to {ALTCOLOUR}${newName}`);
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} set {ALTCOLOUR}${getPlayerName(targetClient)}'s{MAINCOLOUR} current character name from {ALTCOLOUR}${oldName}{MAINCOLOUR} to {ALTCOLOUR}${newName}`);
updateAllPlayerNameTags();
}
@@ -1349,7 +1341,36 @@ function setPlayerSkinCommand(command, params, client) {
getPlayerCurrentSubAccount(targetClient).skin = skinIndex;
setPlayerSkin(targetClient, skinIndex);
messageAdmins(`${getPlayerName(client)} {MAINCOLOUR}set ${getPlayerName(targetClient)}'s{MAINCOLOUR} skin to {ALTCOLOUR}${getGameConfig().skins[getGame()][skinIndex][1]}`);
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} set ${getPlayerName(targetClient)}'s{MAINCOLOUR} skin to {ALTCOLOUR}${getGameConfig().skins[getGame()][skinIndex][1]}`);
}
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function setPlayerStaffTitleCommand(command, params, client) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
return false;
}
let splitParams = params.split(" ");
let targetClient = getPlayerFromParams(splitParams[0]);
let newTitle = splitParams.slice(1).join(" ");
if(!targetClient) {
messagePlayerError(client, getLocaleString(client, "InvalidPlayer"));
return false;
}
getPlayerData(client).accountData.staffTitle = newTitle;
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} set ${getPlayerName(targetClient)}'s{MAINCOLOUR} staff title to {ALTCOLOUR}${newTitle}`);
}
// ===========================================================================
@@ -1385,7 +1406,7 @@ function setPlayerHealthCommand(command, params, client) {
setPlayerHealth(targetClient, health);
messageAdmins(`${getPlayerName(client)}{MAINCOLOUR} set ${getPlayerName(targetClient)}'s{MAINCOLOUR} health to {ALTCOLOUR}${health}`);
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} set ${getPlayerName(targetClient)}'s{MAINCOLOUR} health to {ALTCOLOUR}${health}`);
}
// ===========================================================================
@@ -1415,7 +1436,7 @@ function setPlayerArmourCommand(command, params, client) {
setPlayerArmour(targetClient, armour);
messageAdmins(`${getPlayerName(client)}{MAINCOLOUR} set ${getPlayerName(targetClient)}'s{MAINCOLOUR} armour to {ALTCOLOUR}${armour}`);
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} set ${getPlayerName(targetClient)}'s{MAINCOLOUR} armour to {ALTCOLOUR}${armour}`);
}
// ===========================================================================
@@ -1451,7 +1472,7 @@ function setPlayerInfiniteRunCommand(command, params, client) {
state = toInteger(state);
setPlayerInfiniteRun(targetClient, intToBool(state));
messageAdmins(`${getPlayerName(client)}{MAINCOLOUR} ${getBoolRedGreenInlineColour(state)}${(state) ? "enabled" : "disabled"}{MAINCOLOUR} infinite run for {ALTCOLOUR}${getPlayerName(targetClient)}`);
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} ${getBoolRedGreenInlineColour(state)}${(state) ? "enabled" : "disabled"}{MAINCOLOUR} infinite run for {ALTCOLOUR}${getPlayerName(targetClient)}`);
}
// ===========================================================================
@@ -1481,7 +1502,7 @@ function setPlayerWantedLevelCommand(command, params, client) {
setPlayerWantedLevel(targetClient, wantedLevel);
//messageAdmins(`${getPlayerName(client)} {MAINCOLOUR}set ${getPlayerName(targetClient)}'s {MAINCOLOUR}skin to {ALTCOLOUR}${getGameConfig().skins[getGame()][skinIndex][1]}`);
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} set ${getPlayerName(targetClient)}'s{MAINCOLOUR} wanted level to {ALTCOLOUR}${wantedLevel}`);
}
// ===========================================================================
@@ -1544,7 +1565,12 @@ function getBusinessesOwnedByPlayerCommand(command, params, client) {
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderPlayerBusinessesList", getCharacterFullName(targetClient))));
for(let i in businesses) {
messagePlayerNormal(client, `🏢 {businessBlue}[Business Info] {MAINCOLOUR}Name: {ALTCOLOUR}${businesses[i].name}, {MAINCOLOUR}Locked: {ALTCOLOUR}${getYesNoFromBool(intToBool(businesses[i].locked))}, {MAINCOLOUR}ID: {ALTCOLOUR}${businesses[i].index}/${businesses[i].databaseId}`);
let info = [
`Name: ${businesses[i].name}`,
`Locked: ${businesses[i].locked}`,
`ID: ${businesses[i].index}/${businesses[i].databaseId}`,
]
messagePlayerNormal(client, `🏢 {businessBlue}[Business Info] {MAINCOLOUR}${info.join(", ")}`);
}
}
@@ -1631,10 +1657,10 @@ function toggleSyncForElementsSpawnedByPlayerCommand(command, params, client) {
if(!hasBitFlag(getPlayerData(client).accountData.flags.moderation, getModerationFlagValue("DontSyncClientElements"))) {
getPlayerData(client).accountData.flags.moderation = addBitFlag(getPlayerData(client).accountData.flags.moderation, getModerationFlagValue("DontSyncClientElements"));
messageAdmins(`${getPlayerName(client)} {MAINCOLOUR}turned {softGreen}ON client element sync for {ALTCOLOUR}${getPlayerName(targetClient)}`);
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} turned {softGreen}ON{MAINCOLOUR} client element sync for {ALTCOLOUR}${getPlayerName(targetClient)}`);
} else {
getPlayerData(client).accountData.flags.moderation = removeBitFlag(getPlayerData(client).accountData.flags.moderation, getModerationFlagValue("DontSyncClientElements"));
messageAdmins(`${getPlayerName(client)} {MAINCOLOUR}turned {softRed}OFF client element sync for {ALTCOLOUR}${getPlayerName(targetClient)}`);
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} turned {softRed}OFF{MAINCOLOUR} client element sync for {ALTCOLOUR}${getPlayerName(targetClient)}`);
}
}
@@ -1714,15 +1740,77 @@ function forceFightStyleCommand(command, params, client) {
if(!fightStyleId) {
messagePlayerError(client, `That fight style doesn't exist!`);
messagePlayerError(client, `Fight styles: ${getGameConfig().fightStyles[getServerGame()].map(fs => fs[0]).join(", ")}`);
messagePlayerError(client, `Fight styles: ${getGameConfig().fightStyles[getGame()].map(fs => fs[0]).join(", ")}`);
return false;
}
getPlayerCurrentSubAccount(client).fightStyle = fightStyleId;
setPlayerFightStyle(client, fightStyleId);
messagePlayerSuccess(client, `You set ${getCharacterFullName(targetClient)}'s fight style to ${getGameConfig().fightStyles[getServerGame()][fightStyleId][0]}`)
messagePlayerSuccess(client, `You set ${getCharacterFullName(targetClient)}'s fight style to ${getGameConfig().fightStyles[getGame()][fightStyleId][0]}`)
return true;
}
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function getPlayerCurrentHouseCommand(command, params, client) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
return false;
}
let targetClient = getPlayerFromParams(getParam(params, " ", 1));
let houseId = getPlayerHouse(targetClient);
if(!houseId) {
messagePlayerAlert(client, `${getPlayerName(targetClient)} isn't in or at a house!`);
return false;
}
let houseData = getHouseData(houseId);
messagePlayerInfo(client, `${getPlayerName(targetClient)}'s is at/in house '${houseData.description}' (ID ${houseId}/${houseData.databaseId})`);
return true;
}
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function getPlayerCurrentBusinessCommand(command, params, client) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
return false;
}
let targetClient = getPlayerFromParams(getParam(params, " ", 1));
let businessId = getPlayerBusiness(targetClient);
if(!businessId) {
messagePlayerAlert(client, `${getPlayerName(targetClient)} isn't in or at a house!`);
return false;
}
let businessData = getBusinessData(houseId);
messagePlayerInfo(client, `${getPlayerName(targetClient)}'s is at/in business '${businessData.name}' (ID ${businessId}/${businessData.databaseId})`);
return true;
}
// ===========================================================================

View File

@@ -38,14 +38,22 @@ function initServerScripts() {
initEconomyScript();
initRadioScript();
initLocaleScript();
initCommandScript();
serverStartTime = getCurrentUnixTimestamp();
// Load config and stuff
loadGlobalConfig();
loadServerConfig();
applyConfigToServer(getServerConfig());
// Load all the server data
loadServerDataFromDatabase();
setAllServerDataIndexes();
createAllServerElements();
initAllClients();
initTimers();
serverStartTime = getCurrentUnixTimestamp();
}
// ===========================================================================
@@ -83,20 +91,20 @@ function checkForAllRequiredModules() {
logToConsole(LOG_DEBUG, "[VRR.Startup]: Checking for required modules ...");
if(!checkForHashingModule()) {
console.warn("[VRR.Startup]: Hashing module is not loaded!");
console.warn("[VRR.Startup]: This resource will now shutdown.");
logToConsole(LOG_WARN, "[VRR.Startup]: Hashing module is not loaded!");
logToConsole(LOG_WARN, "[VRR.Startup]: This resource will now shutdown.");
thisResource.stop();
}
if(!checkForMySQLModule()) {
console.warn("[VRR.Startup]: MySQL module is not loaded!");
console.warn("[VRR.Startup]: This resource will now shutdown.");
logToConsole(LOG_WARN, "[VRR.Startup]: MySQL module is not loaded!");
logToConsole(LOG_WARN, "[VRR.Startup]: This resource will now shutdown.");
thisResource.stop();
}
if(!checkForSMTPModule()) {
console.warn("[VRR.Startup]: SMTP Email module is not loaded!");
console.warn("[VRR.Startup]: Email features will NOT be available!");
logToConsole(LOG_WARN, "[VRR.Startup]: SMTP Email module is not loaded!");
logToConsole(LOG_WARN, "[VRR.Startup]: Email features will NOT be available!");
}
logToConsole(LOG_DEBUG, "[VRR.Startup]: All required modules loaded!");
@@ -105,6 +113,71 @@ function checkForAllRequiredModules() {
// ===========================================================================
function loadServerDataFromDatabase() {
logToConsole(LOG_INFO, "[VRR.Config]: Loading server data ...");
// Always load these regardless of "test server" status
getServerData().localeStrings = loadAllLocaleStrings();
getServerData().allowedSkins = getAllowedSkins(getGame());
// Translation Cache
getServerData().cachedTranslations = new Array(getGlobalConfig().locale.locales.length);
getServerData().cachedTranslationFrom = new Array(getGlobalConfig().locale.locales.length);
getServerData().cachedTranslationFrom.fill([]);
getServerData().cachedTranslations.fill(getServerData().cachedTranslationFrom);
// Only load these if the server isn't a testing/dev server
if(!getServerConfig().devServer) {
getServerData().itemTypes = loadItemTypesFromDatabase();
getServerData().items = loadItemsFromDatabase();
getServerData().businesses = loadBusinessesFromDatabase();
getServerData().houses = loadHousesFromDatabase();
getServerData().vehicles = loadVehiclesFromDatabase();
getServerData().clans = loadClansFromDatabase();
getServerData().npcs = loadNPCsFromDatabase();
getServerData().races = loadRacesFromDatabase();
getServerData().radioStations = loadRadioStationsFromDatabase();
getServerData().gates = loadGatesFromDatabase();
getServerData().jobs = loadJobsFromDatabase();
}
getServerData().commands = loadCommands();
}
// ===========================================================================
function setAllServerDataIndexes() {
setAllItemTypeDataIndexes();
setAllItemDataIndexes();
setBusinessDataIndexes();
setHouseDataIndexes();
setAllClanDataIndexes();
setAllJobDataIndexes();
setNPCDataIndexes();
setAllRaceDataIndexes();
setAllRadioStationIndexes();
cacheAllGroundItems();
cacheAllBusinessItems();
cacheAllCommandsAliases();
}
// ===========================================================================
function createAllServerElements() {
createAllBusinessPickups();
createAllBusinessBlips();
createAllHousePickups();
createAllHouseBlips();
createAllJobPickups();
createAllJobBlips();
createAllGroundItemObjects();
spawnAllVehicles();
spawnAllNPCs();
addAllCommandHandlers();
}
// ===========================================================================
initServerScripts();
// ===========================================================================

View File

@@ -224,9 +224,9 @@ function showCharacterSelectToClient(client) {
getPlayerData(client).currentSubAccount = 0;
logToConsole(LOG_DEBUG, `[VRR.SubAccount] Setting ${getPlayerDisplayForConsole(client)}'s character to ID ${getPlayerData(client).currentSubAccount}`);
let tempSubAccount = getPlayerData(client).subAccounts[0];
let ClanName = (tempSubAccount.clan != 0) ? getClanData(getClanIdFromDatabaseId(tempSubAccount.clan)).name : "None";
let clanName = (tempSubAccount.clan != 0) ? getClanData(getClanIdFromDatabaseId(tempSubAccount.clan)).name : "None";
let lastPlayedText = (tempSubAccount.lastLogin != 0) ? `${msToTime(getCurrentUnixTimestamp()-tempSubAccount.lastLogin)} ago` : "Never";
showPlayerCharacterSelectGUI(client, tempSubAccount.firstName, tempSubAccount.lastName, tempSubAccount.cash, ClanName, lastPlayedText, getGameConfig().skins[getGame()][tempSubAccount.skin][0]);
showPlayerCharacterSelectGUI(client, tempSubAccount.firstName, tempSubAccount.lastName, tempSubAccount.cash, clanName, lastPlayedText, getGameConfig().skins[getGame()][tempSubAccount.skin][0]);
//spawnPlayer(client, getServerConfig().characterSelectPedPosition, getServerConfig().characterSelectPedHeading, getPlayerCurrentSubAccount(client).skin, getServerConfig().characterSelectInterior, getServerConfig().characterSelectDimension);
//setTimeout(function() {
@@ -520,7 +520,7 @@ function setFightStyleCommand(command, params, client) {
if(!fightStyle) {
messagePlayerError(client, `That fight style doesn't exist!`);
messagePlayerError(client, `Fight styles: ${getGameConfig().fightStyles[getServerGame()].map(fs => fs[0]).join(", ")}`);
messagePlayerError(client, `Fight styles: ${getGameConfig().fightStyles[getGame()].map(fs => fs[0]).join(", ")}`);
return false;
}
@@ -532,7 +532,7 @@ function setFightStyleCommand(command, params, client) {
}
setPlayerFightStyle(client, fightStyleId);
messagePlayerSuccess(client, `Your fight style has been set to ${getGameConfig().fightStyles[getServerGame()][fightStyleId][0]}`)
messagePlayerSuccess(client, `Your fight style has been set to ${getGameConfig().fightStyles[getGame()][fightStyleId][0]}`)
return true;
}

View File

@@ -19,53 +19,65 @@ function saveServerDataToDatabase() {
logToConsole(LOG_DEBUG, "[VRR.Utilities]: Saving all server data to database ...");
try {
saveClientsToDatabase();
saveAllPlayersToDatabase();
} catch(error) {
logToConsole(LOG_ERROR, `Could not save clients to database: ${error}`);
logToConsole(LOG_ERROR, `Could not save players to database: ${error}`);
}
try {
saveClansToDatabase();
saveAllClansToDatabase();
} catch(error) {
logToConsole(LOG_ERROR, `Could not save clans to database: ${error}`);
}
try {
saveHousesToDatabase();
saveAllHousesToDatabase();
} catch(error) {
logToConsole(LOG_ERROR, `Could not save houses to database: ${error}`);
}
try {
saveBusinessesToDatabase();
saveAllBusinessesToDatabase();
} catch(error) {
logToConsole(LOG_ERROR, `Could not save businesses to database: ${error}`);
}
try {
saveVehiclesToDatabase();
saveAllVehiclesToDatabase();
} catch(error) {
logToConsole(LOG_ERROR, `Could not save vehicles to database: ${error}`);
}
try {
saveItemTypesToDatabase();
saveAllItemTypesToDatabase();
} catch(error) {
logToConsole(LOG_ERROR, `Could not save item types to database: ${error}`);
}
try {
saveItemsToDatabase();
saveAllItemsToDatabase();
} catch(error) {
logToConsole(LOG_ERROR, `Could not save items to database: ${error}`);
}
try {
saveJobsToDatabase();
saveAllJobsToDatabase();
} catch(error) {
logToConsole(LOG_ERROR, `Could not save jobs to database: ${error}`);
}
try {
saveAllNPCsToDatabase();
} catch(error) {
logToConsole(LOG_ERROR, `Could not save NPCs to database: ${error}`);
}
try {
saveAllGatesToDatabase();
} catch(error) {
logToConsole(LOG_ERROR, `Could not save gates to database: ${error}`);
}
try {
saveServerConfigToDatabase();
} catch(error) {
@@ -93,7 +105,7 @@ function oneMinuteTimerFunction() {
checkServerGameTime();
logToConsole(LOG_DEBUG, `[VRR.Event] Checking rentable vehicles`);
vehicleRentCheck();
checkVehicleRenting();
logToConsole(LOG_DEBUG, `[VRR.Event] Updating all player name tags`);
updateAllPlayerNameTags();
@@ -118,19 +130,18 @@ function thirtyMinuteTimerFunction() {
// ===========================================================================
function vehicleRentCheck() {
// Loop through players, not vehicles. Much more efficient (and doesn't consume resources when no players are connected)
let clients = getClients();
for(let i in clients) {
if(isClientInitialized(clients[i])) {
if(getPlayerData(clients[i]) != false) {
if(isPlayerLoggedIn(clients[i] && isPlayerSpawned(clients[i]))) {
if(getPlayerData(clients[i]).rentingVehicle != false) {
if(getPlayerCurrentSubAccount(clients[i]).cash < getServerData().vehicles[getPlayerData(clients[i]).rentingVehicle].rentPrice) {
messagePlayerAlert(clients[i], `You do not have enough money to continue renting this vehicle!`);
stopRentingVehicle(clients[i]);
function checkVehicleRenting() {
let renting = getServerData().rentingVehicleCache;
for(let i in renting) {
if(isClientInitialized(renting[i])) {
if(getPlayerData(renting[i]) != false) {
if(isPlayerLoggedIn(renting[i] && isPlayerSpawned(renting[i]))) {
if(getPlayerData(renting[i]).rentingVehicle != false) {
if(getPlayerCurrentSubAccount(renting[i]).cash < getServerData().vehicles[getPlayerData(renting[i]).rentingVehicle].rentPrice) {
messagePlayerAlert(renting[i], `You do not have enough money to continue renting this vehicle!`);
stopRentingVehicle(renting[i]);
} else {
takePlayerCash(clients[i], getServerData().vehicles[getPlayerData(clients[i]).rentingVehicle].rentPrice);
takePlayerCash(renting[i], getServerData().vehicles[getPlayerData(renting[i]).rentingVehicle].rentPrice);
}
}
}

View File

@@ -7,19 +7,7 @@
// TYPE: Server (JavaScript)
// ===========================================================================
let disconnectReasons = [
"Lost Connection",
"Disconnected",
"Unsupported Client",
"Wrong Game",
"Incorrect Password",
"Unsupported Executable",
"Disconnected",
"Banned",
"Failed",
"Invalid Name",
"Crashed"
];
// ===========================================================================
@@ -28,7 +16,7 @@ function getPositionArea(position) {
position = vec3ToVec2(position);
}
let gameAreas = getGameAreas(getServerGame());
let gameAreas = getGameAreas(getGame());
for(let i in gameAreas) {
if(isPositionInArea(position, gameAreas[i][1])) {
return i;
@@ -64,7 +52,7 @@ function getGameAreas(gameId) {
function getPlayerData(client) {
if(client != null) {
if(isClientInitialized(client)) {
return getServerData().clients[client.index];
return getServerData().clients[getPlayerId(client)];
}
}
return false;
@@ -94,9 +82,11 @@ function updateServerRules() {
if(isWeatherSupported()) {
if(getServerConfig() != false) {
let value = getGameConfig().weatherNames[getServerGame()][getServerConfig().weather];
logToConsole(LOG_DEBUG, `[VRR.Utilities]: Setting server rule "Weather" as ${value}`);
server.setRule("Weather", value);
if(typeof getGameConfig().weatherNames[getGame()] != "undefined") {
let value = getGameConfig().weatherNames[getGame()][getServerConfig().weather];
logToConsole(LOG_DEBUG, `[VRR.Utilities]: Setting server rule "Weather" as ${value}`);
server.setRule("Weather", value);
}
}
}
@@ -114,13 +104,13 @@ function updateServerRules() {
function getWeatherFromParams(params) {
if(isNaN(params)) {
for(let i in getGameConfig().weatherNames[getServerGame()]) {
if(toLowerCase(getGameConfig().weatherNames[getServerGame()][i]).indexOf(toLowerCase(params)) != -1) {
for(let i in getGameConfig().weatherNames[getGame()]) {
if(toLowerCase(getGameConfig().weatherNames[getGame()][i]).indexOf(toLowerCase(params)) != -1) {
return i;
}
}
} else {
if(typeof getGameConfig().weatherNames[getServerGame()][params] != "undefined") {
if(typeof getGameConfig().weatherNames[getGame()][params] != "undefined") {
return toInteger(params);
}
}
@@ -132,13 +122,13 @@ function getWeatherFromParams(params) {
function getFightStyleFromParams(params) {
if(isNaN(params)) {
for(let i in getGameConfig().fightStyles[getServerGame()]) {
if(toLowerCase(getGameConfig().fightStyles[getServerGame()][i][0]).indexOf(toLowerCase(params)) != -1) {
for(let i in getGameConfig().fightStyles[getGame()]) {
if(toLowerCase(getGameConfig().fightStyles[getGame()][i][0]).indexOf(toLowerCase(params)) != -1) {
return i;
}
}
} else {
if(typeof getGameConfig().fightStyles[getServerGame()][params] != "undefined") {
if(typeof getGameConfig().fightStyles[getGame()][params] != "undefined") {
return toInteger(params);
}
}
@@ -149,27 +139,35 @@ function getFightStyleFromParams(params) {
// ===========================================================================
function getClosestHospital(position) {
let closest = 0;
for(let i in getGameConfig().hospitals[getServerGame()]) {
if(getDistance(getGameConfig().hospitals[getServerGame()][i].position, position) < getDistance(getGameConfig().hospitals[getServerGame()][closest].position, position)) {
closest = i;
if(typeof getGameConfig().hospitals[getGame()] == "undefined") {
return {position: getServerConfig().newCharacter.spawnPosition};
} else {
let closest = 0;
for(let i in getGameConfig().hospitals[getGame()]) {
if(getDistance(getGameConfig().hospitals[getGame()][i].position, position) < getDistance(getGameConfig().hospitals[getGame()][closest].position, position)) {
closest = i;
}
}
}
return getGameConfig().hospitals[getServerGame()][closest];
return getGameConfig().hospitals[getGame()][closest];
}
}
// ===========================================================================
function getClosestPoliceStation(position) {
let closest = 0;
for(let i in getGameConfig().policeStations[getServerGame()]) {
if(getDistance(getGameConfig().policeStations[getServerGame()][i].position, position) < getDistance(getGameConfig().policeStations[getServerGame()][closest].position, position)) {
closest = i;
if(typeof getGameConfig().policeStations[getGame()] == "undefined") {
return {position: getServerConfig().newCharacter.spawnPosition};
} else {
let closest = 0;
for(let i in getGameConfig().policeStations[getGame()]) {
if(getDistance(getGameConfig().policeStations[getGame()][i].position, position) < getDistance(getGameConfig().policeStations[getGame()][closest].position, position)) {
closest = i;
}
}
}
return getGameConfig().policeStations[getServerGame()][closest];
return getGameConfig().policeStations[getGame()][closest];
}
}
// ===========================================================================
@@ -178,7 +176,7 @@ function getPlayerDisplayForConsole(client) {
if(isNull(client)) {
return "(Unknown client)";
}
return `${getPlayerName(client)}[${client.index}]`;
return `${getPlayerName(client)}[${getPlayerId(client)}]`;
}
// ===========================================================================
@@ -208,8 +206,8 @@ function getPlayerIsland(client) {
// ===========================================================================
function isAtPayAndSpray(position) {
for(let i in getGameConfig().payAndSprays[getServerGame()]) {
if(getDistance(position, getGameConfig().payAndSprays[getServerGame()][i]) <= getGlobalConfig().payAndSprayDistance) {
for(let i in getGameConfig().payAndSprays[getGame()]) {
if(getDistance(position, getGameConfig().payAndSprays[getGame()][i]) <= getGlobalConfig().payAndSprayDistance) {
return true;
}
}
@@ -295,19 +293,16 @@ function showCharacterSelectCameraToPlayer(client) {
// ===========================================================================
function getClosestPlayer(position, exemptPlayer) {
//let clients = getClients();
//let closest = 0;
//for(let i in clients) {
// if(exemptClient != clients[i]) {
// if(getDistance(getPlayerPosition(clients[i]), position) < getDistance(getPlayerPosition(clients[closest]), position)) {
// closest = i;
// }
// }
//}
return getElementsByType(ELEMENT_PLAYER).filter((fp) => fp != exemptPlayer).reduce((i, j) => ((i.position.distance(position) <= j.position.distance(position)) ? i : j));
//return clients[closest];
let clients = getClients();
let closest = 0;
for(let i in clients) {
if(exemptClient != clients[i]) {
if(getDistance(getPlayerPosition(clients[i]), position) < getDistance(getPlayerPosition(clients[closest]), position)) {
closest = i;
}
}
}
return clients[closest];
}
// ===========================================================================
@@ -358,6 +353,10 @@ function updateConnectionLogOnAuth(client, authId) {
// ===========================================================================
function updateConnectionLogOnClientInfoReceive(client, clientVersion, screenWidth, screenHeight) {
if(getPlayerData(client) != false) {
getPlayerData(client).clientVersion = clientVersion;
}
let dbConnection = connectToDatabase();
if(dbConnection) {
let safeClientVersion = escapeDatabaseString(dbConnection, clientVersion);
@@ -396,6 +395,10 @@ 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);
@@ -449,7 +452,7 @@ function clearTemporaryPeds() {
function kickAllClients() {
getClients().forEach((client) => {
client.disconnect();
disconnectPlayer(client);
})
}
@@ -464,7 +467,7 @@ function updateTimeRule() {
// ===========================================================================
function isClientInitialized(client) {
return (typeof getServerData().clients[client.index] != "undefined");
return (typeof getServerData().clients[getPlayerId(client)] != "undefined");
}
// ===========================================================================
@@ -494,3 +497,13 @@ function getPlayerConnectionsInLastMonthByName(name) {
}
// ===========================================================================
function addPrefixNumberFill(number, amount) {
let numberString = toString(number);
while(numberString.length < amount) {
numberString = toString(`0${numberString}`);
}
return toString(numberString);
}
// ===========================================================================

View File

@@ -9,12 +9,6 @@
function initVehicleScript() {
logToConsole(LOG_INFO, "[VRR.Vehicle]: Initializing vehicle script ...");
if(!getServerConfig().devServer) {
getServerData().vehicles = loadVehiclesFromDatabase();
}
spawnAllVehicles();
setAllVehicleIndexes();
logToConsole(LOG_INFO, "[VRR.Vehicle]: Vehicle script initialized successfully!");
return true;
}
@@ -28,10 +22,13 @@ function loadVehiclesFromDatabase() {
let dbAssoc;
if(dbConnection) {
let dbQueryString = `SELECT * FROM veh_main WHERE veh_server = ${getServerId()} AND veh_deleted = 0`;
dbAssoc = await fetchQueryAssoc(dbConnection, dbQueryString);
for(let i in dbAssoc) {
let tempVehicleData = new VehicleData(dbAssoc[i]);
tempVehicles.push(tempVehicleData);
let dbQuery = queryDatabase(dbConnection, dbQueryString);
if(dbQuery) {
while(dbAssoc = fetchQueryAssoc(dbQuery)) {
let tempVehicleData = new VehicleData(dbAssoc);
tempVehicles.push(tempVehicleData);
}
freeDatabaseQuery(dbQuery);
}
disconnectFromDatabase(dbConnection);
}
@@ -42,7 +39,7 @@ function loadVehiclesFromDatabase() {
// ===========================================================================
function saveVehiclesToDatabase() {
function saveAllVehiclesToDatabase() {
if(getServerConfig().devServer) {
return false;
}
@@ -147,7 +144,7 @@ function saveVehicleToDatabase(vehicleDataId) {
getServerData().vehicles[vehicleDataId].needsSaved = false;
} else {
let queryString = createDatabaseUpdateQuery("veh_main", data, `veh_id=${tempVehicleData.databaseId}`);
dbQuery = queryDatabase(dbConnection, queryString);
dbQuery = queryDatabase(dbConnection, queryString, true);
getServerData().vehicles[vehicleDataId].needsSaved = false;
}
@@ -174,9 +171,9 @@ function spawnAllVehicles() {
// ===========================================================================
/**
* @param {Vehicle} vehicle - The vehicle element
* @return {VehicleData} The vehicles's data (class instance)
*/
* @param {Vehicle} vehicle - The vehicle element
* @return {VehicleData} The vehicles's data (class instance)
*/
function getVehicleData(vehicle) {
if(getGame() != VRR_GAME_GTA_IV) {
if(isVehicleObject(vehicle)) {
@@ -215,7 +212,7 @@ function createVehicleCommand(command, params, client) {
let frontPos = getPosInFrontOfPos(getPlayerPosition(client), getPlayerHeading(client), getGlobalConfig().spawnCarDistance);
let vehicle = createPermanentVehicle(modelIndex, frontPos, heading, getPlayerInterior(client), getPlayerDimension(client));
messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} {MAINCOLOUR}created a {vehiclePurple}${getVehicleName(vehicle)}!`);
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} created a {vehiclePurple}${getVehicleName(vehicle)}`);
}
// ===========================================================================
@@ -236,22 +233,38 @@ function createTemporaryVehicleCommand(command, params, client) {
let frontPos = getPosInFrontOfPos(getPlayerPosition(client), getPlayerHeading(client), getGlobalConfig().spawnCarDistance);
let vehicle = createTemporaryVehicle(modelIndex, frontPos, getPlayerHeading(client), getPlayerInterior(client), getPlayerDimension(client));
messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} {MAINCOLOUR}created a temporary {vehiclePurple}${getVehicleName(vehicle)}`);
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} created a temporary {vehiclePurple}${getVehicleName(vehicle)}`);
}
// ===========================================================================
function getNearbyVehiclesCommand(command, params, client) {
let distance = getParam(params, " ", 1) || 10.0;
let distance = 10.0;
let nearbyVehicles = getElementsByTypeInRange(ELEMENT_VEHICLE, getPlayerPosition, distance);
if(!areParamsEmpty(params)) {
distance = getParam(params, " ", 1);
}
if(isNaN(distance)) {
messagePlayerError(client, "The distance must be a number!");
return false;
}
distance = toFloat(distance);
if(distance <= 0) {
messagePlayerError(client, "The distance must be more than 0!");
return false;
}
let nearbyVehicles = getVehiclesInRange(getPlayerPosition(client), distance);
if(nearbyVehicles.length == 0) {
messagePlayerAlert(client, getLocaleString(client, "NoVehiclesWithinRange", distance));
return false;
}
let vehiclesList = getServerData().radioStations.map(function(x) { return `{ALTCOLOUR}${getVehicleData(x).index}: {MAINCOLOUR}${getVehicleName(x)} {darkGrey}(${getDistance(getPlayerPosition(client), getVehiclePosition(x))} ${getLocaleString(client, "Meters")} ${getGroupedLocaleString(client, "CardinalDirections")[getCardinalDirection(getPlayerPosition(client), getVehiclePosition(x))]}})`; });
let vehiclesList = nearbyVehicles.map(function(x) { return `{ALTCOLOUR}${getVehicleData(x).index}: {MAINCOLOUR}${getVehicleName(x)} {darkGrey}(${getDistance(getPlayerPosition(client), getVehiclePosition(x))} ${getLocaleString(client, "Meters")} ${getGroupedLocaleString(client, "CardinalDirections")[getCardinalDirection(getPlayerPosition(client), getVehiclePosition(x))]}})`; });
let chunkedList = splitArrayIntoChunks(vehiclesList, 4);
messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderVehiclesInRangeList")));
@@ -262,42 +275,6 @@ function getNearbyVehiclesCommand(command, params, client) {
// ===========================================================================
function vehicleLockCommand(command, params, client) {
let vehicle = getClosestVehicle(getPlayerPosition(client));
if(!getPlayerVehicle(client) && getDistance(getVehiclePosition(vehicle), getPlayerPosition(client)) > getGlobalConfig().vehicleLockDistance) {
messagePlayerError(client, getLocaleString(client, "MustBeInOrNearVehicle"));
return false;
}
if(!getVehicleData(vehicle)) {
messagePlayerError(client, getLocaleString(client, "RandomVehicleCommandsDisabled"));
return false;
}
if(isPlayerInAnyVehicle(client)) {
vehicle = getPlayerVehicle(client);
if(!isPlayerInFrontVehicleSeat(client)) {
messagePlayerError(client, getLocaleString(client, "MustBeInVehicleFrontSeat"));
return false;
}
} else {
if(!doesPlayerHaveVehicleKeys(client, vehicle)) {
messagePlayerError(client, getLocaleString(client, "DontHaveVehicleKey"));
return false;
}
}
getVehicleData(vehicle).locked = !getVehicleData(vehicle).locked;
vehicle.locked = getVehicleData(vehicle).locked;
getVehicleData(vehicle).needsSaved = true;
meActionToNearbyPlayers(client, `${toLowerCase(getLockedUnlockedFromBool(getVehicleData(vehicle).locked))} the ${getVehicleName(vehicle)}`);
}
// ===========================================================================
function vehicleTrunkCommand(command, params, client) {
let vehicle = getClosestVehicle(getPlayerPosition(client));
@@ -318,8 +295,8 @@ function vehicleTrunkCommand(command, params, client) {
}
getVehicleData(vehicle).trunk = !getVehicleData(vehicle).trunk;
getVehicleData(vehicle).needsSaved = true;
setVehicleTrunkState(vehicle, getVehicleData(vehicle).trunk);
meActionToNearbyPlayers(client, `${toLowerCase(getOpenedClosedFromBool(getVehicleData(vehicle).trunk))} the ${getVehicleName(vehicle)}'s trunk.`);
}
@@ -345,8 +322,8 @@ function vehicleLightsCommand(command, params, client) {
}
getVehicleData(vehicle).lights = !getVehicleData(vehicle).lights;
setVehicleLightsState(vehicle, getVehicleData(vehicle).lights);
getVehicleData(vehicle).needsSaved = true;
setVehicleLightsState(vehicle, getVehicleData(vehicle).lights);
meActionToNearbyPlayers(client, `turned the ${getVehicleName(vehicle)}'s lights ${toLowerCase(getOnOffFromBool(getVehicleData(vehicle).lights))}`);
}
@@ -570,6 +547,7 @@ function buyVehicleCommand(command, params, client) {
setPlayerBuyingVehicleState(client, VRR_VEHBUYSTATE_TESTDRIVE, vehicle.id, getVehiclePosition(vehicle));
meActionToNearbyPlayers(client, `receives a set of keys to test drive the ${getVehicleName(vehicle)} and starts the engine`);
messagePlayerInfo(client, getLocaleString(client, "DealershipPurchaseTestDrive"));
getServerData().purchasingVehicleCache.push(client);
}
// ===========================================================================
@@ -608,10 +586,15 @@ function rentVehicleCommand(command, params, client) {
}
}
if(getVehicleData(vehicle).rentPrice > getPlayerCurrentSubAccount(client).cash) {
messagePlayerError(client, getLocaleString(client, "NotEnoughCashNeedAmountMore", getVehicleData(vehicle).rentPrice-getPlayerCurrentSubAccount(client).cash));
return false;
}
getVehicleData(vehicle).rentedBy = client;
getPlayerData(client).rentingVehicle = vehicle;
getVehicleData(vehicle).rentStart = getCurrentUnixTimestamp();
getServerData().rentingVehicleCache.push(client);
getVehicleData(vehicle).needsSaved = true;
meActionToNearbyPlayers(client, `rents the ${getVehicleName(vehicle)} and receives a set of vehicle keys!`);
@@ -731,6 +714,11 @@ function setVehicleJobCommand(command, params, client) {
let vehicle = getPlayerVehicle(client);
if(!getVehicleData(vehicle)) {
messagePlayerError(client, getLocaleString(client, "RandomVehicleCommandsDisabled"));
return false;
}
let closestJobLocation = getClosestJobLocation(getVehiclePosition(vehicle));
let jobId = closestJobLocation.job;
@@ -749,7 +737,7 @@ function setVehicleJobCommand(command, params, client) {
getVehicleData(vehicle).needsSaved = true;
messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} {MAINCOLOUR}set their {vehiclePurple}${getVehicleName(vehicle)} {MAINCOLOUR}owner to the {jobYellow}${getJobData(jobId).name} {MAINCOLOUR}job! (Job ID ${jobId})`);
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} set their {vehiclePurple}${getVehicleName(vehicle)}{MAINCOLOUR} owner to the {jobYellow}${getJobData(jobId).name} {MAINCOLOUR}job! (Job ID ${jobId})`);
}
// ===========================================================================
@@ -766,9 +754,13 @@ function setVehicleRankCommand(command, params, client) {
}
let vehicle = getPlayerVehicle(client);
let rankId = params;
if(!getVehicleData(vehicle)) {
messagePlayerError(client, getLocaleString(client, "RandomVehicleCommandsDisabled"));
return false;
}
if(getVehicleData(vehicle).ownerType == VRR_VEHOWNER_CLAN) {
rankId = getClanRankFromParams(getVehicleData(vehicle).ownerId, params);
if(!getClanRankData(getVehicleData(vehicle).ownerId, rankId)) {
@@ -776,10 +768,10 @@ function setVehicleRankCommand(command, params, client) {
return false;
}
getVehicleData(vehicle).rank = getClanRankData(getVehicleData(vehicle).ownerId, rankId).databaseId;
messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} {MAINCOLOUR}set their {vehiclePurple}${getVehicleName(vehicle)} {MAINCOLOUR}rank to {ALTCOLOUR}${getClanRankData(getVehicleData(vehicle).ownerId, rankId).name} {MAINCOLOUR}of the {clanOrange}${getClanData(getVehicleData(vehicle).ownerId).name} [#FFFFFFclan!`);
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} set their {vehiclePurple}${getVehicleName(vehicle)}{MAINCOLOUR} rank to {ALTCOLOUR}${getClanRankData(getVehicleData(vehicle).ownerId, rankId).name}{MAINCOLOUR} of the {clanOrange}${getClanData(getVehicleData(vehicle).ownerId).name}{MAINCOLOUR} clan!`);
} else if(getVehicleData(vehicle).ownerType == VRR_VEHOWNER_JOB) {
getVehicleData(vehicle).rank = rankId;
messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} {MAINCOLOUR}set their {vehiclePurple}${getVehicleName(vehicle)} {MAINCOLOUR}rank to {ALTCOLOUR}${rankId} {MAINCOLOUR}of the {jobYellow}${getJobData(getJobIdFromDatabaseId(getVehicleData(vehicle).ownerId)).name} {MAINCOLOUR}job!`);
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} set their {vehiclePurple}${getVehicleName(vehicle)}{MAINCOLOUR} rank to {ALTCOLOUR}${rankId}{MAINCOLOUR} of the {jobYellow}${getJobData(getJobIdFromDatabaseId(getVehicleData(vehicle).ownerId)).name}{MAINCOLOUR} job!`);
}
getVehicleData(vehicle).needsSaved = true;
@@ -796,6 +788,11 @@ function setVehicleClanCommand(command, params, client) {
let vehicle = getPlayerVehicle(client);
let clanId = getPlayerClan(client);
if(!getVehicleData(vehicle)) {
messagePlayerError(client, getLocaleString(client, "RandomVehicleCommandsDisabled"));
return false;
}
if(!getClanData(clanId)) {
messagePlayerError(client, "That clan is invalid or doesn't exist!");
return false;
@@ -811,7 +808,7 @@ function setVehicleClanCommand(command, params, client) {
return false;
}
showPlayerPromptGUI(client, getLocaleString(client, "SetVehicleClanConfirmMessage"), getLocaleString(client, "SetVehicleClanConfirm"), getLocaleString(client, "Yes"), getLocaleString(client, "No"));
showPlayerPrompt(client, getLocaleString(client, "SetVehicleClanConfirmMessage"), getLocaleString(client, "SetVehicleClanConfirmTitle"), getLocaleString(client, "Yes"), getLocaleString(client, "No"));
getPlayerData(client).promptType = VRR_PROMPT_GIVEVEHTOCLAN;
getVehicleData(vehicle).needsSaved = true;
@@ -826,12 +823,22 @@ function setVehicleToBusinessCommand(command, params, client) {
}
let vehicle = getPlayerVehicle(client);
let businessId = toInteger(isPlayerInAnyBusiness(client)) ? getPlayerBusiness(client) : getClosestBusinessEntrance(getPlayerPosition(client));
let businessId = getPlayerBusiness(client);
if(!getVehicleData(vehicle)) {
messagePlayerError(client, getLocaleString(client, "RandomVehicleCommandsDisabled"));
return false;
}
if(!getBusinessData(businessId)) {
messagePlayerError(client, getLocaleString(client, "InvalidBusiness"));
return false;
}
getVehicleData(vehicle).ownerType = VRR_VEHOWNER_BIZ;
getVehicleData(vehicle).ownerId = getBusinessData(businessId).databaseId;
messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} {MAINCOLOUR}set their {vehiclePurple}${getVehicleName(vehicle)} {MAINCOLOUR}owner to the {businessBlue}${getBusinessData(businessId).name} {MAINCOLOUR}business`);
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} set their {vehiclePurple}${getVehicleName(vehicle)}{MAINCOLOUR} owner to the {businessBlue}${getBusinessData(businessId).name} {MAINCOLOUR}business`);
getVehicleData(vehicle).needsSaved = true;
}
@@ -847,6 +854,11 @@ function setVehicleOwnerCommand(command, params, client) {
let vehicle = getPlayerVehicle(client);
let targetClient = getPlayerFromParams(params);
if(!getVehicleData(vehicle)) {
messagePlayerError(client, getLocaleString(client, "RandomVehicleCommandsDisabled"));
return false;
}
if(!targetClient) {
messagePlayerError(client, "That player is invalid or isn't connected!");
return false;
@@ -855,7 +867,7 @@ function setVehicleOwnerCommand(command, params, client) {
getVehicleData(vehicle).ownerType = VRR_VEHOWNER_PLAYER;
getVehicleData(vehicle).ownerId = getPlayerCurrentSubAccount(targetClient).databaseId;
messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} {MAINCOLOUR}set their {vehiclePurple}${getVehicleName(vehicle)} {MAINCOLOUR}owner to {ALTCOLOUR}${getClientSubAccountName(targetClient)}`);
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} set their {vehiclePurple}${getVehicleName(vehicle)}{MAINCOLOUR} owner to {ALTCOLOUR}${getClientSubAccountName(targetClient)}`);
getVehicleData(vehicle).needsSaved = true;
}
@@ -870,10 +882,15 @@ function setVehiclePublicCommand(command, params, client) {
let vehicle = getPlayerVehicle(client);
if(!getVehicleData(vehicle)) {
messagePlayerError(client, getLocaleString(client, "RandomVehicleCommandsDisabled"));
return false;
}
getVehicleData(vehicle).ownerType = VRR_VEHOWNER_PUBLIC;
getVehicleData(vehicle).ownerId = 0;
messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} {MAINCOLOUR}set their {vehiclePurple}${getVehicleName(vehicle)} {MAINCOLOUR}a public vehicle!`);
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} set their {vehiclePurple}${getVehicleName(vehicle)}{MAINCOLOUR} to a public vehicle!`);
getVehicleData(vehicle).needsSaved = true;
}
@@ -888,6 +905,11 @@ function setVehicleRentPriceCommand(command, params, client) {
let vehicle = getPlayerVehicle(client);
if(!getVehicleData(vehicle)) {
messagePlayerError(client, getLocaleString(client, "RandomVehicleCommandsDisabled"));
return false;
}
if(!doesClientOwnVehicle(client, vehicle)) {
if(!doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageVehicles"))) {
messagePlayerError(client, "You can't set the rent price for this vehicle!");
@@ -899,9 +921,7 @@ function setVehicleRentPriceCommand(command, params, client) {
getVehicleData(vehicle).rentPrice = amount;
getVehicleData(vehicle).needsSaved = true;
messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} {MAINCOLOUR}set their {vehiclePurple}${getVehicleName(vehicle)} {MAINCOLOUR}rent price to {ALTCOLOUR}$${makeLargeNumberReadable(amount)}`);
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} set their {vehiclePurple}${getVehicleName(vehicle)}{MAINCOLOUR} rent price to {ALTCOLOUR}$${makeLargeNumberReadable(amount)}`);
}
// ===========================================================================
@@ -914,6 +934,11 @@ function setVehicleBuyPriceCommand(command, params, client) {
let vehicle = getPlayerVehicle(client);
if(!getVehicleData(vehicle)) {
messagePlayerError(client, getLocaleString(client, "RandomVehicleCommandsDisabled"));
return false;
}
if(!doesClientOwnVehicle(client, vehicle)) {
if(!doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageVehicles"))) {
messagePlayerError(client, "You can't set the buy price for this vehicle!");
@@ -925,7 +950,7 @@ function setVehicleBuyPriceCommand(command, params, client) {
getVehicleData(vehicle).buyPrice = amount;
getVehicleData(vehicle).needsSaved = true;
messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} {MAINCOLOUR}set their {vehiclePurple}${getVehicleName(vehicle)}'s {MAINCOLOUR}buy price to {ALTCOLOUR}$${makeLargeNumberReadable(amount)}`);
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} set their {vehiclePurple}${getVehicleName(vehicle)}'s{MAINCOLOUR} buy price to {ALTCOLOUR}$${makeLargeNumberReadable(amount)}`);
}
// ===========================================================================
@@ -939,6 +964,11 @@ function removeVehicleOwnerCommand(command, params, client) {
let vehicle = getPlayerVehicle(client);
let targetClient = getPlayerFromParams(params);
if(!getVehicleData(vehicle)) {
messagePlayerError(client, getLocaleString(client, "RandomVehicleCommandsDisabled"));
return false;
}
if(!targetClient) {
messagePlayerError(client, "That player is invalid or isn't connected!");
return false;
@@ -949,7 +979,7 @@ function removeVehicleOwnerCommand(command, params, client) {
getVehicleData(vehicle).needsSaved = true;
messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} {MAINCOLOUR}set their {vehiclePurple}${getVehicleName(vehicle)} {MAINCOLOUR}owner to nobody!`);
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} set their {vehiclePurple}${getVehicleName(vehicle)}{MAINCOLOUR} owner to nobody!`);
messagePlayerInfo(client, `Nobody will be able to use this vehicle until it receives a new owner (either bought or set by admin).`);
}
@@ -964,7 +994,7 @@ function getVehicleInfoCommand(command, params, client) {
let vehicle = getPlayerVehicle(client);
if(!getVehicleData(vehicle)) {
messagePlayerError(client, "This is a random traffic vehicle and doesn't have any info");
messagePlayerError(client, getLocaleString(client, "RandomVehicleCommandsDisabled"));
return false;
}
@@ -975,7 +1005,7 @@ function getVehicleInfoCommand(command, params, client) {
ownerType = toLowerCase(getVehicleOwnerTypeText(vehicleData.ownerType));
switch(vehicleData.ownerType) {
case VRR_VEHOWNER_CLAN:
ownerName = getClanData(vehicleData.ownerId).name;
ownerName = getClanData(getClanIdFromDatabaseId(vehicleData.ownerId)).name;
ownerType = "clan";
break;
@@ -991,7 +1021,7 @@ function getVehicleInfoCommand(command, params, client) {
break;
case VRR_VEHOWNER_BIZ:
ownerName = getBusinessData(vehicleData.ownerId).name;
ownerName = getBusinessData(getBusinessIdFromDatabaseId(vehicleData.ownerId)).name;
ownerType = "business";
break;
@@ -1013,7 +1043,7 @@ function getLastVehicleInfoCommand(command, params, client) {
let vehicle = getPlayerLastVehicle(client);
if(!getVehicleData(vehicle)) {
messagePlayerError(client, "This is a random traffic vehicle and doesn't have any info");
messagePlayerError(client, getLocaleString(client, "RandomVehicleCommandsDisabled"));
return false;
}
@@ -1067,7 +1097,7 @@ function toggleVehicleSpawnLockCommand(command, params, client) {
getVehicleData(vehicle).spawnRotation = getVehicleHeading(vehicle);
}
messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} {MAINCOLOUR}set their {vehiclePurple}${getVehicleName(vehicle)} {MAINCOLOUR}to spawn {ALTCOLOUR}${(getVehicleData(vehicle).spawnLocked) ? "at it's current location" : "wherever a player leaves it."}`);
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} set their {vehiclePurple}${getVehicleName(vehicle)}{MAINCOLOUR} to spawn {ALTCOLOUR}${(getVehicleData(vehicle).spawnLocked) ? "at it's current location" : "wherever a player leaves it."}`);
getVehicleData(vehicle).needsSaved = true;
}
@@ -1203,11 +1233,11 @@ function respawnBusinessVehiclesCommand(command, params, client) {
// ===========================================================================
function stopRentingVehicle(client) {
getServerData().rentingVehicleCache.splice(getServerData().rentingVehicleCache.indexOf(client), 1);
let vehicle = getPlayerData(client).rentingVehicle;
getPlayerData(client).rentingVehicle = false;
getVehicleData(vehicle).rentedBy = false;
respawnVehicle(vehicle);
getVehicleData(vehicle).needsSaved = true;
}
// ===========================================================================
@@ -1241,13 +1271,18 @@ function respawnVehicle(vehicle) {
function spawnVehicle(vehicleData) {
logToConsole(LOG_DEBUG, `[VRR.Vehicle]: Spawning ${getVehicleNameFromModel(vehicleData.model)} at ${vehicleData.spawnPosition.x}, ${vehicleData.spawnPosition.y}, ${vehicleData.spawnPosition.z} with heading ${vehicleData.spawnRotation}`);
let vehicle = createGameVehicle(vehicleData.model, vehicleData.spawnPosition, vehicleData.spawnRotation);
setVehicleHeading(vehicle, vehicleData.spawnRotation);
setElementTransient(vehicle, false);
addToWorld(vehicle);
if(!vehicle) {
return false;
}
setVehicleHeading(vehicle, vehicleData.spawnRotation)
setVehicleHeading(vehicle, vehicleData.spawnRotation);
setElementDimension(vehicle, vehicleData.dimension);
addToWorld(vehicle);
vehicleData.vehicle = vehicle;
if(isGameFeatureSupported("vehicleColours")) {
@@ -1267,8 +1302,7 @@ function spawnVehicle(vehicleData) {
setVehicleEngine(vehicle, false);
logToConsole(LOG_VERBOSE, `[VRR.Vehicle]: Setting vehicle ${vehicle.id}'s engine to OFF`);
} else {
setVehicleEngine(vehicle, intToBool(vehicleData.engine));
logToConsole(LOG_VERBOSE, `[VRR.Vehicle]: Setting vehicle ${vehicle.id}'s engine to ${toUpperCase(getOnOffFromBool(getVehicleEngine(vehicle)))}`);
setVehicleEngine(vehicle, intToBool(vehicleData.engine));logToConsole(LOG_VERBOSE, `[VRR.Vehicle]: Setting vehicle ${vehicle.id}'s engine to ${toUpperCase(getOnOffFromBool(getVehicleEngine(vehicle)))}`);
}
if(typeof vehicle.locked != "undefined") {
@@ -1276,8 +1310,6 @@ function spawnVehicle(vehicleData) {
logToConsole(LOG_VERBOSE, `[VRR.Vehicle]: Setting vehicle ${vehicle.id}'s lock state to ${toUpperCase(getOnOffFromBool(getVehicleLocked(vehicle)))}`);
}
setElementDimension(vehicle, vehicleData.dimension);
//setVehicleHealth(vehicle, 1000);
repairVehicle(vehicle);
@@ -1287,14 +1319,16 @@ function spawnVehicle(vehicleData) {
setEntityData(vehicle, "vrr.engine", vehicleData.engine, true);
forcePlayerToSyncElementProperties(null, vehicle);
return vehicle;
}
// ===========================================================================
function isVehicleAtPayAndSpray(vehicle) {
for(let i in getServerData().payAndSprays[getServerGame()]) {
if(getDistance(getVehiclePosition(vehicle), getServerData().payAndSprays[getServerGame()][i].position) <= getGlobalConfig().payAndSprayDistance) {
for(let i in getServerData().payAndSprays[getGame()]) {
if(getDistance(getVehiclePosition(vehicle), getServerData().payAndSprays[getGame()][i].position) <= getGlobalConfig().payAndSprayDistance) {
return true;
}
}
@@ -1433,9 +1467,9 @@ function processVehiclePurchasing() {
return false;
}
let clients = getClients();
for(let i in clients) {
checkVehicleBuying(clients[i]);
let purchasingVehicles = getServerData().purchasingVehicleCache;
for(let i in purchasingVehicles) {
checkVehiclePurchasing(purchasingVehicles[i]);
}
return false;
@@ -1443,7 +1477,7 @@ function processVehiclePurchasing() {
// ===========================================================================
function checkVehicleBuying(client) {
function checkVehiclePurchasing(client) {
if(!isPlayerLoggedIn(client)) {
setPlayerBuyingVehicleState(client, VRR_VEHBUYSTATE_NONE, null, null);
return false;
@@ -1466,6 +1500,7 @@ function checkVehicleBuying(client) {
if(!isPlayerInAnyVehicle(client)) {
if(getPlayerData(client).buyingVehicle != false) {
getServerData().purchasingVehicleCache.splice(getServerData().purchasingVehicleCache.indexOf(client), 1);
messagePlayerError(client, getLocaleString(client, "DealershipPurchaseExitedVehicle"));
respawnVehicle(getPlayerData(client).buyingVehicle);
getPlayerData(client).buyingVehicle = false;
@@ -1476,6 +1511,7 @@ function checkVehicleBuying(client) {
if(getDistance(getVehiclePosition(getPlayerData(client).buyingVehicle), getVehicleData(getPlayerData(client).buyingVehicle).spawnPosition) > getGlobalConfig().buyVehicleDriveAwayDistance) {
if(getPlayerCurrentSubAccount(client).cash < getVehicleData(getPlayerData(client).buyingVehicle).buyPrice) {
getServerData().purchasingVehicleCache.splice(getServerData().purchasingVehicleCache.indexOf(client), 1);
messagePlayerError(client, getLocaleString(client, "VehiclePurchaseNotEnoughMoney"));
respawnVehicle(getPlayerData(client).buyingVehicle);
getPlayerData(client).buyingVehicle = false;
@@ -1483,6 +1519,7 @@ function checkVehicleBuying(client) {
return false;
}
getServerData().purchasingVehicleCache.splice(getServerData().purchasingVehicleCache.indexOf(client), 1);
createNewDealershipVehicle(getVehicleData(getPlayerData(client).buyingVehicle).model, getVehicleData(getPlayerData(client).buyingVehicle).spawnPosition, getVehicleData(getPlayerData(client).buyingVehicle).spawnRotation, getVehicleData(getPlayerData(client).buyingVehicle).buyPrice, getVehicleData(getPlayerData(client).buyingVehicle).ownerId);
takePlayerCash(client, getVehicleData(getPlayerData(client).buyingVehicle).buyPrice);
updatePlayerCash(client);
@@ -1501,10 +1538,16 @@ function checkVehicleBuying(client) {
// ===========================================================================
function processVehicleBurning() {
if(!getGlobalConfig().useServerSideVehicleBurnCheck) {
return false;
}
let vehicles = getElementsByType(ELEMENT_VEHICLE);
for(let i in vehicles) {
if(vehicles[i].health <= 250) {
return false;
if(vehicles[i].syncer == null) {
if(vehicles[i].health <= 250) {
vehicles[i].health = 250;
}
}
}
}