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

Solved Get damager who push player into void

Comments in 'Plugin Development' started by deot, Nov 12, 2015.

  1. deot
    Offline

    deot Active Member Plugin Developer

    Joined:
    Apr 22, 2015
    Posts:
    219
    Plugins:
    1
    Minecraft User:
    deot
    I wanted to get damager who push/hit a player into void...
    But, problem is how can I achieve that?
    PHP:
    $p->getLastDamageCause()->getDamager;
    I think this will only work for when player hit player
    If im using this code and player drop into void, I think it will just return "void" as damager, is it?

    How can I get the damager who push/hit that player to void?
    It will be good if Pocketmine implant API like this:
    getLastHit() :p
  2. deot
    Offline

    deot Active Member Plugin Developer

    Joined:
    Apr 22, 2015
    Posts:
    219
    Plugins:
    1
    Minecraft User:
    deot
    Nvm, I found out a way :p
  3. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Which?:D I would recommended creating an array for that and save the lastHit in there
    hoyinm14mc likes this.
  4. deot
    Offline

    deot Active Member Plugin Developer

    Joined:
    Apr 22, 2015
    Posts:
    219
    Plugins:
    1
    Minecraft User:
    deot
    Yep :)
    Save the player name when EntityDamageByEntityEvent is fired, and create a function to call out that name when PlayerDeathEvent :)
    But, I have no idea on how to send the message "You smashed $player to void" to that damager.. zzz :p
  5. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    PHP:
    $name "whatever that is:P";
    $player null;
    if(
    $player $this->getServer()->getPlayer($name)){ // Player online
    $player->sendMessage();
    // Player offline
  6. thebigsmileXD
    Offline

    thebigsmileXD Banned

    Joined:
    May 19, 2015
    Posts:
    845
    Plugins:
    1
    Minecraft User:
    XenialDan
    You could save the last Entity colliding with the player i guess. I am sure there was an entity collide with entity event
  7. deot
    Offline

    deot Active Member Plugin Developer

    Joined:
    Apr 22, 2015
    Posts:
    219
    Plugins:
    1
    Minecraft User:
    deot
    Thank you, but I already solved it.. LOL
    Now, I'm just figuring how to send message to that damager :p
  8. thebigsmileXD
    Offline

    thebigsmileXD Banned

    Joined:
    May 19, 2015
    Posts:
    845
    Plugins:
    1
    Minecraft User:
    XenialDan
    Please send your code
  9. deot
    Offline

    deot Active Member Plugin Developer

    Joined:
    Apr 22, 2015
    Posts:
    219
    Plugins:
    1
    Minecraft User:
    deot
    Why I need to? zzz :p
  10. thebigsmileXD
    Offline

    thebigsmileXD Banned

    Joined:
    May 19, 2015
    Posts:
    845
    Plugins:
    1
    Minecraft User:
    XenialDan
    I would love to help you with the message. I only need the function that is called on EntityDamageEvent
  11. Lambo
    Offline

    Lambo Notable Member Plugin Developer

    Joined:
    Sep 14, 2013
    Posts:
    431
    Plugins:
    4
    Minecraft User:
    Lambo
    You don't need $player = null
  12. TryoneLegendZzz
    Offline

    TryoneLegendZzz Active Member

    Joined:
    May 31, 2015
    Posts:
    201
    Minecraft User:
    SavionLegendZzz
    Just add the $damager to a $victim s array such as
    PHP:
    $this->damager[$victim->getName]["Damager"];
  13. CrazedMiner
    Offline

    CrazedMiner Notable Member Plugin Developer

    Joined:
    Jan 31, 2015
    Posts:
    348
    Plugins:
    2
    Minecraft User:
    CrazedMinerYT
    Save the victims last PLAYER damager in an array and get it when the player dies.
  14. thebigsmileXD
    Offline

    thebigsmileXD Banned

    Joined:
    May 19, 2015
    Posts:
    845
    Plugins:
    1
    Minecraft User:
    XenialDan
    He did it that way. And still, you don't get the person pushing the other xD you can't even push players
  15. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
  16. thebigsmileXD
    Offline

    thebigsmileXD Banned

    Joined:
    May 19, 2015
    Posts:
    845
    Plugins:
    1
    Minecraft User:
    XenialDan

Share This Page

Advertisement