Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Conquer Online 2 > CO2 Private Server
You last visited: Today at 03:56

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

Advertisement



[Help] 5095 MySql Error

Discussion on [Help] 5095 MySql Error within the CO2 Private Server forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
killersub's Avatar
 
elite*gold: 0
Join Date: May 2009
Posts: 884
Received Thanks: 211
[Help] 5095 MySql Error

okay so I've been getting this error most usual lately. it's a MySql error ofc but can't seem to find the mistake at.

the error is:

Code:
Input string was not in a correct format.
and I checked all my inputted strings and I think they're all in the correct format.

the last edits I made were in Database.cs where I changed and added some things such as Mobs and MobSpawns aswell as NPCs and NPC actions.

here are some of the things I added feel free to check for the correct/incorrect formats:

Code:
public static void LoadActions()
        {
            MySqlCommand cmd = new MySqlCommand("SELECT * FROM `actions`", DatabaseConnection.NewConnection());
            MySqlDataReader DR = cmd.ExecuteReader(CommandBehavior.CloseConnection);
            while (DR.Read())
            {
                Struct.Actions A = new Struct.Actions();
                A.ID = Convert.ToInt32("id");
                A.IDNext = Convert.ToInt32("id_next");
                A.IDNextFail = Convert.ToInt32("id_nextfail");
                A.Type = Convert.ToInt32("type");
                A.Data = Convert.ToInt32("data");
                A.Param = Convert.ToString("param");
                if (!Nano.NpcActions.ContainsKey(A.ID))
                    Nano.NpcActions.Add(A.ID, A);
            }
            Console.WriteLine("[WorldServer] Loaded " + Nano.NpcActions.Count + " Npc Actions into the World.");
        }
        public static void LoadMonsters()
        {
            MySqlCommand cmd = new MySqlCommand("SELECT * FROM `monsters` ", DatabaseConnection.NewConnection());
            MySqlDataReader DR = cmd.ExecuteReader(CommandBehavior.CloseConnection);
            while (DR.Read())
            {
                Struct.MonsterInfo MI = new Struct.MonsterInfo();
                MI.ViewDistance = Convert.ToInt32("jrange");
                MI.AttackRange = Convert.ToInt32("arange");
                MI.AttackSpeed = Convert.ToInt32("attack_speed");
                MI.Defense = Convert.ToInt32("pdef");
                MI.Dodge = Convert.ToInt32("dodge");
                MI.ID = Convert.ToInt32("id");
                MI.Level = Convert.ToInt32("level");
                MI.MagicID = Convert.ToInt32("atype");
                MI.MaxAttack = Convert.ToInt32("atkmax");
                MI.MaxHP = Convert.ToInt32("hp");
                MI.MDefense = Convert.ToInt32("mdef");
                MI.Mesh = Convert.ToInt32("mech");
                MI.MinAttack = Convert.ToInt32("atkmin");
                MI.Name = Convert.ToString("name");
                MI.Speed = Convert.ToInt32("speed");
                MI.MinSilvers = Convert.ToInt32("avgmoney");
                MI.MaxSilvers = Convert.ToInt32("drop_money");
                MI.DropItemType = Convert.ToInt32("drop_itemtype");
                MI.DropChance = Convert.ToDouble("drop_chance");
                if (!Nano.MonsterTypes.ContainsKey(MI.ID))
                {
                    Nano.MonsterTypes.Add(MI.ID, MI);
                }
            }
            Console.WriteLine("[WorldServer] Loaded " + Nano.MonsterTypes.Count + " Monster Types into the World.");
        }
        public static void LoadMonsterSpawns()
        {
            MySqlCommand cmd = new MySqlCommand("SELECT * FROM `mobspawns` ", DatabaseConnection.NewConnection());
            MySqlDataReader DR = cmd.ExecuteReader(CommandBehavior.CloseConnection);
            int TotalSpawns = 0;
            while (DR.Read())
            {
                MonsterSpawn MS = new MonsterSpawn();
                MS.Map = Convert.ToInt32("Map");
                MS.MobID = Convert.ToInt32("ID");
                MS.SpawnID = Convert.ToInt32("UniSpawnID");
                MS.SpawnNumber = Convert.ToInt32("NumberToSpawnf");
                if (MS.Map == 1015)
                    MS.SpawnNumber = Convert.ToInt32("NumberToSpawnf");
                MS.MaxSpawnNumber = MS.SpawnNumber * 2;
                if (MS.Map == 1015)
                    MS.MaxSpawnNumber = MS.SpawnNumber;
                if (MS.MobID >= 900 && MS.MobID <= 912)
                {
                    MS.SpawnNumber = 1;
                    MS.MaxSpawnNumber = 1;
                }
                TotalSpawns += MS.SpawnNumber;
                MS.X = Convert.ToInt32("x-start");
                MS.XStop = Convert.ToInt32("x-stop");
                MS.Y = Convert.ToInt32("y-start");
                MS.YStop = Convert.ToInt32("y-stop");
                MS.RespawnInterval = Convert.ToInt32("rest_secs");
                if (!Nano.MonsterSpawns.ContainsKey(MS.SpawnID))
                {
                    Nano.MonsterSpawns.Add(MS.SpawnID, MS);
                }
            }
            Console.WriteLine("[WorldServer] Loaded " + Nano.MonsterSpawns.Count + " unique monster spawns.");
            Console.WriteLine("[WorldServer] Will theoretically spawn " + TotalSpawns + " monsters into the world.");
        }
        public static void LoadNpcs()
        {
            MySqlCommand cmd = new MySqlCommand("SELECT * FROM `npcs` ", DatabaseConnection.NewConnection());
            MySqlDataReader DR = cmd.ExecuteReader(CommandBehavior.CloseConnection);
            while (DR.Read())
            {
                Struct.NPC NPC = new Struct.NPC();
                NPC.ID = Convert.ToInt32("id");
                NPC.OwnerID = Convert.ToInt32("ownerid");
                NPC.PlayerID = Convert.ToInt32("playerid");
                NPC.Name = Convert.ToString("name");
                NPC.Type = Convert.ToInt32("type");
                NPC.LookFace = Convert.ToInt32("lookface");
                NPC.Map = Convert.ToInt32("mapid");
                NPC.X = Convert.ToInt32("cellx");
                NPC.Y = Convert.ToInt32("celly");
                NPC.Task0 = Convert.ToInt32("task0");
                NPC.Task1 = Convert.ToInt32("task1");
                NPC.Task2 = Convert.ToInt32("task2");
                NPC.Task3 = Convert.ToInt32("task3");
                NPC.Task4 = Convert.ToInt32("task4");
                NPC.Task5 = Convert.ToInt32("task5");
                NPC.Task6 = Convert.ToInt32("task6");
                NPC.Task7 = Convert.ToInt32("task7");
                NPC.Data0 = Convert.ToInt32("data0");
                NPC.Data1 = Convert.ToInt32("data1");
                NPC.Data2 = Convert.ToInt32("data2");
                NPC.Data3 = Convert.ToInt32("data3");
                NPC.DataString = Convert.ToString("datastr");
                NPC.LinkID = Convert.ToInt32("linkid");
                NPC.Life = Convert.ToInt32("life");
                NPC.MaxLife = Convert.ToInt32("maxlife");
                NPC.Base = Convert.ToInt32("base");
                NPC.Sort = Convert.ToInt32("sort");
                NPC.ItemID = Convert.ToInt32("itemid");
                if (!Nano.Npcs.ContainsKey(NPC.ID))
                    Nano.Npcs.Add(NPC.ID, NPC);
            }
            Console.WriteLine("[WorldServer] Loaded " + Nano.Npcs.Count + " Npcs into the World.");
        }
Any help would be appreciated
killersub is offline  
Old 06/26/2011, 10:01   #2
 
{ Angelius }'s Avatar
 
elite*gold: 0
Join Date: Aug 2010
Posts: 992
Received Thanks: 1,110
there are 2 things to rethink about.

converting a char string to a uint/int/etc value gives you the same error .
A.IDNext = Convert.ToInt32("id_next");

"id_next" is a string value that that should contain numbers not letters so once you use the "" you turned it to a letters which means the convert sees it as letters (i d _ n e x t) lets say that the (id_next) is a int and the A.IDNext is a uint you can just do something like A.IDNext = (uint)(id_next)

and the other thing is in that load void you are using a sql reader which reads directly from the database so the convert.towhatever is useless

MySqlDataReader DR = cmd.ExecuteReader(CommandBehavior.CloseConnection) ;

that means that your sql reader = DR

so you go

A.IDNext = DR.ReadUInt32("id_next");
or
A.IDNext = DR.ReadUInt16("id_next");
depending on what is the value that you are reading int/uint/ushort/etc.


good luck .
{ Angelius } is offline  
Old 06/26/2011, 19:21   #3
 
killersub's Avatar
 
elite*gold: 0
Join Date: May 2009
Posts: 884
Received Thanks: 211
Quote:
Originally Posted by { Angelius } View Post
there are 2 things to rethink about.

converting a char string to a uint/int/etc value gives you the same error .
A.IDNext = Convert.ToInt32("id_next");

"id_next" is a string value that that should contain numbers not letters so once you use the "" you turned it to a letters which means the convert sees it as letters (i d _ n e x t) lets say that the (id_next) is a int and the A.IDNext is a uint you can just do something like A.IDNext = (uint)(id_next)

and the other thing is in that load void you are using a sql reader which reads directly from the database so the convert.towhatever is useless

MySqlDataReader DR = cmd.ExecuteReader(CommandBehavior.CloseConnection) ;

that means that your sql reader = DR

so you go

A.IDNext = DR.ReadUInt32("id_next");
or
A.IDNext = DR.ReadUInt16("id_next");
depending on what is the value that you are reading int/uint/ushort/etc.


good luck .
In other words just change all the Converts to Read from the MySqlDataReader?
killersub is offline  
Old 06/27/2011, 06:33   #4
 
{ Angelius }'s Avatar
 
elite*gold: 0
Join Date: Aug 2010
Posts: 992
Received Thanks: 1,110
Quote:
Originally Posted by killersub View Post
In other words just change all the Converts to Read from the MySqlDataReader?
Exactly . cus the way you did it earlier it not reading anything at all as no values provided .
{ Angelius } is offline  
Old 06/27/2011, 10:11   #5


 
Korvacs's Avatar
 
elite*gold: 20
Join Date: Mar 2006
Posts: 6,126
Received Thanks: 2,518
Quote:
Originally Posted by killersub View Post
In other words just change all the Converts to Read from the MySqlDataReader?
Currently your not reading data from the DataReader your just trying to convert text into numbers...

You need to learn some fundamentals for C#..
Korvacs is offline  
Reply


Similar Threads Similar Threads
[ERROR] Mysql can't connect to local Mysql server through socket
11/06/2010 - Metin2 Private Server - 5 Replies
I just recently tried to configure a DNS server for MT2.. It came up with this error ERROR: 2002 (HY000): Can't connect to local Mysql server through socket '/tmp/mysql.sock' (2) Do I need to do a fresh installation of FBSD? :S Thanks.
[Help]5095 error
03/03/2010 - CO2 Private Server - 3 Replies
is there anyway to host a server without a static ip or using hamachi
[help]5095 error
02/05/2010 - CO2 Private Server - 1 Replies
every time i login it just says: after a few minutes it disconnects me can anyone help please
[Help] Wamp error or mysql error
09/27/2009 - EO PServer Hosting - 1 Replies
Notice: Undefined variable: myaccount in C:\wamp\www\pages\register.php on line 17 Warning: mysql_select_db() : Connecting to 3.22, 3.23 & 4.0 is not supported. Server is 4.0.18-nt in C:\wamp\www\pages\register.php on line 17 Warning: mysql_select_db() : Connecting to 3.22, 3.23 & 4.0 servers is not supported in C:\wamp\www\pages\register.php on line 17 Warning: mysql_select_db() : A link to the server could not be established in C:\wamp\www\pages\register.php on line 17 Warning:...
[HELP] Error on 5095
05/28/2009 - CO2 Private Server - 4 Replies
Ok our login server starts fine and then when we start the game server it loads ok to the lastpart then it messes up here is the error http://img12.imageshack.us/img12/8310/errorcms.pn g



All times are GMT +1. The time now is 03:56.


Powered by vBulletin®
Copyright ©2000 - 2025, 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 ©2025 elitepvpers All Rights Reserved.