Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

PHP clarifications (sp?)

Comments in 'Plugin Development' started by alkurian, Dec 17, 2013.

  1. alkurian
    Offline

    alkurian New Member

    Joined:
    Oct 15, 2013
    Posts:
    21
    Minecraft User:
    LaVerge
    working on a plugin and referencing glitches function list

    something i was curious about was the difference between using isOP and PermissionsCheck

    example: say im using a command and i only want a staff member to be able to use it, the correct way would be $this>api>ban>isop right?

    Now if I'm using the permissions plus plugin would i use permissioncheck instead or since im using that is defining staff redundant?

    second question: If I want to see on the console that someone used a command (example: "joe-schmoe teleported to world B") how would i go about that (cannot for the life of me figure that out) x.x

    Thanks in advanced! ^_^
  2. Falk
    Offline

    Falk Staff Member Global Moderator

    Joined:
    Sep 2, 2013
    Posts:
    1,707
    Plugins:
    22
    Minecraft User:
    Falkirknh
    2: Boost your debug level or use the now removed CommandEcho
  3. Darunia18
    Offline

    Darunia18 Staff Member Sectional Moderator

    Joined:
    Aug 23, 2013
    Posts:
    755
    Plugins:
    2
    Minecraft User:
    Darunia18
    For number one, that would be how you check if the player is OP or not. If you want to check their rank in PermissionPlus, use
    PHP:
    $user_permission $this->api->dhandle("get.player.permission"$username);
    but you have to set what $username is beforehand (I usually use $username = $issuer->username;). Then you can check their rank with something like
    PHP:
    if($user_permission GUEST){
         
    $this->api->chat->broadcast("You just checked a player's rank!");}
    I hope this helps :)
  4. Glitchmaster_PE
    Offline

    Glitchmaster_PE Notable Member Plugin Developer

    Joined:
    Aug 31, 2013
    Posts:
    834
    Plugins:
    8
    Minecraft User:
    Glitchmaster_PE
    Also, if you just want to check if a player is OP, do:

    For a command:
    PHP:
    $username $issuer->username;
    if(
    $this->api->ban->isOP($username) == true){
    //Random code
    }
    else{
    //More random code
    }
    For an event:
    PHP:
    $username $data["player"]->username;
    if(
    $this->api->ban->isOP($username) == true){
    //Random code
    }
    else{
    //More random code
    }
  5. Darunia18
    Offline

    Darunia18 Staff Member Sectional Moderator

    Joined:
    Aug 23, 2013
    Posts:
    755
    Plugins:
    2
    Minecraft User:
    Darunia18
    Oh yeah I forgot about events XDD
  6. alkurian
    Offline

    alkurian New Member

    Joined:
    Oct 15, 2013
    Posts:
    21
    Minecraft User:
    LaVerge
    i saw something about debug lvl before, how do you change that?

    tried echo before and it gave me errors, guessing thats a no-go.
    thanks ^_^
  7. alkurian
    Offline

    alkurian New Member

    Joined:
    Oct 15, 2013
    Posts:
    21
    Minecraft User:
    LaVerge
    ok, that makes sense. defining user and adding a handler to check the permission lvl, thought that was the way to go but havint messed with this yet.

    thanks, gave me a duh moment and clarity moment at the same time ^_^
  8. alkurian
    Offline

    alkurian New Member

    Joined:
    Oct 15, 2013
    Posts:
    21
    Minecraft User:
    LaVerge
    ok, so I am on the right track. (whew)
    focusing on the former:

    PHP:
    case "protect":
       if(
    $this->api->ban->isOp($issuer->username) == false)
    {return(
    "This command can only use by an OP. ");
    }
    this would be the correct format for someone who is not op and it would tell them only an op can use this comand, correct?
  9. Glitchmaster_PE
    Offline

    Glitchmaster_PE Notable Member Plugin Developer

    Joined:
    Aug 31, 2013
    Posts:
    834
    Plugins:
    8
    Minecraft User:
    Glitchmaster_PE
    Hmm, get rid of the return parentheses:

    PHP:
    return "This command can only use by an OP. ";
  10. alkurian
    Offline

    alkurian New Member

    Joined:
    Oct 15, 2013
    Posts:
    21
    Minecraft User:
    LaVerge
    ok so:

    PHP:
    case "protect":
     if(
    $this->api->ban->isOp($issuer->username) == false)
    {return 
    "This command can only use by an OP. ";
    }
    correct?
  11. Glitchmaster_PE
    Offline

    Glitchmaster_PE Notable Member Plugin Developer

    Joined:
    Aug 31, 2013
    Posts:
    834
    Plugins:
    8
    Minecraft User:
    Glitchmaster_PE
    I think so
    alkurian likes this.
  12. Falk
    Offline

    Falk Staff Member Global Moderator

    Joined:
    Sep 2, 2013
    Posts:
    1,707
    Plugins:
    22
    Minecraft User:
    Falkirknh
    A
    Add debug=<level number 1-4> to your server.properties
    alkurian likes this.
  13. alkurian
    Offline

    alkurian New Member

    Joined:
    Oct 15, 2013
    Posts:
    21
    Minecraft User:
    LaVerge
    *feels dumb*
    thanks falk ^_^
  14. alkurian
    Offline

    alkurian New Member

    Joined:
    Oct 15, 2013
    Posts:
    21
    Minecraft User:
    LaVerge
    ok, i'll test it out

    edit: sweet! so far 0 errors/issues

    thanks alot glitch ^_^
  15. Glitchmaster_PE
    Offline

    Glitchmaster_PE Notable Member Plugin Developer

    Joined:
    Aug 31, 2013
    Posts:
    834
    Plugins:
    8
    Minecraft User:
    Glitchmaster_PE
    No problem

Share This Page

Advertisement