Return Custom Afk Output
- Author: DennisTheSeagull
- Description: Check if a player is afk & then return a custom output depending on the boolean.
This script is using the %essentials_afk% placeholder. In simpler terms, this allows you to change the normal yes/no output to something of your choice. Very useful!
- Usage:
%javascript_check_afk%
Javascript Code:
check_afk.js
var afk = "%essentials_afk%";
function checkAfk() {
if (afk == "yes") {
return "[AFK]";
}
return "";
}
checkAfk();
Commented Javascript Code:
check_afk.js
// create a variable and name it to whichever you prefer
// %essentials_afk% is the placeholder that we'll be changing the output of
var afk = "%essentials_afk%";
// create a function with your prefered name
function checkAfk() {
// if the afk variable that we created before returns yes (true boolean)
// the javascript placeholder will return whichever we set the return output to
if (afk == "yes") {
return "[AFK]";
}
// if the afk variable isn't true, it will return a different output
return "";
}
// this calls the function to run
checkAfk();
Add to javascript_placeholder.yml
check_afk:
file: check_afk.js
Return Custom Afk Output
This script is using the
%essentials_afk%placeholder. In simpler terms, this allows you to change the normal yes/no output to something of your choice. Very useful!%javascript_check_afk%Javascript Code:
check_afk.js
Commented Javascript Code:
check_afk.js
Add to
javascript_placeholder.yml