[help] trying to add stats in

06/04/2009 21:00 coreymills#1
trying to have it so that class stats load by an ini can someone help me with this please


Thanks in advance
06/04/2009 21:17 kinshi88#2
Since CoEmu v2 using Sql, why don't you just load it from the Sql?
Make a Dictionary to load them with a Stat class.
Then when you gain a level, select the stat class from the dictionary level entry.
06/04/2009 22:29 coreymills#3
i'm still learning to code could u do a guide for me
06/04/2009 23:12 yuko#4
by using the lotf system i've made you the ini read stuff

nano.cs
Code:
[COLOR="RoyalBlue"]using [/COLOR]System;
[COLOR="RoyalBlue"]using [/COLOR]System.Collections;
[COLOR="RoyalBlue"]using [/COLOR]System.Threading;
[COLOR="RoyalBlue"]using [/COLOR]System.Collections.Generic;
[COLOR="RoyalBlue"]using [/COLOR]CoEmu_v2_GameServer.Connections;
[COLOR="RoyalBlue"]using [/COLOR]CoEmu_v2_GameServer.Structs;
[COLOR="RoyalBlue"]using [/COLOR]CoEmu_v2_GameServer.Entities;
[COLOR="RoyalBlue"]using [/COLOR]System.Text;
[COLOR="RoyalBlue"]using [/COLOR]System.Runtime.InteropServices;
[COLOR="RoyalBlue"]using [/COLOR]System.Timers;
[COLOR="RoyalBlue"]using [/COLOR]System.Data;
be sure to have all these location (at the 10 first lines of the page)

now, scroll down a bit
where you see
Code:
	[COLOR="royalblue"]public class [/COLOR]COLOR="Lime"]Nano[/COLOR]
	{
and place this right under it
Code:
[COLOR="RoyalBlue"]public static[/COLOR] [COLOR="Lime"]Ini [/COLOR]Stats = [COLOR="RoyalBlue"]new [/COLOR][COLOR="Lime"]Ini[/COLOR](System.Windows.Forms.[COLOR="lime"]Application[/COLOR].StartupPath + [COLOR="Red"]@"\Stats.ini"[/COLOR]);
i put it in nano.cs caus i have other ini reading stuff in there too

open exp.cs
searche for
Code:
[COLOR="RoyalBlue"]public static void[/COLOR] GiveLevel([COLOR="Lime"]ClientSocket [/COLOR]CSocket)
		{
under
Code:
CSocket.Client.Level++;
add
Code:
[COLOR="RoyalBlue"]if[/COLOR] (CSocket.Client.Reborn == 0)
            {
                [COLOR="RoyalBlue"]if[/COLOR] (CSocket.Client.Level <= 120)
                {
                    [COLOR="RoyalBlue"]if[/COLOR] ([COLOR="RoyalBlue"]([COLOR="RoyalBlue"]int[/COLOR])[/COLOR]CSocket.Client.Class > 9 && [COLOR="RoyalBlue"]([COLOR="RoyalBlue"]int[/COLOR])[/COLOR]CSocket.Client.Class < 16)
                    {
                        CSocket.Client.Strength = [COLOR="RoyalBlue"]int[/COLOR].Parse([COLOR="Lime"]Nano[/COLOR].Stats.ReadValue([COLOR="Red"]"Trojan"[/COLOR], [COLOR="Red"]"Strength["[/COLOR] + CSocket.Client.Level + [COLOR="Red"]"]"[/COLOR]));
                        CSocket.Client.Dexterity = [COLOR="RoyalBlue"]int[/COLOR].Parse([COLOR="Lime"]Nano[/COLOR].Stats.ReadValue([COLOR="Red"]"Trojan"[/COLOR], [COLOR="Red"]"Agility["[/COLOR] + CSocket.Client.Level + [COLOR="Red"]"]"[/COLOR]));
                        CSocket.Client.Vitality = [COLOR="RoyalBlue"]int[/COLOR].Parse([COLOR="Lime"]Nano[/COLOR].Stats.ReadValue([COLOR="Red"]"Trojan"[/COLOR], [COLOR="Red"]"Vitality["[/COLOR] + CSocket.Client.Level + [COLOR="Red"]"]"[/COLOR]));
                        CSocket.Client.Spirit = [COLOR="RoyalBlue"]int[/COLOR].Parse([COLOR="Lime"]Nano[/COLOR].Stats.ReadValue([COLOR="Red"]"Trojan"[/COLOR], [COLOR="Red"]"Spirit[" + CSocket.Client.Level + [COLOR="Red"]"]"));
                    }
                    [COLOR="RoyalBlue"]else if[/COLOR] ([COLOR="RoyalBlue"]([COLOR="RoyalBlue"]int[/COLOR])[/COLOR]CSocket.Client.Class > 19 && [COLOR="RoyalBlue"]([COLOR="RoyalBlue"]int[/COLOR])[/COLOR]CSocket.Client.Class < 26)
                    {
                        CSocket.Client.Strength = [COLOR="RoyalBlue"]int[/COLOR].Parse([COLOR="Lime"]Nano[/COLOR].Stats.ReadValue([COLOR="Red"]"Warrior"[/COLOR], [COLOR="Red"]"Strength["[/COLOR] + CSocket.Client.Level + [COLOR="Red"]"]"[/COLOR]));
                        CSocket.Client.Dexterity = [COLOR="RoyalBlue"]int[/COLOR].Parse([COLOR="Lime"]Nano[/COLOR].Stats.ReadValue([COLOR="Red"]"Warrior"[/COLOR], [COLOR="Red"]"Agility["[/COLOR] + CSocket.Client.Level + [COLOR="Red"]"]"[/COLOR]));
                        CSocket.Client.Vitality = [COLOR="RoyalBlue"]int[/COLOR].Parse([COLOR="Lime"]Nano[/COLOR].Stats.ReadValue([COLOR="Red"]"Warrior"[/COLOR], [COLOR="Red"]"Vitality["[/COLOR] + CSocket.Client.Level + [COLOR="Red"]"]"[/COLOR]));
                        CSocket.Client.Spirit = [COLOR="RoyalBlue"]int[/COLOR].Parse([COLOR="Lime"]Nano[/COLOR].Stats.ReadValue([COLOR="Red"]"Warrior"[/COLOR], [COLOR="Red"]"Spirit[" + CSocket.Client.Level + [COLOR="Red"]"]"));
                    }
                    [COLOR="RoyalBlue"]else if[/COLOR] ([COLOR="RoyalBlue"]([COLOR="RoyalBlue"]int[/COLOR])[/COLOR]CSocket.Client.Class > 39 && [COLOR="RoyalBlue"]([COLOR="RoyalBlue"]int[/COLOR])[/COLOR]CSocket.Client.Class < 46)
                    {
                        CSocket.Client.Strength = [COLOR="RoyalBlue"]int[/COLOR].Parse([COLOR="Lime"]Nano[/COLOR].Stats.ReadValue([COLOR="Red"]"Archer"[/COLOR], [COLOR="Red"]"Strength[" [/COLOR]+ CSocket.Client.Level + [COLOR="Red"]"]"[/COLOR]));
                        CSocket.Client.Dexterity = [COLOR="RoyalBlue"]int[/COLOR].Parse([COLOR="Lime"]Nano[/COLOR].Stats.ReadValue([COLOR="Red"]"Archer"[/COLOR], [COLOR="Red"]"Agility[" [/COLOR]+ CSocket.Client.Level + [COLOR="Red"]"]"[/COLOR]));
                        CSocket.Client.Vitality = [COLOR="RoyalBlue"]int[/COLOR].Parse([COLOR="Lime"]Nano[/COLOR].Stats.ReadValue([COLOR="Red"]"Archer"[/COLOR], [COLOR="Red"]"Vitality[" [/COLOR]+ CSocket.Client.Level + [COLOR="Red"]"]"[/COLOR]));
                        CSocket.Client.Spirit = [COLOR="RoyalBlue"]int[/COLOR].Parse([COLOR="Lime"]Nano[/COLOR].Stats.ReadValue([COLOR="Red"]"Archer"[/COLOR], [COLOR="Red"]"Spirit[" + CSocket.Client.Level + [COLOR="Red"]"]"));
                    }
                    [COLOR="RoyalBlue"]else if[/COLOR] ([COLOR="RoyalBlue"]([COLOR="RoyalBlue"]int[/COLOR])[/COLOR]CSocket.Client.Class > 129 && [COLOR="RoyalBlue"]([COLOR="RoyalBlue"]int[/COLOR])[/COLOR]CSocket.Client.Class < 136 || [COLOR="RoyalBlue"]([COLOR="RoyalBlue"]int[/COLOR])[/COLOR]CSocket.Client.Class > 139 && [COLOR="RoyalBlue"]([COLOR="RoyalBlue"]int[/COLOR])[/COLOR]CSocket.Client.Class < 146 || [COLOR="RoyalBlue"]([COLOR="RoyalBlue"]int[/COLOR])[/COLOR]CSocket.Client.Class == 100 || [COLOR="RoyalBlue"]([COLOR="RoyalBlue"]int[/COLOR])[/COLOR]CSocket.Client.Class == 101)
                    {
                        CSocket.Client.Strength = [COLOR="RoyalBlue"]int[/COLOR].Parse([COLOR="Lime"]Nano[/COLOR].Stats.ReadValue([COLOR="Red"]"Taoist"[/COLOR], [COLOR="Red"]"Strength[" [/COLOR]+ CSocket.Client.Level + [COLOR="Red"]"]"[/COLOR]));
                        CSocket.Client.Dexterity = [COLOR="RoyalBlue"]int[/COLOR].Parse([COLOR="Lime"]Nano[/COLOR].Stats.ReadValue([COLOR="Red"]"Taoist"[/COLOR], [COLOR="Red"]"Agility[" [/COLOR]+ CSocket.Client.Level + [COLOR="Red"]"]"[/COLOR]));
                        CSocket.Client.Vitality = [COLOR="RoyalBlue"]int[/COLOR].Parse([COLOR="Lime"]Nano[/COLOR].Stats.ReadValue([COLOR="Red"]"Taoist"[/COLOR], [COLOR="Red"]"Vitality[" [/COLOR]+ CSocket.Client.Level + [COLOR="Red"]"]"[/COLOR]));
                        CSocket.Client.Spirit = [COLOR="RoyalBlue"]int[/COLOR].Parse([COLOR="Lime"]Nano[/COLOR].Stats.ReadValue([COLOR="Red"]"Taoist"[/COLOR], [COLOR="Red"]"Spirit[" + CSocket.Client.Level + [COLOR="Red"]"]"));
                    }
                    [COLOR="RoyalBlue"]else if[/COLOR]([COLOR="RoyalBlue"]([COLOR="RoyalBlue"]int[/COLOR])[/COLOR]CSocket.Client.Class > 69 && [COLOR="RoyalBlue"]([COLOR="RoyalBlue"]int[/COLOR])[/COLOR]CSocket.Client.Class < 75)
                    {
                        CSocket.Client.StatPoints += 3;
                    }
                    [COLOR="Lime"]//CSocket.Client.StatPoints += 3;[/COLOR]
                }
            }
            [COLOR="RoyalBlue"]else[/COLOR]
            {
               CSocket.Client.StatPoints += 3;
            }
than just aboven the if(lvl < 135)
you add
Code:
CSocket.Send([COLOR="lime"]ConquerPacket[/COLOR].Status(CSocket, 2, CSocket.Client.Dexterity, [COLOR="lime"]Struct[/COLOR].[COLOR="lime"]StatusTypes[/COLOR].DexterityStatPoints));
            CSocket.Send([COLOR="lime"]ConquerPacket[/COLOR].Status(CSocket, 2, CSocket.Client.Spirit, [COLOR="lime"]Struct[/COLOR].[COLOR="lime"]StatusTypes[/COLOR].ManaStatPoints));
            CSocket.Send([COLOR="lime"]ConquerPacket[/COLOR].Status(CSocket, 2, CSocket.Client.Vitality, [COLOR="lime"]Struct[/COLOR].[COLOR="lime"]StatusTypes[/COLOR].VitalityStatPoints));
            CSocket.Send([COLOR="lime"]ConquerPacket[/COLOR].Status(CSocket, 2, CSocket.Client.Strength, [COLOR="lime"]Struct[/COLOR].[COLOR="lime"]StatusTypes[/COLOR].StrengthStatPoints));
            [COLOR="Lime"]Calculation[/COLOR].Vitals(CSocket, [COLOR="RoyalBlue"]false[/COLOR]);
the last thing is adding the ini file it belongs in debug folder (Stats.ini)
you'll just need to add ninja if you want that :p
good luck

----------------------edit------------------------------
Code:
public class Ini
        {
            public IniFile TheIni;

            public Ini(string path)
            {
                TheIni = new IniFile(path);
            }

            public string ReadValue(string Section, string Key)
            {
                string it = TheIni.IniReadValue(Section, Key);
                return it;
            }
            public void WriteString(string Section, string Key, string Value)
            {
                TheIni.IniWriteValue(Section, Key, Value);
            }
        }

        public class IniFile
        {
            public string path;

            [DllImport("kernel32")]
            private static extern long WritePrivateProfileString(string section, string key, string val, string filePath);
            [DllImport("kernel32")]
            private static extern int GetPrivateProfileString(string section,
                string key, string def, StringBuilder retVal, int size, string filePath);

            public IniFile(string INIPath)
            {
                path = INIPath;
            }
            public void IniWriteValue(string Section, string Key, string Value)
            {
                WritePrivateProfileString(Section, Key, Value, this.path);
            }

            public string IniReadValue(string Section, string Key)
            {
                StringBuilder temp = new StringBuilder(255);
                int i = GetPrivateProfileString(Section, Key, "", temp, 255, this.path);
                return temp.ToString();

            }
        }
this belonges in nano.cs
i put it at the end of
Code:
public static void Kill()
		{
			CoEmu_v2_GameServer.Packets.ConquerPacket.ToServer(CoEmu_v2_GameServer.Packets.ConquerPacket.Chat(0, "SYSTEM", "ALLUSERS", "[GameServer] Shutting down in 5 seconds.", CoEmu_v2_GameServer.Structs.Struct.ChatType.Talk), 0);
			Thread.Sleep(1000);
			CoEmu_v2_GameServer.Packets.ConquerPacket.ToServer(CoEmu_v2_GameServer.Packets.ConquerPacket.Chat(0, "SYSTEM", "ALLUSERS", "[GameServer] Shutting down in 4 seconds.", CoEmu_v2_GameServer.Structs.Struct.ChatType.Talk), 0);
			Thread.Sleep(1000);
			CoEmu_v2_GameServer.Packets.ConquerPacket.ToServer(CoEmu_v2_GameServer.Packets.ConquerPacket.Chat(0, "SYSTEM", "ALLUSERS", "[GameServer] Shutting down in 3 seconds.", CoEmu_v2_GameServer.Structs.Struct.ChatType.Talk), 0);
			Thread.Sleep(1000);
			CoEmu_v2_GameServer.Packets.ConquerPacket.ToServer(CoEmu_v2_GameServer.Packets.ConquerPacket.Chat(0, "SYSTEM", "ALLUSERS", "[GameServer] Shutting down in 2 seconds.", CoEmu_v2_GameServer.Structs.Struct.ChatType.Talk), 0);
			Thread.Sleep(1000);
			CoEmu_v2_GameServer.Packets.ConquerPacket.ToServer(CoEmu_v2_GameServer.Packets.ConquerPacket.Chat(0, "SYSTEM", "ALLUSERS", "[GameServer] Shutting down in 1 second.", CoEmu_v2_GameServer.Structs.Struct.ChatType.Talk), 0);
			Nano.AuthServer.Close();
			Nano.GameServer.Close();
			System.Environment.Exit(1);
		}
06/04/2009 23:37 coreymills#5
error: the type or namespace name Ini could not be found (are u missing a using directive or an assembly reference?)
06/04/2009 23:38 yuko#6
last edit thats whats missing