1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

spam Click

Discussion in 'Help' started by Winchester, Aug 8, 2018.

  1. Winchester

    Winchester Baby Zombie

    Messages:
    133
    I created a store with EconomyShop but when I click on the item to buy the action it is executed several times, how do I get fix it ?
     
  2. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    Right click on the air, not on the ground, Minecraft spams packets...
     
  3. Winchester

    Winchester Baby Zombie

    Messages:
    133
    Sorry, I do not understand
     
  4. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    The client spams packets to the server, you can't prevent that.
     
  5. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    But you can work around it in plugins.
    Create an issue on GitHub for the developer to handle. You should do that for any plugin problem you have, before posting here.
     
  6. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    It is not a plugin problem...
    Make an item that says "Hello" to you. Right click on the ground and count how many "Hello"s you got. I will write you a plugin.
     
    Winchester likes this.
  7. Winchester

    Winchester Baby Zombie

    Messages:
    133
    this click spam happens with any command but only in the version windows 10
     
    SkySeven likes this.
  8. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    Uhh, I told you it is only a win10 bug.
     
    SkySeven likes this.
  9. Winchester

    Winchester Baby Zombie

    Messages:
    133
    Do you have any idea how to get around this?
     
  10. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    I do not want to share my friend's code.
     
    Winchester likes this.
  11. Winchester

    Winchester Baby Zombie

    Messages:
    133
    :(
     
  12. Winchester

    Winchester Baby Zombie

    Messages:
    133
    please help me,
    my server is for private use only for my children and friends
     
  13. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    You might be able to do it through a plugin, by ignoring playerinteractevent from the same player within a very small amount of time. Are you able to write a plugin like that? I may be able to do it otherwise.
     
  14. Winchester

    Winchester Baby Zombie

    Messages:
    133
    I do not know how to do this, I'm not a programmer!
     
  15. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    Okay, I'll try to help. Which version of PMMP are you using, and can you link me to where you got the shop plugin?
     
    Winchester likes this.
  16. Winchester

    Winchester Baby Zombie

    Messages:
    133
    This server is running PocketMine-MP 3.1.3 for Minecraft: PE v1.5.0 (protocol version 274)
    this plugin
    https://github.com/BoxOfDevs/CommandShop


    but all the plugins that use the touch to perform some action have this problem!
     
  17. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    So I worked a bit with my friend and we still have that issue. We have a plently amount of win10 players and they crash due to addWindow() on each interaction. A solution for that would be the item held event but the bad thing is that we can't use the soul well without crashes.
    PHP:
    <?php

    namespace FreeGamingHere;

    use 
    pocketmine\event\player\PlayerJoinEvent;
    use 
    pocketmine\event\player\PlayerInteractEvent;
    use 
    pocketmine\scheduler\Task;
    use 
    pocketmine\Player;
    use 
    pocketmine\item\Item;
    use 
    pocketmine\event\EventPriority;
    use 
    pocketmine\command\CommandSender;
    use 
    pocketmine\command\Command;

    class 
    Win10Fix extends \pocketmine\plugin\PluginBase implements \pocketmine\event\Listener{

        public 
    $ids = array();
        public 
    $time = array();
        public 
    $blockIds = array();

        public function 
    onEnable() : void{
            
    $this->getLogger()->info("Enabled!");
            
    $this->getServer()->getPluginManager()->registerEvents($this$this);
        }

        public function 
    onDisable() : void{
            
    $this->getScheduler()->cancelAllTasks();
        }

        public function 
    doStuff(Player $player) : void{
            if(
    $this->time[$player->getName()] < 3){
                
    $this->time[$player->getName()] = $this->time[$player->getName()] + 1;
            } else {
                
    $this->getScheduler()->cancelTask($this->ids[$player->getName()]);
                
    $this->ids[$player->getName()] = 0;
                
    $this->time[$player->getName()] = 0;
                
    $this->blockIds[$player->getName()] = 0;
            }
        }

        public function 
    onJoin(PlayerJoinEvent $event) : void{
            
    $name $event->getPlayer()->getName();
            if(!
    in_array($name$this->ids)){
                
    $this->ids[] = $name;
            }
            
    $this->ids[$name] = 0;
            if(!
    in_array($name$this->time)){
                
    $this->time[] = $name;
            }
            
    $this->time[$name] = 0;
            if(!
    in_array($name$this->blockIds)){
                
    $this->blockIds[] = $name;
            }
            
    $this->blockIds[$name] = 0;
        }

        
    /**
         * @param PlayerInteractEvent $event
         *
         * @priority MONITOR
         */
        
    public function onInteract(PlayerInteractEvent $event) : void{
            
    $player $event->getPlayer();
            if(
    $this->ids[$player->getName()] === 0){
                
    $this->getScheduler()->scheduleRepeatingTask(new InteractTask($this$player$event->getBlock()->getId()), 1);
            } elseif(
    $this->ids[$player->getName()] !== && $this->blockIds[$player->getName()] === $event->getBlock()->getId()){
                
    $event->setCancelled();
            }
        }
    }


    class 
    InteractTask extends Task{

        public function 
    __construct(Win10Fix $pluginPlayer $playerint $blockId){
            
    $this->plugin $plugin;
            
    $this->player $player;
            
    $this->blockId $blockId;
        }

        public function 
    onRun(int $currentTick) : void{
            if(
    $this->player->isOnline()){
                
    $player $this->player;
                
    $this->plugin->ids[$player->getName()] = $this->getTaskId();
                
    $this->plugin->blockIds[$player->getName()] = $this->blockId;
                
    $this->plugin->doStuff($player);
            } else {
                
    $this->plugin->getScheduler()->cancelTask($this->getTaskId());
            }
        }
    }
     
  18. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    Please help me. I do not know what to do...

    Go to the sixth minute, fourteenth second
     
  19. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    Result of my code above: It cancelled the block placing in some cases and it did not fix the crashes with the win10 users.
     
  20. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    Override function in player class to prevent calling interact event multiple times
     
  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.