|
You last visited: Today at 05:45
Advertisement
Need help :X
Discussion on Need help :X within the CO2 Private Server forum part of the Conquer Online 2 category.
07/14/2009, 06:29
|
#1
|
elite*gold: 0
Join Date: Mar 2009
Posts: 510
Received Thanks: 104
|
Need help :X
my server is changing sources from an ini source into a mysql source and i dont want to restart all the accounts.. so i just decided to code something in that will convert the main stuff like equips, levels and cps into the new mysql source.. i have the whole code with no errors but for some reason it wont update.
here is the code
Code:
public static void Transfer(Client UClient)
{
Ini Transfer = new Ini(System.Windows.Forms.Application.StartupPath + @"\accounts\\" + UClient.Account + ".acc");
string CharName = Transfer.ReadValue("Account", "Charr");
Ini CharInfo = new Ini(System.Windows.Forms.Application.StartupPath + @"\characters\\" + CharName + ".chr");
string equip = CharInfo.ReadValue("Character", "Equipment");
Console.WriteLine("transfer in progress for account id " + UClient.Account + " and for char name " + CharName);
string level1 = CharInfo.ReadValue("Character", "Level");
string cps1 = CharInfo.ReadValue("Character", "CPs");
MySqlCommand Command = new MySqlCommand("UPDATE `Characters` SET `Level` = " + level1 +", `CPs` = " + cps1 + ",`Equipment` = '" + equip, Connection);
Command.ExecuteNonQuery();
}
also i added the actual actication code under the Creat char.. so when someone creates the char with the same username it auto gives the stuff.. this is the code i put under the creat char
Code:
if (System.IO.File.Exists(System.Windows.Forms.Application.StartupPath + @"\accounts\\" + UClient.Account + ".acc"))
{
DataBase.Transfer(UClient);
}
anyways if u see any problem or know how to fix it id appreciate it.. thank you in advance ^^
|
|
|
07/14/2009, 15:21
|
#2
|
elite*gold: 0
Join Date: Jul 2009
Posts: 548
Received Thanks: 52
|
I'm not the best with ini but it seems to me like your not reading from the ini file.
|
|
|
07/14/2009, 16:21
|
#3
|
elite*gold: 0
Join Date: Jun 2009
Posts: 787
Received Thanks: 314
|
For the MYSQL you need to `UPDATE` those fields WHERE something=something.
Example:
And if their account isn't in MySQL already you'll need to INSERT in the things instead of updating something that doesn't exist yet.
Example:
|
|
|
07/14/2009, 17:00
|
#4
|
elite*gold: 0
Join Date: Jun 2005
Posts: 692
Received Thanks: 353
|
Quote:
Originally Posted by f0am
I'm not the best with ini but it seems to me like your not reading from the ini file.
|
Maybe you're just blind, cause I can see it just fine.
Code:
public static void Transfer(Client UClient)
{
[COLOR="Red"]Ini Transfer = new Ini(System.Windows.Forms.Application.StartupPath + @"\accounts\\" + UClient.Account + ".acc");[/COLOR]
[COLOR="Red"]string CharName = Transfer.ReadValue("Account", "Charr");[/COLOR]
Ini CharInfo = new Ini(System.Windows.Forms.Application.StartupPath + @"\characters\\" + CharName + ".chr");
string equip = CharInfo.ReadValue("Character", "Equipment");
Console.WriteLine("transfer in progress for account id " + UClient.Account + " and for char name " + CharName);
string level1 = CharInfo.ReadValue("Character", "Level");
string cps1 = CharInfo.ReadValue("Character", "CPs");
MySqlCommand Command = new MySqlCommand("UPDATE `Characters` SET `Level` = " + level1 +", `CPs` = " + cps1 + ",`Equipment` = '" + equip, Connection);
Command.ExecuteNonQuery();
}
Quote:
Originally Posted by AndreaCo
my server is changing sources from an ini source into a mysql source and i dont want to restart all the accounts.. so i just decided to code something in that will convert the main stuff like equips, levels and cps into the new mysql source.. i have the whole code with no errors but for some reason it wont update.
here is the code
Code:
public static void Transfer(Client UClient)
{
Ini Transfer = new Ini(System.Windows.Forms.Application.StartupPath + @"\accounts\\" + UClient.Account + ".acc");
string CharName = Transfer.ReadValue("Account", "Charr");
Ini CharInfo = new Ini(System.Windows.Forms.Application.StartupPath + @"\characters\\" + CharName + ".chr");
string equip = CharInfo.ReadValue("Character", "Equipment");
Console.WriteLine("transfer in progress for account id " + UClient.Account + " and for char name " + CharName);
string level1 = CharInfo.ReadValue("Character", "Level");
string cps1 = CharInfo.ReadValue("Character", "CPs");
MySqlCommand Command = new MySqlCommand("UPDATE `Characters` SET `Level` = " + level1 +", `CPs` = " + cps1 + ",`Equipment` = '" + equip, Connection);
Command.ExecuteNonQuery();
}
also i added the actual actication code under the Creat char.. so when someone creates the char with the same username it auto gives the stuff.. this is the code i put under the creat char
Code:
if (System.IO.File.Exists(System.Windows.Forms.Application.StartupPath + @"\accounts\\" + UClient.Account + ".acc"))
{
DataBase.Transfer(UClient);
}
anyways if u see any problem or know how to fix it id appreciate it.. thank you in advance ^^
|
As for AndreaCo, why are you attempting to escape the backslash when the entire string is already escaped?
Code:
[COLOR="Red"]@[/COLOR]"\accounts[COLOR="Red"]\\[/COLOR]"
|
|
|
07/14/2009, 17:23
|
#5
|
elite*gold: 0
Join Date: Jul 2009
Posts: 548
Received Thanks: 52
|
Quote:
Originally Posted by nTL3fTy
Maybe you're just blind, cause I can see it just fine.
Code:
public static void Transfer(Client UClient)
{
[COLOR=Red]Ini Transfer = new Ini(System.Windows.Forms.Application.StartupPath + @"\accounts\\" + UClient.Account + ".acc");[/COLOR]
[COLOR=Red]string CharName = Transfer.ReadValue("Account", "Charr");[/COLOR]
Ini CharInfo = new Ini(System.Windows.Forms.Application.StartupPath + @"\characters\\" + CharName + ".chr");
string equip = CharInfo.ReadValue("Character", "Equipment");
Console.WriteLine("transfer in progress for account id " + UClient.Account + " and for char name " + CharName);
string level1 = CharInfo.ReadValue("Character", "Level");
string cps1 = CharInfo.ReadValue("Character", "CPs");
MySqlCommand Command = new MySqlCommand("UPDATE `Characters` SET `Level` = " + level1 +", `CPs` = " + cps1 + ",`Equipment` = '" + equip, Connection);
Command.ExecuteNonQuery();
}
As for AndreaCo, why are you attempting to escape the backslash when the entire string is already escaped?
Code:
[COLOR=Red]@[/COLOR]"\accounts[COLOR=Red]\\[/COLOR]"
|
More like there is more than just rading name level cps and equipment. Also you dont have to be such an ass.
|
|
|
07/14/2009, 20:53
|
#6
|
elite*gold: 0
Join Date: Mar 2009
Posts: 510
Received Thanks: 104
|
it reads the ini files just fine.. like i said my problem was it does not not update the mysql files.. lol
|
|
|
07/15/2009, 01:50
|
#7
|
elite*gold: 0
Join Date: Jul 2009
Posts: 548
Received Thanks: 52
|
Quote:
Originally Posted by AndreaCo
it reads the ini files just fine.. like i said my problem was it does not not update the mysql files.. lol
|
well like i think saint said before, your not updating because you dont have them there, your inserting.
or try tizag.com
or pm me and i can help u ill try my bestestttt
|
|
|
07/15/2009, 03:06
|
#8
|
elite*gold: 20
Join Date: Mar 2008
Posts: 958
Received Thanks: 494
|
|
|
|
07/15/2009, 11:31
|
#9
|
elite*gold: 20
Join Date: Aug 2005
Posts: 1,734
Received Thanks: 1,000
|
PHP Code:
public static void Transfer(Client Client) { Ini File = new Ini(Application.StartupPath + "\\accounts\\" + Client.Account + ".acc"); string Name = File.ReadValue("Account", "Charr"); File = new Ini(Application.StartupPath + "\\characters\\" + Name + ".chr"); string Equipment = File.ReadValue("Character", "Equipment"); string Level = File.ReadValue("Character", "Level"); string ConquerPoints = File.ReadValue("Character", "CPs"); string Query = "INSERT Characters(Name, Level, Equipment, CPs) VALUES (`{0}`, {1}, {2}, {3})"; string FullQuery = string.Format(Query, Name, Level, Equipment, ConquerPoints); SendQuery(FullQuery); } public static void SendQuery(string Query) { MySqlCommand SQLCommand = new MySqlCommand(Query, Connection); SQLCommand.ExecuteNonQuery(); }
Bottom line is that you need to use "INSERT" instead of "UPDATE". The syntax may be a little off, not used to MySQL
|
|
|
07/17/2009, 02:46
|
#10
|
elite*gold: 0
Join Date: Mar 2009
Posts: 510
Received Thanks: 104
|
nah i found out wat was wrong.. the code was right but when i added the catch thing to show me what the error was it said that the mysql wont support the transfer of equipment.. but the levels and cps transfered fine.. thx anyways ^^
|
|
|
All times are GMT +2. The time now is 05:45.
|
|