My First CFG (hard coding items renamed cleints)
ok it probably took me 2 hours and this is my first cfg i ever made
yes this is a tut and it HAS NOT BEEN TESTED
im to lazy to test it and i wana know if some can do it for me
its been compiled with no errors so im pretty sure it will work
it doesnt work but mabey some one smarter can fix the problem =P
if you do fix it up please give me credits
so here it is this all goes in itemdef.java
so add this some where
Code:
public static boolean loadItems(String FileName) {
String line = "";
String token = "";
String token2 = "";
String token2_2 = "";
String[] token3 = new String[22];
boolean EndOfFile = false;
int ReadMode = 0;
BufferedReader characterfile = null;
try {
characterfile = new BufferedReader(new FileReader("./"+FileName));
} catch(FileNotFoundException fileex) {
System.out.println(FileName+": file not found.");
return false;
}
try {
line = characterfile.readLine();
} catch(IOException ioexception) {
System.out.println(FileName+": error loading file.");
return false;
}
while(EndOfFile == false && line != null) {
line = line.trim();
int spot = line.indexOf("=");
if (spot > -1) {
token = line.substring(0, spot);
token = token.trim();
token2 = line.substring(spot + 1);
token2 = token2.trim();
token2_2 = token2.replaceAll("\t\t", "\t");
token2_2 = token2_2.replaceAll("\t\t", "\t");
token2_2 = token2_2.replaceAll("\t\t", "\t");
token2_2 = token2_2.replaceAll("\t\t", "\t");
token2_2 = token2_2.replaceAll("\t\t", "\t");
token3 = token2_2.split("\t");
if (token.equals("ItemID")) {
if (token3[(22)] != null) {
} else {
break;
}
newItems(Integer.parseInt(token3[0]), token3[1].replaceAll("_", " "), token3[2].replaceAll("_", " "), token3[3].replaceAll("_", " "), Integer.parseInt(token3[4]), Integer.parseInt(token3[5]), Integer.parseInt(token3[6]), Integer.parseInt(token3[7]), Integer.parseInt(token3[8]), Integer.parseInt(token3[9]), Integer.parseInt(token3[10]), Integer.parseInt(token3[11]), Integer.parseInt(token3[12]), Integer.parseInt(token3[13]), Integer.parseInt(token3[14]), Integer.parseInt(token3[15]), Integer.parseInt(token3[16]), Integer.parseInt(token3[17]), Integer.parseInt(token3[18]), Integer.parseInt(token3[19]), Integer.parseInt(token3[20]), Integer.parseInt(token3[21]));
}
} else {
if (line.equals("[ENDOFITEMS]")) {
try { characterfile.close(); } catch(IOException ioexception) { }
return true;
}
}
try {
line = characterfile.readLine();
} catch(IOException ioexception1) { EndOfFile = true; }
}
try { characterfile.close(); } catch(IOException ioexception) { }
return false;
}
public static void newItems(int ItemID, String ItemName, String ItemDescription, String Action, int originalMC, int modifiedMC, int originalMC1, int modifiedMC1, int originalMC2, int modifiedMC2, int ModelZoom, int ModelRo1, int ModelRo2, int ModelOff1, int ModelOff2, int ItemLook, int Sleeves, int MaleM, int FemaleM, int A184, int A204, int A197) {
int i = 0;
ItemDef itemDef = forID(i);
if(i == ItemID){
itemDef.name = ItemName;
itemDef.description = ItemDescription.getBytes();
itemDef.actions = new String[5];
itemDef.actions[1] = Action;
itemDef.modifiedModelColors = new int[3];
itemDef.originalModelColors = new int[3];
itemDef.modifiedModelColors[0] = originalMC;
itemDef.originalModelColors[0] = modifiedMC;
itemDef.modifiedModelColors[1] = originalMC1;
itemDef.originalModelColors[1] = modifiedMC1;
itemDef.modifiedModelColors[2] = originalMC2;
itemDef.originalModelColors[2] = modifiedMC2;
itemDef.modelZoom = ModelZoom;//model zoom
itemDef.modelRotation1 = ModelRo1; //model rotation 1
itemDef.modelRotation2 = ModelRo2;//model rotation 2
itemDef.modelOffset1 = ModelOff1;//model offset 1
itemDef.modelOffset2 = ModelOff2;//model offset2
itemDef.modelID = ItemLook;//Item Look
itemDef.anInt188 = Sleeves;//Sleeves
itemDef.anInt165 = MaleM;//Male
itemDef.anInt200 = FemaleM;//Female
itemDef.anInt184 = A184;
itemDef.anInt204 = A204;
itemDef.anInt197 = A197;
}
}
then youd add this where you normaly put your items
Code:
loadItems("config/items.cfg");
heres an example i made
Code:
/*Item ID Item Name Item Description Item action(wear, equipt, ect...)
Original color New Color Original color 1 New Color 1 Original color 2 New Color 2
Model Zoom Model Rotation 1 Model Rotation 2 Model Offset 1 Model Offset 2
Item look Sleeves Male Female anInt 184 anInt 204 anInt 197*/
ItemID = 10000 Bandos chestplate A chest plate once worn by the god Bandos. Equipt 0 0 0 0 0 0 984 501 6 1 4 3045 3043 3046 3032 150 2047 120
ItemID = 7252 White Mask It's a white mask. Wear 926 100 0 0 0 0 730 516 0 0 5 -10 2438 -1 3188 3192 0 0 0
[ENDOFITEMS]
eh its not working it has to do with the item id (int i)