Register for your free account! | Forgot your password?

You last visited: Today at 16:32

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



NPC.ini Parser

Discussion on NPC.ini Parser within the CO2 Programming forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
Arco.'s Avatar
 
elite*gold: 0
Join Date: Feb 2011
Posts: 335
Received Thanks: 170
NPC.ini Parser

Ah, well I know this is REALLY simple, but as I was rummaging through my hard drive, I found something that might be useful to some people. It pretty much goes through the npc.ini and parses the data and writes it to a new text file, and writes it like this,
Code:
10-19	Storekeeper
Yeah its pretty simple, but it should help most people.

You MIGHT need to change the value of the 1122 in "for (int x = 1; x < 1122; x++)" depending on what patch the npc.ini is.

Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Runtime.InteropServices;

namespace NPC.ini_Parser
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.Title = "Npc.ini Parser";
            IniFile NPC = new IniFile(Application.StartupPath + "/npc.ini");

            StreamWriter sw = new StreamWriter(Application.StartupPath + "/Npc Info.txt");
            for (int x = 1; x < 1122; x++)
            {
                string name = NPC.ReadString("NpcType" + x.ToString(), "Name", "Error");
                switch (name)
                {
                    case "Error":
                        continue;
                    default:
                        sw.WriteLine(x.ToString() + "0-" + x.ToString() + "9\t" + name);
                        break;
                }
            }
            sw.Close();
            Console.WriteLine("Npc.ini  has been parsed.");
            Console.ReadLine();
        }
    }

    class IniFile
    {
        public string FileName;

        public IniFile()
        {
        }

        public IniFile(string _FileName)
        {
            this.FileName = _FileName;
        }

        [DllImport("kernel32.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
        private static extern int GetPrivateProfileStringA(string Section, string Key, string _Default, StringBuilder Buffer, int BufferSize, string FileName);
        [DllImport("kernel32.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
        private static extern int WritePrivateProfileStringA(string Section, string Key, string Arg, string FileName);

        public byte ReadByte(string Section, string Key, byte _Default)
        {
            byte buf = _Default;
            byte.TryParse(this.ReadString(Section, Key, _Default.ToString(), 6), out buf);
            return buf;
        }

        public short ReadInt16(string Section, string Key, short _Default)
        {
            short buf = _Default;
            short.TryParse(this.ReadString(Section, Key, _Default.ToString(), 9), out buf);
            return buf;
        }

        public int ReadInt32(string Section, string Key, int _Default)
        {
            int buf = _Default;
            int.TryParse(this.ReadString(Section, Key, _Default.ToString(), 15), out buf);
            return buf;
        }

        public sbyte ReadSByte(string Section, string Key, byte _Default)
        {
            sbyte buf = (sbyte)_Default;
            sbyte.TryParse(this.ReadString(Section, Key, _Default.ToString(), 6), out buf);
            return buf;
        }

        public string ReadString(string Section, string Key, string _Default)
        {
            return this.ReadString(Section, Key, _Default, 255);
        }

        public string ReadString(string Section, string Key, string _Default, int BufSize)
        {
            StringBuilder Buffer = new StringBuilder(BufSize);
            GetPrivateProfileStringA(Section, Key, _Default, Buffer, BufSize, this.FileName);
            return Buffer.ToString();
        }

        public ushort ReadUInt16(string Section, string Key, ushort _Default)
        {
            ushort buf = _Default;
            ushort.TryParse(this.ReadString(Section, Key, _Default.ToString(), 9), out buf);
            return buf;
        }

        public uint ReadUInt32(string Section, string Key, uint _Default)
        {
            uint buf = _Default;
            uint.TryParse(this.ReadString(Section, Key, _Default.ToString(), 15), out buf);
            return buf;
        }

        public void Write(string Section, string Key, object Value)
        {
            WritePrivateProfileStringA(Section, Key, Value.ToString(), this.FileName);
        }

        public void Write(string Section, string Key, string Value)
        {
            WritePrivateProfileStringA(Section, Key, Value, this.FileName);
        }

    }

}
Arco. is offline  
Thanks
1 User
Old 03/13/2011, 23:32   #2
 
elite*gold: 0
Join Date: Aug 2010
Posts: 940
Received Thanks: 76
Ok not sure I will be needing this but I will give thanks anway
denominator is offline  
Reply


Similar Threads Similar Threads
Item-Parser
07/13/2010 - Diablo 2 - 17 Replies
D2Parser Diesen Parser hab ich mir runtergeladen. Hab alles nach Anleitung befolgt, aber: Wenn ich D2 per Parser starte und mich in Europe einlogge, dort mit nem Char ingame gehe und dann anschließend aus dem Spiel wieder austrete wird keine .xml Datei erstellt, es gibt auch garkeinen d2plog-Ordner im Hauptverzeichnis. Jemand eine Ahnung was ich vergessen hab?
Item Parser Hilfe
05/29/2010 - Diablo 2 - 2 Replies
bekomme öfter den fehler typ1 is not a function bla kommt nur bei kiefernknochen hut : == jawboneCap # ( >= 1 || >= 1 || >= 1 ) && ( >= 1 || >= 1 || >= 1 ) && <= 9 == fangedHelm # ( >= 1 || >= 1 || >= 1 ) && ( >= 1 || >= 1 || >= 1 ) && <= 9 == jawboneCap # ( >= 1 || >= 1 ) && ( >= 1 || >= 1 ) && <= 9 == fangedHelm # ( >= 1 || >= 1 ) && ( >= 1 || >= 1 ) && <= 9
Parser
04/08/2009 - FFXI Exploits, Hacks, Bots, Tools & Macros - 0 Replies
Hello, sorry i have been looking for a parser for some time and have tried many different ones and none seem to work in some way or another, most of the time its compatibility issues (vista x64) or some .net framework problem or something. The ones i did get working only displayed my data (which was innacurate btw) and did not display anyone elses data that was in the party. If anyone can help it would be greatly appreciated, thanks ^^
FFXI Parser
04/06/2006 - FFXI Exploits, Hacks, Bots, Tools & Macros - 10 Replies
FFXI Parser Für alle die jemanden was beweisen müssen ;D Setup Download



All times are GMT +2. The time now is 16:32.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.