Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. <?php
  2. $file = '220010000.xml';
  3.  
  4. $f = new DirectoryIterator('.');
  5. foreach($f as $file) {
  6. if ($file->isDot())
  7. continue;
  8. if ($file->isFile())
  9. continue;
  10. $d = new DirectoryIterator($file);
  11. foreach ($d as $ff) {
  12. if ($ff->isDot())
  13. continue;
  14. if (!fnmatch('*.xml', $ff))
  15. continue;
  16. read($ff->getPathname());
  17. }
  18. }
  19.  
  20.  
  21. function read($file) {
  22. $xml = new XMLReader();
  23. $xml->open($file);
  24. while ($xml->read()) {
  25. if (($xml->name == 'spawn') && ($xml->nodeType == XMLReader::ELEMENT)) {
  26. insert($xml->readOuterXml());
  27. }
  28. }
  29. }
  30.  
  31. function insert($str) {
  32. $xml = new SimpleXMLElement($str);
  33. $npcid = $xml['npcid'];
  34. $mapid = $xml['map'];
  35. $pool = $xml['pool'];
  36. $delay = $xml['interval'];
  37. $routeid = $xml['w'];
  38. if (!$routeid)
  39. $routeid = 0;
  40. foreach ($xml->children() as $ob) {
  41. $x = $ob['x'];
  42. $y = $ob['y'];
  43. $z = $ob['z'];
  44. $h = $ob['h'];
  45. $static_id = $ob['static_id'];
  46. if (!$static_id)
  47. $static_id = 0;
  48. 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",
  49. $x, $y, $z, $h, $npcid, $mapid, $routeid, $delay, $static_id
  50. );
  51. }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement