diff --git a/scripts/client/chat.js b/scripts/client/chat.js index 3d23d142..c5f107d8 100644 --- a/scripts/client/chat.js +++ b/scripts/client/chat.js @@ -11,7 +11,6 @@ // =========================================================================== let chatTimeStampsEnabled = false; -let chatProfanityFilterEnabled = false; let chatEmojiEnabled = false; let chatBoxHistory = []; @@ -53,15 +52,19 @@ function unBindChatBoxKeys() { // =========================================================================== -function receiveChatBoxMessageFromServer(messageString, colour) { +function receiveChatBoxMessageFromServer(messageString, colour, hour, minute, second) { logToConsole(LOG_DEBUG, `[VRR.Chat]: Received chatbox message from server: ${messageString}`); // Just in case it's hidden by auto hide //setChatWindowEnabled(true); - let timeStamp = findResourceByName("agrp_time").exports.getCurrentUnixTimeStampSquirrel(); + //let timeStamp = findResourceByName("agrp_time").exports.getCurrentUnixTimeStampSquirrel(); - addToChatBoxHistory(messageString, colour, timeStamp); + hour = fillLeadingZeros(hour, 2); + minute = fillLeadingZeros(minute, 2); + second = fillLeadingZeros(second, 2); + + addToChatBoxHistory(messageString, colour, hour, minute, second); //let unixTimeStampMS = new Date().getTime(); //let timeStampDate = new Date(unixTimeStampMS); @@ -69,23 +72,26 @@ function receiveChatBoxMessageFromServer(messageString, colour) { //let timeStampText = `${timeStampDate.getHours()}:${timeStampDate.getMinutes()}:${timeStampDate.getSeconds()}`; let outputString = messageString; - //let timeStampString = ""; - //if (chatTimeStampsEnabled == true) { - // timeStampString = `{TIMESTAMPCOLOUR}[${findResourceByName("agrp_time").exports.getTimeStampOutput(timeStamp)}]{MAINCOLOUR}`; - //} + if (chatTimeStampsEnabled == true) { + //timeStampString = `{TIMESTAMPCOLOUR}[${findResourceByName("agrp_time").exports.getTimeStampOutput(timeStamp)}]{MAINCOLOUR}`; + let timeStampString = `{TIMESTAMPCOLOUR}[${hour}:${minute}:${second}] `; + outputString = `${timeStampString}${messageString}`; + } logToConsole(LOG_DEBUG, `[VRR.Chat]: Changed colours in string: ${outputString}`); - let colouredString = replaceColoursInMessage(`${timeStampString}${outputString}`); + outputString = replaceColoursInMessage(`${outputString}`); if (chatEmojiEnabled == true) { - colouredString = replaceEmojiInMessage(colouredString); + logToConsole(LOG_DEBUG, `[VRR.Chat]: Enabled emoji in string: ${outputString}`); + outputString = replaceEmojiInMessage(outputString); } - if (chatProfanityFilterEnabled == true) { - colouredString = replaceProfanityInMessage(colouredString); + if (profanityFilterEnabled == true) { + logToConsole(LOG_DEBUG, `[VRR.Chat]: Removed profanity in string: ${outputString}`); + outputString = replaceProfanityInMessage(outputString); } - message(colouredString, colour); + message(outputString, colour); bottomMessageIndex = chatBoxHistory.length - 1; chatLastUse = getCurrentUnixTimestamp(); @@ -106,8 +112,8 @@ function setChatTimeStampsState(state) { // =========================================================================== -function setChatProfanityFilterState(state) { - chatProfanityFilterEnabled = state; +function setChatEmojiState(state) { + chatEmojiEnabled = state; updateChatBox(); } @@ -119,8 +125,8 @@ function setChatAutoHideDelay(delay) { // =========================================================================== -function addToChatBoxHistory(messageString, colour, timeStamp) { - chatBoxHistory.push([messageString, colour, timeStamp]); +function addToChatBoxHistory(messageString, colour, hour, minute, second) { + chatBoxHistory.push([messageString, colour, hour, minute, second]); } // =========================================================================== @@ -159,12 +165,22 @@ function updateChatBox() { if (chatTimeStampsEnabled == true) { //let timeStampDate = new Date(chatBoxHistory[i][2]); //let timeStampText = `${timeStampDate.getHours()}:${timeStampDate.getMinutes()}:${timeStampDate.getSeconds()}`; - let timeStampText = findResourceByName("agrp_time").exports.getTimeStampOutput(chatBoxHistory[i][2]); + //let timeStampText = findResourceByName("agrp_time").exports.getTimeStampOutput(chatBoxHistory[i][2]); + let timeStampText = `${chatBoxHistory[i][2]}:${chatBoxHistory[i][3]}:${chatBoxHistory[i][4]}`; outputString = `{TIMESTAMPCOLOUR}[${timeStampText}]{MAINCOLOUR} ${chatBoxHistory[i][0]}`; } outputString = replaceColoursInMessage(outputString); + + if (chatEmojiEnabled == true) { + outputString = replaceEmojiInMessage(outputString); + } + + if (profanityFilterEnabled == true) { + outputString = replaceProfanityInMessage(outputString); + } + message(outputString, chatBoxHistory[i][1]); } else { message("", COLOUR_WHITE); diff --git a/scripts/client/main.js b/scripts/client/main.js index 7daab5b8..eed985f9 100644 --- a/scripts/client/main.js +++ b/scripts/client/main.js @@ -79,6 +79,8 @@ let guiDownKey = false; // Pre-cache all allowed skins let allowedSkins = getAllowedSkins(getGame()); +let profanityFilterEnabled = false; + let localLocaleId = 0; let serverData = { diff --git a/scripts/client/netevents.js b/scripts/client/netevents.js index 57a3a497..37ff165e 100644 --- a/scripts/client/netevents.js +++ b/scripts/client/netevents.js @@ -24,7 +24,7 @@ function addAllNetworkHandlers() { addNetworkEventHandler("agrp.chatScrollLines", setChatScrollLines); addNetworkEventHandler("agrp.chatAutoHideDelay", setChatAutoHideDelay); addNetworkEventHandler("agrp.chatTimeStamps", setChatTimeStampsState); - addNetworkEventHandler("agrp.chatProfanityFilter", setChatProfanityFilterState); + addNetworkEventHandler("agrp.chatEmoji", setChatEmojiState); // Messaging (like textdraws and stuff) addNetworkEventHandler("agrp.smallGameMessage", showSmallGameMessage); @@ -154,6 +154,7 @@ function addAllNetworkHandlers() { addNetworkEventHandler("agrp.elementCollisions", setElementCollisionsEnabled); addNetworkEventHandler("agrp.vehBuyState", setVehiclePurchaseState); addNetworkEventHandler("agrp.holdObject", makePedHoldObject); + addNetworkEventHandler("agrp.profanityFilter", setProfanityFilterState); } // =========================================================================== diff --git a/scripts/client/utilities.js b/scripts/client/utilities.js index 1e4e9a19..6907cca7 100644 --- a/scripts/client/utilities.js +++ b/scripts/client/utilities.js @@ -616,4 +616,11 @@ function getServerData() { return serverData; } +// =========================================================================== + +function setProfanityFilterState(state) { + profanityFilterEnabled = state; + updateChatBox(); +} + // =========================================================================== \ No newline at end of file diff --git a/scripts/server/account.js b/scripts/server/account.js index 3b6f22ed..9ea80f1c 100644 --- a/scripts/server/account.js +++ b/scripts/server/account.js @@ -298,7 +298,7 @@ function toggleAccountGUICommand(command, params, client) { logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the login GUI`); } else { hideAllPlayerGUI(client); - messagePlayerNormal(client, getLocaleString(client, "WelcomeBack", getServerConfig().name, getPlayerName(client), "{ALTCOLOUR}/login{MAINCOLOUR}")); + 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 { @@ -307,7 +307,7 @@ function toggleAccountGUICommand(command, params, client) { logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the register GUI`); } else { hideAllPlayerGUI(client); - messagePlayerNormal(client, getLocaleString(client, "WelcomeNewPlayer", getServerConfig().name, getPlayerName(client), "{ALTCOLOUR}/register{MAINCOLOUR}")); + 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)`); } } @@ -422,6 +422,23 @@ function toggleAccountProfanityFilterCommand(command, params, client) { // =========================================================================== +function toggleAccountReplaceEmojiCommand(command, params, client) { + let flagValue = getAccountSettingsFlagValue("ChatEmoji"); + + if (hasBitFlag(getPlayerData(client).accountData.settings, flagValue)) { + getPlayerData(client).accountData.settings = removeBitFlag(getPlayerData(client).accountData.settings, flagValue); + messagePlayerSuccess(client, getLocaleString(client, "ChatEmojiSet", `{softRed}${toUpperCase(getLocaleString(client, "Off"))}{MAINCOLOUR}`)); + sendPlayerChatEmojiState(client, false); + } else { + getPlayerData(client).accountData.settings = addBitFlag(getPlayerData(client).accountData.settings, flagValue); + messagePlayerSuccess(client, getLocaleString(client, "ChatEmojiSet", `{softGreen}${toUpperCase(getLocaleString(client, "On"))}{MAINCOLOUR}`)); + sendPlayerChatEmojiState(client, true); + } + return true; +} + +// =========================================================================== + function toggleAccountHideBloodCommand(command, params, client) { let flagValue = getAccountSettingsFlagValue("NoBlood"); @@ -1210,7 +1227,7 @@ function checkRegistration(client, password, confirmPassword = "", emailAddress messagePlayerAlert(client, getLocaleString(client, "RegistrationFailedCreateError")); } - messagePlayerAlert(client, `${getServerConfig().name} staff have been notified of the problem and will fix it shortly.`); + messagePlayerAlert(client, `${getServerName()} staff have been notified of the problem and will fix it shortly.`); return false; } @@ -1469,7 +1486,7 @@ function initClient(client) { showPlayerLoginGUI(client); } else { logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the login message (GUI disabled).`); - messagePlayerNormal(client, getLocaleString(client, "WelcomeBack", getServerConfig().name, getPlayerName(client), "/login"), getColourByName("softGreen")); + messagePlayerNormal(client, getLocaleString(client, "WelcomeBack", getServerName(), getPlayerName(client), "/login"), getColourByName("softGreen")); //if(checkForGeoIPModule()) { // let iso = module.geoip.getCountryISO(getPlayerIP(client)); @@ -1487,7 +1504,7 @@ function initClient(client) { showPlayerRegistrationGUI(client); } else { logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the register message (GUI disabled).`); - messagePlayerNormal(client, getLocaleString(client, "WelcomeNewPlayer", getServerConfig().name, getPlayerName(client), "/register"), getColourByName("softGreen")); + messagePlayerNormal(client, getLocaleString(client, "WelcomeNewPlayer", getServerName(), getPlayerName(client), "/register"), getColourByName("softGreen")); } playRadioStreamForPlayer(client, getServerIntroMusicURL(), true, getPlayerStreamingRadioVolume(client)); } @@ -1725,9 +1742,9 @@ function generateEmailVerificationCode() { function sendEmailVerificationEmail(client, emailVerificationCode) { let emailBodyText = getEmailConfig().bodyContent.confirmEmail; emailBodyText = emailBodyText.replace("{VERIFICATIONCODE}", emailVerificationCode); - emailBodyText = emailBodyText.replace("{SERVERNAME}", getServerConfig().name); + emailBodyText = emailBodyText.replace("{SERVERNAME}", getServerName()); - sendEmail(getPlayerData(client).accountData.emailAddress, getPlayerData(client).accountData.name, `Confirm email on ${getServerConfig().name}`, emailBodyText); + sendEmail(getPlayerData(client).accountData.emailAddress, getPlayerData(client).accountData.name, `Confirm email on ${getServerName()}`, emailBodyText); } // =========================================================================== @@ -1735,9 +1752,9 @@ function sendEmailVerificationEmail(client, emailVerificationCode) { function sendPasswordResetEmail(client, verificationCode) { let emailBodyText = getEmailConfig().bodyContent.confirmPasswordReset; emailBodyText = emailBodyText.replace("{VERIFICATIONCODE}", verificationCode); - emailBodyText = emailBodyText.replace("{SERVERNAME}", getServerConfig().name); + emailBodyText = emailBodyText.replace("{SERVERNAME}", getServerName()); - sendEmail(getPlayerData(client).accountData.emailAddress, getPlayerData(client).accountData.name, `Reset your password on ${getServerConfig().name}`, emailBodyText); + sendEmail(getPlayerData(client).accountData.emailAddress, getPlayerData(client).accountData.name, `Reset your password on ${getServerName()}`, emailBodyText); } // =========================================================================== @@ -1747,9 +1764,9 @@ function verifyAccountEmail(accountData, verificationCode) { let emailBodyText = getEmailConfig().bodyContent.confirmEmail; emailBodyText = emailBodyText.replace("{VERIFICATIONCODE}", emailVerificationCode); - emailBodyText = emailBodyText.replace("{SERVERNAME}", getServerConfig().name); + emailBodyText = emailBodyText.replace("{SERVERNAME}", getServerName()); - sendEmail(getPlayerData(client).accountData.emailAddress, getPlayerData(client).accountData.name, `Confirm email on ${getServerConfig().name}`, emailBodyText); + sendEmail(getPlayerData(client).accountData.emailAddress, getPlayerData(client).accountData.name, `Confirm email on ${getServerName()}`, emailBodyText); getPlayerData(client).accountData.emailAddress = emailAddress; getPlayerData(client).accountData.emailVerificationCode = module.hashing.sha512(emailVerificationCode); @@ -1766,10 +1783,10 @@ function sendAccountLoginFailedNotification(emailAddress, name, ip, game = getGa emailBodyText = emailBodyText.replace("{GAMENAME}", getGameName(game)); emailBodyText = emailBodyText.replace("{IPADDRESS}", ip); emailBodyText = emailBodyText.replace("{LOCATION}", `${cityName}, ${subDivisionName}, ${countryName}`); - emailBodyText = emailBodyText.replace("{SERVERNAME}", getServerConfig().name); + emailBodyText = emailBodyText.replace("{SERVERNAME}", getServerName()); emailBodyText = emailBodyText.replace("{TIMESTAMP}", new Date().toLocaleString('en-US')); - sendEmail(emailAddress, name, `Login failed on ${getServerConfig().name}`, emailBodyText); + sendEmail(emailAddress, name, `Login failed on ${getServerName()}`, emailBodyText); return true; } @@ -1784,10 +1801,10 @@ function sendAccountLoginSuccessNotification(emailAddress, name, ip, game = getG emailBodyText = emailBodyText.replace("{GAMENAME}", getGameName(game)); emailBodyText = emailBodyText.replace("{IPADDRESS}", ip); emailBodyText = emailBodyText.replace("{LOCATION}", `${cityName}, ${subDivisionName}, ${countryName}`); - emailBodyText = emailBodyText.replace("{SERVERNAME}", getServerConfig().name); + emailBodyText = emailBodyText.replace("{SERVERNAME}", getServerName()); emailBodyText = emailBodyText.replace("{TIMESTAMP}", new Date().toLocaleString('en-US')); - sendEmail(emailAddress, name, `Login successful on ${getServerConfig().name}`, emailBodyText); + sendEmail(emailAddress, name, `Login successful on ${getServerName()}`, emailBodyText); return true; } @@ -1837,9 +1854,9 @@ 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}", getServerConfig().name); + emailBodyText = emailBodyText.replace("{SERVERNAME}", getServerName()); - sendEmail(emailAddress, name, `Login code for ${getServerConfig().name}`, emailBodyText); + sendEmail(emailAddress, name, `Login code for ${getServerName()}`, emailBodyText); return true; } diff --git a/scripts/server/bitflag.js b/scripts/server/bitflag.js index 1d0814fe..116952ae 100644 --- a/scripts/server/bitflag.js +++ b/scripts/server/bitflag.js @@ -119,9 +119,10 @@ let serverBitFlagKeys = { "NoRandomTips", "NoActionTips", "ChatBoxTimestamps", - "ChatProfanityFilter", + "ProfanityFilter", "ChatAutoHide", "NoPlayerContent", + "ChatEmoji", //"NoBlood", ], diff --git a/scripts/server/business.js b/scripts/server/business.js index 194d4e27..8c036c4b 100644 --- a/scripts/server/business.js +++ b/scripts/server/business.js @@ -13,7 +13,8 @@ const AGRP_BIZ_TYPE_NONE = 0; // None (invalid) const AGRP_BIZ_TYPE_NORMAL = 1; // Normal business (sells items) const AGRP_BIZ_TYPE_BANK = 2; // Bank const AGRP_BIZ_TYPE_PUBLIC = 3; // Public business (Government, public service, etc) -const AGRP_BIZ_TYPE_PAINTBALL = 4; // Paintball arena. Player joins paintball/airsoft when they enter +const AGRP_BIZ_TYPE_PAINTBALL = 4; // Paintball arena. Player joins paintball/airsoft when they enter +const AGRP_BIZ_TYPE_DEALERSHIP = 5; // Vehicle Dealership (also for airplane, boat, etc) // =========================================================================== @@ -846,7 +847,7 @@ function setBusinessEntranceFeeCommand(command, params, client) { getBusinessData(businessId).entranceFee = entranceFee; getBusinessData(businessId).needsSaved = true; - messagePlayerSuccess(client, `{MAINCOLOUR}You set business {businessBlue}${getBusinessData(businessId).name} {MAINCOLOUR}entrance fee to [#AAAAAAA]$${entranceFee}`); + messagePlayerSuccess(client, `{MAINCOLOUR}You set business {businessBlue}${getBusinessData(businessId).name}{MAINCOLOUR} entrance fee to [#AAAAAAA]$${entranceFee}`); } // =========================================================================== @@ -873,7 +874,7 @@ function setBusinessPaintBallCommand(command, params, client) { return false; } - getBusinessData(businessId).entranceType = AGRP_BIZ_ENTRANCE_TYPE_PAINTBALL; + getBusinessData(businessId).type = AGRP_BIZ_TYPE_PAINTBALL; getBusinessData(businessId).needsSaved = true; messagePlayerSuccess(client, getLocaleString(client, "BusinessIsNowPaintBall")); } @@ -1305,6 +1306,7 @@ function setBusinessEntranceLabelToDealershipCommand(command, params, client) { } getBusinessData(businessId).labelHelpType == AGRP_PROPLABEL_INFO_ENTERVEHICLE; + getBusinessData(businessId).type = AGRP_BIZ_TYPE_VEHDEALERSHIP; updateBusinessPickupLabelData(businessId); messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} set the business type of {businessBlue}${getBusinessData(businessId).name}{MAINCOLOUR} to dealership`); } diff --git a/scripts/server/netevents.js b/scripts/server/netevents.js index 02858f61..ddc2230f 100644 --- a/scripts/server/netevents.js +++ b/scripts/server/netevents.js @@ -527,7 +527,8 @@ function sendPlayerRemoveFromVehicle(client) { function sendChatBoxMessageToPlayer(client, messageText, colour) { //messageClient(messageText, client, colour); - sendNetworkEventToPlayer("m", client, messageText, colour); + let date = new Date(); + sendNetworkEventToPlayer("m", client, messageText, colour, date.getHours(), date.getMinutes(), date.getSeconds()); } // =========================================================================== @@ -1244,4 +1245,16 @@ function sendPlayerChatBoxTimeStampsState(client, state) { sendNetworkEventToPlayer("agrp.chatTimeStamps", client, state); } +// ========================================================================== + +function sendPlayerChatEmojiState(client, state) { + sendNetworkEventToPlayer("agrp.chatEmoji", client, state); +} + +// ========================================================================== + +function sendPlayerProfanityFilterState(client, state) { + sendNetworkEventToPlayer("agrp.profanityFilter", client, state); +} + // ========================================================================== \ No newline at end of file diff --git a/scripts/shared/utilities.js b/scripts/shared/utilities.js index fe65c6ca..163d2268 100644 --- a/scripts/shared/utilities.js +++ b/scripts/shared/utilities.js @@ -742,7 +742,7 @@ let serverEmoji = [ [":dizzy:", "💫"], [":speech_balloon:", "💬"], [":white_flower:", "💮"], - [":_100:", "💯"], + [":100:", "💯"], [":moneybag:", "💰"], [":currency_exchange:", "💱"], [":heavy_dollar_sign:", "💲"], @@ -2462,11 +2462,18 @@ function doesWordStartWithVowel(word) { // =========================================================================== -function replaceEmojiIntoString(message) { - for (let i in emojiReplaceString) { - message = message.replace(emojiReplaceString[i][0], emojiReplaceString[i][1]); +/** + * Replaces emoji texts with actual emoji + * + * @param {String} messageString - String with emoji names + * @return {String} String with actual emoji images + * + */ +function replaceEmojiInMessage(messageString) { + for (let i in serverEmoji) { + messageString = messageString.replace(serverEmoji[i][0], serverEmoji[i][1]); } - return message; + return messageString; } // =========================================================================== @@ -2998,24 +3005,6 @@ function removeColoursInMessage(messageText) { // =========================================================================== -/** - * Replaces emoji texts with actual emoji - * - * @param {String} messageString - String with emoji names - * @return {String} String with actual emoji images - * - */ -function replaceEmojiInString(messageString) { - for (let i in emojiReplaceString) { - while (messageString.indexOf(emojiReplaceString[i][0]) != -1) { - messageString = messageString.replace(emojiReplaceString[i][0], emojiReplaceString[i][1]); - } - } - return messageString; -} - -// =========================================================================== - /** * Replaces profanity with masked words like: ****** * @@ -3023,7 +3012,7 @@ function replaceEmojiInString(messageString) { * @return {String} String with profanity masked * */ -function replaceProfanityInString(messageString) { +function replaceProfanityInMessage(messageString) { for (let i in profanityFilterWords) { while (messageString.indexOf(profanityFilterWords[i]) != -1) { messageString = messageString.replace(profanityFilterWords[i], fillStringWithCharacter("*", profanityFilterWords[i].length)); @@ -3162,4 +3151,14 @@ function getAnimationData(animationSlot, gameId = getGame()) { return getGameConfig().animations[gameId][animationSlot]; } +// =========================================================================== + +function fillLeadingZeros(number, length) { + let str = toString(number); + while (str.length < length) { + str = "0" + str; + } + return str; +} + // =========================================================================== \ No newline at end of file