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

help

Discussion in 'Facepalm' started by Levi, Aug 10, 2017.

  1. Levi

    Levi Skeleton

    Messages:
    955
    GitHub:
    captainleviftw
    hey there, how can i make it /gms <player>?

    what i've done:

    PHP:
    public function execute(CommandSender $sender$commandLabel, array $args){
                    
    $player $sender;
            if(
    $sender->hasPermission("staff")){
                    
    $player->setGamemode(0);
            
    $player->sendMessage("§eYou are now in survival mode");
            }else{
                
    $sender->sendMessage("§cInvalid Permission");
            }
        }
     
  2. Levi

    Levi Skeleton

    Messages:
    955
    GitHub:
    captainleviftw
    wtf is this not about development?
     
  3. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    it is but someone out of the A-Team decided your thread belongs to Development/Facepalm.
    Regarding your question:
    you need to check if in the array args (arguments) there is a string in index 0, then check if that string is a playername of an online player and then execute the gamemode change on that.
     
  4. Levi

    Levi Skeleton

    Messages:
    955
    GitHub:
    captainleviftw
    i figured it out yesterday by reading a plugin. thanks for the help
     
  5. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    good thing to do! learning by yourself is the best thing you can do :)
     
  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.