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

Help

Comments in 'Plugin Development' started by Legomite, Jun 5, 2014.

  1. Legomite
    Offline

    Legomite Active Member Plugin Developer

    Joined:
    Sep 8, 2013
    Posts:
    470
    Plugins:
    2
    Minecraft User:
    Legomite
    DO NOT FORGE! Why won't this work! It is suppose to count how many caps you have and if you have 5 or over capital letters is blocks you.
    PHP:
    <?php

    /*
     __PocketMine Plugin__
     name=SpecialText
     version=1.0.0
     author=Legomite
     class=color
     apiversion=12,13,14
     */

    /*
     ___Changelog___
     1.0.0
     * Initial Release
     */
    class color implements Plugin {
        private 
    $api$message$player;
        public function 
    __construct(ServerAPI $api$server false) {
            
    $this -> api $api;
            
    $this -> server ServerAPI::request();
        }

        public function 
    init() {
            
    $this -> api -> addHandler("player.chat", array($this"eventHandler"), 100);
            
    console("§a[SpecialText] loading...");
            
    console("§a[SpecialText] §dThis plugin is created by §cLegomite.§dCheck if you have the latest version of this plugin!");
        }

        public function 
    eventHandler($data$event) {
            
    $playerTalk $data['message'];
            
    preg_match_all("/[A-Z]/"$playerTalk$caps_atch);
            
    $caps_count count($caps_atch[0]);
            if (
    $caps_count == 5) {
                
    $player -> sendChat("[PvpPro] Do not use to many Caps!");
                return 
    false;
            } else {
                return 
    true;
            }

        }

        public function 
    __destruct() {

        }

    }
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Why is it == 5 not >= 5?
    Also why not directly use the result from preg_match?
  3. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Also don't name your class "color"!!!
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    You also forgot to define $player.

    Learn to read error dumps.

    Anyway, good plugin!
  5. Legomite
    Offline

    Legomite Active Member Plugin Developer

    Joined:
    Sep 8, 2013
    Posts:
    470
    Plugins:
    2
    Minecraft User:
    Legomite
    Emm, I don't remember how to build plugins from sracth anymore. So I used the specialtext plugin a a template.
  6. Legomite
    Offline

    Legomite Active Member Plugin Developer

    Joined:
    Sep 8, 2013
    Posts:
    470
    Plugins:
    2
    Minecraft User:
    Legomite
    How do you do it directly?
  7. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    I mean the name is too generic anyway.

Share This Page

Advertisement