Code: }elseif($args[0] == "make"){ if($sender->getLevel()->getName() == $this->getConfig()->get("spawn")){ $sender->sendTip("You are on the spawn!"); return true; }else{ $this->makeHouse($sender->getName()); return true; } } So i can use random public function on command ? This is makeHouse function but i have more functions like this and i want random e.g makeParkour, makeViphouse ... Thanks in advance
PHP: $r = rand(1, 3);if($r === 1){$this->makeHouse(...);return true;}if($r === 2){$this->makeParkour(...);return true;}if($r === 3){$this->makeVipHouse();return true;}
So what? It looks better and is better practice. If you want short code then removed all returns in your code.
PHP: public function switchRandom($number){switch($number){case 0:return $this->makeHouse();break;case 1:return $this->function();break;}}//use like this:$this->switchRandom(mt_rand(0,1));//orself::switchRandom(mt_rand(0,1));
To @Gamecrafter only: self::switchRandom() is bad practice as it implies you expect it to be a static function, but actually not that "you can't", just that you "should not". PHP would understand it as $this->switchRandom() just like how it understands parent::fx() as a call to a parent function. To other people: ignore me, you should use $this->fx() instead of self::fx() for non-static functions.
I am naughty, so I ignored the first three words of your post. Why is calling static function like that bad practice? Just curious
Using the static function style to call a function (for $this only; won't work on other classes) would make readers think that you are trying to call a static function while you aren't.