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

Player count on slapper

Discussion in 'Help' started by A354-PH, Dec 23, 2018.

  1. A354-PH

    A354-PH Baby Zombie

    Messages:
    186
    GitHub:
    Kizu
    Hello, how to put the player count of an world on an slapper/npc?
     
    Kkora likes this.
  2. Kkora

    Kkora Baby Zombie

    Messages:
    189
    GitHub:
    shisui203
    I have the same question like yours
     
  3. Kkora

    Kkora Baby Zombie

    Messages:
    189
    GitHub:
    shisui203
    I found a code. It may help you:
    PHP:
    count($this->getServer()->getLevelByName("World")->getPlayers());
     
  4. princeace

    princeace Slime

    Messages:
    78
    GitHub:
    PrincessSeah
    this is not working
     
  5. RicardoMilos384

    RicardoMilos384 Slime

    Messages:
    82
    GitHub:
    ricardomilos384
    That is working code
    You just have to think about it
     
  6. princeace

    princeace Slime

    Messages:
    78
    GitHub:
    PrincessSeah
    what exactly code? cuz not working on me?
     
  7. princeace

    princeace Slime

    Messages:
    78
    GitHub:
    PrincessSeah
    [03:15:19] [Server thread/CRITICAL]: Error: "Call to undefined method slapper\entities\SlapperHuman::getServer()" (EXCEPTION) in "plugins/Slapper.phar/src/slapper/SlapperTrait" at line 83

    i got this error i input this code
     
  8. princeace

    princeace Slime

    Messages:
    78
    GitHub:
    PrincessSeah
    PHP:
    "{CreativePlot}" => count($this->getServer()->getLevelByName("CreativePlot")->getPlayers());
    this is my line 83
     
  9. Kkora

    Kkora Baby Zombie

    Messages:
    189
    GitHub:
    shisui203
    This code was fine for 2 years ago. Now I'm not interested in PMMP anymore.
     
  10. princeace

    princeace Slime

    Messages:
    78
    GitHub:
    PrincessSeah
    help me for 1 sec pls?
     
  11. princeace

    princeace Slime

    Messages:
    78
    GitHub:
    PrincessSeah
    PHP:
    count($this->getServer()->getLevelByName("World")->getPlayers());
    i input this and i got this error
    [03:07:47] [Server thread/CRITICAL]: Error: "Call to undefined method slapper\entities\SlapperHuman::getServer()" (EXCEPTION) in "plugins/Slapper.phar/src/slapper/SlapperTrait" at line 84
     
  12. RicardoMilos384

    RicardoMilos384 Slime

    Messages:
    82
    GitHub:
    ricardomilos384
    use pocketmine\Server;

    You Miss it
     
  13. princeace

    princeace Slime

    Messages:
    78
    GitHub:
    PrincessSeah
    ok ill try thanks
     
  14. princeace

    princeace Slime

    Messages:
    78
    GitHub:
    PrincessSeah
    [08:46:33] [Server thread/CRITICAL]: Error: "Call to undefined method slapper\entities\SlapperHuman::getServer()" (EXCEPTION) in "plugins/Slapper.phar/src/slapper/SlapperTrait" at line 87

    how about this?
     
  15. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    @RicardoMilos384's answer was wrong. Remove use pocketmine\Server; again and replace $this->getServer() with $player->getServer().
     
    GamakCZ likes this.
  16. princeace

    princeace Slime

    Messages:
    78
    GitHub:
    PrincessSeah
    i got this code after i change and remove?
    [18:01:01] [Server thread/CRITICAL]: Error: "Call to a member function getPlayers() on null" (EXCEPTION) in "plugins/Slapper.phar/src/slapper/SlapperTrait" at line 86

    this is my line 86
    PHP:
    "{CreativePlot}" => count($player->getServer()->getLevelByName("CreativePlot")->getPlayers()),
     
  17. GamakCZ

    GamakCZ Zombie Pigman

    Messages:
    598
    GitHub:
    GamakCZ
    You have to use valid level name, that means the level 'CreativePlot' must be generated and loaded
     
    HimbeersaftLP likes this.
  18. princeace

    princeace Slime

    Messages:
    78
    GitHub:
    PrincessSeah
    same error

    [01:20:15] [Server thread/CRITICAL]: Error: "Call to a member function getPlayers() on null" (EXCEPTION) in "plugins/Slappcount.phar/src/slapper/SlapperTrait" at line 86

    PHP:
    "{PvP}" => count($player->getServer()->getLevelByName("PvP")->getPlayers()),
    PS: i dont have PvP world
     
  19. DonSpiderLord

    DonSpiderLord Silverfish

    Messages:
    15
    Then just use the level name that you have. Don't put name that will return null.
     
    HimbeersaftLP likes this.
  20. princeace

    princeace Slime

    Messages:
    78
    GitHub:
    PrincessSeah
    i cant understand? sorry how?
     
  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.