- Joined
- Sep 10, 2007
- Messages
- 970
- Reaction score
- 815
So, this is something I made a long while back, completely basic... in C#...
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.IO;
namespace ShopBuilder
{
class Items
{
public string Name { get; set; }
public int Level { get; set; }
}
class Program
{
public static void BuildShop()
{
XmlTextReader xml = new XmlTextReader("C:\\zitem.xml");
string XMLOut;
List<string> Chest = new List<string>();
List<string> Feet = new List<string>();
List<string> hands = new List<string>();
List<string> head = new List<string>();
List<string> legs = new List<string>();
List<string> finger = new List<string>();
List<string> Dagger = new List<string>();
List<string> DualDagger = new List<string>();
List<string> Katana = new List<string>();
List<string> DoubleKatana = new List<string>();
List<string> LargeSword = new List<string>();
List<string> Pistol = new List<string>();
List<string> Revolver = new List<string>();
List<string> SMG = new List<string>();
List<string> Shotgun = new List<string>();
List<string> Rifle = new List<string>();
List<string> MachineGun = new List<string>();
List<string> Rocket = new List<string>();
List<string> Snifer = new List<string>();
List<string> Frag = new List<string>();
List<string> FlashBang = new List<string>();
List<string> Smoke = new List<string>();
List<string> Medkit = new List<string>();
List<string> Repairkit = new List<string>();
List<string> Enchant = new List<string>();
List<string> Candy = new List<string>();
List<string> BulletKit = new List<string>();
Console.WriteLine("Shop XML File Name?");
XMLOut = "shop.xml";
StreamWriter sWriter = new StreamWriter("C:\\" + XMLOut);
sWriter.WriteLine("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");
sWriter.WriteLine("<XML id=\"shop\">");
for (int i = 0; i <= 2; i++) xml.Read();
while (xml.Read())
{
if (xml.AttributeCount > 0 && xml.GetAttribute("snd_fire") != "blade_swing" && !xml.GetAttribute("name").ToLower().Contains("don") && !xml.GetAttribute("name").ToLower().Contains("staff"))
{
try
{
string s = xml.GetAttribute("weapon").ToLower();
if (s.StartsWith("dagger"))
{
Dagger.Add("<!-- Dagger --><SELL itemid=\"" + xml.GetAttribute(0) + "\" />");
}
if (s.StartsWith("dualdagger"))
{
DualDagger.Add("<!-- DualDagger --><SELL itemid=\"" + xml.GetAttribute(0) + "\" />");
}
if (s.StartsWith("katana"))
{
Katana.Add("<!-- Sword --><SELL itemid=\"" + xml.GetAttribute(0) + "\" />");
}
if (s.StartsWith("doublekatana"))
{
DoubleKatana.Add("<!-- Double Swords --><SELL itemid=\"" + xml.GetAttribute(0) + "\" />");
}
if (s.StartsWith("greatsword"))
{
LargeSword.Add("<!-- Large Sword --><SELL itemid=\"" + xml.GetAttribute(0) + "\"/>");
}
if (s.StartsWith("pistol"))
{
Pistol.Add("<!-- Pistol --><SELL itemid=\"" + xml.GetAttribute(0) + "\" />");
}
if (s.StartsWith("revolver"))
{
Revolver.Add("<!-- Revolver --><SELL itemid=\"" + xml.GetAttribute(0) + "\" />");
}
if (s.StartsWith("smg"))
{
SMG.Add("<!-- SMG --><SELL itemid=\"" + xml.GetAttribute(0) + "\" />");
}
if (s.StartsWith("shotgun"))
{
Shotgun.Add("<!-- Shotgun --><SELL itemid=\"" + xml.GetAttribute(0) + "\" />");
}
if (s.StartsWith("rifle"))
{
Rifle.Add("<!-- Rifle --><SELL itemid=\"" + xml.GetAttribute(0) + "\" />");
}
if (s.StartsWith("machinegun"))
{
MachineGun.Add("<!-- MachineGun --><SELL itemid=\"" + xml.GetAttribute(0) + "\" />");
}
if (s.StartsWith("rocket"))
{
Rocket.Add("<!-- Rocket --><SELL itemid=\"" + xml.GetAttribute(0) + "\" />");
}
if (s.StartsWith("frag"))
{
Frag.Add("<!-- Frag --><SELL itemid=\"" + xml.GetAttribute(0) + "\" />");
}
if (s.StartsWith("flashbang"))
{
FlashBang.Add("<!-- Flash Bang --><SELL itemid=\"" + xml.GetAttribute(0) + "\" />");
}
if (s.StartsWith("smoke"))
{
Smoke.Add("<!-- Smoke --><SELL itemid=\"" + xml.GetAttribute(0) + "\" />");
}
if (s.StartsWith("medkit"))
{
Medkit.Add("<!-- Medkit --><SELL itemid=\"" + xml.GetAttribute(0) + "\" />");
}
if (s.StartsWith("repairkit"))
{
Repairkit.Add("<!-- Repairkit --><SELL itemid=\"" + xml.GetAttribute(0) + "\" />");
}
if (s.StartsWith("enchant"))
{
Enchant.Add("<!-- Enchant --><SELL itemid=\"" + xml.GetAttribute(0) + "\" />");
}
if (s.StartsWith("candy"))
{
Candy.Add("<!-- Candy --><SELL itemid=\"" + xml.GetAttribute(0) + "\" />");
}
if (s.StartsWith("bulletkit"))
{
BulletKit.Add("<!-- bulletkit --><SELL itemid=\"" + xml.GetAttribute(0) + "\" />");
}
if (s.StartsWith("snifer"))
{
Snifer.Add("<!-- Snifer --><SELL itemid=\"" + xml.GetAttribute(0) + "\" />");
}
}
catch (Exception e)
{
}
switch (xml.GetAttribute("slot").ToLower())
{
case "chest":
Chest.Add("<!-- Chest --><SELL itemid=\"" + xml.GetAttribute(0) + "\" />");
break;
case "feet":
Feet.Add("<!-- Feet --><SELL itemid=\"" + xml.GetAttribute(0) + "\" />");
break;
case "hands":
hands.Add("<!-- Hands --> <SELL itemid=\"" + xml.GetAttribute(0) + "\" />");
break;
case "head":
head.Add("<!-- Head --> <SELL itemid=\"" + xml.GetAttribute(0) + "\" />");
break;
case "legs":
legs.Add("<!-- Legs --> <SELL itemid=\"" + xml.GetAttribute(0) + "\" />");
break;
case "finger":
finger.Add("<!-- Ring --> <SELL itemid=\"" + xml.GetAttribute(0) + "\" />");
break;
default:
break;
}
}
}
//Write The poop Yo!
for (int i = 0; i < Dagger.Count; i++) sWriter.WriteLine(Dagger[i]);
for (int i = 0; i < DualDagger.Count; i++) sWriter.WriteLine(DualDagger[i]);
for (int i = 0; i < Katana.Count; i++) sWriter.WriteLine(Katana[i]);
for (int i = 0; i < DoubleKatana.Count; i++) sWriter.WriteLine(DoubleKatana[i]);
for (int i = 0; i < LargeSword.Count; i++) sWriter.WriteLine(LargeSword[i]);
for (int i = 0; i < Pistol.Count; i++) sWriter.WriteLine(Pistol[i]);
for (int i = 0; i < Revolver.Count; i++) sWriter.WriteLine(Revolver[i]);
for (int i = 0; i < SMG.Count; i++) sWriter.WriteLine(SMG[i]);
for (int i = 0; i < Shotgun.Count; i++) sWriter.WriteLine(Shotgun[i]);
for (int i = 0; i < Rifle.Count; i++) sWriter.WriteLine(Rifle[i]);
for (int i = 0; i < Snifer.Count; i++) sWriter.WriteLine(Snifer[i]);
for (int i = 0; i < MachineGun.Count; i++) sWriter.WriteLine(MachineGun[i]);
for (int i = 0; i < Rocket.Count; i++) sWriter.WriteLine(Rocket[i]);
for (int i = 0; i < Frag.Count; i++) sWriter.WriteLine(Frag[i]);
for (int i = 0; i < FlashBang.Count; i++) sWriter.WriteLine(FlashBang[i]);
for (int i = 0; i < Smoke.Count; i++) sWriter.WriteLine(Smoke[i]);
for (int i = 0; i < Medkit.Count; i++) sWriter.WriteLine(Medkit[i]);
for (int i = 0; i < Repairkit.Count; i++) sWriter.WriteLine(Repairkit[i]);
for (int i = 0; i < Candy.Count; i++) sWriter.WriteLine(Candy[i]);
for (int i = 0; i < BulletKit.Count; i++) sWriter.WriteLine(BulletKit[i]);
for (int i = 0; i < Enchant.Count; i++) sWriter.WriteLine(Enchant[i]);
for (int i = 0; i < head.Count; i++) sWriter.WriteLine(head[i]);
for (int i = 0; i < Chest.Count; i++) sWriter.WriteLine(Chest[i]);
for (int i = 0; i < hands.Count; i++) sWriter.WriteLine(hands[i]);
for (int i = 0; i < legs.Count; i++) sWriter.WriteLine(legs[i]);
for (int i = 0; i < Feet.Count; i++) sWriter.WriteLine(Feet[i]);
for (int i = 0; i < finger.Count; i++) sWriter.WriteLine(finger[i]);
sWriter.WriteLine("</XML>");
sWriter.Close();
xml.Close();
}
static void Main(string[] args)
{
BuildShop();
}
}
}