Advertisement
Guest User

Untitled

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