Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

full inventory swap

Comments in 'Plugin Development' started by dxm_hippie, Sep 16, 2015.

  1. dxm_hippie
    Offline

    dxm_hippie Active Member Plugin Developer

    Joined:
    Feb 1, 2015
    Posts:
    413
    Plugins:
    1
    Minecraft User:
    XxDXM_hippiexX
    How might i go about automatically switching a players inventory to another player on death?..something like this? ik its pretty off i just wanted to give you a idea what i was going for here.

    PHP:
    public function onPlayerDeath(PlayerDeathEvent $event){
    $victim $event->getEntity();
    $loot $victim->getInventory();
                    if(
    $loot != NULL){
                    
    $killer->getInventory()->addItem($loot);
    $event->setDrops([]);
                    }
    }
  2. CookieSteve
    Offline

    CookieSteve Active Member

    Joined:
    Apr 22, 2014
    Posts:
    132
    Minecraft User:
    iStrqfeChris
    What if the Player leaves?
  3. dxm_hippie
    Offline

    dxm_hippie Active Member Plugin Developer

    Joined:
    Feb 1, 2015
    Posts:
    413
    Plugins:
    1
    Minecraft User:
    XxDXM_hippiexX
    What player? the one who died?..ik there's a lot wrong with this I was just trying to show what I was looking for all I really need to know is how to do

    PHP:
    $loot $victim->getInventory();

                    if(
    $loot != NULL){

                    
    $killer->getInventory()->addItem($loot);
    but the right way and a way that actually works lol
  4. CookieSteve
    Offline

    CookieSteve Active Member

    Joined:
    Apr 22, 2014
    Posts:
    132
    Minecraft User:
    iStrqfeChris
    You should set their inventory on PlayerRespawnEvent
  5. dxm_hippie
    Offline

    dxm_hippie Active Member Plugin Developer

    Joined:
    Feb 1, 2015
    Posts:
    413
    Plugins:
    1
    Minecraft User:
    XxDXM_hippiexX
    I think you gots it backwards lol the player who dies loses everything in their inventory like usual.. but the stuff don't drop it just transfers into their killers inventory. But I guess I'd have problems if the player didn't have enough slots also..
  6. CookieSteve
    Offline

    CookieSteve Active Member

    Joined:
    Apr 22, 2014
    Posts:
    132
    Minecraft User:
    iStrqfeChris
    Oh I read it wrong I thought it give the Person who died items on Spawn My Bad :p
  7. CookieSteve
    Offline

    CookieSteve Active Member

    Joined:
    Apr 22, 2014
    Posts:
    132
    Minecraft User:
    iStrqfeChris
    You could do PlayerDamagerEvent then get $event->getDamager=$killer
  8. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    What's PlayerDamagerEvent? Learn the API...
    iksaku and Taha_The_Hacker like this.
  9. dxm_hippie
    Offline

    dxm_hippie Active Member Plugin Developer

    Joined:
    Feb 1, 2015
    Posts:
    413
    Plugins:
    1
    Minecraft User:
    XxDXM_hippiexX
    Yes i was thinking of doing EntityDammageByEntityEvent or how ever that one goes bc thats another problem..once the players dead his inventory will = NULL lol idk..might go a different rout with this. wish i knew how to handle timings..like setting a timer.
  10. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    A timer isn't needed. You're overthinking...
  11. dxm_hippie
    Offline

    dxm_hippie Active Member Plugin Developer

    Joined:
    Feb 1, 2015
    Posts:
    413
    Plugins:
    1
    Minecraft User:
    XxDXM_hippiexX
    Actually a timer would be perfect I think..I'm still not good enough to make awesome plugins by myself. So I am "tampering" with others work /: lol you devs probably frown upon that but its good practice and study. What I am attempting is modifying 1vs1..took away all kits and anything to do with kits and am trying to make it so the player may still get his victims loot before being teleported back to spawn. So a 10 sec timer before tp back to spawn would work perfect.
  12. andre_the_gamer
    Offline

    andre_the_gamer Active Member

    Joined:
    Feb 5, 2015
    Posts:
    112
    Minecraft User:
    Andre_The_Gamer
    Wow:eek: The plugin 1Vs1 has been released Saturday at 11:20 AM And @dxm_hippie is already copying:p:D
  13. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    Trying to start a flames war? There's a difference between copying and modifying. @dxm_hippie said he was learning from it, and was playing around by modifying things in it. And guess what copying means? Copying means completely copying someone's plugin and claiming it's your own(without giving the original author credit). So if you excuse me, don't flame.
    dxm_hippie likes this.
  14. andre_the_gamer
    Offline

    andre_the_gamer Active Member

    Joined:
    Feb 5, 2015
    Posts:
    112
    Minecraft User:
    Andre_The_Gamer
    You didnt get that i meant By "Copying" and i never stated which kind of copying he was doing so... Please ask before trying to start a War :) and didnt you see the ":D"? It's alright to copy people plugins and make it better as long you give them credits / full credits
  15. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    You're the one that said he was "copying". :p
  16. andre_the_gamer
    Offline

    andre_the_gamer Active Member

    Joined:
    Feb 5, 2015
    Posts:
    112
    Minecraft User:
    Andre_The_Gamer
    I've never stated which "Kind" xD of copying, :D
  17. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    Obviously there is only one kind of copying. *throws fireballs at @andre_the_gamer*
  18. andre_the_gamer
    Offline

    andre_the_gamer Active Member

    Joined:
    Feb 5, 2015
    Posts:
    112
    Minecraft User:
    Andre_The_Gamer
    That was mean what you said :( , But okay sure @Gamecrafter :p
  19. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Stop the flames please. There was nothing wrong initially, and @Gamecrafter started firing at people by being probably oversensitive or simply got bored and wanted to argue with somebody. Please, this is the PocketMine forums. We are not discussing about the disambiguation of English words here. Can you just leave alone that "copying" word, since it has nothing to do with our topic at all? You know, if moderators are a bit more strict, doing this is enough to cost a warning.
    What about doing that in EntityDamageEvent where health < 0?
  20. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    Maybe take a look at how LIAB handles it?
    When a player dies, get the drops and save it. Then setDrops to null. Put all stuff you saved and add it into the killers inv.
    PEMapModder and dxm_hippie like this.

Share This Page

Advertisement