From 9b60cc18d2958f21856c51901f7c361fc848ca59 Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Fri, 18 Dec 2020 19:00:15 -0600 Subject: [PATCH] Add auto spawn as last character setting --- scripts/server/account.js | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/scripts/server/account.js b/scripts/server/account.js index bc08f0db..779a15e9 100644 --- a/scripts/server/account.js +++ b/scripts/server/account.js @@ -47,6 +47,21 @@ function autoLoginByIPCommand(command, params, client) { // --------------------------------------------------------------------------- +function autoSelectLastCharacterCommand(command, params, client) { + let flagValue = getAccountSettingsFlagValue("autoSelectLastCharacter"); + + if(isAccountAutoSelectLastCharacterEnabled(getClientData(client).accountData)) { + getClientData(client).accountData.settings = getClientData(client).accountData.settings & ~flagValue; + messageClientSuccess(client, `You will not be automatically spawned as your last used character`); + } else { + getClientData(client).accountData.settings = getClientData(client).accountData.settings | flagValue; + messageClientSuccess(client, `You will now be automatically spawned as your last used character`); + } + return true; +} + +// --------------------------------------------------------------------------- + function toggleAccountGUICommand(command, params, client) { let flagValue = getAccountSettingsFlagValue("noGUI"); @@ -556,6 +571,7 @@ function saveClientToDatabase(client) { function initClient(client) { triggerNetworkEvent("ag.guiColour", client, getServerConfig().guiColour[0], getServerConfig().guiColour[1], getServerConfig().guiColour[2]); triggerNetworkEvent("ag.logo", client, getServerConfig().showLogo); + triggerNetworkEvent("ag.snow", client, getServerConfig().fallingSnow, getServerConfig().groundSnow); showConnectCameraToPlayer(client); messageClient(`Please wait ...`, client, getColourByName("softGreen")); @@ -760,4 +776,14 @@ function doesPlayerHaveAutoLoginByIPEnabled(client) { return true; } -// --------------------------------------------------------------------------- \ No newline at end of file +// --------------------------------------------------------------------------- + +function doesPlayerHaveAutoSelectLastCharacterEnabled(client) { + if(hasBitFlag(getClientData(client).accountData.settings, getAccountSettingsFlagValue("autoSelectLastCharacter"))) { + return false; + } + + return true; +} + +// ---------------------------------------------------------------------------