TradeGUI plugin

Discussion in 'Help' started by XxMegaIs123xX, May 4, 2019.

  1. XxMegaIs123xX

    XxMegaIs123xX Silverfish

    Messages:
    18
    uh hi can anyone help me with my code ?​
    Im trying to make a tradeGUI
    So if a player will enter the command /trade <playername> the other player should get a message like do /trade accept or decline

    PHP:
    <?php

    namespace TradeGUI;

    use 
    pocketmine\Server;
    use 
    pocketmine\Player;
    use 
    pocketmine\plugin\PluginBase;

    use 
    pocketmine\utils\TextFormat as TF;

    use 
    pocketmine\event\Listener;

    use 
    pocketmine\command\Command;
    use 
    pocketmine\command\CommandSender;

    class 
    Trade extends PluginBase implements Listener{
        
        public function 
    onEnable(){
            
    $this->getLogger()->info("[TradeGUI] Plugin Has Been Enabled");
        }
        
        public function 
    onCommand(CommandSender $senderCommand $cmdstring $label, array $args) : bool {
            if(
    $cmd->getName() == "trade"){
                if(!
    $sender instanceof Player){
                    
    $sender->sendMessage("please use this command in-game");
                    return 
    false;
                }
                if(!isset(
    $args[0])){
                    
    $sender->sendMessage("§aUsage: §7/trade <name> \n §7<accept> \n §7<decline>")
                }else{
                    
                    
    $tradewith $this->getServer()->getPlayer()->getName($args[0]);
                    
                    if(
    $tradewith->isOnline()){
                        
    $sender->sendMessage("§cYou have sent a request to:" $args[0]);
                        
    $tradewith->sendMessage($sender->getName() . "§cHas sent a request to trade do /trade <decline/accept>");
                    }else{
                        
    $sender->sendMessage("§cPlayer is not online!");
                    }
                }
                if(
    $args[0] == "accept"){
                    
    //do something
                    
    }
                }
            }
            return 
    true;
        }
    }
     
    Last edited: May 4, 2019
  2. MusicNOvas

    MusicNOvas Spider Jockey

    Messages:
    43
    I can't help you but I think you can use InvSee plugin to help you
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.