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

Permission

Discussion in 'Plugin Help' started by Gilsheys, May 12, 2020.

  1. Gilsheys

    Gilsheys Spider Jockey

    Messages:
    37
    GitHub:
    gilsheys
    How can i let players tap a sign and give them the prefix in the sign? i use tap to do. i just want them to have the prefix listed on the sign which is (Citizen). How can i set this command without giving them permission to /setprefix?
     
  2. Willoxey

    Willoxey Spider Jockey

    Messages:
    33
    Use the PlayerInteractEvent. If the player taps a sign that is made by a OP and it contains some certain words it will execute a command sent by the console.
    Ex: [Prefix]
    Test
    If the sign contains that and that sign is made by a OP it will give you the rank.

    InteractEvent example:
    PHP:
        public function signTapPrefix(PlayerInteractEvent $event): void{
            
    $jugador $event->getPlayer();
            
    $tile $event->getBlock()->getLevel()->getTile(new Vector3($event->getBlock()->getFloorX(), $event->getBlock()->getFloorY(), $event->getBlock()->getFloorZ()));
            if(
    $tile instanceof Sign){
                if(
    TextFormat::clean($tile->getText()[0], true) === "[PREFIX]"//otherwise you can set whatever text you want){
                        
    $event->setCancelled(true);
                        if((
    $tile->getText()[1]) === "Test"){
                                        
    // do the ConsoleCommand stuff here and give the player that prefix
                                
    }
                }
            }      
        }    
    Make that only OP can make that sign:
    PHP:
        public function onBlockPlace(BlockPlaceEvent $event): void{
            
    $player $event->getPlayer();
            
    $tile $event->getBlock()->getLevel()->getTile(new Vector3($event->getBlock()->getFloorX(), $event->getBlock()->getFloorY(), $event->getBlock()->getFloorZ()));
            if(
    $tile instanceof Sign){
                if(
    TextFormat::clean($tile->getText()[0], true) === "[PREFIX]" //it has to be same as the set in the Event){
                    
    if(!$player->hasPermission("prefix.sign.set" //set whatever perm you want)){
                        
    $player->sendMessage("You don't have permission");
                        return;
                    }  
                }
            }
        }
    I hope that this helped. If you have any other questions you can ask me.
     
    Gilsheys likes this.
  3. Gilsheys

    Gilsheys Spider Jockey

    Messages:
    37
    GitHub:
    gilsheys
    where should i put this?
     
  4. Gilsheys

    Gilsheys Spider Jockey

    Messages:
    37
    GitHub:
    gilsheys
    Hello! could you give your discord tag so we can talk there? i'm having some problems on some stuffs.. thanks!
     
  5. Willoxey

    Willoxey Spider Jockey

    Messages:
    33
    Put in the main class. But you should change the PREFIX stuff. That was an example
     
  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.