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

Solved Disable some commands

Discussion in 'Development' started by BruhLol, May 18, 2017.

  1. BruhLol

    BruhLol Baby Zombie

    Messages:
    122
    How to disable some commands while a task is running? Or if a player uses that command then the task will get disabled
     
  2. DanielYTK

    DanielYTK Zombie

    Messages:
    227
    When a task is started, you can add a player to an array, when the task finishes you remove the player from the array, you can use the PlayerCommandPreprocessEvent command to detect the command. When the event is called make sure the player is in the array, you can cancel the event.
     
    jasonwynn10 and BruhLol like this.
  3. BruhLol

    BruhLol Baby Zombie

    Messages:
    122
    Ahh lemme try that out! Thanks
     
  4. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    Just temporarily revoke the player's permission to use that command, setting a negative value in a PermissionAttachment.
     
  5. BruhLol

    BruhLol Baby Zombie

    Messages:
    122
    Worked thanks!
    I don't know how to do that..
     
    jasonwynn10 likes this.
  6. 0x15f

    0x15f Baby Zombie

    Messages:
    145
    GitHub:
    0x15f
    Cache what commands are blocked to which players and then check on PlayerCommandPreprocessEvent (I think thats the event name) and block them then. As for your signature, wrongo PHP is very well paying.
     
    jasonwynn10 likes this.
  7. BruhLol

    BruhLol Baby Zombie

    Messages:
    122
    Yea ik it worked, i said it. and yes its well playing, its just a quote i like lol
     
    jasonwynn10 and 0x15f like this.
  8. Lowkey

    Lowkey Slime

    Messages:
    94
    To revoke permission, simple type the permission with a hyphon infront, for example;

    -pocketmine.command.gamemode
    (revokes permission to change gamemode)
     
  9. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    Using PlayerCommandPreprocessEvent should not be the best solution if there is alternative, because we don't really have a good plugin-compatibility solution on events.
    You're talking about using a permission manager. I think @BruhLol's talking about doing it programmatically (I'm struggling the proper third-person pronoun to use :p).
     
    jasonwynn10 and BruhLol like this.
  10. BruhLol

    BruhLol Baby Zombie

    Messages:
    122
    CombatLogger by Lambo still uses PlayerCommandPreprocessEvent
     
  11. Lowkey

    Lowkey Slime

    Messages:
    94
    Oh hehe. 'Programmatically', that SHOULD be a word imo.
     
  12. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    That's the point. Different plugins use PlayerCommandPreprocessEvent for different reasons, and if you aren't careful enough, they'll easily clash.
     
    jasonwynn10 and BruhLol like this.
  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.