WTF!? This is the weirdest thing I've seen with PocketMine. I wrote my code, I run the command but the server goes offline when ran for example: /wop steve world The server only goes off only if the player is online, but when player is offline it send the offline error. The code is the following: PHP: case 'wop': if($s->hasPermission("pwo.op.add")){ if(isset($args[0]) && isset($args[1])){ $op = $this->server->getPlayerExact($args[0]); $world = $args[1]; if($op){ $this->addWorldOP($op, $world); $s->sendMessage(TXT::GREEN . "Successfully added " . $op . " to " . $world . "'s op list."); $op->sendMessage(TXT::GREEN . "You are now op in " . $world . "!"); }elseif(!$op){ $s->sendMessage(TXT::RED . $args[0] . " is offline."); }elseif($this->worldExist($world) === false){ $s->sendMessage(TXT::RED . $world . " does not exist."); } } if(empty($args) || count($args) < 1){ $s->sendMessage(TXT::RED . "Usage: /wop <player> <world>"); } } break;
What did you expect this to do? PHP: if($op){ // if $op is resolved to true, which in this case, if $op is a valid player object}elseif(!$op){ // why elseif(!$op)? You can simply do an else here.}elseif(blahblahblah){ // this block will never be run, because either $op or !$op will be run. Also, if $args[1] is set, $args[0] must be set. The problem about your whole code is that your logic is wrong. Any variables in PHP are either true or false, if you cast them into booleans (if($op) and !$op will both cast them into booleans), you only need to check if(). So can you tell me, about the worldExists thing, do you expect it to be run when $op is online or not? And also, the array $args is defined by an explode() from PocketMine (there is an array_shift() too, but the contents in the array are still ascending from 0). Hence, if $args[0] is not set, count($args) will obviously be 0, and empty($args) will obviously be true. However, in your code, if count($args) is 1, nothing will b run at all.
segfault means some strange thing happened, just restart the server and it shouldn't happen again. I am saying that the logic of your code is wrong.
I already fixed up my code and the same thing happens. the worldExists($world) function find the loaded levels if they exists (works perfectly).