1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Solved Experience

Discussion in 'Development' started by iCirgio, Jan 6, 2018.

  1. iCirgio

    iCirgio Slime

    Messages:
    92
    GitHub:
    lolnova
    Hello I wanted to ask how to add experience to a player.

    I tried
    PHP:
    $player->setXpLevel($player->getTotalXp() + $tier2win);
    It replaces xp and adds tier2win prize that is randomized.

    But I want it to add on to the xp not replace
     
  2. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    please don't duplicate threads (https://forums.pmmp.io/threads/adding-xp.4988/)
    you can either use `Human->getXpLevel()` instead of `Human->getTotalXp()` or simply use
    PHP:
    $playSound true//If you don't want a sound, set this to false
    $player->addXpLevels($tier2win$playSound);
    you can even decide if you want to play a sound
     
    OnTheVerge and EdwardHamHam like this.
  3. iCirgio

    iCirgio Slime

    Messages:
    92
    GitHub:
    lolnova
    I'm sorry I didn't see that when o searched thank you
     
  4. iCirgio

    iCirgio Slime

    Messages:
    92
    GitHub:
    lolnova
    PHP:
    06.01 14:59:46 [ServerServer thread/CRITICAL Error"Call to undefined method pocketmine\Player::addXpLevels()" (EXCEPTIONin "Imcore/src/Core/Events/XPPouch" at line 84
    06.01 14
    :59:46 [ServerServer thread/CRITICAL Could not pass event 'pocketmine\event\player\PlayerInteractEvent' to 'ImmenseCore v1.0.0'Call to undefined method pocketmine\Player::addXpLevels() on Core\Events\XPPouch
    Error
     
  5. iCirgio

    iCirgio Slime

    Messages:
    92
    GitHub:
    lolnova
    Doesn't work
     
  6. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    artulloss likes this.
  7. iCirgio

    iCirgio Slime

    Messages:
    92
    GitHub:
    lolnova
    Worked thanks
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.