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

How to give items to a dead player?

Discussion in 'Development' started by BruhLol, Jun 2, 2019.

  1. BruhLol

    BruhLol Baby Zombie

    Messages:
    122
    I want to give back the items the player had before a match so that there's no need to clear inventory, i have saved the contents of the inventory in an array but sometimes setting the player's inventory in PlayerDeathEvent never occurs, i dont understand why? whats the alternative to this? please any help is appreciated!
     
  2. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    Wait for the respawn event to set the inventory
     
  3. BruhLol

    BruhLol Baby Zombie

    Messages:
    122
    But what if the player quits? he loses the items then
     
  4. UnknownOre

    UnknownOre Silverfish

    Messages:
    21
    GitHub:
    UnknownOre
    use EntitySpawnEvent then
    when he spawn/join give his items
     
  5. BruhLol

    BruhLol Baby Zombie

    Messages:
    122
    you sure?
     
  6. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    That's the only way. You can save the items to a file to keep them across server restarts
     
    Diduhless and BruhLol like this.
  7. ChampOfGames

    ChampOfGames Creeper

    Messages:
    4
    GitHub:
    ChampOfGamesYT
    You can make it that way:

    public Function onDeath (PlayerDeathEvent $event){
    $event->setkeepInventory(true);
    }
     
  8. BruhLol

    BruhLol Baby Zombie

    Messages:
    122
    I dont want to give that inventory
     
  9. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    At least read OP's post
     
  10. ChampOfGames

    ChampOfGames Creeper

    Messages:
    4
    GitHub:
    ChampOfGamesYT
    I understood it wrong.
     
  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.