Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const ENMAPLEVEL = require('enmap-level')
- const ENMAP = require('enmap');
- const SKILLS = new ENMAP({
- provider: new ENMAPLEVEL({
- name: "Skill Data"
- })
- })
- const SKILL_OBJECTS = {}
- const SKILLS_ARRAY = ["Combat", "Farming", "Mining", "Fishing", "Woodcutting"]
- const LEVEL_3_DOOR = Game.findBrickByName("level3doorstart");
- SKILLS.set("data", SKILL_OBJECTS);
- function find_skill(skill) {
- for (let index of SKILLS_ARRAY) {
- if (index.toLowerCase().indexOf(skill) == 0) {
- return index
- }
- }
- }
- function notification(msg, player) {
- if (!msg) return;
- return player.message(`[#0000FF][Skills]: [#FFFFFF]${msg}`);
- };
- Game.on('playerJoin', plr => {
- if (SKILLS.has("data", plr.userId)) return;
- SKILL_OBJECTS[plr.userId] = {
- "Combat": {
- level: 0,
- exp: 0
- },
- "Farming": {
- level: 0,
- exp: 0
- },
- "Mining": {
- level: 0,
- exp: 0
- },
- "Fishing": {
- level: 0,
- exp: 0
- },
- "Woodcutting": {
- level: 0,
- exp: 0
- },
- };
- return SKILLS.set("data", SKILL_OBJECTS[plr.userId], plr.userId)
- });
- LEVEL_3_DOOR.touching(player => {
- const data = SKILLS.get("data", player.userId);
- const level_require = 3;
- if (!data) return Error(`No data found for user ${player.userId}`);
- if (data.Combat.level < level_require) return {
- NOTI: notification(`Come back when you're level ${level_require}!`, player),
- TELE: player.position = Game.findBrickByName("brick1541").position
- }
- LEVEL_3_DOOR.collision = false;
- setTimeout(() => {
- LEVEL_3_DOOR.collision = true
- }, 2000);
- })
- Game.on("skillsCmd", plr => {
- const data = SKILLS.get("data", plr.userId);
- if (data) {
- for (let index of Object.keys(data)) {
- plr.message(`[#00FF00][Skills]: [#FFFFFF]${index}: ${data[index].level} [#00FFFF][EXP]: [#FFFFFF]${data[index].exp}`)
- }
- }
- })
- Game.on('setCmd', (plr, msg) => {
- const messages = msg.split(" ")
- if (!messages[0], !messages[1]) return;
- if (isNaN(messages[1])) return;
- const skill = find_skill(messages[0]);
- if (skill) {
- return {
- SET_DATA: SKILLS.set("data", Number(messages[1]), `${plr.userId}.${skill}.level`),
- NOTI: notification(`You set ${skill} to level ${Number(messages[1])}`, plr)
- }
- }
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement