Use disconnect names

This commit is contained in:
Vortrex
2022-09-22 05:20:45 -05:00
parent 582fce8757
commit 4464b3f49a
2 changed files with 34 additions and 31 deletions

View File

@@ -71,7 +71,7 @@ function accountBanCommand(command, params, client) {
announceAdminAction(`PlayerAccountBanned`, `{ALTCOLOUR}${getPlayerName(targetClient)}{MAINCOLOUR}`); announceAdminAction(`PlayerAccountBanned`, `{ALTCOLOUR}${getPlayerName(targetClient)}{MAINCOLOUR}`);
banAccount(getPlayerData(targetClient).accountData.databaseId, getPlayerData(client).accountData.databaseId, reason); banAccount(getPlayerData(targetClient).accountData.databaseId, getPlayerData(client).accountData.databaseId, reason);
getPlayerData(targetClient).customDisconnectReason = `Banned - ${reason}`; getPlayerData(targetClient).customDisconnectReason = "Banned";
disconnectPlayer(targetClient); disconnectPlayer(targetClient);
} }
@@ -103,7 +103,7 @@ function subAccountBanCommand(command, params, client, fromDiscord) {
announceAdminAction(`PlayerCharacterBanned`, `{ALTCOLOUR}${getPlayerName(targetClient)}{MAINCOLOUR}`); announceAdminAction(`PlayerCharacterBanned`, `{ALTCOLOUR}${getPlayerName(targetClient)}{MAINCOLOUR}`);
banSubAccount(getPlayerData(targetClient).currentSubAccountData.databaseId, getPlayerData(client).accountData.databaseId, reason); banSubAccount(getPlayerData(targetClient).currentSubAccountData.databaseId, getPlayerData(client).accountData.databaseId, reason);
getPlayerData(targetClient).customDisconnectReason = `Banned - ${reason}`; getPlayerData(targetClient).customDisconnectReason = "Banned";
disconnectPlayer(targetClient); disconnectPlayer(targetClient);
} }
@@ -133,7 +133,7 @@ function ipBanCommand(command, params, client, fromDiscord) {
announceAdminAction(`PlayerIPBanned`, `{ALTCOLOUR}${getPlayerName(targetClient)}{MAINCOLOUR}`); announceAdminAction(`PlayerIPBanned`, `{ALTCOLOUR}${getPlayerName(targetClient)}{MAINCOLOUR}`);
banIPAddress(getPlayerIP(targetClient), getPlayerData(client).accountData.databaseId, reason); banIPAddress(getPlayerIP(targetClient), getPlayerData(client).accountData.databaseId, reason);
getPlayerData(targetClient).customDisconnectReason = `IP Banned - ${reason}`; getPlayerData(targetClient).customDisconnectReason = "Banned";
serverBanIP(getPlayerIP(targetClient)); serverBanIP(getPlayerIP(targetClient));
disconnectPlayer(targetClient); disconnectPlayer(targetClient);
} }
@@ -165,7 +165,7 @@ function subNetBanCommand(command, params, client, fromDiscord) {
announceAdminAction(`PlayerSubNetBanned`, `{ALTCOLOUR}${getPlayerName(client)}{MAINCOLOUR}`); announceAdminAction(`PlayerSubNetBanned`, `{ALTCOLOUR}${getPlayerName(client)}{MAINCOLOUR}`);
banSubNet(getPlayerIP(targetClient), getSubNet(getPlayerIP(targetClient), octetAmount), getPlayerData(client).accountData.databaseId, reason); banSubNet(getPlayerIP(targetClient), getSubNet(getPlayerIP(targetClient), octetAmount), getPlayerData(client).accountData.databaseId, reason);
getPlayerData(client).customDisconnectReason = `IP Subnet Banned - ${reason}`; getPlayerData(client).customDisconnectReason = "Banned";
serverBanIP(getPlayerIP(targetClient)); serverBanIP(getPlayerIP(targetClient));
} }

View File

@@ -99,35 +99,42 @@ function onElementStreamOut(event, element, client) {
// =========================================================================== // ===========================================================================
function onPlayerQuit(event, client, quitReasonId) { function onPlayerQuit(event, client, quitReasonId) {
logToConsole(LOG_INFO, `👋 Client ${getPlayerDisplayForConsole(client)} disconnected (${disconnectReasons[quitReasonId]}[${quitReasonId}])`); let disconnectName = disconnectReasons[quitReasonId];
let reasonTextEnglish = getLanguageGroupedLocaleString(englishLocale, "DisconnectReasons", disconnectName);
updateConnectionLogOnQuit(client, quitReasonId); updateConnectionLogOnQuit(client, quitReasonId);
let reasonText = disconnectReasons[quitReasonId];
if (getPlayerData(client) != false) { if (getPlayerData(client) != false) {
if (getPlayerData(client).customDisconnectReason != "") { if (getPlayerData(client).customDisconnectReason != "") {
reasonText = getPlayerData(client).customDisconnectReason; disconnectName = getPlayerData(client).customDisconnectReason;
} }
} }
//messagePlayerNormal(null, `👋 ${getPlayerName(client)} has left the server (${reasonText})`, getColourByName("softYellow")); logToConsole(LOG_INFO, `👋 Client ${getPlayerDisplayForConsole(client)} disconnected (quitReasonId - ${reasonTextEnglish})`);
messageDiscordEventChannel(`👋 ${getPlayerName(client)} has left the server (${getLanguageGroupedLocaleString(englishLocale, "DisconnectReasons", reasonTextEnglish)})`);
//if (isPlayerFishing(client)) { getClients().forEach(forClient => {
// stopFishing(client); messagePlayerNormal(forClient, getLocaleString(forClient, "PlayerLeftServer", getPlayerName(client), getGroupedLocaleString(forClient, "DisconnectReasons", disconnectName)));
//} });
if (isPlayerInPaintBall(client)) {
stopPaintBall(client);
}
if (isPlayerOnJobRoute(client)) {
stopJobRoute(client, false, false);
}
if (isPlayerWorking(client)) {
stopWorking(client);
}
if (isPlayerLoggedIn(client)) { if (isPlayerLoggedIn(client)) {
if (isPlayerInPaintBall(client)) {
stopPaintBall(client);
}
if (isPlayerOnJobRoute(client)) {
stopJobRoute(client, false, false);
}
if (isPlayerWorking(client)) {
stopWorking(client);
}
//if (isPlayerFishing(client)) {
// stopFishing(client);
//}
savePlayerToDatabase(client); savePlayerToDatabase(client);
resetClientStuff(client); resetClientStuff(client);
} }
@@ -136,11 +143,7 @@ function onPlayerQuit(event, client, quitReasonId) {
clearTimeout(getPlayerData(client).loginTimeout); clearTimeout(getPlayerData(client).loginTimeout);
} }
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));
});
playerResourceReady[client.index] = false; playerResourceReady[client.index] = false;
playerResourceStarted[client.index] = false; playerResourceStarted[client.index] = false;
@@ -432,7 +435,7 @@ async function onPlayerSpawn(client) {
//logToConsole(LOG_DEBUG, `[AGRP.Event] Checking ${getPlayerDisplayForConsole(client)}'s player data`); //logToConsole(LOG_DEBUG, `[AGRP.Event] Checking ${getPlayerDisplayForConsole(client)}'s player data`);
if (!getPlayerData(client)) { if (!getPlayerData(client)) {
logToConsole(LOG_DEBUG, `[AGRP.Event] ${getPlayerDisplayForConsole(client)}'s player data is invalid. Kicking them from server.`); logToConsole(LOG_DEBUG, `[AGRP.Event] ${getPlayerDisplayForConsole(client)}'s player data is invalid. Kicking them from server.`);
getPlayerData(targetClient).customDisconnectReason = `Kicked - Spawn bug. Data invalid.`; getPlayerData(targetClient).customDisconnectReason = "Desync";
disconnectPlayer(client); disconnectPlayer(client);
return false; return false;
} }
@@ -440,7 +443,7 @@ async function onPlayerSpawn(client) {
//logToConsole(LOG_DEBUG, `[AGRP.Event] Checking ${getPlayerDisplayForConsole(client)}'s login status`); //logToConsole(LOG_DEBUG, `[AGRP.Event] Checking ${getPlayerDisplayForConsole(client)}'s login status`);
if (!isPlayerLoggedIn(client)) { if (!isPlayerLoggedIn(client)) {
logToConsole(LOG_DEBUG, `[AGRP.Event] ${getPlayerDisplayForConsole(client)} is NOT logged in. Despawning their player.`); logToConsole(LOG_DEBUG, `[AGRP.Event] ${getPlayerDisplayForConsole(client)} is NOT logged in. Despawning their player.`);
getPlayerData(targetClient).customDisconnectReason = `Kicked - Tried to force spawn without logging in.`; getPlayerData(targetClient).customDisconnectReason = "Desync";
disconnectPlayer(client); disconnectPlayer(client);
return false; return false;
} }
@@ -448,7 +451,7 @@ async function onPlayerSpawn(client) {
//logToConsole(LOG_DEBUG, `[AGRP.Event] Checking ${getPlayerDisplayForConsole(client)}'s selected character status`); //logToConsole(LOG_DEBUG, `[AGRP.Event] Checking ${getPlayerDisplayForConsole(client)}'s selected character status`);
if (getPlayerData(client).currentSubAccount == -1) { if (getPlayerData(client).currentSubAccount == -1) {
logToConsole(LOG_DEBUG, `[AGRP.Event] ${getPlayerDisplayForConsole(client)} has NOT selected a character. Despawning their player.`); logToConsole(LOG_DEBUG, `[AGRP.Event] ${getPlayerDisplayForConsole(client)} has NOT selected a character. Despawning their player.`);
getPlayerData(targetClient).customDisconnectReason = `Kicked - Tried to force spawn without selecting a character.`; getPlayerData(targetClient).customDisconnectReason = "Desync";
disconnectPlayer(client); disconnectPlayer(client);
return false; return false;
} }