/** * /cncnet/create/GFsd4jf5-9lcld34f==/Irony's Room/1 * /cncnet/create/GFsd4jf5-9lcld34f==/Irony's Room/1/true * /cncnet/create/GFsd4jf5-9lcld34f==/Irony's Room/1/true/6 * /cncnet/create/GFsd4jf5-9lcld34f==/Irony's Room/1/true/6/paSsw0rd. * * @param string $s_key Session Key * @param string $name Name of room. * @param string $game Game ID. -1 is chat room. * @param string $late_start Are late start joins allowed? * @param string $players Number of players allowed to join. -1 = game maximum/infinite for chat. * @param string $password Room password. If empty string then room is open. * @return boolean Success */ public function create($s_key, $name, $game = -1, $late_start = false, $players = -1, $password = "") { if (!$this->validate_session($s_key)) { return array('success' => false, 'errors' => array($this->error_code(-3))); } $r = new CnCNet_Room(); $player = new CnCNet_Player(); $event = new CnCNet_Event(); $rooms = $r->lst(0); $game = array('name' => $name, 'game' => $game, 'players' => $game == -1 ? $players : 6, 'pass' => $password, 'late' => $late_start); $plyr = array('id' => $player->get_id($s_key), 'nickname' => $player->get_name($s_key)); $game['id'] = $r->create($game, $plyr); $game['users'] = array($plyr['id'] => $plyr['nickname']); $event->add('room', $rooms[0]['users'], $game['id'], $player->get_id($s_key), $game); return array('success' => true, 'room' => $game['id']); }