Advertisement
Guest User

Untitled

a guest
May 23rd, 2015
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.78 KB | None | 0 0
  1. #! /usr/bin/php
  2. <?php
  3. $db=mysqli_connect("hive.hfbservers.com","user-4030","yhp6RIXM","user-4030");
  4. // Check connection
  5. if (mysqli_connect_errno($db))
  6. {
  7. echo "Failed to connect to MySQL: " . mysqli_connect_error();
  8. }
  9. //delete destroyed vehicles
  10. echo "Deleting damaged vehicles \n\n";
  11. $del_dmg = mysqli_query($db,"DELETE FROM instance_vehicle WHERE damage > .7");
  12.  
  13. //delete unused vehicles
  14. $del_old_veh = mysqli_query($db,"DELETE FROM instance_vehicle WHERE DATE(`last_updated`) < CURDATE() - INTERVAL 3 DAY");
  15. //$del_old_heli = mysqli_query($db,"DELETE FROM instance_vehicle WHERE DATE(`last_updated`) < CURDATE() - INTERVAL 1 DAY and vehicle_id IN (15,53,54,92) ");
  16.  
  17.  
  18. //delete bikes (13,14) taxis (5278,5279) planes (55,61,91,94,338), large heli (15,318,,319,321,328,343,17116,
  19. //echo "Deleting RESPAWN vehicles bicycles, taxis, planes,\n\n";
  20. //$reset = mysqli_query($db,"SELECT * FROM v_vehicle WHERE vehicle_id IN (3,13,14,15,21,38,40,50,53,54,55,59,61,62,65,66,67,68,91,94,107,108,129,131,318,319,321,328,343,17116,338,5278,5279)");
  21.  
  22.  
  23. //while ($row = mysqli_fetch_array($reset))
  24. //{
  25. // $del_veh = mysqli_query($db,"DELETE FROM instance_vehicle WHERE id = " . $row["instance_vehicle_id"]);
  26. // echo "--deleted vehicle id ". $row['instance_vehicle_id'] . "\n";
  27. //}
  28.  
  29.  
  30. //select world vehicle rows which do not exist in instance vehicle. These are the vehicles to respawn.
  31. $result = mysqli_query($db,"SELECT * from world_vehicle wv WHERE NOT EXISTS (SELECT 1 FROM instance_vehicle iv where wv.id = iv.world_vehicle_id) ORDER BY wv.id ASC LIMIT 500");
  32.  
  33. $row_cnt = mysqli_num_rows($result);
  34. echo "Respawning " . $row_cnt . " vehicles\n\n";
  35.  
  36. while ($row = mysqli_fetch_array($result)){
  37. echo $row['id']. "\n";
  38.  
  39. $random_inv = rand ( 1 , 10 );
  40. echo "--Respawning vehicle ID ". $row['vehicle_id'] ." with Inventory #" . $random_inv . "\n";
  41.  
  42. switch ($random_inv) {
  43. case 1:
  44. $inserted = mysqli_query($db,"INSERT into instance_vehicle (id, world_vehicle_id, instance_id, worldspace, inventory, parts, fuel, damage, last_updated, created) VALUES (NULL, " . $row['id'] . ", 1, '" . $row['worldspace'] . "', '[[[\"ItemGPS\",\"NVG\",\"Binocular_Vector\"],[1,1,1]],[[], []], [[], []]]', '[]', .5, 0, CURRENT_TIMESTAMP, '0000-00-00 00:00:00')");
  45. break;
  46. case 2:
  47. $inserted = mysqli_query($db,"INSERT into instance_vehicle (id, world_vehicle_id, instance_id, worldspace, inventory, parts, fuel, damage, last_updated, created) VALUES (NULL, " . $row['id'] . ", 1, '" . $row['worldspace'] . "', '[[[],[]],[[\"ItemBloodbag\",\"ItemBandage\",\"ItemMorphine\",\"ItemPainkiller\"], [1,1,1,1]], [[], []]]', '[]', .3, 0, CURRENT_TIMESTAMP, '0000-00-00 00:00:00')");
  48. break;
  49. case 3:
  50. $inserted = mysqli_query($db,"INSERT into instance_vehicle (id, world_vehicle_id, instance_id, worldspace, inventory, parts, fuel, damage, last_updated, created) VALUES (NULL, " . $row['id'] . ", 1, '" . $row['worldspace'] . "', '[[[\"ItemKnife\",\"ItemMatchbox\"],[1,1]],[[\"ItemJerrycanEmpty\"], [1]], [[\"DZ_CivilBackpack_EP1\"], [1]]]', '[]', .7, 0, CURRENT_TIMESTAMP, '0000-00-00 00:00:00')");
  51. break;
  52. case 4:
  53. $inserted = mysqli_query($db,"INSERT into instance_vehicle (id, world_vehicle_id, instance_id, worldspace, inventory, parts, fuel, damage, last_updated, created) VALUES (NULL, " . $row['id'] . ", 1, '" . $row['worldspace'] . "', '[[[\"ItemEtool\",\"ItemMatchbox\"],[1,1]],[[], []], [[], []]]', '[]', .4, 0, CURRENT_TIMESTAMP, '0000-00-00 00:00:00')");
  54. break;
  55. case 5:
  56. $inserted = mysqli_query($db,"INSERT into instance_vehicle (id, world_vehicle_id, instance_id, worldspace, inventory, parts, fuel, damage, last_updated, created) VALUES (NULL, " . $row['id'] . ", 1, '" . $row['worldspace'] . "', '[[[\"ItemKnife\",\"ItemMatchbox\",\"ItemFuelcan\"],[1,1,1]],[[\"ItemTent\"], [1]], [[], []]]', '[]', .2, 0, CURRENT_TIMESTAMP, '0000-00-00 00:00:00')");
  57. break;
  58. case 6:
  59. $inserted = mysqli_query($db,"INSERT into instance_vehicle (id, world_vehicle_id, instance_id, worldspace, inventory, parts, fuel, damage, last_updated, created) VALUES (NULL, " . $row['id'] . ", 1, '" . $row['worldspace'] . "', '[[[\"ItemToolbox\"],[1]],[[], []], [[], []]]', '[]', .4, 0, CURRENT_TIMESTAMP, '0000-00-00 00:00:00')");
  60. break;
  61. case 7:
  62. $inserted = mysqli_query($db,"INSERT into instance_vehicle (id, world_vehicle_id, instance_id, worldspace, inventory, parts, fuel, damage, last_updated, created) VALUES (NULL, " . $row['id'] . ", 1, '" . $row['worldspace'] . "', '[[[\"ItemHatchet\"],[1]],[[], []], [[\"DZ_CivilBackpack_EP1\"], [1]]]', '[]', .8, 0, CURRENT_TIMESTAMP, '0000-00-00 00:00:00')");
  63. break;
  64. case 8:
  65. $inserted = mysqli_query($db,"INSERT into instance_vehicle (id, world_vehicle_id, instance_id, worldspace, inventory, parts, fuel, damage, last_updated, created) VALUES (NULL, " . $row['id'] . ", 1, '" . $row['worldspace'] . "', '[[[\"MeleeMachete\"],[1]],[[\"ItemSodaRabbit\"], [6]], [[\"DZ_CivilBackpack_EP1\"], [1]]]', '[]', .4, 0, CURRENT_TIMESTAMP, '0000-00-00 00:00:00')");
  66. break;
  67. case 9:
  68. $inserted = mysqli_query($db,"INSERT into instance_vehicle (id, world_vehicle_id, instance_id, worldspace, inventory, parts, fuel, damage, last_updated, created) VALUES (NULL, " . $row['id'] . ", 1, '" . $row['worldspace'] . "', '[[[],[]],[[\"Pipebomb\",\"Handgrenade_West\"], [1,2]], [[], []]]', '[]', .3, 0, CURRENT_TIMESTAMP, '0000-00-00 00:00:00')");
  69. break;
  70. case 10:
  71. $inserted = mysqli_query($db,"INSERT into instance_vehicle (id, world_vehicle_id, instance_id, worldspace, inventory, parts, fuel, damage, last_updated, created) VALUES (NULL, " . $row['id'] . ", 1, '" . $row['worldspace'] . "', '[[[\"ItemFlashlightRed\"],[1]],[[\"PartVrotor\"], [1]], [[\"DZ_Assault_Pack_EP1\"], [1]]]', '[]', .5, 0, CURRENT_TIMESTAMP, '0000-00-00 00:00:00')");
  72. break;
  73.  
  74. }
  75. }
  76.  
  77.  
  78.  
  79.  
  80. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement