diff --git a/Community-Scripts.md b/Community-Scripts.md index 0666306..8883d04 100644 --- a/Community-Scripts.md +++ b/Community-Scripts.md @@ -1079,6 +1079,53 @@ healthbar: *** +### Player Exp Points +* **Author:** BlitzGamer_88 +* **Description:** A javascript placeholder to return the player's exp points. +* **Usage:** `%javascript_exp_points%` + +**Save as** `player_exp.js` + +```javascript +var player = BukkitPlayer +var expPrc = player.getExp() +var levels = player.getLevel() + +function expPoints() { + + var exp = Math.round(getExpAtLevel(levels) * expPrc) + var currentLevel = player.getLevel() + while (currentLevel > 0) { + currentLevel-- + exp += getExpAtLevel(currentLevel) + } + if (exp < 0) exp = Integer.MAX_VALUE + return parseInt(exp) + +} + + + +function getExpAtLevel(level) { + + if (level <= 15) return (2*level) + 7 + if ((level >= 16) && (level <=30)) return (5 * level) -38 + return (9*level)-158 + +} + +expPoints() +``` + +**Add to** `javascript_placeholders.yml` + +```yaml +exp_points: + file: exp_points.js +``` + +*** + ### Number of Players in Group of Worlds * **Author:** meowsome * **Description:** Get the number of players for multiple different worlds and add them together. This is useful for holograms and menus that display the number of players for each section of a server.