From 4c8630c174b2a8d9759240ae7b00ebb009359b44 Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Sun, 19 Jun 2022 11:28:25 -0500 Subject: [PATCH] Private message and quick reply cmds --- scripts/server/chat.js | 49 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/scripts/server/chat.js b/scripts/server/chat.js index b1cf4425..39024167 100644 --- a/scripts/server/chat.js +++ b/scripts/server/chat.js @@ -194,6 +194,55 @@ function clanChatCommand(command, params, client) { // =========================================================================== +function privateMessageCommand(command, params, client) { + if (isPlayerMuted(client)) { + messagePlayerError(client, getLocaleString(client, "MutedCantChat")); + return false; + } + + if (areParamsEmpty(params)) { + messagePlayerSyntax(client, getCommandSyntaxText(command)); + return false; + } + + let splitParams = params.split(" "); + let targetClient = getPlayerFromParams(splitParams[0]); + let messageText = splitParams.slice(1).join(" "); + + if (!targetClient) { + messagePlayerError(client, getLocaleString(client, "InvalidPlayer")); + return false; + } + + getPlayerData(targetClient).privateMessageReplyTo = client; + messagePlayerPrivateMessage(targetClient, client, messageText); + messagePlayerTip(client, getLocaleString(client, "PrivateMessageReplyCommandTip", "{ALTCOLOUR}/reply{MAINCOLOUR}")) +} + +// =========================================================================== + +function replyToLastPrivateMessageCommand(command, params, client) { + if (isPlayerMuted(client)) { + messagePlayerError(client, getLocaleString(client, "MutedCantChat")); + return false; + } + + if (areParamsEmpty(params)) { + messagePlayerSyntax(client, getCommandSyntaxText(command)); + return false; + } + + if (getPlayerData(client).privateMessageReplyTo == null) { + messagePlayerError(client, getLocaleString(client, "NoPrivateMessageToReply")); + return false; + } + + getPlayerData(targetClient).privateMessageReplyTo = client; + messagePlayerPrivateMessage(targetClient, client, messageText); +} + +// =========================================================================== + function talkToNearbyPlayers(client, messageText) { let clients = getClients(); for (let i in clients) {