/** * Disconnect account from server * * Reasons: * 0 - Incorrect namae/password. * 1 - Someone is already using this account. * 2 - Your account has been blocked. * 3 - Your account credentials are invalid. * 4 - Communication problem. [DEFAULT] * 5 - The IGR concurrency limit has been met. * 6 - The IGR time limit has been met. * 7 - General IGR authentication failure. */ public function disconnect($reason = 4) { $packet = chr(130) . chr(hexdec($reason)); UltimaPHP::log("Client " . UltimaPHP::$socketClients[$this->client]['ip'] . " disconnected from the server"); Sockets::out($this->client, $packet, false, true, true); }
public function updateCurrentStamina($runInLot = false) { $packet = "A3" . str_pad($this->serial, 8, "0", STR_PAD_LEFT) . str_pad(dechex($this->maxstam), 2, "0", STR_PAD_LEFT) . str_pad(dechex($this->stam), 2, "0", STR_PAD_LEFT); Sockets::out($this->client, $packet, $runInLot); }
public function finalPacket($runInLot = false) { $packet = "254006D58B0EED00E6780029007A01400765090000"; Sockets::out($this->client, $packet, $runInLot); }
/** * Receive login request from client */ public static function packet_0x80($data, $client) { $command = $data[0]; $account = Functions::hexToChr($data, 1, 30, true); $password = Functions::hexToChr($data, 31, 61, true); $login = false; // Account / Password validadion TODO UltimaPHP::$socketClients[$client]['account'] = array('account' => $account, 'password' => md5($password)); UltimaPHP::log("Account {$account} connected from " . UltimaPHP::$socketClients[$client]['ip']); UltimaPHP::$socketClients[$client]['account'] = new Account($account, md5($password), $client); if (true === UltimaPHP::$socketClients[$client]['account']->isValid) { // Send the client an client version request Sockets::out($client, "bd0003"); UltimaPHP::$socketClients[$client]['account']->sendServerList(); } else { UltimaPHP::$socketClients[$client]['account']->disconnect(3); } }
/** * Update players with objects from desired chunk */ public static function updateChunk($chunk) { $chunk = self::$chunks[$chunk['x']][$chunk['y']]; /* Update items on map */ foreach ($chunk['objects'] as $object) { $packet = "F3"; $packet .= "0001"; $packet .= "00"; $packet .= $object->serial; $packet .= str_pad(dechex($object->graphic), 4, "0", STR_PAD_LEFT); $packet .= "00"; $packet .= str_pad(dechex($object->amount), 4, "0", STR_PAD_LEFT); $packet .= str_pad(dechex($object->amount), 4, "0", STR_PAD_LEFT); $packet .= str_pad(dechex($object->pos_x), 4, "0", STR_PAD_LEFT); $packet .= str_pad(dechex($object->pos_y), 4, "0", STR_PAD_LEFT); $packet .= str_pad("00", 2, "0", STR_PAD_LEFT); $packet .= str_pad(dechex($object->layer), 2, "0", STR_PAD_LEFT); $packet .= str_pad(dechex($object->color), 4, "0", STR_PAD_LEFT); $packet .= "20"; $packet .= "0000"; $updateRange = array('from' => array('x' => $object->pos_x - 10, 'y' => $object->pos_y - 10), 'to' => array('x' => $object->pos_x + 10, 'y' => $object->pos_y + 10)); foreach ($chunk['players'] as $client => $alive) { $player = UltimaPHP::$socketClients[$client]['account']->player; if ($player->position['x'] >= $updateRange['from']['x'] && $player->position['x'] <= $updateRange['to']['x'] && $player->position['y'] >= $updateRange['from']['y'] && $player->position['y'] <= $updateRange['to']['y']) { Sockets::out($player->client, $packet, false); } } } }