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

Floating Texter

Discussion in 'Help' started by WoolChannel3295, Mar 31, 2020.

  1. WoolChannel3295

    WoolChannel3295 Silverfish

    Messages:
    22
    GitHub:
    KietTran0308
    HEY, I NEED HELP:(
    HOW TO CREATE TOP MONEY OR TOP KILL = FLOATING TEXTER EVENT
     
  2. FurkanYks

    FurkanYks Creeper

    Messages:
    5
    GitHub:
    FurkanYks
    okey try this code:


    <?php

    namespace TopMoney;

    use pocketmine\level\particle\FloatingTextParticle;
    use pocketmine\Player;
    use pocketmine\event\Listener;
    use pocketmine\math\Vector3;
    use pocketmine\event\player\PlayerJoinEvent;

    class TopMoney extends implements Listener{


    public function joinevent(PlayerJoinEvent $e){


    $player = $e->getPlayer();


    $this->topmoney($player);

    }
    public function topmoney($p){



    $player = $p->getPlayer();

    $configs = $this->moneyconfig->getAll();

    $count = count($configs);


    $message = “”;
    $top = “Top Money LeaderBoard”;

    arsort($configs);



    $i = 1;
    foreach($configs as $name => $amount){


    $message .= “§e ”.$i.”. §7” .$name.” §f” .$amount. “§aMoney\n”;
    if($i > 4 ){
    break;
    }
    ++$i;
    }
    $x = 100;
    $y = 100;
    $z = 101;
    $p = new FloatingTextParticle(new Vector3($x,$y +1, $z), $message, $top);
    $player->getLevel()->addParticle($p);
    }

    }
    }
    }
     
  3. xSoapers

    xSoapers Spider

    Messages:
    6
    GitHub:
    xSoapers
    <?php

    namespace TopMoney\Task;

    use TopMoney\TopMoney;
    use pocketmine\scheduler\Task;
    use pocketmine\Player;

    class UpdateTask extends Task {

    public function __construct(TopMoney $plugin) {
    $this->plugin = $plugin;
    }

    public function onRun(int $currentTick) {
    $this->plugin->TopMoney();​
    }
    }

    use this task
     
  4. Invy55

    Invy55 Witch

    Messages:
    52
    GitHub:
    invy55
    Please use the php tag between two [].
    PHP:
    <?php
    //example of php using [php] tag
     
  5. WoolChannel3295

    WoolChannel3295 Silverfish

    Messages:
    22
    GitHub:
    KietTran0308
    I have tested the code task doesn't work
    (╯_╰)
     
  6. xSoapers

    xSoapers Spider

    Messages:
    6
    GitHub:
    xSoapers
    change $this->plugin->TopMoney(); to $this->plugin->topmoney();
     
  7. WoolChannel3295

    WoolChannel3295 Silverfish

    Messages:
    22
    GitHub:
    KietTran0308
    1. I have changed but the code doesn't work
     
  8. WoolChannel3295

    WoolChannel3295 Silverfish

    Messages:
    22
    GitHub:
    KietTran0308
    Help me, the code run but my money was initially 5 and I adjusted it to 10, so the 2 text tables are nested! Is there any way for a text table?
     
  9. FurkanYks

    FurkanYks Creeper

    Messages:
    5
    GitHub:
    FurkanYks
    Ok thanks for information.
     
  10. Draglor56

    Draglor56 Silverfish

    Messages:
    24
    You have to define $p that means do it like that:

    public function topmoney(Player $player){}

    And in the Task you must write the argument Player like that:

    foreach($this->plugin->getServer()->getOnlinePlayers() as $player){
    $this->plugin->topmoney($player)
    }
     
  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.