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

What I'm doing bad? Help.

Comments in 'Plugin Development' started by AndrewBit, Aug 13, 2015.

  1. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    I code this, and idk what I'm doing bad :/
    It not works...

    PHP:
     function onJoin(PlayerJoinEvent $event)
        {
            
    $name $event->getPlayer()->getDisplayName();
            
    $rank1 $this->getConfig()->get("Rank-1-Name");
            
    $rank2 $this->getConfig()->get("Rank-2-Name");
            
    $NormalPlayer $this->getConfig()->get("NormalPlayer-Name");

            
    #NormalPlayer message

            
    $NormalPlayerMessage $this->getConfig()->get("NormalPlayer-Message");
            
    $NormalPlayerMessage str_replace("{player}"$name$NormalPlayerMessage);
            
    $NormalPlayerMessage str_replace("{name}"$NormalPlayer$NormalPlayerMessage);


            
    #Rank 1 members

            
    $IGN1 $this->getConfig()->get("Member-1");
            
    $IGN2 $this->getConfig()->get("Member-2");
            
    $IGN3 $this->getConfig()->get("Member-3");
            
    $IGN4 $this->getConfig()->get("Member-4");

            
    #message

            
    $rank1message $this->getConfig()->get("Rank-1-Message");
            
    $rank1message str_replace("{player}"$name$rank1message);
            
    $rank1message str_replace("{rank1}"$rank1$rank1message);

            
    #Rank 2 members

            
    $IGN5 $this->getConfig()->get("Member-5");
            
    $IGN6 $this->getConfig()->get("Member-6");
            
    $IGN7 $this->getConfig()->get("Member-7");
            
    $IGN8 $this->getConfig()->get("Member-8");
            
    $IGN9 $this->getConfig()->get("Member-9");
            
    $IGN10 $this->getConfig()->get("Member-10");
            
    $IGN11 $this->getConfig()->get("Member-11");
            
    $IGN12 $this->getConfig()->get("Member-12");
            
    $IGN13 $this->getConfig()->get("Member-13");
            
    $IGN14 $this->getConfig()->get("Member-14");
            
    $IGN15 $this->getConfig()->get("Member-15");

            
    #Message

            
    $rank2message $this->getConfig()->get("Rank-2-Message");
            
    $rank2message str_replace("{player}"$name$rank2message);
            
    $rank2message str_replace("{rank2}"$rank2$rank2message);

            if(
    $this->getConfig()->get("Rank-1-On") == "true"){
                if(
    $name $IGN1 or $name $IGN2 or $name $IGN3 or $name $IGN4){
                    
    $this->getServer()->broadcastMessage($rank1message);
                }
            }
            elseif(
    $this->getConfig()->get("Rank-2-On") == "true"){
                if(
    $name $IGN5 or $name $IGN6 or $name $IGN7 or $name $IGN8 or $name $IGN9 or $name $IGN10 or $name $IGN11 or $name $IGN12 or $name $IGN13 or $name $IGN14 or $name $IGN15){
                    
    $this->getServer()->broadcastMessage($rank2message);
                }
            }
            elseif(
    $this->getConfig()->get("NormalPlayer-On") == "true"){
                if (
    $name != $IGN1 or $name != $IGN2 or $name != $IGN3 or $name != $IGN4 or $name != $IGN5 or $name != $IGN6 or $name != $IGN7 or $name != $IGN8 or $name != $IGN9 or $name != $IGN10 or $name != $IGN11 or $name != $IGN12 or $name != $IGN13 or $name != $IGN14 or $name != $IGN15){
                    
    $this->getServer()->broadcastMessage($NormalPlayerMessage);
                }
            }
            elseif(
    $this->getConfig()->get("DelPMJoinMessage") == "true"){
                if(
    $name != "KickMe"){
                    
    $event->setJoinMessage("");
                }
                
    #If he has this name... Kick.
                
    elseif($name "KickMe"){
                    
    $event->getPlayer()->kick("Why you have this name? Sorry but I need kick you. :(");
                }
            }
        }
    }
    I was trying to add broadcastPopup but I change it to broadcastMessage bc broadcastPopup also don't work :'c

    My config.yml:

    Code:
    ---
    ################################################################################
    #JoinPopup v1.0 Config             # by Andrew, @AndrewBit4 on twitter
    ################################################################################
    # [email protected]
    ################################################################################
    #If you want contact me, I recommend you search me in Twitter.
    ################################################################################
    #
    #If Rank-1-On is 'false' instead of 'true', all members of this rank will not get PopUp.
    #
    Rank-1-On: true
    Rank-1-Name: owner
    #
    #Rank 1 Members   -  Leave blank if you don't want member in any Member-Slot
    Member-1: AndrewBit4
    Member-2: MyBigDog12345
    Member-3: Andrew
    Member-4: ImWorkingInOtherNewPlugin
    #
    #Rank 1 Message
    Rank-1-Message: Guys! The {rank1} {player} joined the game!
    #The example message show "Guys! The owner PLAYER joined the game!
    #
    #If Rank-2-On is 'false' instead of 'true', all members of this rank will not get PopUp.
    Rank-2-On: true
    Rank-2-Name: builder
    #
    #Rank 2 Members   -   Leave blank if you don't want member in any Member-Slot
    Member-5: StrikerKillerHD
    Member-6: ZenCloudYT
    Member-7:
    Member-8:
    Member-9:
    Member-10:
    Member-11:
    Member-12:
    Member-13:
    Member-14:
    Member-15:
    #
    #Rank 2 Message
    Rank-2-Message: Wow! The {rank2} {player} joined the game!
    #NormalPlayer get PopUps?
    NormalPlayerOn: false
    NormalPlayer-Name: Player
    #
    NormalPlayer-Message: {name} {player} joined the game!
    #Other stuff - Not working!   Don't uncomment any, plz! x)
    #
    #Delete message of PocketMine that say "Player joined the game".
    #DelPMJoinMessage: true
    ...
    Last edited: Aug 13, 2015
  2. thebigsmileXD
    Offline

    thebigsmileXD Banned

    Joined:
    May 19, 2015
    Posts:
    845
    Plugins:
    1
    Minecraft User:
    XenialDan
    Does the console give you an error? If so, please post it
  3. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,472
    Minecraft User:
    PrimusLV
    PHP:
      if($name != "KickMe"){
    $event->setJoinMessage("");
    $event->getPlayer()->kick("Why you have this name? Sorry but I need kick you. :(");
     }
    Bad coded :O
  4. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,472
    Minecraft User:
    PrimusLV
    Using arrays will make your code smaller.
  5. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    I was getting this error:
    [Server thread/CRITICAL]: "Could not pass event 'pocketmine\event\player\PlayerJoinEvent' to 'JoinPopup v1': yaml_parse(): parsing error encountered during parsing: did not find expected key (line 48, column 30), context while parsing a block mapping (line 12, column 1) on andrew\JoinPopup\JoinPopup


    And this all the code:
    PHP:
    <?php



    namespace andrew\JoinPopup;

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

    #* Stuff I need add (Future version):
    // [X] You can change rank in a setting. "Rank 1" => "Owner" for example.
    // [X] Popups for people that haven't any special rank! :D (NormalPlayers)
    // [X] Customizable NormalPlayer message.
    // [X] Option for activate or no NormalPlayer. (NormalPlayerOn)
    // [ ] More IGN space.
    // [ ] More ranks.
    // [X] Option for delete stock broadcastMessage at join by PocketMine.
    // [ ] I need a website for my plugins! <3
    // *#
    # If you like this plugin... Follow me on twitter! Thanks! @AndrewBit4

    class JoinPopup extends PluginBase implements Listener
    {
        public function 
    onLoad()
        {
            
    $this->getLogger()->info(TextFormat::BLUE "Loading JoinPopup v1.O by @AndrewBit4...");
        }

        public function 
    onEnable()
        {

            
    $this->getServer()->getPluginManager()->registerEvents($this$this);
            
    $this->saveDefaultConfig();
            
    $this->getLogger()->info(TextFormat::GOLD "JoinPopup v1.0 by @AndrewBit4 is loaded =)");
            if (!
    is_dir($this->getDataFolder())) {
                @
    mkdir($this->getDataFolder());
            }

        }

        function 
    onJoin(PlayerJoinEvent $event)
        {
            
    $name $event->getPlayer()->getDisplayName();
            
    $player $event->getPlayer();
            
    $rank1 $this->getConfig()->get("Rank-1-Name");
            
    $rank2 $this->getConfig()->get("Rank-2-Name");
            
    $NormalPlayer $this->getConfig()->get("NormalPlayer-Name");

            
    #NormalPlayer message

            
    $NormalPlayerMessage $this->getConfig()->get("NormalPlayer-Message");
            
    $NormalPlayerMessage str_replace("{player}"$name$NormalPlayerMessage);
            
    $NormalPlayerMessage str_replace("{name}"$NormalPlayer$NormalPlayerMessage);


            
    #Rank 1 members

            
    $IGN1 $this->getConfig()->get("Member-1");
            
    $IGN2 $this->getConfig()->get("Member-2");
            
    $IGN3 $this->getConfig()->get("Member-3");
            
    $IGN4 $this->getConfig()->get("Member-4");

            
    #message

            
    $rank1message $this->getConfig()->get("Rank-1-Message");
            
    $rank1message str_replace("{player}"$name$rank1message);
            
    $rank1message str_replace("{rank1}"$rank1$rank1message);

            
    #Rank 2 members

            
    $IGN5 $this->getConfig()->get("Member-5");
            
    $IGN6 $this->getConfig()->get("Member-6");
            
    $IGN7 $this->getConfig()->get("Member-7");
            
    $IGN8 $this->getConfig()->get("Member-8");
            
    $IGN9 $this->getConfig()->get("Member-9");
            
    $IGN10 $this->getConfig()->get("Member-10");
            
    $IGN11 $this->getConfig()->get("Member-11");
            
    $IGN12 $this->getConfig()->get("Member-12");
            
    $IGN13 $this->getConfig()->get("Member-13");
            
    $IGN14 $this->getConfig()->get("Member-14");
            
    $IGN15 $this->getConfig()->get("Member-15");

            
    #Message

            
    $rank2message $this->getConfig()->get("Rank-2-Message");
            
    $rank2message str_replace("{player}"$name$rank2message);
            
    $rank2message str_replace("{rank2}"$rank2$rank2message);

            if(
    $this->getConfig()->get("Rank-1-On") == "true"){
                if(
    $name $IGN1 or $name $IGN2 or $name $IGN3 or $name $IGN4){
                    
    $player->sendPopup($rank1message);
                }
            }
            elseif(
    $this->getConfig()->get("Rank-2-On") == "true"){
                if(
    $name $IGN5 or $name $IGN6 or $name $IGN7 or $name $IGN8 or $name $IGN9 or $name $IGN10 or $name $IGN11 or $name $IGN12 or $name $IGN13 or $name $IGN14 or $name $IGN15){
                    
    $player->sendPopup($rank2message);
                }
            }
            elseif(
    $this->getConfig()->get("NormalPlayer-On") == "true"){
                if (
    $name != $IGN1 or $name != $IGN2 or $name != $IGN3 or $name != $IGN4 or $name != $IGN5 or $name != $IGN6 or $name != $IGN7 or $name != $IGN8 or $name != $IGN9 or $name != $IGN10 or $name != $IGN11 or $name != $IGN12 or $name != $IGN13 or $name != $IGN14 or $name != $IGN15){
                    
    $player->sendPopup($NormalPlayerMessage);
                }
            }
            elseif(
    $this->getConfig()->get("DelPMJoinMessage") == "true"){
                if(
    $name != "KickMe"){
                    
    $event->setJoinMessage("");
                }
                
    #If he has this name... Kick.
                
    elseif($name "KickMe"){
                    
    $event->getPlayer()->kick("Why you have this name? Sorry but I need kick you. :(");
                }
            }
        }
    }

    Also....
    What I'm doing bad, Primus?
  6. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,472
    Minecraft User:
    PrimusLV
    try this
    Code:
    ---
    ################################################################################
    #JoinPopup v1.0 Config  # by Andrew, @AndrewBit4 on twitter
    ################################################################################
    # [email protected]
    ################################################################################
    #If you want contact me, I recommend you search me in Twitter.
    ################################################################################
    #
    #If Rank-1-On is 'false' instead of 'true', all members of this rank will not get PopUp.
    #
    Rank-1-On: true
    Rank-1-Name: owner
    #
    #Rank 1 Members  -  Leave blank if you don't want member in any Member-Slot
    Member-1: AndrewBit4
    Member-2: MyBigDog12345
    Member-3: Andrew
    Member-4: ImWorkingInOtherNewPlugin
    #
    #Rank 1 Message
    Rank-1-Message: Guys! The {rank1} {player} joined the game!
    #The example message show "Guys! The owner PLAYER joined the game!
    #
    #If Rank-2-On is 'false' instead of 'true', all members of this rank will not get PopUp.
    Rank-2-On: true
    Rank-2-Name: builder
    #
    #Rank 2 Members  -  Leave blank if you don't want member in any Member-Slot
    Member-5: StrikerKillerHD
    Member-6: ZenCloudYT
    Member-7:
    Member-8:
    Member-9:
    Member-10:
    Member-11:
    Member-12:
    Member-13:
    Member-14:
    Member-15:
    #
    #Rank 2 Message
    Rank-2-Message: Wow! The {rank2} {player} joined the game!
    #NormalPlayer get PopUps?
    NormalPlayerOn: false
    NormalPlayer-Name: Player
    #
    NormalPlayer-Message: '{name} {player} joined the game!' # Added ''
    #Other stuff - Not working!  Don't uncomment any, plz! x)
    #
    #Delete message of PocketMine that say "Player joined the game".
    #DelPMJoinMessage: true
    ...
    
    Btw doing this is more better
    Code:
    Members:
    1: 'm1'
    2: 'm2'
    
    PHP:
    $this->getConfig()->get('Members')['1']; // will return: "m1" i supose
  7. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4

    I'm using

    $this->getServer()->broadcastPopup();

    (In the code you see
    broadcastMessage();
    but i change it to broadcastPopup)


    This is well done? Or I need do

    $players->sendPopup();

    (Idk how I can define $players, but I will see)








    Wait...
    I'm getting the same error.

    Code:
    [18:44:32] [Server thread/CRITICAL]: "Could not pass event 'pocketmine\event\player\PlayerJoinEvent' to 'JoinPopup v1': yaml_parse(): parsing error encountered during parsing: did not find expected key (line 48, column 30), context while parsing a block mapping (line 12, column 1) on andrew\JoinPopup\JoinPopup
    [18:44:32] [Server thread/WARNING]: RuntimeException: "yaml_parse(): parsing error encountered during parsing: did not find expected key (line 48, column 30), context while parsing a block mapping (line 12, column 1)" (E_WARNING) in "/src/pocketmine/utils/Config" at line 143
    
    And I add ''
    Last edited: Aug 13, 2015
  8. thebigsmileXD
    Offline

    thebigsmileXD Banned

    Joined:
    May 19, 2015
    Posts:
    845
    Plugins:
    1
    Minecraft User:
    XenialDan
    :D:D
    I just saw it.. You use
    PHP:
    if ($bla="bla")
    You have to use
    PHP:
    if($bla=="bla")
    Thats a pretty basic mistake..
    One "=" sets something, like $bla="bla"
    Two or three "=" are comparing
  9. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    Wait, when I have the error?
    In $name = "baldkd" ??
  10. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,472
    Minecraft User:
    PrimusLV
    Can you leave blank?
    Code:
    Member1:
    
  11. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,472
    Minecraft User:
    PrimusLV
    No
    PHP:
    $bla 'something'
    if($bla === 'something'// true
    if($bla == 'something'// true
    if($bla 'something'// Will define $bla;
    thebigsmileXD likes this.
  12. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4

    Done! But I'm getting exactly the same error :/


    Also if I leave blank all members I get the same error. I think the problem can be by the uses...

    Because I see in Phpstorm
    use pocketmine\Player;
    and
    use pocketmine\Server;

    With the error
    "Multiple definition exist for Player/Server"
  13. thebigsmileXD
    Offline

    thebigsmileXD Banned

    Joined:
    May 19, 2015
    Posts:
    845
    Plugins:
    1
    Minecraft User:
    XenialDan
    Well.. Where you have:
    #if he has the name kick

    Also, @Primus is right.
    You should use arrays.
    Like.. $ignorethisplayers=array("player1","Steve","Lucas");
    And then finding it in the if-function:
    if(isset($ignorethisplayers["Steve"])){//code}
  14. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    I do:

    PHP:
    <?php



    namespace andrew\JoinPopup;

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

    #* Stuff I need add (Future version):
    // [X] You can change rank in a setting. "Rank 1" => "Owner" for example.
    // [X] Popups for people that haven't any special rank! :D (NormalPlayers)
    // [X] Customizable NormalPlayer message.
    // [X] Option for activate or no NormalPlayer. (NormalPlayerOn)
    // [ ] More IGN space.
    // [ ] More ranks.
    // [X] Option for delete stock broadcastMessage at join by PocketMine.
    // [ ] I need a website for my plugins! <3
    // *#
    # If you like this plugin... Follow me on twitter! Thanks! @AndrewBit4

    class JoinPopup extends PluginBase implements Listener
    {
        public function 
    onLoad()
        {
            
    $this->getLogger()->info(TextFormat::BLUE "Loading JoinPopup v1.O by @AndrewBit4...");
        }

        public function 
    onEnable()
        {

            
    $this->getServer()->getPluginManager()->registerEvents($this$this);
            
    $this->saveDefaultConfig();
            
    $this->getLogger()->info(TextFormat::GOLD "JoinPopup v1.0 by @AndrewBit4 is loaded =)");
            if (!
    is_dir($this->getDataFolder())) {
                @
    mkdir($this->getDataFolder());
            }

        }

        function 
    onJoin(PlayerJoinEvent $event)
        {
            
    $name $event->getPlayer()->getDisplayName();
            
    $rank1 $this->getConfig()->get("Rank-1-Name");
            
    $rank2 $this->getConfig()->get("Rank-2-Name");
            
    $NormalPlayer $this->getConfig()->get("NormalPlayer-Name");

            
    #NormalPlayer message

            
    $NormalPlayerMessage $this->getConfig()->get("NormalPlayer-Message");
            
    $NormalPlayerMessage str_replace("{player}"$name$NormalPlayerMessage);
            
    $NormalPlayerMessage str_replace("{name}"$NormalPlayer$NormalPlayerMessage);


            
    #Rank 1 members

            
    $IGN1 $this->getConfig()->get('Members')['1'];
            
    $IGN2 $this->getConfig()->get('Members')['2'];
            
    $IGN3 $this->getConfig()->get('Members')['3'];
            
    $IGN4 $this->getConfig()->get('Members')['4'];

            
    #message

            
    $rank1message $this->getConfig()->get("Rank-1-Message");
            
    $rank1message str_replace("{player}"$name$rank1message);
            
    $rank1message str_replace("{rank1}"$rank1$rank1message);

            
    #Rank 2 members

            
    $IGN5 $this->getConfig()->get('Members')['5'];
            
    $IGN6 $this->getConfig()->get('Members')['6'];
            
    $IGN7 $this->getConfig()->get('Members')['7'];
            
    $IGN8 $this->getConfig()->get('Members')['8'];
            
    $IGN9 $this->getConfig()->get('Members')['9'];
            
    $IGN10 $this->getConfig()->get('Members')['10'];
            
    $IGN11 $this->getConfig()->get('Members')['11'];
            
    $IGN12 $this->getConfig()->get('Members')['12'];
            
    $IGN13 $this->getConfig()->get('Members')['13'];
            
    $IGN14 $this->getConfig()->get('Members')['14'];
            
    $IGN15 $this->getConfig()->get('Members')['15'];

            
    #Message

            
    $rank2message $this->getConfig()->get("Rank-2-Message");
            
    $rank2message str_replace("{player}"$name$rank2message);
            
    $rank2message str_replace("{rank2}"$rank2$rank2message);

            if(
    $this->getConfig()->get("Rank-1-On") == "true"){
                if(
    $name == $IGN1 or $name == $IGN2 or $name == $IGN3 or $name == $IGN4){
                    
    $this->getServer()->broadcastMessage($rank1message);
                }
            }
            elseif(
    $this->getConfig()->get("Rank-2-On") == "true"){
                if(
    $name == $IGN5 or $name == $IGN6 or $name == $IGN7 or $name == $IGN8 or $name == $IGN9 or $name == $IGN10 or $name == $IGN11 or $name == $IGN12 or $name == $IGN13 or $name == $IGN14 or $name == $IGN15){
                    
    $this->getServer()->broadcastMessage($rank2message);
                }
            }
            elseif(
    $this->getConfig()->get("NormalPlayer-On") == "true"){
                if (
    $name != $IGN1 or $name != $IGN2 or $name != $IGN3 or $name != $IGN4 or $name != $IGN5 or $name != $IGN6 or $name != $IGN7 or $name != $IGN8 or $name != $IGN9 or $name != $IGN10 or $name != $IGN11 or $name != $IGN12 or $name != $IGN13 or $name != $IGN14 or $name != $IGN15){
                    
    $this->getServer()->broadcastMessage($NormalPlayerMessage);
                }
            }
            elseif(
    $this->getConfig()->get("DelPMJoinMessage") == "true"){
                if(
    $name != "KickMe"){
                    
    $event->setJoinMessage("");
                }
                
    #If he has this name... Kick.
                
    elseif($name == "KickMe"){
                    
    $event->getPlayer()->kick("Why you have this name? Sorry but I need kick you. :(");
                }
            }
        }
    }
    And I change the config to:

    Code:
    ---
    ################################################################################
    #JoinPopup v1.0 Config             # by Andrew, @AndrewBit4 on twitter
    ################################################################################
    # [email protected]
    ################################################################################
    #If you want contact me, I recommend you search me in Twitter.
    ################################################################################
    #
    #If Rank-1-On is 'false' instead of 'true', all members of this rank will not get PopUp.
    #
    Rank-1-On: true
    Rank-1-Name: owner
    #
    #Rank 1 Message
    Rank-1-Message: Guys! The {rank1} {player} joined the game!
    #The example message show "Guys! The owner PLAYER joined the game!
    #
    #If Rank-2-On is 'false' instead of 'true', all members of this rank will not get PopUp.
    Rank-2-On: true
    Rank-2-Name: builder
    #Rank 1 Members   -  Leave blank if you don't want member in any Member-Slot
    Members:
    1: ''
    2: ''
    3: ''
    4: ''
    #
    #
    #Rank 2 Members   -   Leave blank if you don't want member in any Member-Slot
    5: ''
    6: ''
    7: ''
    8: ''
    9: ''
    10: ''
    11: ''
    12: ''
    13: ''
    14: ''
    15: ''
    #
    #Rank 2 Message
    Rank-2-Message: Wow! The {rank2} {player} joined the game!
    #NormalPlayer get PopUps?
    NormalPlayerOn: false
    NormalPlayer-Name: Player
    #
    NormalPlayer-Message: {name} {player} joined the game!
    #Other stuff - Not working!   Don't uncomment any, plz! x)
    #
    #Delete message of PocketMine that say "Player joined the game".
    #DelPMJoinMessage: true
    ...
    I need also add '' to messages in config.yml?

    I'm really confused wtf is happening to my plugin
  15. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    Help, please..
  16. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,472
    Minecraft User:
    PrimusLV
    or as @shoghicp said use array_key_exits instead of in_array
  17. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    How? Can you edit my code?
    This is my first plugin and I'm really confused! D':
  18. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,472
    Minecraft User:
    PrimusLV
    Give me the main idea of plugin i'll try to figure out better way.
  19. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    When a user enter in the server, he get a custom popup if he is in the list 1 or a different custom popup if he is in the list 2 ('List of members 1 and 2'), and if he is a normal player, he also get a different popup. x)
  20. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,472
    Minecraft User:
    PrimusLV
    PHP:
    <?php
    namespace blah\blah;

    use 
    pocketmine\event\Listener;
    use 
    pocketmine\event\player\PlayerJoinEvent;
    use 
    pocketmine\event\player\PlayerQuitEvent;
    use 
    pocketmine\Player;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\utils\Config;

    class 
    Main exends PlguinBase implements Listener{

    public 
    $config;

    public function 
    onEnable(){
    $this->getServer()->getPluginManager()->registerEvents($this$this);
    $this->config $this->saveDefaultConfig()->getAll(); // Put in array
    }

    public function 
    onJoin(PlayerJoinEvent $event){
    $player  $event->getPlayer();
    if(
    array_key_exists($player->getName(), $this->config['players'])){
    $event->setJoinMessage(null);
    $this->broadcastPopup($this->config['players-join-popup'][$player->getName()]);
    }
    }

    public function 
    broadcastPopup($popup){
    foreach(
    $this->getServer()->getOnlinePlayers() as $player){
    $player->sendPopup($popup$this->config['popup-duration']);
    }
    }

    }
    Code:
    # Custom popup on player join
    players-join-popup:
     Steve: 'Stevy joined :P'
     Johny: 'Jon is back :@'
    # How long popup will stay on player's screen
    popup-duration: 2
    

Share This Page

Advertisement