/** * Checks player online status. * * <p> * This method uses binary info protocol. * </p> * * @param string $name Player name. * @return bool True if player is online, false if player or server is online. * @throws E_OTS_OutOfBuffer When there is read attemp after end of packet stream. * @example examples/server.php info.php * @tutorial POT/Server_status.pkg */ public function playerStatus($name) { // request packet $request = new OTS_Buffer(); $request->putChar(255); $request->putChar(1); $request->putShort(OTS_ServerStatus::REQUEST_PLAYER_STATUS_INFO); $request->putString($name); $status = $this->send($request); // checks if server is online if ($status) { $status->getChar(); return (bool) $status->getChar(); } // offline return false; }
/** * Sends COMMAND_KICK command with given parameter. * * <p> * Kicks given player from server. * </p> * * @version 0.1.4 * @since 0.1.4 * @param string $name Name of player to be kicked. * @throws E_OTS_ErrorCode If failure respond received. * @throws E_OTS_OutOfBuffer When there is read attemp after end of packet stream. */ public function kick($name) { // sends message $buffer = new OTS_Buffer(); $buffer->putChar(self::COMMAND_KICK); $buffer->putString($name); $this->sendCommand($buffer); }