SHARE
TWEET

Untitled

a guest Aug 17th, 2019 83 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const ENMAPLEVEL = require('enmap-level')
  2. const ENMAP = require('enmap');
  3. const SKILLS = new ENMAP({
  4.     provider: new ENMAPLEVEL({
  5.         name: "Skill Data"
  6.     })
  7. })
  8. const SKILL_OBJECTS = {}
  9. const SKILLS_ARRAY = ["Combat", "Farming", "Mining", "Fishing", "Woodcutting"]
  10. const LEVEL_3_DOOR = Game.findBrickByName("level3doorstart");
  11.  
  12.  
  13.  
  14. SKILLS.set("data", SKILL_OBJECTS);
  15.  
  16.  
  17. function find_skill(skill) {
  18.     for (let index of SKILLS_ARRAY) {
  19.         if (index.toLowerCase().indexOf(skill) == 0) {
  20.             return index
  21.         }
  22.     }
  23. }
  24.  
  25. function notification(msg, player) {
  26.     if (!msg) return;
  27.     return player.message(`[#0000FF][Skills]: [#FFFFFF]${msg}`);
  28. };
  29.  
  30. Game.on('playerJoin', plr => {
  31.     if (SKILLS.has("data", plr.userId)) return;
  32.  
  33.     SKILL_OBJECTS[plr.userId] = {
  34.         "Combat": {
  35.             level: 0,
  36.             exp: 0
  37.         },
  38.         "Farming": {
  39.             level: 0,
  40.             exp: 0
  41.         },
  42.         "Mining": {
  43.             level: 0,
  44.             exp: 0
  45.         },
  46.         "Fishing": {
  47.             level: 0,
  48.             exp: 0
  49.         },
  50.         "Woodcutting": {
  51.             level: 0,
  52.             exp: 0
  53.         },
  54.     };
  55.  
  56.     return SKILLS.set("data", SKILL_OBJECTS[plr.userId], plr.userId)
  57. });
  58.  
  59. LEVEL_3_DOOR.touching(player => {
  60.     const data = SKILLS.get("data", player.userId);
  61.     const level_require = 3;
  62.     if (!data) return Error(`No data found for user ${player.userId}`);
  63.     if (data.Combat.level < level_require) return {
  64.         NOTI: notification(`Come back when you're level ${level_require}!`, player),
  65.         TELE: player.position = Game.findBrickByName("brick1541").position
  66.     }
  67.     LEVEL_3_DOOR.collision = false;
  68.     setTimeout(() => {
  69.         LEVEL_3_DOOR.collision = true
  70.     }, 2000);
  71. })
  72.  
  73. Game.on("skillsCmd", plr => {
  74.     const data = SKILLS.get("data", plr.userId);
  75.     if (data) {
  76.         for (let index of Object.keys(data)) {
  77.             plr.message(`[#00FF00][Skills]: [#FFFFFF]${index}: ${data[index].level} [#00FFFF][EXP]: [#FFFFFF]${data[index].exp}`)
  78.         }
  79.     }
  80. })
  81.  
  82. Game.on('setCmd', (plr, msg) => {
  83.     const messages = msg.split(" ")
  84.     if (!messages[0], !messages[1]) return;
  85.     if (isNaN(messages[1])) return;
  86.     const skill = find_skill(messages[0]);
  87.     if (skill) {
  88.         return {
  89.             SET_DATA: SKILLS.set("data", Number(messages[1]), `${plr.userId}.${skill}.level`),
  90.             NOTI: notification(`You set ${skill} to level ${Number(messages[1])}`, plr)
  91.         }
  92.     }
  93. })
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top