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

[New Api] function run

Comments in 'Plugin Development' started by GamesLoad, Jul 3, 2014.

  1. GamesLoad
    Offline

    GamesLoad Active Member

    Joined:
    Jun 28, 2014
    Posts:
    106
    Minecraft User:
    GamesLoad
    Hello everyone I have a problem with the function run can not find itplease let Let me know how to do .Scusate for my english I'm Italian.

    So far I have developed this
    PHP:
    <?php
    namespace xXx;

    use 
    pocketmine\command\Command;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\Player;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\Server;
    use 
    pocketmine\utils\TextFormat;
    use 
    pocketmine\event\player\PlayerJoinEvent;
    use 
    pocketmine\event\block\BlockBreakEvent;
    use 
    pocketmine\event\block\BlockPlaceEvent;
    use 
    pocketmine\math\Vector3;
    use 
    pocketmine\utils\Config;
    use 
    pocketmine\inventory\PlayerInventory;
    use 
    pocketmine\event\Event;
    use 
    pocketmine\event\player\PlayerInteractEvent;
    use 
    pocketmine\item\Item;
    use 
    pocketmine\tile\Sign;
    use 
    pocketmine\nbt\tag\Compound;
    use 
    pocketmine\nbt\tag\String;
    use 
    pocketmine\nbt\tag\Int;
    use 
    pocketmine\tile\Tile;
    use 
    pocketmine\level\Level;
    use 
    pocketmine\item\Block;
    use 
    pocketmine\utils\Utils;
    use 
    pocketmine\event\player\PlayerRespawnEvent;
    class 
    xXx extends PluginBase implements Listener{
    public 
    $interval = array();

    public function 
    onLoad(){}
    public function 
    onEnable() {
    $this->getServer()->getPluginManager()->registerEvents($this$this);
    }

    public function 
    setInterval($player){
    $this->interval[$player] = (time()+2);
    }

    public function 
    checkInterval($player){
    if(!isset(
    $this->interval[$player])){
    return 
    true;
    }
    if(
    time() < $this->interval[$player]){
    return 
    false;
    }else{
    return 
    true;
    }
    }

    public function 
    playerBlockTouch(PlayerInteractEvent $event){
    $player $event->getPlayer();
    $block $event->getBlock()->getID();

    if(
    $block == 323 || $block == 63 || $block == 68){
    $x$event->getBlock()->getX();
    $y$event->getBlock()->getY();
    $z$event->getBlock()->getZ();
    $world $event->getBlock()->getLevel();

    $sign $this->getSign(new Position($x$y$z$world));
    $var $sign->getText();
    if (!
    $this->checkInterval($player->getDisplayName())) return false;
    $cmd explode("/"$var[1]);
    $cmd$cmd[0];

    /*

    *
    */

    $this->setInterval($player->getDisplayName());

    }
    }

    public function 
    onDisable() {}
    }
    Last edited: Jul 3, 2014
    Jon likes this.
  2. xpyctum
    Offline

    xpyctum Active Member Plugin Developer

    Joined:
    Jan 13, 2014
    Posts:
    292
    Plugins:
    4
    Minecraft User:
    tylerdisney
    What do you want?
    And, you have error?
    GamesLoad likes this.
  3. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Can you change the BBCode tag to [php][/php] instead of [code][/code] so that we can help you better?
    Jon likes this.
  4. Jon
    Offline

    Jon Active Member Plugin Developer

    Joined:
    Sep 1, 2013
    Posts:
    201
    Plugins:
    3
    Minecraft User:
    Heromine14
    Scusate=sorry
    Aiutatemi=help
    Let me know how to do
    Oppure
    Help me
    E un consiglio ;)
  5. GamesLoad
    Offline

    GamesLoad Active Member

    Joined:
    Jun 28, 2014
    Posts:
    106
    Minecraft User:
    GamesLoad
    I miss the function run
  6. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Also, onLoad() is not necessary to be inherited.
  7. xpyctum
    Offline

    xpyctum Active Member Plugin Developer

    Joined:
    Jan 13, 2014
    Posts:
    292
    Plugins:
    4
    Minecraft User:
    tylerdisney
    You already know your problem
  8. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Why did you have so many `use` lines?
  9. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    BTW: Did you make this code with reference to economys?
  10. Jon
    Offline

    Jon Active Member Plugin Developer

    Joined:
    Sep 1, 2013
    Posts:
    201
    Plugins:
    3
    Minecraft User:
    Heromine14
    He uses a lot of things xD
  11. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Don't use $player->getDisplayName() unless you want chat things.
  12. xpyctum
    Offline

    xpyctum Active Member Plugin Developer

    Joined:
    Jan 13, 2014
    Posts:
    292
    Plugins:
    4
    Minecraft User:
    tylerdisney
    He use source code from EconomyS
  13. GamesLoad
    Offline

    GamesLoad Active Member

    Joined:
    Jun 28, 2014
    Posts:
    106
    Minecraft User:
    GamesLoad
    I was wrong this plugin must execute the command by pressing a sign
  14. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    I don't see half of them appearing.
  15. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Yep I noticed the sign check thing. I only saw @onebone checking ID 323 for sign blocks.
  16. xpyctum
    Offline

    xpyctum Active Member Plugin Developer

    Joined:
    Jan 13, 2014
    Posts:
    292
    Plugins:
    4
    Minecraft User:
    tylerdisney
    But if I want to write username in config file, it is necessary?
  17. Jon
    Offline

    Jon Active Member Plugin Developer

    Joined:
    Sep 1, 2013
    Posts:
    201
    Plugins:
    3
    Minecraft User:
    Heromine14
    strange
  18. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    If you want a field saving data of different players (sessions) as an array, my advice is using $player->getID() as key for better performance, or spl_object_hash($player) for a few microseconds slower but more stable.
  19. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Use $player->getName(). The display name can be changed for things like prefixes. CustomRanks is an example.
  20. xpyctum
    Offline

    xpyctum Active Member Plugin Developer

    Joined:
    Jan 13, 2014
    Posts:
    292
    Plugins:
    4
    Minecraft User:
    tylerdisney
    From SimpleAuth?)

Share This Page

Advertisement