Guida Sql>Txt converter 34/40K

Stato
Discussione chiusa ad ulteriori risposte.

ByBoom

Bannato
4 Maggio 2013
53
24
11
77
Ultima modifica da un moderatore:
Ciao a tutti visto che e tanti di voi usano di sicuro un serverfile a 34k oppure a 40k e come sapete non è cosi facile convertire l'item_proto/mob_proto sql in txt ho deciso di condividervi un piccolo programma fatto in java. Vi lascio anche la lista con le funzioni:
Codice:
[COLOR=#2C2C2C][FONT=Consolas]private String trim(String ddd) {[/FONT][/COLOR]
        String[] blah = ddd.split(",");
        String lol = "";
        for(int k = 0; k < blah.length; ++k)
            lol += blah[k] + " | ";
                               
        lol = lol.substring(0, lol.length() - 3);
                               
        return lol;
    }
   
    private String convertHexToString(String hex){
       
          if(!hex.contains("0x")) {
              return hex.substring(1, hex.length() - 1);
          }
          StringBuilder output = new StringBuilder();
          for (int i = 2; i < hex.length(); i+=2) {
              String str = hex.substring(i, i+2);
              output.append((char)Integer.parseInt(str, 16));
          }
         
          return output.toString();
  }
   
    private void createMobProto() {
        String entry = pfadBox.getText();
        if(entry.isEmpty()) {
            return;
        }
        try {
           
            BufferedReader br = new BufferedReader(new FileReader(entry));
            Writer fw = new FileWriter("mob_proto.txt");
            Writer fw2 = new FileWriter("mob_names.txt");
            String line;
            String asdf;
           
            String[] ranks = new String[]{
                "PAWN",
                "PAWN",
                "S_PAWN",
                "S_KNIGHT",
                "BOSS",
                "KING"
            };
           
            String[] types = new String[]{
                "MONSTER", // 0
                "NPC", // 1
                "STONE", // 2
                "WARP", // 3
                "DOOR", // 4
                "BUILDING", // 5
                "", // 6
                "", // 7
                "", // 8
                "GOTO", // 9
            };
           
            String[] battletypes = new String[]{
                "MELEE", // 0
                "RANGE", // 1
                "MAGIC", // 2
                "SPECIAL", // 3
                "POWER", // 4
                "TANKER", // 5
            };
           
            while((line = br.readLine()) != null) {
                if(line.contains("INSERT INTO")) {
                    asdf = line.split("VALUES")[1].substring(2,line.split("VALUES")[1].lastIndexOf(";")-1);
                    String[] entries = asdf.split(", ");
                    String uff = entries[0].substring(1, entries[0].length() - 1) + "\t";
                    for(int i = 1; i < entries.length; ++i) {
                        if(i != 2) {
                            String ddd = entries[I].substring(1, entries[I].length() - 1);
                           
                            if(i == 3)
                                ddd = ranks[Integer.parseInt(ddd)];
                           
                            if(i == 4)
                                ddd = types[Integer.parseInt(ddd)];
                           
                            if(i == 5)
                                ddd = battletypes[Integer.parseInt(ddd)];
                           
                            if(i == 8 && ddd.contains(",")) {
                                ddd = trim(ddd);
                            }
                           
                            if(i == 11 && ddd.contains(",")) {
                                ddd = trim(ddd);
                            }
                           
                            uff += ddd + "\t";
                        }
                    }
                    fw.append(uff + "\n");
                    fw2.append(entries[0].substring(1, entries[0].length() - 1) + "\t" + convertHexToString(entries[2]) + "\n");
                }
            }
            fw.flush();
            fw.close();
            fw2.flush();
            fw2.close();
        } catch (FileNotFoundException ex) {
            JOptionPane.showMessageDialog(null, ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
        } catch (IOException ex) {
            JOptionPane.showMessageDialog(null, ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
        } [/I][/I][I][I]    }[/I][/I]
Prima di avviare il programma dovete assicurarvi di aver installato Java

Download Link: MEGA

Fonte: Metin2Area
 
Ciao a tutti visto che e tanti di voi usano di sicuro un serverfile a 34k oppure a 40k e come sapete non è cosi facile convertire l'item_proto/mob_proto sql in txt ho deciso di condividervi un piccolo programma fatto in java. Vi lascio anche la lista con le funzioni:
Codice:
[COLOR=#2C2C2C][FONT=Consolas]private String trim(String ddd) {[/FONT][/COLOR]
        String[] blah = ddd.split(",");
        String lol = "";
        for(int k = 0; k < blah.length; ++k)
            lol += blah[k] + " | ";
                               
        lol = lol.substring(0, lol.length() - 3);
                               
        return lol;
    }
   
    private String convertHexToString(String hex){
       
          if(!hex.contains("0x")) {
              return hex.substring(1, hex.length() - 1);
          }
          StringBuilder output = new StringBuilder();
          for (int i = 2; i < hex.length(); i+=2) {
              String str = hex.substring(i, i+2);
              output.append((char)Integer.parseInt(str, 16));
          }
         
          return output.toString();
  }
   
    private void createMobProto() {
        String entry = pfadBox.getText();
        if(entry.isEmpty()) {
            return;
        }
        try {
           
            BufferedReader br = new BufferedReader(new FileReader(entry));
            Writer fw = new FileWriter("mob_proto.txt");
            Writer fw2 = new FileWriter("mob_names.txt");
            String line;
            String asdf;
           
            String[] ranks = new String[]{
                "PAWN",
                "PAWN",
                "S_PAWN",
                "S_KNIGHT",
                "BOSS",
                "KING"
            };
           
            String[] types = new String[]{
                "MONSTER", // 0
                "NPC", // 1
                "STONE", // 2
                "WARP", // 3
                "DOOR", // 4
                "BUILDING", // 5
                "", // 6
                "", // 7
                "", // 8
                "GOTO", // 9
            };
           
            String[] battletypes = new String[]{
                "MELEE", // 0
                "RANGE", // 1
                "MAGIC", // 2
                "SPECIAL", // 3
                "POWER", // 4
                "TANKER", // 5
            };
           
            while((line = br.readLine()) != null) {
                if(line.contains("INSERT INTO")) {
                    asdf = line.split("VALUES")[1].substring(2,line.split("VALUES")[1].lastIndexOf(";")-1);
                    String[] entries = asdf.split(", ");
                    String uff = entries[0].substring(1, entries[0].length() - 1) + "\t";
                    for(int i = 1; i < entries.length; ++i) {
                        if(i != 2) {
                            String ddd = entries[I].substring(1, entries[I].length() - 1);
                           
                            if(i == 3)
                                ddd = ranks[Integer.parseInt(ddd)];
                           
                            if(i == 4)
                                ddd = types[Integer.parseInt(ddd)];
                           
                            if(i == 5)
                                ddd = battletypes[Integer.parseInt(ddd)];
                           
                            if(i == 8 && ddd.contains(",")) {
                                ddd = trim(ddd);
                            }
                           
                            if(i == 11 && ddd.contains(",")) {
                                ddd = trim(ddd);
                            }
                           
                            uff += ddd + "\t";
                        }
                    }
                    fw.append(uff + "\n");
                    fw2.append(entries[0].substring(1, entries[0].length() - 1) + "\t" + convertHexToString(entries[2]) + "\n");
                }
            }
            fw.flush();
            fw.close();
            fw2.flush();
            fw2.close();
        } catch (FileNotFoundException ex) {
            JOptionPane.showMessageDialog(null, ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
        } catch (IOException ex) {
            JOptionPane.showMessageDialog(null, ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
        } [/I][/I][I][I]    }[/I][/I]
Prima di avviare il programma dovete assicurarvi di aver installato Java

Download Link: MEGA

Fonte: Metin2Area

Not bad anche se era già stato postato un script in python con lo stesso scopo.
 
Ultima modifica da un moderatore:
Visto che per alcuni valori fai le stesse operazioni anzicchè fare codici chilometrici potesti utilizzare gli operatori logici. Magari su piccoli programmi non te ne rendi conto ma se scrivi molto, ridurre le operazioni al minimo è consigliato
 
Stato
Discussione chiusa ad ulteriori risposte.
Indietro
Top Bottom