I have developed a plugin that allows a predefined command to be run when a player stands on a predefined block. The command currently runs as the console but I would like it to run as the player that activates it. How can I do this? Here is the line that runs the command as the console: $command = $this->api->console->run (COMMAND); The original code came from Darunia18s Claymores plugin with his permission. <3
[ERROR] A level 8 error happened: "Undefined variable: p" in "C:\Users\root\Desktop\PocketMine- MP PvP Maze - Copy\plugins\CMDBlock.php" at line 30 The line you gave me is all that is on line 30
And the command is already defined in a yml file. It still runs the command but as the console and also gives the undefined variable: p error.
Of course it gives the "$p is undefined" error. You never assigned anything to it. $p must be an instance of Player. You should probably ask an actual PHP developer to do this for you.
I am trying to learn I figured I needed to define %p as a player and am looking at other plugins to see how it is done. Any help would be appreciated.
I had to change it a little as the command is already defined but I am still getting [DEBUG] * issued server command: tp 10 10 10 PHP: public function entitymove($data){ $activate = $data->level->getBlock(new Vector3($data->x, ($data->y -1), $data->z)); if($activate->getID() == ACTIVATE){ $p = $this->api->player->get("username"); $this->api->console->run(COMMAND,$p); I am very proud of myself to have got this far though. Am i allowed to post the whole plugin in order to get a real developer to help? And thanks for your help.
Yep! By the way, if you haven't already, try looking into PHP tutorials on codecademy.com and at @Glitchmaster_PE's plugin tutorials on here