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

doFirstSpawn ()

Comments in 'Plugin Development' started by LoveToBeDev, Sep 10, 2015.

  1. LoveToBeDev
    Offline

    LoveToBeDev Active Member

    Joined:
    Aug 19, 2015
    Posts:
    55
    Minecraft User:
    LoveToBeDev
  2. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    LoveToBeDev likes this.
  3. LoveToBeDev
    Offline

    LoveToBeDev Active Member

    Joined:
    Aug 19, 2015
    Posts:
    55
    Minecraft User:
    LoveToBeDev
    is there something to detect if the player is making his first spawn??
  4. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    Like when they join the server for the first time?
    LoveToBeDev likes this.
  5. LoveToBeDev
    Offline

    LoveToBeDev Active Member

    Joined:
    Aug 19, 2015
    Posts:
    55
    Minecraft User:
    LoveToBeDev
    yes! :D
  6. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    I think you can use Player::hasPlayedBefore(), but I'm not really sure. Just try it. ;)
    LoveToBeDev likes this.
  7. LoveToBeDev
    Offline

    LoveToBeDev Active Member

    Joined:
    Aug 19, 2015
    Posts:
    55
    Minecraft User:
    LoveToBeDev
    ohh my god, im so stupid :p look at this please, how can i get the name of the player??
    PHP:
    <?php

    namespace welcometoserver\lovetobedev;

    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\utils\TextFormat as Color;
    use 
    pocketmine\Player;
    use 
    pocketmine\Server;
    use 
    pocketmine\item\Item;
    use 
    pocketmine\IPlayer;
    use 
    pocketmine\event\player\PlayerJoinEvent;

    class 
    Main extends PluginBase{
        public function 
    onEnable() {
            
    $this->getLogger()->info("Plugin Enabled, new people in your server will be happy!");
        }
       
        public function 
    onDisable() {
            
    $this->getLogger()->info("Plugin Disabled");
        }
       
        public function 
    hasPlayedBefore(){
            
    $items = [
                
    Item::get(27201),
                
    Item::get(27301),
                
    Item::get(27401),
                
    Item::get(27501)
            ];
            
    Server::getInstance()->broadcastMessage(Color::LIGHT_PURPLE."Welcome Back!");
        }
       
    }
    Where can i establish the name??!
  8. LoveToBeDev
    Offline

    LoveToBeDev Active Member

    Joined:
    Aug 19, 2015
    Posts:
    55
    Minecraft User:
    LoveToBeDev
    i have put this->getName() but i don't think it will work :(
  9. TryoneLegendZzz
    Offline

    TryoneLegendZzz Active Member

    Joined:
    May 31, 2015
    Posts:
    201
    Minecraft User:
    SavionLegendZzz
    1. please learn PM api 2.
    PHP:
    $player->getName()
  10. LoveToBeDev
    Offline

    LoveToBeDev Active Member

    Joined:
    Aug 19, 2015
    Posts:
    55
    Minecraft User:
    LoveToBeDev
    you are incorrect! im not using function onCommand!! hahaha, you should learn the api, the fix is here, i just figured out:
    PHP:
    $name $this->getServer()->getPlayer()->getName();
    i just finished the plugin, it actually works perfectly!!
  11. LoveToBeDev
    Offline

    LoveToBeDev Active Member

    Joined:
    Aug 19, 2015
    Posts:
    55
    Minecraft User:
    LoveToBeDev
    and, i think the instanceof Compound is ok for checking the has played before i think :p let me know, cuz im getting a lot of confusion on that
  12. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Note that the doFirstSpawn function is a protected function, which mean you can't access it outside the player class hierarchy.
    That's PHP not the API.
    Actually, the Server object does not contain a getPlayer function. Apparently neither of you know what you are doing.
  13. LoveToBeDev
    Offline

    LoveToBeDev Active Member

    Joined:
    Aug 19, 2015
    Posts:
    55
    Minecraft User:
    LoveToBeDev
    WELL, INSTEAD OF ANNOYING US, HELP !!
  14. TryoneLegendZzz
    Offline

    TryoneLegendZzz Active Member

    Joined:
    May 31, 2015
    Posts:
    201
    Minecraft User:
    SavionLegendZzz
    you had this no where in your code.
  15. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    I have no idea what you want to do at all, so how could I help? I am not a mind reader or a fortune teller.
    Hotshot_9930 and jojoe77777 like this.
  16. LoveToBeDev
    Offline

    LoveToBeDev Active Member

    Joined:
    Aug 19, 2015
    Posts:
    55
    Minecraft User:
    LoveToBeDev
    Im trying to make a first join send message to the player
  17. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    When a player joins store their name in an array, database or config. If you want to send a message to a player when they first join the server, just check to see if that player's name is in the array, database or config and if it isnt send them the message.
  18. GlaciercreepsMC
    Offline

    GlaciercreepsMC Active Member Plugin Developer

    Joined:
    Jan 21, 2014
    Posts:
    91
    Plugins:
    1
    Minecraft User:
    GlaciercreepsMC
    What do you mean? I found this. Or, were you saying that there isn't a getPlayer() func with no args?
  19. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    PHP:
    public function onJoin(PlayerJoinEvent $event){
    $player $event->getName();
    if(
    file_exists("players/".strtolower($player->getName()).".dat") == false){
    $event->setJoinMessage($player->getName()." Joined for the first time :)");
    }
    }
    Last edited: Sep 11, 2015
    Taha_The_Hacker likes this.
  20. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Player::hasPlayedBefore() always returns true (dont use it)

Share This Page

Advertisement