When you are using some basic functions, you can do $player->kill(). However, in the function kill() itself, how do they know which player to kill? I mean, if you wrote: $player->kill() $p->kill() $thisguy->kill() $someone->kill() (Where $player, $p, $thisguy and $someone is a valid player, silly.) the plugin will still recognise these variables, and how do I make a functions so that it can be used through: $player->doSomething() Instead of writing: $this->doSonething($player) ? Sorry for being vague, I only have extremely basic knowledge of PHP and programming in general. I can explain to you what I want to know if you need more information on what I am trying to say. #TheseKindOfNoobs
There is no way, you just need to edit Pocketmine's source on Player.php, you can't create functions on a class while you're on another class.
$this->xxx() calls to function xxx() in your own class. This is what "$this" means - your own class, the current running instance. This is not JavaScript. You cannot add methods to a class not defined by yourself. Well, it is actually possible by PlayerCreationEvent, but unless it is very necessary, avoid using it in public plugins that have the chance to be used with other plugins. However, if you use a structure like player sessions, it will be possible to call, like, $session->xxx(), where $session is an instance of a class defined by your plugin that has an instance for each player. However, you need to be familiar with object-oriented programming to do this. Remember, object-oriented programming wasn't designed to let you type $object->fx() rather than $this->fx($object).
The only way you could do $player->yourFunction() is if yourFunction() exists in the pocketmine\Player class itself. Meaning you would have to edit pocketmine's source code and add your function to the Player class. You should learn OOP (Object oriented programming) then you would understand what @PEMapModder is saying, if you don't already.
Nope, it can be done by extending Player + handling PlayerCreationEvent. But this is just a little bit better than modifying PocketMine source. Still bad for public plugins.