stoneharry

Untitled

Mar 6th, 2013
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 4.58 KB | None | 0 0
  1. <?php
  2. $connection = mysql_connect("localhost", "root", "12345") or die("Connection to Database failed");
  3. mysql_select_db("world") or die ("Database selection failed");
  4.  
  5. $myFile = "update.sql";
  6. $fh = fopen($myFile, 'w') or die("can't open file");
  7.  
  8. $q = mysql_query("SELECT * FROM creature_names");
  9. $q2 = mysql_query("SELECT * FROM creature_proto");
  10.  
  11. echo "Running...";
  12. while($row = mysql_fetch_array($q))
  13. {
  14.     $row2 = mysql_fetch_array($q2);
  15.     $string = "replace into `creature_template` (`entry`, `difficulty_entry_1`, `difficulty_entry_2`, `difficulty_entry_3`, `KillCredit1`, `KillCredit2`, `modelid1`, `modelid2`, `modelid3`, `modelid4`, `name`, `subname`, `IconName`, `gossip_menu_id`, `minlevel`, `maxlevel`, `exp`, `faction_A`, `faction_H`, `npcflag`, `speed_walk`, `speed_run`, `scale`, `rank`, `mindmg`, `maxdmg`, `dmgschool`, `attackpower`, `dmg_multiplier`, `baseattacktime`, `rangeattacktime`, `unit_class`, `unit_flags`, `unit_flags2`, `dynamicflags`, `family`, `trainer_type`, `trainer_spell`, `trainer_class`, `trainer_race`, `minrangedmg`, `maxrangedmg`, `rangedattackpower`, `type`, `type_flags`, `lootid`, `pickpocketloot`, `skinloot`, `resistance1`, `resistance2`, `resistance3`, `resistance4`, `resistance5`, `resistance6`, `spell1`, `spell2`, `spell3`, `spell4`, `spell5`, `spell6`, `spell7`, `spell8`, `PetSpellDataId`, `VehicleId`, `mingold`, `maxgold`, `AIName`, `MovementType`, `InhabitType`, `HoverHeight`, `Health_mod`, `Mana_mod`, `Armor_mod`, `RacialLeader`, `questItem1`, `questItem2`, `questItem3`, `questItem4`, `questItem5`, `questItem6`, `movementId`, `RegenHealth`, `equipment_id`, `mechanic_immune_mask`, `flags_extra`, `ScriptName`, `WDBVerified`) VALUES ('{$row[0]}', '0', '0', '0', '0', '0', ";
  16.     $string = $string . "'{$row['male_displayid']}', '{$row['female_displayid']}', '{$row['male_displayid2']}', '{$row['female_displayid2']}',";
  17.     $name = str_replace("\"", "\\\"", $row['name']);
  18.     $subname = str_replace("\"", "\\\"", $row['subname']);
  19.     $string = $string . "\"{$name}\", \"{$subname}\", '{$row['info_str']}', '0',"; // 0 = gossip menu ID
  20.     $string = $string . "'{$row2['minlevel']}', '{$row2['maxlevel']}', '0', '{$row2['faction']}', '{$row2['faction']}',"; // 0 = exp
  21.     $string = $string . "'{$row2['npcflags']}', '1', '1', '{$row2['scale']}',";
  22.     $string = $string . "'{$row['rank']}', '{$row2['mindamage']}', '{$row2['maxdamage']}', '0',"; // 0 = school damage
  23.     $attackpower = $row2['maxlevel'] * 2;
  24.     $string = $string . "'{$attackpower}', '1', '{$row2['attacktime']}', '{$row2['rangedattacktime']}',";
  25.     $string = $string . "'1', '0', '{$row2['npcflags']}', '8', '{$row['family']}', '0', '0', '0', '0', "; // `trainer_type`, `trainer_spell`, `trainer_class`, `trainer_race`,
  26.     $string = $string . "'{$row2['rangedmindamage']}', '{$row2['rangedmaxdamage']}', '{$attackpower}',";
  27.     $lootid = $row[0];
  28.     $string = $string . "'{$row['type']}', '0', '{$lootid}', '0', '0',";
  29.     $string = $string . "'{$row2['resistance1']}', ";
  30.     $string = $string . "'{$row2['resistance2']}', ";
  31.     $string = $string . "'{$row2['resistance3']}', ";
  32.     $string = $string . "'{$row2['resistance4']}', ";
  33.     $string = $string . "'{$row2['resistance5']}', ";
  34.     $string = $string . "'{$row2['resistance6']}', ";
  35.     $string = $string . "'{$row2['spell1']}', ";
  36.     $string = $string . "'{$row2['spell2']}', ";
  37.     $string = $string . "'{$row2['spell3']}', ";
  38.     $string = $string . "'{$row2['spell4']}', ";
  39.     $string = $string . "'{$row2['spell5']}', ";
  40.     $string = $string . "'{$row2['spell6']}', ";
  41.     $string = $string . "'{$row2['spell7']}', ";
  42.     $string = $string . "'{$row2['spell8']}', '0', "; // PetSpellDataId
  43.     $string = $string . "'{$row2['vehicleid']}', '{$row2['money']}', '{$row2['money']}',";
  44.     $string = $string . "'', '0', '3', '1', '1', '1', '1', '{$row2['boss']}', ";
  45.     $string = $string . "'{$row['questitem1']}', '{$row['questitem2']}', ";
  46.     $string = $string . "'{$row['questitem3']}', '{$row['questitem4']}', ";
  47.     $string = $string . "'{$row['questitem5']}', '{$row['questitem6']}', ";
  48.     $equipmentID = "0";
  49.     $string = $string . "'0', '1', '{$equipmentID}', '{$row2['modImmunities']}', ";
  50.     $string = $string . "'0', '', '12340'";
  51.     $string = $string . ");\n";
  52.    
  53.     $q3 = mysql_query("SELECT * FROM loot_creatures WHERE `entryid` = '{$lootid}'");
  54.     while($lr = mysql_fetch_array($q3))
  55.     {
  56.         $string = $string . "replace into `creature_loot_template` VALUES (";
  57.         $string = $string . "'{$lootid}', '{$lr['itemid']}', '{$lr['normal10percentchance']}', '1', '0', '{$lr['mincount']}', '{$lr['maxcount']}'";
  58.         $string = $string . ");\n";
  59.     }
  60.    
  61.     fwrite($fh, $string);
  62. }
  63. echo "<br>Done.";
  64.  
  65.    
  66. fclose($fh);
  67. mysql_close($connection);
  68. ?>
Advertisement
Add Comment
Please, Sign In to add comment