Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $file = '220010000.xml';
- $f = new DirectoryIterator('.');
- foreach($f as $file) {
- if ($file->isDot())
- continue;
- if ($file->isFile())
- continue;
- $d = new DirectoryIterator($file);
- foreach ($d as $ff) {
- if ($ff->isDot())
- continue;
- if (!fnmatch('*.xml', $ff))
- continue;
- read($ff->getPathname());
- }
- }
- function read($file) {
- $xml = new XMLReader();
- $xml->open($file);
- while ($xml->read()) {
- if (($xml->name == 'spawn') && ($xml->nodeType == XMLReader::ELEMENT)) {
- insert($xml->readOuterXml());
- }
- }
- }
- function insert($str) {
- $xml = new SimpleXMLElement($str);
- $npcid = $xml['npcid'];
- $mapid = $xml['map'];
- $pool = $xml['pool'];
- $delay = $xml['interval'];
- $routeid = $xml['w'];
- if (!$routeid)
- $routeid = 0;
- foreach ($xml->children() as $ob) {
- $x = $ob['x'];
- $y = $ob['y'];
- $z = $ob['z'];
- $h = $ob['h'];
- $static_id = $ob['static_id'];
- if (!$static_id)
- $static_id = 0;
- printf("INSERT INTO spawns SET x = %f, y = %f, z = %f, h = %d, npc_id = %d, map_id = %d, route_id = %d, respawn_delay = %d, staticid = %d;\n",
- $x, $y, $z, $h, $npcid, $mapid, $routeid, $delay, $static_id
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement