PHP: public function myFunction(){ echo "Hello!";}//and e.g. in a join event:public function onJoin(PlayerJoinEvent $e){ $this->myFunction(); //this calls myFunction}
Look at this random teleportation code: https://github.com/Artide/PM-1.5-Plugins/blob/master/RandTeleport/src/RandTeleport/Main.php
You need to be more descriptive, and what's random function? Use your brain and read: http://php.net/manual/en/function.mt-rand.php
PHP: <?phppublic function getRandomFunction($num1,$num2){$rand = mt_rand($num1,$num2);}public function onJoin(PlayerJoinEvent $e){$rand = $this->getRandomFunction(1,5);switch($rand){case 1://codebreak;case 2://2 codebreak;/* etc... */}}
PHP: public function getRandomFunction($num1,$num2){$rand = mt_rand($num1,$num2);return $rand;//gotta return to make the function run}