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
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
PHP: 06.01 14:59:46 [Server] Server thread/CRITICAL Error: "Call to undefined method pocketmine\Player::addXpLevels()" (EXCEPTION) in "Imcore/src/Core/Events/XPPouch" at line 8406.01 14:59:46 [Server] Server 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
well, maybe https://github.com/pmmp/PocketMine-MP/blob/master/src/pocketmine/entity/Human.php#L316 isn't available in your version of pmmp yet. you can still use my 2nd suggestion: PHP: $player->setXpLevel($player->getXpLevel() + $tier2win);