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

Plugin making help

Comments in 'Plugin Development' started by Mclover152, May 17, 2014.

  1. Mclover152
    Offline

    Mclover152 Active Member

    Joined:
    Apr 26, 2014
    Posts:
    64
    Minecraft User:
    mclover152
    Hello. Im not a plugin maker, but i make plugins and test them on my server. I was wondering, does all php coding work in plugin coding?
  2. BlinkSun
    Offline

    BlinkSun Active Member Plugin Developer

    Joined:
    Mar 26, 2014
    Posts:
    128
    Plugins:
    4
    Minecraft User:
    BlinkSun
    Plugin are coded with php ! Can you specify what you wanna mean ?
  3. Dinokiller
    Offline

    Dinokiller Notable Member

    Joined:
    Sep 22, 2013
    Posts:
    376
    Minecraft User:
    Dinokiller_
    Yes, PocketMine-MP runs entirely on PHP (obviously). Loading the plugin is like using the "include()" function, in that everything included in PHP is available to the script. If you know what I mean.
  4. Mclover152
    Offline

    Mclover152 Active Member

    Joined:
    Apr 26, 2014
    Posts:
    64
    Minecraft User:
    mclover152
    Yes, i know what you mean. Thanks for the help!
  5. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    It is require_once()
    Falk likes this.
  6. Mclover152
    Offline

    Mclover152 Active Member

    Joined:
    Apr 26, 2014
    Posts:
    64
    Minecraft User:
    mclover152
    I was wondering, how can you make a variable for what someone typed in a cmd. for example:
    /console <message>
    What would a variable for <message> be equal to?
    Because if the variable was $Console then the coding would be:
    $this->api->console->run($username, say $console);
    So what I'm trying to say is: If you wanna set a variable for a parimeter of a command, what would that variable be equal to?
    (Sorry, im kinda still learning plugin making)
  7. wies
    Offline

    wies Notable Member

    Joined:
    Aug 23, 2013
    Posts:
    390
    The second parameter of the commandHandler function (usually called $args or $params) contains an array of all the additional arguments used after the main command. So for example when I use the command "/console I love PocketMine" the variable $args will contain an array that looks like this ["I", "love", "PocketMine"]. So the original command you entered is split by the spaces.
    If you want the original string back, you can use implode(" ", $args) which will combine all the values in the $args array to one string and seperate them with a space.
  8. Dinokiller
    Offline

    Dinokiller Notable Member

    Joined:
    Sep 22, 2013
    Posts:
    376
    Minecraft User:
    Dinokiller_
    Close enough.
  9. Mclover152
    Offline

    Mclover152 Active Member

    Joined:
    Apr 26, 2014
    Posts:
    64
    Minecraft User:
    mclover152
    I guess i kinda understand. So the variable is preset by "$Args"?
  10. Dinokiller
    Offline

    Dinokiller Notable Member

    Joined:
    Sep 22, 2013
    Posts:
    376
    Minecraft User:
    Dinokiller_
    In the command handler, yes.
  11. Mclover152
    Offline

    Mclover152 Active Member

    Joined:
    Apr 26, 2014
    Posts:
    64
    Minecraft User:
    mclover152
    So the return function would be "$this->api->console->run($username, say $args);"?
  12. Dinokiller
    Offline

    Dinokiller Notable Member

    Joined:
    Sep 22, 2013
    Posts:
    376
    Minecraft User:
    Dinokiller_
    I don't think you know what your doing. Go learn the PocketMine API properly. There's lots of tutorials on the forum.
    PEMapModder likes this.
  13. Mclover152
    Offline

    Mclover152 Active Member

    Joined:
    Apr 26, 2014
    Posts:
    64
    Minecraft User:
    mclover152
    Sorry :( im new to php and api and coding and pocketmine. Im just trying to learn plugin making.
  14. Mclover152
    Offline

    Mclover152 Active Member

    Joined:
    Apr 26, 2014
    Posts:
    64
    Minecraft User:
    mclover152
    I'm confused. Where the heck am i supposed to learn pocketmine 1.3.11 api?!?!
  15. Mclover152
    Offline

    Mclover152 Active Member

    Joined:
    Apr 26, 2014
    Posts:
    64
    Minecraft User:
    mclover152
    I guess i understand what you ment by $args now. The question i still have is, how does the coding work for /say.
    In my perspective it tells the console to display in the chat [Server] (your message represented by a variable). You explained how that message would be represented as an array. I wanna make a plugin that looks like this:
    $this->api->console->register->("message", "<message> Sends a raw message in the chat", array($this, "send"));
    $this->api->ban->cmdwhitelist("message");
    }

    Public function commandHandler($cmd, $params, $issuer, $alias){
    $message = (what would this be equal to for what user typed after /message)
    $this->api->chat->broadcast("$message");
    }
  16. Mclover152
    Offline

    Mclover152 Active Member

    Joined:
    Apr 26, 2014
    Posts:
    64
    Minecraft User:
    mclover152
    If you know what i mean, what would $message be equal to
  17. iksaku
    Offline

    iksaku Notable Member Plugin Developer

    Joined:
    Sep 2, 2013
    Posts:
    1,130
    Plugins:
    4
    Minecraft User:
    iksaku
    How can I detect a specific $arg and get it out the message?
    I use:
    PHP:
    $message implode(" "str_replace("&""%"$args);
    then I broadcast the message, but I want to detect if the arguments has a "p:a.permission" get it out of $message.
    Any ideas?
  18. wies
    Offline

    wies Notable Member

    Joined:
    Aug 23, 2013
    Posts:
    390
    That code will give an error because you forgot a ) and str_replace needs to be applied later than implode. I would do something like this:
    $message = str_ireplace('p:a.permission', '', str_replace('&', '%', implode(' ', $args))));
    iksaku likes this.
  19. iksaku
    Offline

    iksaku Notable Member Plugin Developer

    Joined:
    Sep 2, 2013
    Posts:
    1,130
    Plugins:
    4
    Minecraft User:
    iksaku
    Whoa! Thanks!
  20. iksaku
    Offline

    iksaku Notable Member Plugin Developer

    Joined:
    Sep 2, 2013
    Posts:
    1,130
    Plugins:
    4
    Minecraft User:
    iksaku
    Another :p
    How can I remove it from $messge is okey, but how do I put it in other $key?

Share This Page

Advertisement