Solved How to set max exp level?

Discussion in 'Plugin Development' started by CrazyYoungBro, Jun 15, 2016.

Thread Status:
Not open for further replies.
  1. Offline

    CrazyYoungBro

    Hello,
    I am making a levelup plugin for which I require to set the max exp level to 100. How can I set it and where?
     
  2. Offline

    Irantwomiles

    What I would do is when a player gains exp check if their level is greater than or equal to 100, if so just set their exp to a hundred or level them up and reset their exp.
     
  3. Offline

    I Al Istannen

    @CrazyYoungBro
    You could set the xp amount in the PlayerXpChangeEvent to 0 if they are level 100 . Doesn't prevent plugins from changing his level, but that is probably negligible.
     
  4. Offline

    CrazyYoungBro

    That seems like a good idea.
    Can't use it as I am making a plugin in which player needs to run command to level up.
     
  5. Offline

    I Al Istannen

    @CrazyYoungBro
    Well, this is the only event I know of that fires on xp change. It says that is fires for "natural" xp gains, so I assumed it doesn't work if a plugin sets the experience.
    Then you may need to run a scheduler resetting the level to 100 if they exceed it.

    The better idea however would be changing the command! What is easier than that? A simple check there can save you a lot of headache at another place.
     
  6. Offline

    Irantwomiles

    You can still use the functionality. use this to check if the players level equals to or greater than a hundred and if so just set the players EXP level to 100. then just send a message to the player and say "You are ready to go to the next level" or something like that and then they can use the command that you've set up.
     
  7. Offline

    I Al Istannen

    @Irantwomiles
    It is what I said and linked.
    I would assume it excludes changes by command.

    But the better idea is adapting the command to not even change the xp if the level is already too high. Makes more sense for the user and also from a programming perspective.

    EDIT: You marked this as solved. Could you say what you used in the end?
     
  8. Offline

    CrazyYoungBro

    I used an if statement to check if the player's level is more than or euqal to 100. If yes then set level to 0
     
  9. Offline

    Irantwomiles

    Dont need a scheduler for that. Just check when the player gains exp and if greater than 100, reset it to 100.
     
  10. Offline

    I Al Istannen

    CrazyYoungBro likes this.
  11. Offline

    Irantwomiles

    @I Al Istannen oh yea true, i was just thinking about them leveling up.
     
Thread Status:
Not open for further replies.

Share This Page