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

Tutorial [New API]Set your own custom join messages

Comments in 'Resources' started by sebagius7110, Aug 10, 2014.

?

Did I help you?

  1. YES OF COURSE

    17 vote(s)
    60.7%
  2. NO LOL U FAILED ME

    11 vote(s)
    39.3%
  1. AvivShopenCraft
    Offline

    AvivShopenCraft New Member

    Joined:
    Oct 14, 2015
    Posts:
    73
    Minecraft User:
    AvivShopen
    pleeease someone , I'm sorry I'm asking too much :(:(:(:confused:
  2. AvivShopenCraft
    Offline

    AvivShopenCraft New Member

    Joined:
    Oct 14, 2015
    Posts:
    73
    Minecraft User:
    AvivShopen
    whats wrong here?

    its says:
    Parse error: syntax error, unexpected 'onPlayerJoin' (T_STRING) in C:\PocketMine-MP\plugins\CustomJoining\src\avivshopen\customjoining\CustomJoining.php on line 23


    PHP:
    <?php

    namespace avivshopen\customjoining\CustomJoining;

    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\event\player\PlayerJoinEvent;
    use 
    pocketmine\Player;
    use 
    pocketmine\Server;
    use 
    pocketmine\event\Listener;

    class 
    CustomJoining extends PluginBase implements Listener{
      
        public function 
    onEnable() {
          
            
    $this->getServer()->getPluginManager()->registerEvents($this$this);
           
            
    $this->getLogger()->info("Plugin Maded By AvivShopen");
        }

    }


        public function 
    onPlayerJoin(PlayerJoinEvent $e) {

            
    $pl $e->getPlayer();


            if (
    $pl == AvivShopen) return;

                
    $pn $pl->getDisplayName();


                
    $this->owner->getServer()->broadcastMessage(mc::_("The Owner AvivShopen is joining!"));

            }


        }


    }
  3. AvivShopenCraft
    Offline

    AvivShopenCraft New Member

    Joined:
    Oct 14, 2015
    Posts:
    73
    Minecraft User:
    AvivShopen
    nvm just fixed it by deleting the 'public' and deleting all the necessary } :D (sorry for bad English)
  4. AvivShopenCraft
    Offline

    AvivShopenCraft New Member

    Joined:
    Oct 14, 2015
    Posts:
    73
    Minecraft User:
    AvivShopen
    still not working..... WHYYY??:mad::mad::mad:
  5. Marcelo234
    Offline

    Marcelo234 New Member

    Joined:
    Oct 18, 2014
    Posts:
    204
    @sebagius7110 Hi.....I am learning PHP....Can you tell me how I must write the code if I want that the server check if a name stand in a .yml ....Than if the Name stand in the .yml he set the BrodcastMessage[BuildTeam]joined the game!
  6. AvivShopenCraft
    Offline

    AvivShopenCraft New Member

    Joined:
    Oct 14, 2015
    Posts:
    73
    Minecraft User:
    AvivShopen
    The problem is in this code:
    PHP:
    $player $event->getPlayer();
            
    $name $player->getDisplayName();
          
            if (
    $name == "yourname") {
    someone can send me the correct code? I'm learning:D
  7. CookieSteve
    Offline

    CookieSteve Active Member

    Joined:
    Apr 22, 2014
    Posts:
    132
    Minecraft User:
    iStrqfeChris
    Sure DM
  8. CookieSteve
    Offline

    CookieSteve Active Member

    Joined:
    Apr 22, 2014
    Posts:
    132
    Minecraft User:
    iStrqfeChris
    PHP:
    public function onJoin(PlayerJoinEvent $event){

    $player $event->getPlayer();
            
    $name $player->getName();
        
            if (
    $name == "random_name") {
    $player->sendMessage("Welcome to the Server Admin!");
    }
    }
    AvivShopenCraft likes this.
  9. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    This tutorial alone isn't enough for you to make a plugin. You'll need a bit more PHP knowledge then that.
    MasterDoctor likes this.
  10. AvivShopenCraft
    Offline

    AvivShopenCraft New Member

    Joined:
    Oct 14, 2015
    Posts:
    73
    Minecraft User:
    AvivShopen
    right, I will go read and learn more....:D
  11. AvivShopenCraft
    Offline

    AvivShopenCraft New Member

    Joined:
    Oct 14, 2015
    Posts:
    73
    Minecraft User:
    AvivShopen
    thank you so much:D that worked!
    (just edited the "$player->sendmessage()" to "$this->getServer->broadcastMessage()" and all fine now!
  12. CookieSteve
    Offline

    CookieSteve Active Member

    Joined:
    Apr 22, 2014
    Posts:
    132
    Minecraft User:
    iStrqfeChris
    Happy to know I helped :p I didn't know what u wanted to say so I put something random
  13. applqpak
    Offline

    applqpak Active Member Plugin Developer

    Joined:
    Dec 16, 2015
    Posts:
    284
    Plugins:
    1
    Minecraft User:
    applqpak
    It's not necessarily "incorrect", it's a different way, and although it may be better practice, still doesn't make it "incorrect" :p
  14. MasterDoctor
    Offline

    MasterDoctor New Member

    Joined:
    Sep 19, 2014
    Posts:
    11
    Minecraft User:
    MasterDoctor
    If you want to learn some of this, I just did a video tutorial on this code and additionally how to do color codes. Link here:

Share This Page

Advertisement