Jump to content
×
×
  • Create New...

Proto Converter | XML 2 SQL | SQL 2 TXT


Recommended Posts

M2 Download Center

Download Here ( Internal )

Hi.
I wanna to show you how can you convert item_proto to sql and later to txt files.
XML -> SQL
First we need this program:

Hidden Content

    Give reaction to this post to see the hidden content.

scan:

Hidden Content

    Give reaction to this post to see the hidden content.

Ther is something, but i haven't better program so you download it for your own responsibility

With it, we can convert our xml proto to sql
But first, from our xml file, we need to delete all <!--AddonType="0"--> and <!--AddonType="99"--> easy with notepad++ and ctrl+h :)

and now we run our program and select file to convert.

After moment we'll have a sql file, but if we have a locale_name column in item_proto we need to change also with ctr+h all gb2312name to locale_name, and now we can upload file with "execute sql file" or simpy with query to our database
 
SQL -> TXT
To convert item_proto sql to txt files, you need this script in python

http://pastebin.com/K5EDE4b6

Configuration:

You need MySQLdb on your freebsd

If you haven't it, just install it - it's a mysql library to python

cd /usr/ports/databases/py-MySQLdb/ && make install clean

You need also change the connection properties in script

default it's:

host_mysql = 'localhost'
user_mysql = 'mt2'
passwd_mysql = '[email protected]#'

And if you want convert also mob_proto in this way, you need onlu change from

#print mob_proto()

to

print mob_proto()

in the end of file.

 

Now script should generate our protos in his directory .

 

These programs are not mine. The python script i found somewhere and just modified it to 40k version

I think that it's all, if you have any better program or any better way or idea you can show it :D

Maybe in the future I will write to that one big script, but now I have no time for this ;/

If there are any problems, I'll try to help :)

 

#Updated python script

 

Regards

Deucalion

  • Metin2 Dev 11
  • Love 22
  • Love 2
  • Good 8
  • Lmao 1
  • Think 2
  • Not Good 1
  • Dislove 1
Link to comment

When i run the script appear one error 
 
 

# cd /usr/home/game/share

# python convert.py

  File "convert.py", line 396

    180,

       ^

SyntaxError: invalid syntax

line 396 is :

 

addon_type = {
180,
Link to comment
  • 4 weeks later...
  • 1 month later...

getting this:

convert_itemm.py:583: SyntaxWarning: name 'errors' is assigned to before global declaration
  global errors
convert_itemm.py:592: SyntaxWarning: name 'errors' is assigned to before global declaration
  global errors
Connecting to database proto...
Connected.
Converting item_proto...
Traceback (most recent call last):
  File "convert_itemm.py", line 867, in <module>
    print item_proto()
  File "convert_itemm.py", line 857, in item_proto
    item_proto_line = "%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%s" % (row[0], """ + row[1] + """, """  + get_item_type(row[3], row[0]) + """ , """  + get_item_subtype(row[3], row[4], row[0]) + """, row[6] , get_antiflag(row[7], row[0]), get_flag(row[8], row[0]), get_wearflag(row[9], row[0]), get_immuneflag(row[10]), row[11], row[12], row[13], row[14], row[16], get_limittype(row[17]), row[18], get_limittype(row[19]), row[20], get_apply(row[21]), row[22], get_apply(row[23]), row[24], get_apply(row[25]), row[26], row[27], row[28], row[29], row[30], row[31], row[32], row[39], row[40], row[41])
IndexError: tuple index out of range

and not work for me

Link to comment

hey Deucalion, im at the first step right now and well, i have to say that this converts my xml ind an succesfully query, but sometimes he miss lines, and sometimes lines are double, im i doing soemthing wrong?

i just renamed gb123name or w/e into "local_name" like my itemproto table is, and well, just removed that addontype=0 and 99. nothing else :/

an expample could be this:


<Item vnum="1"  name="돈꾸러미" locale_name="Yang" type="9" subtype="0" weight="0" size="1" antiflag="0" flag="0" wearflag="0" immuneflag="0" gold="0" 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" socket3="0" socket4="0" socket5="0" refine_vnum="0" refine_set="0" magic_pct="0" specular="0" socket_pct="0" />
 
<Item vnum="2"  name="한국무쌍버젼" locale_name="Versi? Espa?la" type="0" subtype="0" weight="0" size="1" antiflag="0" flag="0" wearflag="0" immuneflag="0" gold="0" 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" socket3="0" socket4="0" socket5="0" refine_vnum="0" refine_set="0" magic_pct="0" specular="0" socket_pct="0" />
 
<Item vnum="10"  name="도+0" locale_name="Espada +0" type="1" subtype="0" weight="0" size="2" antiflag="32" flag="1" wearflag="16" immuneflag="0" gold="0" 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" socket3="0" socket4="0" socket5="0" refine_vnum="11" refine_set="1" magic_pct="15" specular="0" socket_pct="1" />
 
<Item vnum="11"  name="도+1" locale_name="Espada +1" type="1" subtype="0" weight="0" size="2" antiflag="32" flag="1" wearflag="16" immuneflag="0" gold="100" 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" socket3="0" socket4="0" socket5="0" refine_vnum="12" refine_set="2" magic_pct="15" specular="0" socket_pct="1" />
 
<Item vnum="12"  name="도+2" locale_name="Espada +2" type="1" subtype="0" weight="0" size="2" antiflag="32" flag="1" wearflag="16" immuneflag="0" gold="100" 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" socket3="0" socket4="0" socket5="0" refine_vnum="13" refine_set="3" magic_pct="15" specular="0" socket_pct="1" />
 
<Item vnum="13"  name="도+3" locale_name="Espada +3" type="1" subtype="0" weight="0" size="2" antiflag="32" flag="1" wearflag="16" immuneflag="0" gold="100" 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" socket2="0" socket3="0" socket4="0" socket5="0" refine_vnum="14" refine_set="4" magic_pct="15" specular="0" socket_pct="1" />
 

 

 

 

and converted;


INSERT INTO `item_proto` VALUES ('2', 'Versi? Espa?la', 'Versi? Espa?la', '0', '0', '0', '1', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0');
 
INSERT INTO `item_proto` VALUES ('10', 'Espada +0', 'Espada +0', '1', '0', '0', '2', '32', '1', '16', '0', '0', '0', '11', '1', '0', '15', '1', '0', '0', '0', '7', '22', '0', '0', '0', '0', '0', '15', '19', '13', '15', '0', '0', '0', '0', '0', '0', '0', '1', '0', '0');
 
INSERT INTO `item_proto` VALUES ('10', 'Espada +0', 'Espada +0', '1', '0', '0', '2', '32', '1', '16', '0', '0', '0', '11', '1', '0', '15', '1', '0', '0', '0', '7', '22', '0', '0', '0', '0', '0', '15', '19', '13', '15', '0', '0', '0', '0', '0', '0', '0', '1', '0', '0');
 
INSERT INTO `item_proto` VALUES ('12', 'Espada +2', 'Espada +2', '1', '0', '0', '2', '32', '1', '16', '0', '100', '100', '13', '3', '0', '15', '1', '0', '0', '0', '7', '22', '0', '0', '0', '0', '0', '15', '19', '13', '15', '14', '0', '0', '0', '0', '0', '0', '1', '0', '0');
 
INSERT INTO `item_proto` VALUES ('12', 'Espada +2', 'Espada +2', '1', '0', '0', '2', '32', '1', '16', '0', '100', '100', '13', '3', '0', '15', '1', '0', '0', '0', '7', '22', '0', '0', '0', '0', '0', '15', '19', '13', '15', '14', '0', '0', '0', '0', '0', '0', '1', '0', '0');
 
INSERT INTO `item_proto` VALUES ('13', 'Espada +3', 'Espada +3', '1', '0', '0', '2', '32', '1', '16', '0', '100', '150', '14', '4', '0', '15', '1', '0', '0', '0', '7', '22', '0', '0', '0', '0', '0', '15', '19', '13', '15', '21', '0', '0', '0', '0', '0', '0', '1', '0', '0');





some lines missing, and other doubles as i said :/


thanks fro reading and for your work ^^

Link to comment
proto.py:583: SyntaxWarning: name 'errors' is assigned to before global declaration
  global errors
proto.py:592: SyntaxWarning: name 'errors' is assigned to before global declaration
  global errors
 
 
It's ok? :S
Link to comment
    item_proto_line = "%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%s" % (row[0], """ + row[1] + """, """  + get_item_type(row[3], row[0]) + """ , """  + get_item_subtype(row[3], row[4], row[0]) + """, row[6] , get_antiflag(row[7], row[0]), get_flag(row[8], row[0]), get_wearflag(row[9], row[0]), get_immuneflag(row[10]), row[11], row[12], row[13], row[14], row[16], get_limittype(row[17]), row[18], get_limittype(row[19]), row[20], get_apply(row[21]), row[22], get_apply(row[23]), row[24], get_apply(row[25]), row[26], row[27], row[28], row[29], row[30], row[31], row[32], row[39], row[40], row[41])
TypeError: cannot concatenate 'str' and 'NoneType' objects
 
 
WTF?
Link to comment
  • 2 months later...

getting this:

convert_itemm.py:583: SyntaxWarning: name 'errors' is assigned to before global declaration
  global errors
convert_itemm.py:592: SyntaxWarning: name 'errors' is assigned to before global declaration
  global errors
Connecting to database proto...
Connected.
Converting item_proto...
Traceback (most recent call last):
  File "convert_itemm.py", line 867, in <module>
    print item_proto()
  File "convert_itemm.py", line 857, in item_proto
    item_proto_line = "%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%s" % (row[0], """ + row[1] + """, """  + get_item_type(row[3], row[0]) + """ , """  + get_item_subtype(row[3], row[4], row[0]) + """, row[6] , get_antiflag(row[7], row[0]), get_flag(row[8], row[0]), get_wearflag(row[9], row[0]), get_immuneflag(row[10]), row[11], row[12], row[13], row[14], row[16], get_limittype(row[17]), row[18], get_limittype(row[19]), row[20], get_apply(row[21]), row[22], get_apply(row[23]), row[24], get_apply(row[25]), row[26], row[27], row[28], row[29], row[30], row[31], row[32], row[39], row[40], row[41])
IndexError: tuple index out of range

and not work for me

 

 

 

    item_proto_line = "%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%st%s" % (row[0], """ + row[1] + """, """  + get_item_type(row[3], row[0]) + """ , """  + get_item_subtype(row[3], row[4], row[0]) + """, row[6] , get_antiflag(row[7], row[0]), get_flag(row[8], row[0]), get_wearflag(row[9], row[0]), get_immuneflag(row[10]), row[11], row[12], row[13], row[14], row[16], get_limittype(row[17]), row[18], get_limittype(row[19]), row[20], get_apply(row[21]), row[22], get_apply(row[23]), row[24], get_apply(row[25]), row[26], row[27], row[28], row[29], row[30], row[31], row[32], row[39], row[40], row[41])
TypeError: cannot concatenate 'str' and 'NoneType' objects
 
 
WTF?

 

 

Take a look here

Link to comment
  • 3 months later...
  • 3 weeks later...
  • 1 year later...

Excellent guide it works good ... 
but i have problem with converting item proto using convertproto.py 
if any1 can correct it will be good 
 

Error while converting

  Hide contents

  File "convert_proto.py", line 857, in item_proto
    item_proto_line = "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s" % (row[0], "\"" + row[1] + "\"", "\""  + get_item_type(row[3], row[0]) + "\"" , "\""  + get_item_subtype(row[3], row[4], row[0]) + "\"", row[6] , get_antiflag(row[7], row[0]), get_flag(row[8], row[0]), get_wearflag(row[9], row[0]), get_immuneflag(row[10]), row[11], row[12], row[13], row[14], row[16], get_limittype(row[17]), row[18], get_limittype(row[19]), row[20], get_apply(row[21]), row[22], get_apply(row[23]), row[24], get_apply(row[25]), row[26], row[27], row[28], row[29], row[30], row[31], row[32], row[39], row[40], row[41])
TypeError: cannot concatenate 'str' and 'long' objects
 


I tell you why it is happening normal convert proto the vnum_range will be last so it wont make problem but here we added vnum_range next to vnum that is row 2... so its making problem So any one who correct this will be helpful i tried but it says 

" TypeError: not enough arguments for format string " 

Here is my Convert proto.py 

Error section 
 

  Hide contents

    out_file_itemproto = open("item_proto.txt", "w")
    out_file_itemnames = open("item_names.txt", "w")
    print "Converting item_proto..."
    for row in rows:
        item_proto_line = "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s" % (row[0], "\"" + row[1] + "\"", "\""  + get_item_type(row[3], row[0]) + "\"" , "\""  + get_item_subtype(row[3], row[4], row[0]) + "\"", row[6] , get_antiflag(row[7], row[0]), get_flag(row[8], row[0]), get_wearflag(row[9], row[0]), get_immuneflag(row[10]), row[11], row[12], row[13], row[14], row[16], get_limittype(row[17]), row[18], get_limittype(row[19]), row[20], get_apply(row[21]), row[22], get_apply(row[23]), row[24], get_apply(row[25]), row[26], row[27], row[28], row[29], row[30], row[31], row[32], row[39], row[40], row[41])
        item_names_line = "%s\t%s" % (row[0], row[2])
        out_file_itemproto.write(item_proto_line + "\r\n")
        out_file_itemnames.write(item_names_line + "\r\n")
    out_file_itemproto.close()


Thanks in Advance 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.