From dc01876de29cf4c0ffeeddd0dbb9bd91c3c83adc Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Mon, 21 Dec 2020 22:54:32 -0600 Subject: [PATCH] Add new utils --- scripts/server/utilities.js | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/scripts/server/utilities.js b/scripts/server/utilities.js index 8a48af2b..e8fbbbc4 100644 --- a/scripts/server/utilities.js +++ b/scripts/server/utilities.js @@ -1717,4 +1717,33 @@ function arrayBufferToString(arrayBuffer) { function getClientDisplayForConsole(client) { return `${client.name}[${client.index}]`; -} \ No newline at end of file +} + +// ---------------------------------------------------------------------------- + +function getBoolRedGreenInlineColour(boolVal) { + return (!boolVal) ? getColourByName("softRed") : getColourByName("softGreen"); +} + +// ---------------------------------------------------------------------------- + +function updatePlayerNameTag(client) { + triggerNetworkEvent("ag.nametag", null, client.name, getPlayerNameForNameTag(client), getPlayerColour(client), false, client.ping); +} + +// ---------------------------------------------------------------------------- + +function getPlayerNameForNameTag(client) { + if(isPlayerSpawned(client)) { + return `${getClientCurrentSubAccount(client).firstName} ${getClientCurrentSubAccount(client).lastName}`; + } + return client.name; +} + +// ---------------------------------------------------------------------------- + +function isPlayerSpawned(client) { + return (localPlayer != null); +} + +// ---------------------------------------------------------------------------- \ No newline at end of file