Evor 72 Posted August 21, 2014 Share Posted August 21, 2014 M2 Download Center This is the hidden content, please Sign In or Sign Up ( Internal ) Hello guys! It is common that, whenever u want to use an old mob_proto, u need to rewrite mob_color column for every mob (serverside mob_proto dosen't include mob_color). I write this really simple python code to convert old mob_proto columns to a sql version of it. (Simply, insert that .sql file). To do: - Place your old mob_proto_dump.xml in a folder with converter.py - Remove first and last line of mob_proto_dump.xml - Make sure that u have python installed. (no matter which version) - Run it and save time Spoiler ## oldMobProto to sqlMobProto Converter ## Created by Evor. ## For personal use oldProto = open("mob_proto_dump.xml", "r+") newProto = open("mob_proto_color.sql", "w+") newProto.write("/* Converter by Evor */n") for line in oldProto: vnum = line.split("vnum=")[1].split(" name=")[0].replace(""", "") mobColor = line.split("mob_color=")[1].split(" />")[0].replace(""", "") if not int(mobColor) == 0: newProto.write("UPDATE mob_proto SET mob_color='%s' WHERE vnum='%s' ;n" % ## there is a space between end of mysql syntax and semicolom, becouse without it navicat has some troubles in inserting that. (mobColor, vnum)) oldProto.close() newProto.close() Kind regards. @Update. Smaller code. 9 3 5 Link to comment Share on other sites More sharing options...
Recommended Posts