当前位置: 首页>>代码示例>>PHP>>正文


PHP Functions::strToHex方法代码示例

本文整理汇总了PHP中Functions::strToHex方法的典型用法代码示例。如果您正苦于以下问题:PHP Functions::strToHex方法的具体用法?PHP Functions::strToHex怎么用?PHP Functions::strToHex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Functions的用法示例。


在下文中一共展示了Functions::strToHex方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: packet_0x02

 /**
  * Packet received when the player try to walk/move
  * 
  * Directions:
  * 	0x00 - North
  * 	0x01 - Northeast
  * 	0x02 - East
  * 	0x03 - Southeast
  * 	0x04 - South
  * 	0x05 - Southwest
  * 	0x06 - West
  * 	0x07 - Northwest
  */
 public static function packet_0x02($data, $client)
 {
     $command = Functions::strToHex(Functions::hexToChr($data, 0, 0, true));
     $direction = Functions::strToHex(Functions::hexToChr($data, 1, 1, true));
     $sequence_number = Functions::strToHex(Functions::hexToChr($data, 2, 2, true));
     $fastwalk_prevention = Functions::strToHex(Functions::hexToChr($data, 3, 6, true));
     UltimaPHP::$socketClients[$client]['account']->player->movePlayer(false, $direction, $sequence_number, $fastwalk_prevention);
 }
开发者ID:joaoescribano,项目名称:UltimaPHP,代码行数:21,代码来源:packets.core.php

示例2: sendCharacterList

 /**
  * Send the account characters list to the client
  */
 public function sendCharacterList($runInLot = false)
 {
     $characters = $this->characters;
     $startingLocations = UltimaPHP::$starting_locations;
     $tmpPacket = "05";
     for ($i = 0; $i < 5; $i++) {
         $tmpPacket .= str_pad(isset($characters[$i]) ? Functions::strToHex($characters[$i]['name']) : 0, 120, "0", STR_PAD_RIGHT);
     }
     $tmpPacket .= str_pad(dechex(count($startingLocations)), 2, "0", STR_PAD_LEFT);
     foreach ($startingLocations as $key => $location) {
         // If Client version is bigger then 7.0.13.0
         if (isset(UltimaPHP::$socketClients[$this->client]['version']) && UltimaPHP::$socketClients[$this->client]['version']['major'] >= 7 && UltimaPHP::$socketClients[$this->client]['version']['minor'] >= 0 && UltimaPHP::$socketClients[$this->client]['version']['revision'] >= 13 && UltimaPHP::$socketClients[$this->client]['version']['prototype'] >= 0) {
             $tmpPacket .= str_pad(dechex($key + 1), 2, "0", STR_PAD_LEFT);
             $tmpPacket .= str_pad(Functions::strToHex($location['name']), 64, "0", STR_PAD_RIGHT);
             $tmpPacket .= str_pad(Functions::strToHex($location['area']), 64, "0", STR_PAD_RIGHT);
             $tmpPacket .= str_pad(strtoupper(dechex($location['position']['x'])), 8, "0", STR_PAD_LEFT);
             $tmpPacket .= str_pad(strtoupper(dechex($location['position']['y'])), 8, "0", STR_PAD_LEFT);
             $tmpPacket .= str_pad(strtoupper(dechex($location['position']['z'])), 8, "0", STR_PAD_LEFT);
             $tmpPacket .= str_pad(strtoupper(dechex($location['position']['map'])), 8, "0", STR_PAD_LEFT);
             $tmpPacket .= str_pad(strtoupper(dechex($location['clioc'])), 8, "0", STR_PAD_LEFT);
             $tmpPacket .= str_pad("", 8, "0", STR_PAD_RIGHT);
         } else {
             $tmpPacket .= str_pad(dechex($key + 1), 2, "0", STR_PAD_LEFT);
             $tmpPacket .= str_pad(Functions::strToHex($location['name']), 62, "0", STR_PAD_RIGHT);
             $tmpPacket .= str_pad(Functions::strToHex($location['area']), 62, "0", STR_PAD_RIGHT);
         }
     }
     $flags = "0580";
     $tmpPacket .= str_pad($flags, 8, "0", STR_PAD_LEFT);
     $tmpPacket .= "0000";
     $packet = "A9";
     $packet .= str_pad(dechex(ceil(strlen($tmpPacket) / 2) + 3), 4, "0", STR_PAD_LEFT);
     $packet .= $tmpPacket;
     Sockets::out($this->client, $packet, $runInLot);
 }
开发者ID:greeduomacro,项目名称:UltimaPHP,代码行数:38,代码来源:account.class.php

示例3: statusBarInfo

 /**
  * Update the status bar information on the client
  */
 public function statusBarInfo($runInLot = false)
 {
     $packet = "11";
     $packet .= "005B";
     $packet .= str_pad($this->serial, 8, "0", STR_PAD_LEFT);
     $packet .= str_pad(Functions::strToHex($this->name), 60, "0", STR_PAD_RIGHT);
     $packet .= str_pad(dechex($this->hits), 4, "0", STR_PAD_LEFT);
     $packet .= str_pad(dechex($this->maxhits), 4, "0", STR_PAD_LEFT);
     $packet .= "00";
     $packet .= "05";
     $packet .= str_pad(dechex($this->sex), 2, "0", STR_PAD_LEFT);
     $packet .= str_pad(dechex($this->str), 4, "0", STR_PAD_LEFT);
     $packet .= str_pad(dechex($this->dex), 4, "0", STR_PAD_LEFT);
     $packet .= str_pad(dechex($this->int), 4, "0", STR_PAD_LEFT);
     $packet .= str_pad(dechex($this->stam), 4, "0", STR_PAD_LEFT);
     $packet .= str_pad(dechex($this->maxstam), 4, "0", STR_PAD_LEFT);
     $packet .= str_pad(dechex($this->mana), 4, "0", STR_PAD_LEFT);
     $packet .= str_pad(dechex($this->maxmana), 4, "0", STR_PAD_LEFT);
     $packet .= str_pad(dechex(5000), 8, "0", STR_PAD_LEFT);
     $packet .= "0000";
     $packet .= str_pad("6", 4, "0", STR_PAD_LEFT);
     $packet .= str_pad(dechex(400), 4, "0", STR_PAD_LEFT);
     $packet .= str_pad(dechex($this->race), 2, "0", STR_PAD_LEFT);
     if ($this->statscap > 0) {
         $packet .= str_pad(dechex($this->statscap), 4, "0", STR_PAD_LEFT);
     } else {
         $packet .= "0000";
     }
     $packet .= str_pad(dechex($this->pets), 2, "0", STR_PAD_LEFT);
     $packet .= str_pad(dechex($this->maxpets), 2, "0", STR_PAD_LEFT);
     $packet .= str_pad(dechex($this->resist_fire), 4, "0", STR_PAD_LEFT);
     $packet .= str_pad(dechex($this->resist_cold), 4, "0", STR_PAD_LEFT);
     $packet .= str_pad(dechex($this->resist_poison), 4, "0", STR_PAD_LEFT);
     $packet .= str_pad(dechex($this->resist_energy), 4, "0", STR_PAD_LEFT);
     $packet .= str_pad(dechex($this->luck), 4, "0", STR_PAD_LEFT);
     $packet .= str_pad(dechex($this->damage_min), 4, "0", STR_PAD_LEFT);
     $packet .= str_pad(dechex($this->damage_max), 4, "0", STR_PAD_LEFT);
     $packet .= "00000000";
     Sockets::out($this->client, $packet, $runInLot);
 }
开发者ID:joaoescribano,项目名称:UltimaPHP,代码行数:43,代码来源:player.class.php

示例4: readStaticsFromPosition

 public static function readStaticsFromPosition($map, $pos_x, $pos_y)
 {
     $staticIdx = fopen(UltimaPHP::$conf['muls']['location'] . "statics{$map}.mul", 'rb');
     $staticMul = fopen(UltimaPHP::$conf['muls']['location'] . "staidx{$map}.mul", 'rb');
     $updateRange = array('from' => array('x' => $pos_x - 10, 'y' => $pos_y - 10), 'to' => array('x' => $pos_x + 10, 'y' => $pos_y + 10));
     for ($x = $updateRange['from']['x']; $x < $updateRange['to']['x']; $x++) {
         for ($y = $updateRange['from']['y']; $y < $updateRange['to']['y']; $y++) {
             $index = ($x * self::$maps[$map]['size']['y'] + $y) * 12;
             fseek($staticIdx, $index, SEEK_SET);
             $lookup = (int) Functions::strToHex(fread($staticIdx, 4));
             $length = (int) Functions::strToHex(fread($staticIdx, 4));
             // $lookup = Functions::read_byte($staticIdx, 4);
             // $length = Functions::read_byte($staticIdx, 4);
             echo "{$lookup}|{$length}\n";
             if ($length > 0 && $lookup > 0) {
                 echo "{$lookup}|{$length}\n";
                 // fseek($staticMul, $lookup, SEEK_SET);
                 // for ($i=0; $i < ($length/7); $i++) {
                 // 	$tileId = Functions::read_byte($staticMul, 2);
                 // 	$x = Functions::read_byte($staticMul, 1);
                 // 	$y = Functions::read_byte($staticMul, 1);
                 // 	$z = Functions::read_byte($staticMul, 1);
                 // 	$hue = Functions::read_byte($staticMul, 2);
                 // 	if ($tileId >= 0) {
                 // 		if ($hue < 0) {
                 // 			$hue = 0;
                 // 		}
                 // 		if ($tileId > 0) {
                 // 			echo "$tileId|$x|$y|$z|$hue\n";
                 // 		}
                 // 	}
                 // }
             }
         }
     }
     exit;
     $data = bin2hex(fread($staticMul, $length));
     echo "\n\n\nFIM\n\n\n";
     exit;
 }
开发者ID:joaoescribano,项目名称:UltimaPHP,代码行数:40,代码来源:map.core.php

示例5: out

 /**
  * Outgoing packet handler
  */
 public static function out($client, $packet, $lot = array(), $dontConvert = false, $dontCompress = false)
 {
     $err = null;
     if (false === $dontCompress && isset(UltimaPHP::$socketClients[$client]['compressed']) && true === UltimaPHP::$socketClients[$client]['compressed']) {
         $compression = new Compression();
         $packet = unpack('H*', $compression->compress(strtoupper($packet)))[1];
     }
     if (false === $dontConvert) {
         $packet = Functions::hexToChr($packet);
     } else {
         $packet = $packet;
     }
     if (is_array($lot) && count($lot) == 2 && isset($lot[0]) && isset($lot[1]) && true === $lot[0] && $lot[1] === false) {
         UltimaPHP::$socketClients[$client]['packetLot'] .= $packet;
         $packet = null;
     } else {
         if (is_array($lot) && count($lot) == 2 && isset($lot[0]) && isset($lot[1]) && true === $lot[0] && $lot[1] === true) {
             $packet = UltimaPHP::$socketClients[$client]['packetLot'] . $packet;
             UltimaPHP::$socketClients[$client]['packetLot'] = null;
         }
     }
     if ($packet !== null) {
         if (true === UltimaPHP::$conf['logs']['debug']) {
             echo "Sending packet: " . Functions::strToHex($packet) . "\n\n";
         }
         UltimaPHP::$socketClients[$client]['packets'][] = array('packet' => $packet, 'time' => microtime(true) + 0.001);
     }
 }
开发者ID:greeduomacro,项目名称:UltimaPHP,代码行数:31,代码来源:sockets.core.php


注:本文中的Functions::strToHex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。