Skip to content

Return Custom Afk Output - Community Scripts Contribution #57

@HLX-DENNIS

Description

@HLX-DENNIS

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions