Server settings

This commit is contained in:
Vortrex
2022-03-03 01:43:32 -06:00
parent e950ad0a00
commit 3de970c7e7
4 changed files with 136 additions and 37 deletions

View File

@@ -106,7 +106,7 @@ function toggleAccountGUICommand(command, params, client) {
if(!isPlayerLoggedIn(client)) {
if(getPlayerData().accountData.databaseId != 0) {
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
if(doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) {
showPlayerLoginGUI(client);
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the login GUI`);
} else {
@@ -115,7 +115,7 @@ function toggleAccountGUICommand(command, params, client) {
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the login message (GUI disabled)`);
}
} else {
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
if(doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) {
showPlayerRegistrationGUI(client);
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the register GUI`);
} else {
@@ -566,8 +566,24 @@ function loginSuccess(client) {
client.administrator = true;
}
if(hasBitFlag(getServerConfig().settings, getServerSettingsFlagValue("Testing"))) {
if(!hasBitFlag(getPlayerData(client).accountData.flags.moderation, getModerationFlagValue("IsTester"))) {
if(doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) {
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the error GUI (not a tester).`);
showPlayerErrorGUI(client, getLocaleString(client, "NotATester"), getLocaleString(client, "AccessDenied"));
} else {
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the login message (GUI disabled).`);
messagePlayerError(client, getLocaleString(client, "NotATester"));
}
setTimeout(function() {
client.disconnect();
}, 3500);
return false;
}
}
if(getPlayerData(client).subAccounts.length == 0) {
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
if(doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) {
showPlayerPromptGUI(client, `You have no characters. Would you like to make one?`, "No characters");
getPlayerData(client).promptType = VRR_PROMPT_CREATEFIRSTCHAR;
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the no characters prompt GUI`);
@@ -760,7 +776,7 @@ function checkLogin(client, password) {
if(isPlayerLoggedIn(client)) {
logToConsole(LOG_WARN, `[VRR.Account] ${getPlayerDisplayForConsole(client)} attempted to login but is already logged in`);
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
if(doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) {
showPlayerLoginSuccessGUI(client);
} else {
messagePlayerError(client, "You are already logged in!");
@@ -771,7 +787,7 @@ function checkLogin(client, password) {
if(!isPlayerRegistered(client)) {
logToConsole(LOG_WARN, `[VRR.Account] ${getPlayerDisplayForConsole(client)} attempted to login but is not registered`);
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
if(doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) {
showPlayerRegistrationGUI(client);
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the register GUI`);
} else {
@@ -783,7 +799,7 @@ function checkLogin(client, password) {
if(areParamsEmpty(password)) {
logToConsole(LOG_WARN, `[VRR.Account] ${getPlayerDisplayForConsole(client)} attempted to login but failed (empty password). ${getPlayerData(client).loginAttemptsRemaining} login attempts remaining`);
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
if(doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) {
showPlayerLoginFailedGUI(client, `Invalid password! ${getPlayerData(client).loginAttemptsRemaining} tries remaining.`);
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the login GUI with ${getPlayerData(client).loginAttemptsRemaining} login attempts remaining alert.`);
} else {
@@ -799,7 +815,7 @@ function checkLogin(client, password) {
if(!isAccountPasswordCorrect(getPlayerData(client).accountData, hashAccountPassword(getPlayerName(client), password))) {
logToConsole(LOG_WARN, `[VRR.Account] ${getPlayerDisplayForConsole(client)} attempted to login but failed (wrong password). ${getPlayerData(client).loginAttemptsRemaining} login attempts remaining`);
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
if(doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) {
showPlayerLoginFailedGUI(client, `Invalid password! ${getPlayerData(client).loginAttemptsRemaining} tries remaining.`);
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the login GUI with ${getPlayerData(client).loginAttemptsRemaining} login attempts remaining alert.`);
} else {
@@ -819,7 +835,7 @@ function checkLogin(client, password) {
// return true;
//}
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
if(doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) {
showPlayerLoginSuccessGUI(client);
}
@@ -836,7 +852,7 @@ function checkRegistration(client, password, confirmPassword = "", emailAddress
logToConsole(LOG_DEBUG, `[VRR.Account]: Checking registration for ${getPlayerName(client)}`);
if(isPlayerRegistered(client)) {
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
if(doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) {
showPlayerLoginGUI(client);
} else {
messagePlayerError(client, getLocaleString(client, "AlreadyRegistered"));
@@ -846,7 +862,7 @@ function checkRegistration(client, password, confirmPassword = "", emailAddress
}
if(isPlayerLoggedIn(client)) {
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
if(doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) {
showPlayerLoginSuccessGUI(client);
} else {
messagePlayerError(client, getLocaleString(client, "AlreadyLoggedIn"));
@@ -856,7 +872,7 @@ function checkRegistration(client, password, confirmPassword = "", emailAddress
}
if(areParamsEmpty(password)) {
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
if(doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) {
showPlayerRegistrationFailedGUI(client, getLocaleString(client, "RegistrationFailedNoPassword"));
logToConsole(LOG_WARN, `${getPlayerDisplayForConsole(client)} failed to create an account (password is blank)`);
} else {
@@ -866,7 +882,7 @@ function checkRegistration(client, password, confirmPassword = "", emailAddress
return false;
}
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
if(doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) {
if(areParamsEmpty(confirmPassword)) {
showPlayerRegistrationFailedGUI(client, getLocaleString(client, "RegistrationFailedNoPasswordConfirm"));
logToConsole(LOG_WARN, `${getPlayerDisplayForConsole(client)} failed to create an account (password confirm is blank)`);
@@ -874,7 +890,7 @@ function checkRegistration(client, password, confirmPassword = "", emailAddress
}
}
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
if(doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) {
if(areParamsEmpty(emailAddress)) {
showPlayerRegistrationFailedGUI(client, getLocaleString(client, "RegistrationFailedNoEmail"));
logToConsole(LOG_WARN, `${getPlayerDisplayForConsole(client)} failed to create an account (email address is blank)`);
@@ -882,7 +898,7 @@ function checkRegistration(client, password, confirmPassword = "", emailAddress
}
}
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
if(doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) {
if(password != confirmPassword) {
showPlayerRegistrationFailedGUI(client, getLocaleString(client, "RegistrationFailedPasswordMismatch"));
logToConsole(LOG_WARN, `${getPlayerDisplayForConsole(client)} failed to create an account (password and confirm don't match)`);
@@ -891,7 +907,7 @@ function checkRegistration(client, password, confirmPassword = "", emailAddress
}
if(!doesPasswordMeetRequirements(password)) {
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
if(doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) {
// Work on this later. Function should return true by default anyway for now.
showPlayerRegistrationFailedGUI(client, getLocaleString(client, "RegistrationFailedNoPasswordWeak"));
logToConsole(LOG_WARN, `${getPlayerDisplayForConsole(client)} failed to create an account (password doesn't meet requirements)`);
@@ -901,7 +917,7 @@ function checkRegistration(client, password, confirmPassword = "", emailAddress
return false
}
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
if(doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) {
if(!isValidEmailAddress(emailAddress)) {
showPlayerRegistrationFailedGUI(client, getLocaleString(client, "RegistrationFailedInvalidEmail"));
return false
@@ -910,7 +926,7 @@ function checkRegistration(client, password, confirmPassword = "", emailAddress
let accountData = createAccount(getPlayerName(client), password, emailAddress);
if(!accountData) {
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
if(doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) {
showPlayerRegistrationFailedGUI(client, getLocaleString(client, "RegistrationFailedCreateError"));
} else {
messagePlayerAlert(client, getLocaleString(client, "RegistrationFailedCreateError"));
@@ -929,7 +945,7 @@ function checkRegistration(client, password, confirmPassword = "", emailAddress
}
messagePlayerAlert(client, getLocaleString(client, "RegistrationCreateCharReminder"));
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
if(doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) {
showPlayerRegistrationSuccessGUI(client);
showPlayerPromptGUI(client, getLocaleString(client, "NoCharactersMessage"), getLocaleString(client, "NoCharactersWindowTitle"), getLocaleString(client, "Yes"), getLocaleString(client, "No"));
getPlayerData(client).promptType = VRR_PROMPT_CREATEFIRSTCHAR;
@@ -1084,6 +1100,12 @@ function initClient(client) {
return false;
}
if(client.getData("vrr.isInitialized") != null || client.getData("vrr.isInitialized") == true) {
return false;
}
client.setData("vrr.isInitialized", true, false);
sendPlayerGUIColours(client);
sendPlayerGUIInit(client);
updatePlayerSnowState(client);
@@ -1109,7 +1131,7 @@ function initClient(client) {
messagePlayerAlert(client, getLocaleString(client, "AutoLoggedInIP"));
loginSuccess(client);
} else {
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
if(doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) {
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the login GUI.`);
showPlayerLoginGUI(client);
} else {
@@ -1119,7 +1141,7 @@ function initClient(client) {
playRadioStreamForPlayer(client, getServerIntroMusicURL(), true, getPlayerStreamingRadioVolume(client));
}
} else {
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
if(doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) {
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the register GUI.`);
showPlayerRegistrationGUI(client);
} else {

View File

@@ -163,7 +163,6 @@ function saveServerConfigToDatabase() {
if(dbConnection) {
let data = [
["svr_settings", toInteger(getServerConfig().settings)],
["svr_gui", boolToInt(hasBitFlag(getServerConfig().settings, getServerSettingsFlagValue("GUI")))],
["svr_start_time_hour", getServerConfig().hour],
["svr_start_time_min", getServerConfig().minute],
["svr_start_weather", getServerConfig().weather],
@@ -492,10 +491,14 @@ function toggleServerLogoCommand(command, params, client) {
*
*/
function toggleServerBusinessBlipsCommand(command, params, client) {
getServerConfig().createBusinessBlips = !getServerConfig().createBusinessBlips;
if(doesServerHaveBusinessBlipsEnabled()) {
getServerConfig().settings = removeBitFlag(getServerConfig().settings, getServerSettingsFlagValue("BusinessBlips"));
} else {
getServerConfig().settings = addBitFlag(getServerConfig().settings, getServerSettingsFlagValue("BusinessBlips"));
}
getServerConfig().needsSaved = true;
messageAdminAction(`${getPlayerName(client)} {MAINCOLOUR}turned ${getBoolRedGreenInlineColour(getServerConfig().createBusinessBlips)}${toUpperCase(getOnOffFromBool(getServerConfig().createBusinessBlips))} {MAINCOLOUR}all business blips`);
messageAdminAction(`${getPlayerName(client)} {MAINCOLOUR}turned ${getBoolRedGreenInlineColour(doesServerHaveBusinessBlipsEnabled())}${toUpperCase(getOnOffFromBool(getServerConfig().createBusinessBlips))} {MAINCOLOUR}all business blips`);
resetAllBusinessBlips();
return true;
}
@@ -512,10 +515,14 @@ function toggleServerLogoCommand(command, params, client) {
*
*/
function toggleServerBusinessPickupsCommand(command, params, client) {
getServerConfig().createBusinessPickups = !getServerConfig().createBusinessPickups;
if(doesServerHaveBusinessPickupsEnabled()) {
getServerConfig().settings = removeBitFlag(getServerConfig().settings, getServerSettingsFlagValue("BusinessPickups"));
} else {
getServerConfig().settings = addBitFlag(getServerConfig().settings, getServerSettingsFlagValue("BusinessPickups"));
}
getServerConfig().needsSaved = true;
messageAdminAction(`${getPlayerName(client)} {MAINCOLOUR}turned ${getBoolRedGreenInlineColour(getServerConfig().createBusinessPickups)}${toUpperCase(getOnOffFromBool(getServerConfig().createBusinessPickups))} {MAINCOLOUR}all business pickups`);
messageAdminAction(`${getPlayerName(client)} {MAINCOLOUR}turned ${getBoolRedGreenInlineColour(doesServerHaveBusinessPickupsEnabled())}${toUpperCase(getOnOffFromBool(getServerConfig().createBusinessPickups))} {MAINCOLOUR}all business pickups`);
resetAllBusinessPickups();
return true;
}
@@ -532,10 +539,14 @@ function toggleServerLogoCommand(command, params, client) {
*
*/
function toggleServerHouseBlipsCommand(command, params, client) {
getServerConfig().createHouseBlips = !getServerConfig().createHouseBlips;
if(doesServerHaveHouseBlipsEnabled()) {
getServerConfig().settings = removeBitFlag(getServerConfig().settings, getServerSettingsFlagValue("HousePickups"));
} else {
getServerConfig().settings = addBitFlag(getServerConfig().settings, getServerSettingsFlagValue("HouseBlips"));
}
getServerConfig().needsSaved = true;
messageAdminAction(`${getPlayerName(client)} {MAINCOLOUR}turned ${getBoolRedGreenInlineColour(getServerConfig().createHouseBlips)}${toUpperCase(getOnOffFromBool(getServerConfig().createHouseBlips))} {MAINCOLOUR}all house blips`);
messageAdminAction(`${getPlayerName(client)} {MAINCOLOUR}turned ${getBoolRedGreenInlineColour(doesServerHaveHouseBlipsEnabled())}${toUpperCase(getOnOffFromBool(getServerConfig().createHouseBlips))} {MAINCOLOUR}all house blips`);
resetAllHouseBlips();
return true;
}
@@ -552,10 +563,14 @@ function toggleServerLogoCommand(command, params, client) {
*
*/
function toggleServerHousePickupsCommand(command, params, client) {
getServerConfig().createHousePickups = !getServerConfig().createHousePickups;
if(doesServerHaveHousePickupsEnabled()) {
getServerConfig().settings = removeBitFlag(getServerConfig().settings, getServerSettingsFlagValue("HousePickups"));
} else {
getServerConfig().settings = addBitFlag(getServerConfig().settings, getServerSettingsFlagValue("HousePickups"));
}
getServerConfig().needsSaved = true;
messageAdminAction(`${getPlayerName(client)} {MAINCOLOUR}turned ${getBoolRedGreenInlineColour(getServerConfig().createHousePickups)}${toUpperCase(getOnOffFromBool(getServerConfig().createHousePickups))} {MAINCOLOUR}all house pickups`);
messageAdminAction(`${getPlayerName(client)} {MAINCOLOUR}turned ${getBoolRedGreenInlineColour(doesServerHaveHousePickupsEnabled())}${toUpperCase(getOnOffFromBool(getServerConfig().createHousePickups))} {MAINCOLOUR}all house pickups`);
resetAllHousePickups();
return true;
}
@@ -572,10 +587,15 @@ function toggleServerLogoCommand(command, params, client) {
*
*/
function toggleServerGUICommand(command, params, client) {
getServerConfig().useGUI = !getServerConfig().useGUI;
if(doesServerHaveGUIEnabled()) {
getServerConfig().settings = removeBitFlag(getServerConfig().settings, getServerSettingsFlagValue("GUI"));
} else {
getServerConfig().settings = addBitFlag(getServerConfig().settings, getServerSettingsFlagValue("GUI"));
}
getServerConfig().needsSaved = true;
messageAdminAction(`${getPlayerName(client)} {MAINCOLOUR}turned GUI ${toLowerCase(getOnOffFromBool(getServerConfig().useGUI))} for this server`);
messageAdminAction(`${getPlayerName(client)} {MAINCOLOUR}turned GUI ${toLowerCase(getOnOffFromBool(doesServerHaveGUIEnabled()))} for this server`);
updateServerRules();
return true;
}
@@ -592,10 +612,15 @@ function toggleServerGUICommand(command, params, client) {
*
*/
function toggleServerUseRealWorldTimeCommand(command, params, client) {
getServerConfig().useRealTime = !getServerConfig().useRealTime;
if(doesServerHaveRealTimeEnabled()) {
getServerConfig().settings = removeBitFlag(getServerConfig().settings, getServerSettingsFlagValue("RealTime"));
} else {
getServerConfig().settings = addBitFlag(getServerConfig().settings, getServerSettingsFlagValue("RealTime"));
}
getServerConfig().needsSaved = true;
messageAdminAction(`${getPlayerName(client)} {MAINCOLOUR}turned real-world time ${toLowerCase(getOnOffFromBool(getServerConfig().useRealTime))} for this server (GMT ${addPositiveNegativeSymbol(getServerConfig().realTimeZone)})`);
messageAdminAction(`${getPlayerName(client)} {MAINCOLOUR}turned real-world time ${toLowerCase(getOnOffFromBool(doesServerHaveRealTimeEnabled()))} for this server (GMT ${addPositiveNegativeSymbol(getServerConfig().realTimeZone)})`);
updateServerGameTime();
updateServerRules();
return true;
@@ -726,3 +751,57 @@ function loadAccentConfig() {
}
// ===========================================================================
function doesServerHaveGUIEnabled() {
return hasBitFlag(getServerConfig().settings, getServerSettingsFlagValue("GUI"));
}
// ===========================================================================
function doesServerHaveTesterOnlyEnabled() {
return hasBitFlag(getServerConfig().settings, getServerSettingsFlagValue("Testing"));
}
// ===========================================================================
function doesServerHaveRealTimeEnabled() {
return hasBitFlag(getServerConfig().settings, getServerSettingsFlagValue("RealTime"));
}
// ===========================================================================
function doesServerHaveBusinessPickupsEnabled() {
return hasBitFlag(getServerConfig().settings, getServerSettingsFlagValue("BusinessPickups"));
}
// ===========================================================================
function doesServerHaveHousePickupsEnabled() {
return hasBitFlag(getServerConfig().settings, getServerSettingsFlagValue("HousePickups"));
}
// ===========================================================================
function doesServerHaveJobPickupsEnabled() {
return hasBitFlag(getServerConfig().settings, getServerSettingsFlagValue("JobPickups"));
}
// ===========================================================================
function doesServerHaveBusinesBlipsEnabled() {
return hasBitFlag(getServerConfig().settings, getServerSettingsFlagValue("BusinessBlips"));
}
// ===========================================================================
function doesServerHaveHouseBlipsEnabled() {
return hasBitFlag(getServerConfig().settings, getServerSettingsFlagValue("HouseBlips"));
}
// ===========================================================================
function doesServerHaveJobBlipsEnabled() {
return hasBitFlag(getServerConfig().settings, getServerSettingsFlagValue("JobBlips"));
}
// ===========================================================================

View File

@@ -99,7 +99,7 @@ function playerPromptAnswerYes(client) {
// ===========================================================================
function canPlayerUseGUI(client) {
return (getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client));
return (doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client));
}
// ===========================================================================

View File

@@ -430,5 +430,3 @@ function kickAllClients() {
client.disconnect();
})
}
// ===========================================================================