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

Undefined error setXpDropAmount

Discussion in 'Development' started by WhoAreMe, Jun 6, 2020.

  1. WhoAreMe

    WhoAreMe Witch

    Messages:
    55
    Hi i want to disable player xp drop on death and give it to them on respawn.
    So i i tried to do it using this code.
    $event->setXpDropAmount(0). Idk if this will disable xp drop but i got undefined error with that function. Any idea why? Or maybe alternative to setXpDropAmount to disable xp drop on death.
     
  2. WhoAreMe

    WhoAreMe Witch

    Messages:
    55
    What class am i missing? I have playerdeathevent and entitydeathevent. setDrops is working while setXpDropAmount aren't
     
  3. KinokiYT

    KinokiYT Spider Jockey

    Messages:
    25
    GitHub:
    kinokiyt
    Cancel the experience drop on death, then restore it by getting their experience before their death.
     
  4. WhoAreMe

    WhoAreMe Witch

    Messages:
    55
    How do i cancel it?
     
  5. WhoAreMe

    WhoAreMe Witch

    Messages:
    55
    $xp = $event->getXpDropAmount(); This is also undefined what am i missing?
     
  6. WhoAreMe

    WhoAreMe Witch

    Messages:
    55
    I just update pmmp and it works
     
  7. WhoAreMe

    WhoAreMe Witch

    Messages:
    55
    Is the issue about PlayerRespawnEvent still occur? I can't setxplevel or addxp on respawn
     
  8. KinokiYT

    KinokiYT Spider Jockey

    Messages:
    25
    GitHub:
    kinokiyt
    Code:
    $event->setXpDropAmount(0);
     
  9. WhoAreMe

    WhoAreMe Witch

    Messages:
    55
    What is the best way to store Xp Data? Is one file yaml good or i need to make a lot of file per player name with xp as data?
     
  10. Heisenburger69

    Heisenburger69 Silverfish

    Messages:
    16
    GitHub:
    heisenburger69
    The event is called *before* the player actually respawns, so any modifications to health/xp/inv contents get reset. There's probably an easier method, but you could try using a delayed task scheduled 1 tick after PlayerRespawnEvent and give xp when its run
     
    Diduhless and WhoAreMe like this.
  11. WhoAreMe

    WhoAreMe Witch

    Messages:
    55
    Now i just need to save the xp on server restart. This is my first time working with config.
     
  12. WhoAreMe

    WhoAreMe Witch

    Messages:
    55
    Welpp somebody im close to make it work. I just bump into a problem does clicking Main Menu in death event screen count as PlayerQuitEvent? The XP don't save it resets to 0
     
  13. WhoAreMe

    WhoAreMe Witch

    Messages:
    55
    How do i save that variable im so confused
     
  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.