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

Slapper Human nametag

Discussion in 'Plugin Help' started by Kkora, Aug 25, 2020.

  1. Kkora

    Kkora Baby Zombie

    Messages:
    189
    GitHub:
    shisui203
    Hi everybody. How can I get Slapper's nametag, just to making for my CustomQuests plugin. If I interact with a specified Slapper with their nametag, it'll appear a UI or doing other events,...
     
  2. GodWeedZao

    GodWeedZao Zombie Pigman

    Messages:
    401
    GitHub:
    godweedzao
    use statments:
    PHP:
    use jojoe77777\FormAPI;
    use 
    pocketmine\event\entity\EntityDamageByEntityEvent;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\Player;
    use 
    pocketmine\plugin\PluginBase;
    use 
    slapper\entities\SlapperHuman;
    code, Example, Explain:
    PHP:
    /**
    * @param EntityDamageByEntityEvent $event
    */
    public function onEntityClick(EntityDamageByEntityEvent $event) {
        
    $slapper $event->getEntity();
        
    $slapperName $slapper->getNameTag();
        
    $player $event->getDamager();
        if (
    $slapper instanceof Slapper) { //if you are clicking on slapper
            
    if ($slapperName === "Test") { //if slapper name is Test
                
    $this->whatEveryouWant($player); //open a form menu to player (who clicking slapper)
            
    }
        }
    }
     
  3. GodWeedZao

    GodWeedZao Zombie Pigman

    Messages:
    401
    GitHub:
    godweedzao
    and you should spawn a slapper with Test name, its done.
    (also set prefix to solved)
     
    Kkora likes this.
  4. Kkora

    Kkora Baby Zombie

    Messages:
    189
    GitHub:
    shisui203
    what about custom slapper, not only single slapper?
     
  5. Kkora

    Kkora Baby Zombie

    Messages:
    189
    GitHub:
    shisui203
    PHP:
    public function onEntityDamage(EntityDamageEvent $event): void {
            
    $entity $event->getEntity();
            
    $cause $entity->getLastDamageCause();
            if (
    $entity instanceof SmaccerEntity || $entity instanceof SmaccerHuman) {
                
    $event->setCancelled(true);
                if (!
    $event instanceof EntityDamageByEntityEvent) {
                    return;
                }
                if(
    $cause instanceof EntityDamageByEntityEvent){
                    
    $damager $cause->getDamager();
                    if(
    $damager instanceof Player){
                        if (
    $entity instanceof SmaccerEntity || $entity instanceof SmaccerHuman) {
                            if (
    $slapperName === "custom name from UI") {
                            
    QuestManager::onQuestEvent($damager"interact");
                            }
                        }
                    }
                }
            }
       }
    I used Smaccer, forked from Slapper with all of Slapper's addon in 1 plugin because it's very easy to use
     
    GodWeedZao likes this.
  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.