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:
    165
    GitHub:
    kkora2k3
    I have the same question like yours
     
  3. Kkora

    Kkora Baby Zombie

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

    princeace Witch

    Messages:
    67
    GitHub:
    PlayZzyAce
    this is not working
     
  5. RicardoMilos384

    RicardoMilos384 Spider Jockey

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

    princeace Witch

    Messages:
    67
    GitHub:
    PlayZzyAce
    what exactly code? cuz not working on me?
     
  7. princeace

    princeace Witch

    Messages:
    67
    GitHub:
    PlayZzyAce
    [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 Witch

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

    Kkora Baby Zombie

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

    princeace Witch

    Messages:
    67
    GitHub:
    PlayZzyAce
    help me for 1 sec pls?
     
  11. princeace

    princeace Witch

    Messages:
    67
    GitHub:
    PlayZzyAce
    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 Spider Jockey

    Messages:
    35
    GitHub:
    RicardoMilos384
    use pocketmine\Server;

    You Miss it
     
  13. princeace

    princeace Witch

    Messages:
    67
    GitHub:
    PlayZzyAce
    ok ill try thanks
     
  14. princeace

    princeace Witch

    Messages:
    67
    GitHub:
    PlayZzyAce
    [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,091
    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 Witch

    Messages:
    67
    GitHub:
    PlayZzyAce
    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:
    439
    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 Witch

    Messages:
    67
    GitHub:
    PlayZzyAce
    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
    GitHub:
    donspiderlord
    Then just use the level name that you have. Don't put name that will return null.
     
    HimbeersaftLP likes this.
  20. princeace

    princeace Witch

    Messages:
    67
    GitHub:
    PlayZzyAce
    i cant understand? sorry how?
     

Share This Page

  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.