Register for your free account! | Forgot your password?

You last visited: Today at 05:45

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

Advertisement



Need help :X

Discussion on Need help :X within the CO2 Private Server forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
AndreaCo's Avatar
 
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 ^^
AndreaCo is offline  
Old 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.
f0am is offline  
Old 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:
_tao4229_ is offline  
Old 07/14/2009, 17:00   #4
 
nTL3fTy's Avatar
 
elite*gold: 0
Join Date: Jun 2005
Posts: 692
Received Thanks: 353
Quote:
Originally Posted by f0am View Post
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 View Post
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]"
nTL3fTy is offline  
Old 07/14/2009, 17:23   #5
 
elite*gold: 0
Join Date: Jul 2009
Posts: 548
Received Thanks: 52
Quote:
Originally Posted by nTL3fTy View Post
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.
f0am is offline  
Old 07/14/2009, 20:53   #6
 
AndreaCo's Avatar
 
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
AndreaCo is offline  
Old 07/15/2009, 01:50   #7
 
elite*gold: 0
Join Date: Jul 2009
Posts: 548
Received Thanks: 52
Quote:
Originally Posted by AndreaCo View Post
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
f0am is offline  
Old 07/15/2009, 03:06   #8
 
danielachraf's Avatar
 
elite*gold: 20
Join Date: Mar 2008
Posts: 958
Received Thanks: 494
Quote:
Originally Posted by f0am View Post
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
danielachraf is offline  
Old 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(QueryNameLevelEquipmentConquerPoints);
    
SendQuery(FullQuery);
}
public static 
void SendQuery(string Query) {
    
MySqlCommand SQLCommand = new MySqlCommand(QueryConnection);
    
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
tanelipe is offline  
Old 07/17/2009, 02:46   #10
 
AndreaCo's Avatar
 
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 ^^
AndreaCo is offline  
Reply




All times are GMT +2. The time now is 05:45.


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.