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?
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.
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)
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.
I don't think you know what your doing. Go learn the PocketMine API properly. There's lots of tutorials on the forum.
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"); }
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?
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))));