mirror of
https://github.com/PlaceholderAPI/Javascript-Expansion.git
synced 2025-05-23 10:39:04 +00:00
Added tags.js, updated has_permission.js (#14)
* Updated documentation * Create tags.js * Update master_list.json
This commit is contained in:
parent
d32eb34d6d
commit
33b8f26ee3
@ -1,20 +1,35 @@
|
||||
// create a variable and name it whatever you want like this
|
||||
// and use the placeholder you want, i'm using this one
|
||||
/*
|
||||
A simple placeholder which checks if the user has a permission
|
||||
|
||||
First we create our permission variables which will give a boolean output whether or not
|
||||
the user has the specified permission
|
||||
*/
|
||||
var haspermission = "%player_has_permission_permission.test%";
|
||||
|
||||
// create a function with the name you want
|
||||
function permission() {
|
||||
/*
|
||||
Here we create a function called hasPermission (can be named whatever you'd like)
|
||||
which will do all the checks
|
||||
*/
|
||||
function hasPermission() {
|
||||
|
||||
// if the haspermission variable that we created before returns yes (true boolean)
|
||||
// the js placeholder will return what we set in the return down
|
||||
|
||||
/*
|
||||
If the haspermission variable which we created above returns yes (true boolean)
|
||||
the placeholder will return the bellow if statements value
|
||||
*/
|
||||
if (haspermission === "yes") {
|
||||
return "&aYou have the Test permission!";
|
||||
}
|
||||
|
||||
// if the haspermission variable wasnt true it will return what we set down
|
||||
/*
|
||||
If the haspermission variable doesn't return the above state (true boolean),
|
||||
the user does not have the checked permission, so we return the bellow else statements value
|
||||
*/
|
||||
else {
|
||||
return "&cYou don't have the Test permission!";
|
||||
}
|
||||
}
|
||||
// by this we are calling the function to run
|
||||
permission();
|
||||
/*
|
||||
Here we call the hasPermission function so it runs
|
||||
*/
|
||||
hasPermission();
|
||||
|
@ -13,4 +13,10 @@
|
||||
"description": "A simple placeholder which will return brackets around the faction name if the user is in a faction, if they are not it will return nothing",
|
||||
"url": "https://raw.githubusercontent.com/PlaceholderAPI/Javascript-Expansion/master/scripts/factions.js"
|
||||
}
|
||||
{
|
||||
"name": "tags",
|
||||
"author": "Frosty",
|
||||
"version": "1.0.0",
|
||||
"description": "A simple placeholder which formats DeluxeTags tag spacing",
|
||||
"url": "https://raw.githubusercontent.com/PlaceholderAPI/Javascript-Expansion/master/scripts/tags.js",
|
||||
]
|
||||
|
37
scripts/tags.js
Normal file
37
scripts/tags.js
Normal file
@ -0,0 +1,37 @@
|
||||
/*
|
||||
A simple placeholder which formats DeluxeTags to better suit a chat format,
|
||||
meaning it returns a space if the user has a tag equipped
|
||||
|
||||
Creating our tags variable which will return either a tag if the user has it equipped
|
||||
or a blank string if they do not
|
||||
*/
|
||||
var tags = "%deluxetags_tag%";
|
||||
|
||||
/*
|
||||
Creating our hasTags function which will return the correct value
|
||||
*/
|
||||
function hasTag()
|
||||
{
|
||||
/*
|
||||
If our tags variable which we created above returns an empty string,
|
||||
we return an empty string back as the user does not have a tag equipped
|
||||
and if our variable isn't empty, we return a space after it to fix spacing
|
||||
in the chat format
|
||||
*/
|
||||
if (tags == '')
|
||||
{
|
||||
return '';
|
||||
}
|
||||
return tags + ' ';
|
||||
|
||||
/*
|
||||
A compacter way of defining if statements
|
||||
Checked value ? Boolean true : Boolean false
|
||||
return tags == '' ? '' : tags + ' ';
|
||||
*/
|
||||
}
|
||||
/*
|
||||
Calling the hasTag function
|
||||
*/
|
||||
hasTag();
|
||||
|
Loading…
x
Reference in New Issue
Block a user