How can I make a level system with my current xp system?

Ok, done, did it.

What should I write in levels.js?

Idk… the level script?

… I made this thread for someone to tell me how to make one…

1 Like

whoops I made a mistake

var level = Yen.level
var count;
count = levels * 100

if (Yen.xp == count -= 100) {
Yen.xp=0;
level+=1;
count = levels * 100
}
1 Like

:0 Ill try this in the morning!!!

Is there a way I can integrate a message every time someone levels up? Is it as easy as doing message.reply(“You have leveled up”)?

1 Like

I found this on Google, this might help you:

You could integrate it with your current one.

1 Like

Ohhhh, this dude. He’s using fs, not mongodb. I think for now Ima try @code-alt 's message tmr, then try this out if his version doesn’t work.

1 Like

Yep!

just add it

var level = Yen.level
var count;
count = levels * 100

if (Yen.xp == count -= 100) {
Yen.xp=0;
level+=1;
callback(); // you can change this to whatever code or put it in the function callback()
count = levels * 100
}

function callback() {
// code goes here
}
1 Like

What goes in the callback function? So far I havve nothing in my levels.js.

So in the callback it would be message.channel.send()?

Yes. You can add any code in the callback. If it does not work then try replacing the callback() line to that code.

It is just something I added for easier access.

Nothing seemed to work… should I try putting this in my index file?

I did this to test:

  var level = Yen.level
  var count;
  count = level * 1
  var counts = level -= 1
  
  if (Yen.xp == 1) {
  Yen.xp=0;
  level+=1;
  message.channel.send("You have leveled up!")
  count = level * 1
  }

But when I got 1 xp my level didn’t increase.

image

I guess you should. I will try and come up with a solution.

edit: == should be there, count should be 100, as you know instead of one.

You should also set a default level since the current one is undefined, which will never actually change.