Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Ranking System v2.0, by Wolfje (Tyler W.), 2013.
- This is a ranking script for the AliasCmd plugin in Javascript. Install it by putting it in your Tshock\SEconomy" directory and starting the Terraria server.
- If the server is already running AliasCmd just type "/aliascmd reload" in the console to cause the script to load.
- Released under Wolfje's Don't-be-a-dick license. You didn't write this, I did, so if you modify it don't claim the work as yours; it isn't.
- ** THIS VERSION OF THE RANKING SCRIPT REQUIRES JIST AND SECONOMY UPDATE 15 OR LATER. **
- --- rankingList Object ---
- There's really nothing to it. :)
- * the first parameter is the rank key.
- * "name" must match the rank key. Avoid spaces
- * "cost" is a SEconomy string representation of how much money it costs to be that rank, "0c" is free
- * "group" is the TShock group this rank is
- * "parentgroup" is used for hierarchy. set it to the group of the rank that comes before it to establish a ladder
- You can specify multiple ranks with the same parent. Doing this is going to create a tree of choices called a class trunk.
- Once a user arrives at a class trunk they cannot /rank up, they will be asked to pick a "class", but you can modify that text to whatever you like.
- You can specify as many trunks as you want. You can have rank choices inside rank choices up to an infinite depth, the sky (or rather, your heap size) is the limit. :)
- "levelupcommands": [
- "/i goldfish",
- "/i goldfish",
- "/i goldfish",
- "/i goldfish",
- "/i goldfish",
- "/i goldfish",
- "/i goldfish",
- "/i goldfish",
- "/i goldfish",
- "/i goldfish",
- "/time noon",
- "/spawnmob \"skeletron head\"",
- ],
- */
- /*
- * Please see the forums at http://plugins.tw.id.au/ for tutorials on how
- * to make a ranking list.
- */
- var rankingList = {
- //----------------------Tier One Lv1-100----------------------
- "Lv1": {
- "name": "Lv1",
- "parentgroup": undefined,
- "group": "rank.L1",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "300"
- },
- "Lv2": {
- "name": "Lv2",
- "parentgroup": "rank.L1",
- "group": "rank.L2",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "Lv3": {
- "name": "Lv3",
- "parentgroup": "rank.L2",
- "group": "rank.L3",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L4": {
- "name": "L4",
- "parentgroup": "rank.L3",
- "group": "rank.L4",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L5": {
- "name": "L5",
- "parentgroup": "rank.L4",
- "group": "rank.L5",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L6": {
- "name": "L6",
- "parentgroup": "rank.L5",
- "group": "rank.L6",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L7": {
- "name": "L7",
- "parentgroup": "rank.L6",
- "group": "rank.L7",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L8": {
- "name": "L8",
- "parentgroup": "rank.L7",
- "group": "rank.L8",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L9": {
- "name": "L9",
- "parentgroup": "rank.L8",
- "group": "rank.L9",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L10": {
- "name": "L10",
- "parentgroup": "rank.L9",
- "group": "rank.L10",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/level"
- ],
- "cost": "1000"
- },
- "L11": {
- "name": "L11",
- "parentgroup": "rank.L10",
- "group": "rank.L11",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L12": {
- "name": "L12",
- "parentgroup": "rank.L11",
- "group": "rank.L12",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L13": {
- "name": "L13",
- "parentgroup": "rank.L12",
- "group": "rank.L13",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L14": {
- "name": "L14",
- "parentgroup": "rank.L13",
- "group": "rank.L14",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp",
- ],
- "cost": "1000"
- },
- "L15": {
- "name": "L15",
- "parentgroup": "rank.L14",
- "group": "rank.L15",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L16": {
- "name": "L16",
- "parentgroup": "rank.L15",
- "group": "rank.L16",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L17": {
- "name": "L17",
- "parentgroup": "rank.L16",
- "group": "rank.L17",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L18": {
- "name": "L18",
- "parentgroup": "rank.L17",
- "group": "rank.L18",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L19": {
- "name": "L19",
- "parentgroup": "rank.L18",
- "group": "rank.L19",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L20": {
- "name": "L20",
- "parentgroup": "rank.L19",
- "group": "rank.L20",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/level"
- ],
- "cost": "1000"
- },
- "L21": {
- "name": "L21",
- "parentgroup": "rank.L20",
- "group": "rank.L21",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L22": {
- "name": "L22",
- "parentgroup": "rank.L21",
- "group": "rank.L22",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L23": {
- "name": "L23",
- "parentgroup": "rank.L22",
- "group": "rank.L23",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L24": {
- "name": "L24",
- "parentgroup": "rank.L23",
- "group": "rank.L24",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L25": {
- "name": "L25",
- "parentgroup": "rank.L24",
- "group": "rank.L25",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L26": {
- "name": "L26",
- "parentgroup": "rank.L25",
- "group": "rank.L26",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L27": {
- "name": "L27",
- "parentgroup": "rank.L26",
- "group": "rank.L27",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L28": {
- "name": "L28",
- "parentgroup": "rank.L27",
- "group": "rank.L28",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L29": {
- "name": "L29",
- "parentgroup": "rank.L28",
- "group": "rank.L29",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L30": {
- "name": "L30",
- "parentgroup": "rank.L29",
- "group": "rank.L30",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/level"
- ],
- "cost": "1000"
- },
- "L31": {
- "name": "L31",
- "parentgroup": "rank.L30",
- "group": "rank.L31",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L32": {
- "name": "L32",
- "parentgroup": "rank.L31",
- "group": "rank.L32",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L33": {
- "name": "L33",
- "parentgroup": "rank.L32",
- "group": "rank.L33",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L34": {
- "name": "L34",
- "parentgroup": "rank.L33",
- "group": "rank.L34",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L35": {
- "name": "L35",
- "parentgroup": "rank.L34",
- "group": "rank.L35",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L36": {
- "name": "L36",
- "parentgroup": "rank.L35",
- "group": "rank.L36",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L37": {
- "name": "L37",
- "parentgroup": "rank.L36",
- "group": "rank.L37",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L38": {
- "name": "L38",
- "parentgroup": "rank.L37",
- "group": "rank.L38",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L39": {
- "name": "L39",
- "parentgroup": "rank.L38",
- "group": "rank.L39",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L40": {
- "name": "L40",
- "parentgroup": "rank.L39",
- "group": "rank.L40",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/level"
- ],
- "cost": "1000"
- },
- "L41": {
- "name": "L41",
- "parentgroup": "rank.L40",
- "group": "rank.L41",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L42": {
- "name": "L42",
- "parentgroup": "rank.L41",
- "group": "rank.L42",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L43": {
- "name": "L43",
- "parentgroup": "rank.L42",
- "group": "rank.L43",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L44": {
- "name": "L44",
- "parentgroup": "rank.L43",
- "group": "rank.L44",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L45": {
- "name": "L45",
- "parentgroup": "rank.L44",
- "group": "rank.L45",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L46": {
- "name": "L46",
- "parentgroup": "rank.L45",
- "group": "rank.L46",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L47": {
- "name": "L47",
- "parentgroup": "rank.L46",
- "group": "rank.L47",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L48": {
- "name": "L48",
- "parentgroup": "rank.L47",
- "group": "rank.L48",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L49": {
- "name": "L49",
- "parentgroup": "rank.L48",
- "group": "rank.L49",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L50": {
- "name": "L50",
- "parentgroup": "rank.L49",
- "group": "rank.L50",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/level"
- ],
- "cost": "1000"
- },
- "L51": {
- "name": "L51",
- "parentgroup": "rank.L50",
- "group": "rank.L51",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L52": {
- "name": "L52",
- "parentgroup": "rank.L51",
- "group": "rank.L52",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L53": {
- "name": "L53",
- "parentgroup": "rank.L52",
- "group": "rank.L53",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L54": {
- "name": "L54",
- "parentgroup": "rank.L53",
- "group": "rank.L54",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L55": {
- "name": "L55",
- "parentgroup": "rank.L54",
- "group": "rank.L55",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L56": {
- "name": "L56",
- "parentgroup": "rank.L55",
- "group": "rank.L56",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L57": {
- "name": "L57",
- "parentgroup": "rank.L56",
- "group": "rank.L57",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L58": {
- "name": "L58",
- "parentgroup": "rank.L57",
- "group": "rank.L58",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L59": {
- "name": "L59",
- "parentgroup": "rank.L58",
- "group": "rank.L59",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L60": {
- "name": "L60",
- "parentgroup": "rank.L59",
- "group": "rank.L60",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/level"
- ],
- "cost": "1000"
- },
- "L61": {
- "name": "L61",
- "parentgroup": "rank.L60",
- "group": "rank.L61",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L62": {
- "name": "L62",
- "parentgroup": "rank.L61",
- "group": "rank.L62",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L63": {
- "name": "L63",
- "parentgroup": "rank.L62",
- "group": "rank.L63",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L64": {
- "name": "L64",
- "parentgroup": "rank.L63",
- "group": "rank.L64",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L65": {
- "name": "L65",
- "parentgroup": "rank.L64",
- "group": "rank.L65",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L66": {
- "name": "L66",
- "parentgroup": "rank.L65",
- "group": "rank.L66",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L67": {
- "name": "L67",
- "parentgroup": "rank.L66",
- "group": "rank.L67",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L68": {
- "name": "L68",
- "parentgroup": "rank.L67",
- "group": "rank.L68",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L69": {
- "name": "L69",
- "parentgroup": "rank.L68",
- "group": "rank.L69",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L70": {
- "name": "L70",
- "parentgroup": "rank.L69",
- "group": "rank.L70",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/level"
- ],
- "cost": "1000"
- },
- "L71": {
- "name": "L71",
- "parentgroup": "rank.L70",
- "group": "rank.L71",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L72": {
- "name": "L72",
- "parentgroup": "rank.L71",
- "group": "rank.L72",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L73": {
- "name": "L73",
- "parentgroup": "rank.L72",
- "group": "rank.L73",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L74": {
- "name": "L74",
- "parentgroup": "rank.L73",
- "group": "rank.L74",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L75": {
- "name": "L75",
- "parentgroup": "rank.L74",
- "group": "rank.L75",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L76": {
- "name": "L76",
- "parentgroup": "rank.L75",
- "group": "rank.L76",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L77": {
- "name": "L77",
- "parentgroup": "rank.L76",
- "group": "rank.L77",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L78": {
- "name": "L78",
- "parentgroup": "rank.L77",
- "group": "rank.L78",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L79": {
- "name": "L79",
- "parentgroup": "rank.L78",
- "group": "rank.L79",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L80": {
- "name": "L80",
- "parentgroup": "rank.L79",
- "group": "rank.L80",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/level"
- ],
- "cost": "1000"
- },
- "L81": {
- "name": "L81",
- "parentgroup": "rank.L80",
- "group": "rank.L81",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L82": {
- "name": "L82",
- "parentgroup": "rank.L81",
- "group": "rank.L82",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L83": {
- "name": "L83",
- "parentgroup": "rank.L82",
- "group": "rank.L83",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L84": {
- "name": "L84",
- "parentgroup": "rank.L83",
- "group": "rank.L84",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L85": {
- "name": "L85",
- "parentgroup": "rank.L84",
- "group": "rank.L85",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L86": {
- "name": "L86",
- "parentgroup": "rank.L85",
- "group": "rank.L86",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L87": {
- "name": "L87",
- "parentgroup": "rank.L86",
- "group": "rank.L87",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L88": {
- "name": "L88",
- "parentgroup": "rank.L87",
- "group": "rank.L88",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L89": {
- "name": "L89",
- "parentgroup": "rank.L88",
- "group": "rank.L89",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L90": {
- "name": "L90",
- "parentgroup": "rank.L89",
- "group": "rank.L90",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/level"
- ],
- "cost": "1000"
- },
- "L91": {
- "name": "L91",
- "parentgroup": "rank.L90",
- "group": "rank.L91",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L92": {
- "name": "L12",
- "parentgroup": "rank.L91",
- "group": "rank.L92",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L93": {
- "name": "L93",
- "parentgroup": "rank.L92",
- "group": "rank.L93",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L94": {
- "name": "L94",
- "parentgroup": "rank.L93",
- "group": "rank.L94",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L95": {
- "name": "L95",
- "parentgroup": "rank.L94",
- "group": "rank.L95",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L96": {
- "name": "L96",
- "parentgroup": "rank.L95",
- "group": "rank.L96",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L97": {
- "name": "L97",
- "parentgroup": "rank.L96",
- "group": "rank.L97",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L98": {
- "name": "L98",
- "parentgroup": "rank.L97",
- "group": "rank.L98",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L99": {
- "name": "L99",
- "parentgroup": "rank.L98",
- "group": "rank.L99",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/hpup-hp"
- ],
- "cost": "1000"
- },
- "L100": {
- "name": "L100",
- "parentgroup": "rank.L99",
- "group": "rank.L100",
- "levelupcommands": [
- "/fire",
- "/buff 119 10",
- "/heal",
- "/level"
- ],
- "cost": "1000"
- }
- }
- /*
- * change this variable to false to disable the broadcast
- * messages when people rank up.
- */
- var rank_enable_broadcast = true;
- /*
- * This is a permission for groups to be EXCLUDED from the ranking system.
- * Give this permission to your moderators or special elevated ranks
- * to stop them from being able to /rank up and screw their account up.
- */
- var rank_excluded_permission = "seconomy.rank.excluded";
- /*
- ------------------------------------------------------------------------------------------------------------------------------------------------------
- */
- /**
- * Iterates over all items pointed to by @a enumerable and executes
- * @a func with a pointer to the item inside it.
- *
- * This function acts as a fast-enumerator, with built-in prototype
- * checking.
- *
- * @param enumerable:Array An Array or other enumerable to iterate over
- * @param func:function A function pointer to execute once for each item
- * in the enumerable. The function prototype must
- * contain one parameter which points to the item
- * in the enumerable.
- */
- function rank_for_each_item(enumerable, func)
- {
- if (enumerable == undefined || func == undefined) {
- return;
- }
- for (var item in enumerable) {
- if (item == undefined || enumerable.hasOwnProperty(item) == false) {
- continue;
- }
- func(enumerable[item]);
- }
- }
- /**
- * Finds all the parent groups for the specified group.
- *
- * @param group:string A string containing the group to look up
- *
- * @returns Array with the group objects if the operation was successful,
- * Array with no objects if none was found, or @a undefined
- * if there was an error.
- */
- function rank_find_parent(group)
- {
- var parentList = undefined;
- if (rankingList == undefined || group == undefined) {
- return;
- }
- if ((parentList = new Array()) == undefined) {
- return;
- }
- rank_for_each_item(rankingList, function(item) {
- if (item.parentgroup == group) {
- parentList.push(item);
- }
- });
- return parentList;
- }
- /**
- * Finds a rank in the rank tree by the name provided by group.
- *
- * @param group:string A string containing the group name in it
- *
- * @returns The group object if it was found, or undefined if it
- * doesn't exist or there was an error.
- */
- function rank_find(group)
- {
- var rank;
- if (group == undefined || rankingList == undefined) {
- return;
- }
- rank_for_each_item(rankingList, function(item) {
- if (item.group == group) {
- rank = item;
- }
- });
- return rank;
- }
- /**
- * Finds a rank in the rank tree by the specified name.
- *
- * @param rankName:string A string containing a valid rank name as
- * specified by the "rank" property in the
- * rankingList
- *
- * @returns The rank item if it was found, or undefined if the rank does
- * not exist in the tree, or an error occured.
- */
- function rank_find_by_name(rankName)
- {
- var rank;
- if (rankName == undefined || rankingList == undefined) {
- return;
- }
- rank_for_each_item(rankingList, function(item) {
- if (item.name.toLowerCase() == rankName.toLowerCase()) {
- rank = item;
- }
- });
- return rank;
- }
- /**
- * Finds the first rank in the rankingList where the parent group isn't defined,
- * which is by definition the starting rank.
- *
- * There should not be more than one rank in the ranking list with an undefined parent.
- *
- * @returns The starting rank if one exists, or undefined if it was not found.
- */
- function rank_starting_rank()
- {
- var startingRank;
- if (rankingList === undefined) {
- return;
- }
- rank_for_each_item(rankingList, function(item) {
- if (item.parentgroup === undefined) {
- startingRank = item;
- }
- });
- return startingRank;
- }
- /**
- * Returns a human-readable error message based on a provided
- * hard-coded error level.
- *
- * @param msgLevel The return-code for functions that return
- * an error code.
- *
- * @returns A string containing the error message for the provided
- * error code.
- */
- function rank_error_message(msgLevel)
- {
- if (msgLevel == undefined) {
- return "Unknown Error";
- }
- switch (msgLevel) {
- case 0:
- return "The operation completed successfully.";
- case -1:
- return "Internal error: the operation failed.";
- case -2:
- return "Internal error: Parsing money failed";
- case -3:
- return "Player does not have a bank account or the account cannot be found";
- case -4:
- return "Transfer failed. Perhaps you don't have enough money.";
- default:
- return "Unknown error.";
- }
- }
- /**
- * Moves a player to a new rank specified by newRank.
- *
- * @param player:Player The player to move the rank
- * @param rank:object The rank to move the player to
- *
- * @returns 0 on success,
- * -1 on input parameter failure
- * -2 on ranking cost parse failure
- * -3 on bank account not found
- * -4 on transfer failed, too poor
- */
- function rank_move(player, rank)
- {
- var rankCost;
- var seconomyAccount;
- if (player == undefined && rank == undefined) {
- return -1;
- }
- if ((rankCost = seconomy_parse_money(rank.cost)) == undefined) {
- return -2;
- }
- if (rankCost.Value == 0) {
- change_group(player, rank.group);
- rank_for_each_item(rank.levelupcommands, function(command) {
- execute_command(player, command);
- });
- return 0;
- }
- if ((seconomyAccount = seconomy_get_account(player)) == undefined) {
- return -3;
- }
- seconomy_pay_async(seconomyAccount, seconomy_world_account(), rankCost,
- "rank " + rank.name, function(payResult) {
- if (payResult.TransferSucceeded == false) {
- msg(player, "You don't have enough money to become a " + rank.name);
- return -4;
- }
- change_group(player, rank.group);
- rank_for_each_item(rank.levelupcommands, function(command) {
- execute_command(player, command);
- });
- if (rank_enable_broadcast) {
- broadcast_colour("#00AAFF", player.Name + " has become a " + rank.name.replace(/s$/i, '') + "!");
- execute_command(tshock_server(), "/firework \"" + player.Name + "\"" );
- }
- return 0;
- });
- }
- /**
- * Simple wrapper around moving a player to the specified rank.
- *
- * Does the move, and informs the player if the move failed,
- * and optionally does the broadcast when a player ranks up
- * successfully if rank_enable_broadcast is set to true.
- */
- function rank_move_wrapper(player, rank)
- {
- if (player == undefined || rank == undefined) {
- return -1;
- }
- if ((moveResult = rank_move(player, rank)) < 0) {
- msg(player, "Moving ranks failed: " + rank_error_message(moveResult));
- return -1;
- }
- return 0;
- }
- /**
- * Moves a player up the ranking tree.
- *
- * Will halt if the player is at a trunk in the tree, forcing them to make
- * a decision. The decision is chosen with the /rank <rank name> command.
- *
- * @param player The player object to move up the rank tree.
- */
- function rank_move_next(player, aliasRef)
- {
- var rank;
- var nextrankingList;
- var moveResult;
- var nextRank;
- var rankCost;
- var rankString;
- if (player == undefined || rankingList == undefined) {
- return;
- }
- if ((nextRank = rank_starting_rank()) === undefined) {
- msg(player, "There has been an error in the ranking script, and you can't move ranks.");
- return;
- }
- if ((rank = rank_find(player.Group.Name)) === undefined) {
- rank_move_wrapper(player, rank_starting_rank());
- return;
- }
- if ((nextrankingList = rank_find_parent(rank.group)) == undefined) {
- msg(player, "There has been an error in the ranking script, and you can't move ranks.");
- return;
- }
- if (nextrankingList.length == 0) {
- msg(player, "You are already the maximum rank!");
- return;
- }
- if (nextrankingList.length == 1 && (nextRank = nextrankingList[0]) != undefined) {
- rank_move_wrapper(player, nextRank);
- return;
- }
- if (nextrankingList.length > 1) {
- msg(player, "You are a " + rank.name + ". Now you must pick a class:");
- rank_for_each_item(nextrankingList, function(item) {
- rankCost = seconomy_parse_money(item.cost);
- rankString = " * /rank " + item.name;
- if (rankCost.Value == 0) {
- rankString += " (free)";
- } else {
- rankString += " (costs " + rankCost.ToString() + ")";
- }
- msg(player, rankString);
- });
- acmd_cooldown_reset(player, aliasRef);
- }
- }
- /**
- * Prints a help message to the player depending on where they are in the rank
- * tree.
- *
- * @param player The player to print the message to, and about.
- *
- */
- function rank_player_help(player)
- {
- var rank;
- var nextRank;
- var playerText;
- var rankCost;
- var rankString;
- if (player == undefined || rankingList == undefined) {
- return;
- }
- if ((rank = rank_find(player.Group.Name)) == undefined) {
- var startingRank;
- if ((startingRank = rank_starting_rank()) === undefined) {
- msg(player, "There is no starting rank, and you cannot rank up.");
- return;
- }
- msg(player, "You aren't a rank yet. Your next rank is " + startingRank.name);
- return;
- }
- playerText = "You are a " + rank.name + ".";
- if ((nextRank = rank_find_parent(rank.group)) === undefined) {
- msg(player, "There has been an internal error in the ranking system.");
- return;
- }
- if (nextRank.length == 0) {
- playerText += " You are the maximum rank!";
- msg(player, playerText);
- return;
- } else if (nextRank.length == 1 && (rank = nextRank[0]) != undefined) {
- playerText += " Your next rank is " + rank.name;
- if ((rankCost = seconomy_parse_money(rank.cost)) == undefined) {
- playerText += ".";
- } else {
- if (rankCost.Value > 0) {
- playerText += " and costs " + rankCost.ToString() + ". To rank up, type \"/rank up\".";
- } else {
- playerText += ".";
- }
- }
- } else {
- playerText += " Type /rank up to pick a class";
- }
- msg(player, playerText);
- }
- /**
- The main /rank aliascommand
- The command itself costs nothing, that's because
- the handlers will charge if need be.
- */
- acmd_alias_create( /*alias name */ "rank", /* cost */ "0c", /* Cool down seconds */0, /* permission needed */ "", /* function to execute */ function (player, parameters) {
- var command;
- var chosenClass;
- if (rankingList == undefined
- || player.Group == undefined) {
- return;
- }
- if (tshock_has_permission(player, rank_excluded_permission)) {
- msg_colour("#FFDD00", player, "You can't rank up on this account.");
- return;
- }
- if (parameters.Count == 0
- || (command = parameters[0]) == "help") {
- rank_player_help(player);
- /*
- * Cooldown gets reset if the
- * player is just querying what
- * rank they are
- */
- acmd_cooldown_reset(player, this);
- return;
- }
- if (command == "up") {
- rank_move_next(player, this);
- return;
- }
- if (!(chosenClass = rank_find_by_name(command.toString().toLowerCase()))) {
- msg_colour("#FFDD00", player, "Cannot find a rank by the name " + command + ".");
- return;
- }
- if (chosenClass.parentgroup.toLowerCase() != rank_find(player.Group.Name).name.toLowerCase()) {
- rank_player_help(player);
- return;
- }
- rank_move_wrapper(player, chosenClass);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement