Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return Custom Afk Output - Community Scripts Contribution #57

Open
HLX-DENNIS opened this issue Jan 29, 2022 · 2 comments
Open

Return Custom Afk Output - Community Scripts Contribution #57

HLX-DENNIS opened this issue Jan 29, 2022 · 2 comments

Comments

@HLX-DENNIS
Copy link

HLX-DENNIS commented Jan 29, 2022

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
@iGabyTM
Copy link
Member

iGabyTM commented Jan 29, 2022

// the PlaceholderAPI.static.setPlaceholders() is used to parse placeholders inside the javascript placeholder

Wrong, that method is used if you have placeholders like "%expannsion_" + argument + "%", all the other placeholders are replaced by default

@HLX-DENNIS
Copy link
Author

HLX-DENNIS commented Jan 30, 2022

// the PlaceholderAPI.static.setPlaceholders() is used to parse placeholders inside the javascript placeholder

Wrong, that method is used if you have placeholders like "%expannsion_" + argument + "%", all the other placeholders are replaced by default

I stand corrected ¯_(ツ)_/¯ Thank you kind sir for the clarification. I've updated the post with the correct information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants