th7nder 17 Posted July 28, 2014 Share Posted July 28, 2014 M2 Download Center This is the hidden content, please Sign In or Sign Up ( Internal ) hi guys! i've recently created converter to item_proto, 2 sides XML->SQL and SQL->XML in PHP, i know it could be written better, but it works, that's the point right? XML->SQL: <?php header('Content-Type: text/html; charset=utf-8'); ini_set('display_errors', 'On'); error_reporting(E_ALL); $handle = 'item_proto.sql'; exec('echo '' > '.$handle.' && chmod 777 '.$handle); $file = fopen("item_proto.xml", "r"); if(!$file){ die("where is item_proto.xml?"); } while($line = fgets($file)){ if(strpos($line, "ItemProto")) continue; $line = explode("" ", $line); $insert = Array(); foreach($line as $lineExploded){ $lineExploded = substr($lineExploded, strpos($lineExploded, """) + 1); $insert[] = $lineExploded; } $set = Array("vnum", "name", "locale_name", "type", "subtype", "weight", "size", "antiflag", "flag", "wearflag", "immuneflag", "gold", "shop_buy_price", "limittype0", "limitvalue0", "limittype1", "limitvalue1", "applytype0", "applyvalue0", "applytype1", "applyvalue1", "applytype2", "applyvalue2", "value0", "value1", "value2", "value3", "value4", "value5", "socket0", "socket1", "socket2", "refined_vnum", "refine_set", "magic_pct","specular", "socket_pct", "addon_type"); $values = "SET "; for($i = 0; $i < count($insert); $i++){ if(count($insert) - 1 == $i){ $values .= '`'.$set[$i].'`=''.substr($insert[$i], 0, 1).'';'; } else { $values .= '`'.$set[$i].'`=''.$insert[$i].'', ';; } } file_put_contents($handle, "INSERT INTO `player`.`item_proto` {$values} n", FILE_APPEND | LOCK_EX); } echo 'item_proto.sql ready and steady, my friend!'; SQL->XML <?php header('Content-Type: text/html; charset=utf-8'); ini_set('display_errors', 'On'); error_reporting(E_ALL); $mysqli = new mysqli("localhost", "user", "passwd", "player"); if ($mysqli->connect_error) { die("and u think that mysql data is ok?"); } $handle = 'item_proto.xml'; exec('echo '' > '.$handle.' && chmod 777 '.$handle); file_put_contents($handle, "<ItemProto Version="1">n", FILE_APPEND | LOCK_EX); $andrw = $mysqli->query("SELECT * from `player`.`item_proto`"); while($data = $andrw->fetch_array()){ $converted = "<ItemDef Vnum="{$data['vnum']}" Name="{$data['vnum']}" LocalizedName="{$data['locale_name']}" Type="{$data['type']}" SubType="{$data['subtype']}" Weight="{$data['weight']}" Size="{$data['size']}" AntiFlags="{$data['antiflag']}" Flags="{$data['flag']}" WearFlags="{$data['wearflag']}" ImmuneFlags="{$data['immuneflag']}" Gold="{$data['gold']}" ShopBuyPrice="{$data['shop_buy_price']}" LimitType0="{$data['limittype0']}" LimitValue0="{$data['limitvalue0']}" LimitType1="{$data['limittype1']}" LimitValue1="{$data['limitvalue1']}" ApplyType0="{$data['applytype0']}" ApplyValue0="{$data['applyvalue0']}" ApplyType1="{$data['applytype1']}" ApplyValue1="{$data['applyvalue2']}" ApplyType2="{$data['applytype2']}" ApplyValue2="{$data['applyvalue2']}" Value0="{$data['value0']}" Value1="{$data['value1']}" Value2="{$data['value2']}" Value3="{$data['value3']}" Value4="{$data['value4']}" Value5="{$data['value5']}" Socket0="{$data['socket0']}" Socket1="{$data['socket1']}" Socket2="{$data['socket2']}" RefinedVnum="{$data['refined_vnum']}" RefineSet="{$data['refine_set']}" AlterToMagicItemPercent="{$data['magic_pct']}" Specular="{$data['specular']}" GainSocketPercent="{$data['socket_pct']}" AddonType="{$data['addon_type']}" />n"; file_put_contents($handle, $converted, FILE_APPEND | LOCK_EX); } file_put_contents($handle, "</ItemProto>", FILE_APPEND | LOCK_EX); echo 'item_proto.sql ready and steady mr Captain!!'; 2 1 1 2 7 Link to comment Share on other sites More sharing options...
Night 367 Posted July 28, 2014 Share Posted July 28, 2014 you know i realy want a little change no ever released a tool for mob proto till now xml > sql Link to comment Share on other sites More sharing options...
th7nder 17 Posted July 28, 2014 Author Share Posted July 28, 2014 u cannot convert from xml to sql, 'cause in xml there isn't enough data (; Link to comment Share on other sites More sharing options...
Shang 371 Posted July 30, 2014 Share Posted July 30, 2014 u cannot convert from xml to sql, 'cause in xml there isn't enough data (; In new mob_proto yeah. Link to comment Share on other sites More sharing options...
Night 367 Posted July 30, 2014 Share Posted July 30, 2014 u cannot convert from xml to sql, 'cause in xml there isn't enough data (; i do know this cz i have already tried Link to comment Share on other sites More sharing options...
fenixplayscz 16 Posted August 27, 2014 Share Posted August 27, 2014 Not working .... [Err] 1054 - Unknown column '' in 'field list' [Err] INSERT INTO `player`.`item_proto` SET `vnum`='true', `name`='1'; INSERT INTO `player`.`item_proto` SET `vnum`='1', `name`='���ٷ���', `locale_name`='Yang', `type`='9', `subtype`='0', `weight`='0', `size`='1', `antiflag`='0', `flag`='0', `wearflag`='0', `immuneflag`='0', `GOLD`='0', `shop_buy_price`='0', `limittype0`='0', `limitvalue0`='0', `limittype1`='0', `limitvalue1`='0', `applytype0`='0', `applyvalue0`='0', `applytype1`='0', `applyvalue1`='0', `applytype2`='0', `applyvalue2`='0', `value0`='0', `value1`='0', `value2`='0', `value3`='0', `value4`='0', `value5`='0', `socket0`='0', `socket1`='0', `socket2`='0', `refined_vnum`='0', `refine_set`='0', `magic_pct`='0', `specular`='0', `socket_pct`='0', `addon_type`='0', ``='0', ``='0', ``='>'; INSERT INTO `player`.`item_proto` SET `vnum`='2', `name`='�ѱ����ֹ���', `locale_name`='Anglick� verze', `type`='0', `subtype`='0', `weight`='0', `size`='1', `antiflag`='0', `flag`='0', `wearflag`='0', `immuneflag`='0', `GOLD`='0', `shop_buy_price`='0', `limittype0`='0', `limitvalue0`='0', `limittype1`='0', `limitvalue1`='0', `applytype0`='0', `applyvalue0`='0', `applytype1`='0', `applyvalue1`='0', `applytype2`='0', `applyvalue2`='0', `value0`='0', `value1`='0', `value2`='0', `value3`='0', `value4`='0', `value5`='0', `socket0`='0', `socket1`='0', `socket2`='0', `refined_vnum`='0', `refine_set`='0', `magic_pct`='0', `specular`='0', `socket_pct`='0', `addon_type`='0', ``='0', ``='0', ``='>'; INSERT INTO `player`.`item_proto` SET `vnum`='10', `name`='��+0', `locale_name`='Me�+0', `type`='1', `subtype`='0', `weight`='0', `size`='2', `antiflag`='32', `flag`='1', `wearflag`='16', `immuneflag`='0', `GOLD`='0', `shop_buy_price`='0', `limittype0`='1', `limitvalue0`='0', `limittype1`='0', `limitvalue1`='0', `applytype0`='7', `applyvalue0`='22', `applytype1`='0', `applyvalue1`='0', `applytype2`='0', `applyvalue2`='0', `value0`='0', `value1`='15', `value2`='19', `value3`='13', `value4`='15', `value5`='0', `socket0`='0', `socket1`='0', `socket2`='0', `refined_vnum`='0', `refine_set`='0', `magic_pct`='0', `specular`='11', `socket_pct`='1', `addon_type`='15', ``='0', ``='1', ``='>'; INSERT INTO `player`.`item_proto` SET `vnum`='11', `name`='��+1', `locale_name`='Me�+1', `type`='1', `subtype`='0', `weight`='0', `size`='2', `antiflag`='32', `flag`='1', `wearflag`='16', `immuneflag`='0', `GOLD`='100', `shop_buy_price`='100', `limittype0`='1', `limitvalue0`='0', `limittype1`='0', `limitvalue1`='0', `applytype0`='7', `applyvalue0`='22', `applytype1`='0', `applyvalue1`='0', `applytype2`='0', `applyvalue2`='0', `value0`='0', `value1`='15', `value2`='19', `value3`='13', `value4`='15', `value5`='7', `socket0`='0', `socket1`='0', `socket2`='0', `refined_vnum`='0', `refine_set`='0', `magic_pct`='0', `specular`='12', `socket_pct`='2', `addon_type`='15', ``='0', ``='1', ``='>'; INSERT INTO `player`.`item_proto` SET `vnum`='12', `name`='��+2', `locale_name`='Me�+2', `type`='1', `subtype`='0', `weight`='0', `size`='2', `antiflag`='32', `flag`='1', `wearflag`='16', `immuneflag`='0', `GOLD`='100', `shop_buy_price`='100', `limittype0`='1', `limitvalue0`='0', `limittype1`='0', `limitvalue1`='0', `applytype0`='7', `applyvalue0`='22', `applytype1`='0', `applyvalue1`='0', `applytype2`='0', `applyvalue2`='0', `value0`='0', `value1`='15', `value2`='19', `value3`='13', `value4`='15', `value5`='14', `socket0`='0', `socket1`='0', `socket2`='0', `refined_vnum`='0', `refine_set`='0', `magic_pct`='0', `specular`='13', `socket_pct`='3', `addon_type`='15', ``='0', ``='1', ``='>'; INSERT INTO `player`.`item_proto` SET `vnum`='13', `name`='��+3', `locale_name`='Me�+3', `type`='1', `subtype`='0', `weight`='0', `size`='2', `antiflag`='32', `flag`='1', `wearflag`='16', `immuneflag`='0', `GOLD`='100', `shop_buy_price`='150', `limittype0`='1', `limitvalue0`='0', `limittype1`='0', `limitvalue1`='0', `applytype0`='7', `applyvalue0`='22', `applytype1`='0', `applyvalue1`='0', `applytype2`='0', `applyvalue2`='0', `value0`='0', `value1`='15', `value2`='19', `value3`='13', `value4`='15', `value5`='21', `socket0`='0', `socket1`='0', `soc [Msg] Finished - Unsuccessfully -------------------------------------------------- Link to comment Share on other sites More sharing options...
baneme22 14 Posted June 23, 2015 Share Posted June 23, 2015 Not working for mi giv this error Parse error: syntax error, unexpected '' > '' (T_CONSTANT_ENCAPSED_STRING) in C:\xampp\htdocs\sql\index.php on line 11 Link to comment Share on other sites More sharing options...
Recommended Posts