[REL] ItemLock Saving/Loading

03/27/2010 14:27 ImmuneOne#1
Since all those people think a code is not complete because I didn't post a save/load method, here it is.

Search for
Code:
                foreach (Game.Item I in C.Inventory)
                    I.WriteThis(BW);
Right click it and click on go to definition.
Then search for
Code:
            I.Write((byte)Color);
Then add underneath it;
Code:
            I.Write(Locked);
Search for;
Code:
                    Color = (ArmorColor)I.ReadByte();
Add underneath it;
Code:
                    Locked = I.ReadInt32();
NOTE: This will only work when you followed my tutorial about implementing.
03/27/2010 14:32 xScott#2
goodjob, stops everyone crying about your other release not saving/loading ;o
03/27/2010 15:00 Paralyzer[GM]#3
As far as I know this bugs ur character up

EDIT: I wonder what ur gonna release next here's a few ideas were I know url sure get my +Thanks
1. Load/Save accounts + character from MySql
2. The 5200+ Arena button code. xP
03/27/2010 15:06 -Shunsui-#4
Quote:
Originally Posted by Paralyzer[GM] View Post
As far as I know this bugs ur character up

EDIT: I wonder what ur gonna release next here's a few ideas were I know url sure get my +Thanks
1. Load/Save accounts + character from MySql
2. The 5200+ Arena button code. xP
>.< Doubt any 1 will release Load/Save Char from MySql, I Can start u off but wount give u the entire code
03/27/2010 15:13 Paralyzer[GM]#5
I think I could do it provided I knew how to make the mysql use the host/user/pass from like MySqlConnection.css so like say I did a command to make it so that it does Reg into mysql and loads the accounts from MySql it will know the user/pass using the MySqlConnection.cs

Don't worrey I just confused myself

Basicly I want the MySql to use the user/pass in the MySqlConnection.cs
03/27/2010 15:34 -Shunsui-#6
Quote:
Originally Posted by Paralyzer[GM] View Post
I think I could do it provided I knew how to make the mysql use the host/user/pass from like MySqlConnection.css so like say I did a command to make it so that it does Reg into mysql and loads the accounts from MySql it will know the user/pass using the MySqlConnection.cs

Don't worrey I just confused myself

Basicly I want the MySql to use the user/pass in the MySqlConnection.cs
why make a new file?

ex this is what i did in database.cs
Code:
 public class Database
    {
        public const string USER_NAME = "root";
        public static string PASSWORD = "";
        public const string SERVER = "";
        public const string DATA_BASE = "";
        static MySqlConnection conn = new MySqlConnection("Server=" + SERVER + ";Database='" + DATA_BASE + "';Username='" + USER_NAME + "';Password='" + PASSWORD + "'");
        static bool did = false;
        public static MySqlConnection Connection
        {
            get
            {
                if (!did)
                { conn.Open(); did = true; conn.StateChange += new System.Data.StateChangeEventHandler(conn_StateChange); }
                return conn;
            }
        }
        static void conn_StateChange(object sender, System.Data.StateChangeEventArgs e)
        {
            if (e.CurrentState == System.Data.ConnectionState.Closed || e.CurrentState == System.Data.ConnectionState.Broken)
            {
                conn.Dispose();
                conn = new MySqlConnection("Server=" + SERVER + ";Database='" + DATA_BASE + "';Username='" + USER_NAME + "';Password='" + PASSWORD + "'");
                conn.Open();
                conn.StateChange += new System.Data.StateChangeEventHandler(conn_StateChange);
            }
        }
03/27/2010 16:55 Luiz01#7
Nice.
03/27/2010 18:15 hunterman01#8
Quote:
Originally Posted by -Shunsui- View Post
why make a new file?

ex this is what i did in database.cs
Code:
 public class Database
    {
        public const string USER_NAME = "root";
        public static string PASSWORD = "";
        public const string SERVER = "";
        public const string DATA_BASE = "";
        static MySqlConnection conn = new MySqlConnection("Server=" + SERVER + ";Database='" + DATA_BASE + "';Username='" + USER_NAME + "';Password='" + PASSWORD + "'");
        static bool did = false;
        public static MySqlConnection Connection
        {
            get
            {
                if (!did)
                { conn.Open(); did = true; conn.StateChange += new System.Data.StateChangeEventHandler(conn_StateChange); }
                return conn;
            }
        }
        static void conn_StateChange(object sender, System.Data.StateChangeEventArgs e)
        {
            if (e.CurrentState == System.Data.ConnectionState.Closed || e.CurrentState == System.Data.ConnectionState.Broken)
            {
                conn.Dispose();
                conn = new MySqlConnection("Server=" + SERVER + ";Database='" + DATA_BASE + "';Username='" + USER_NAME + "';Password='" + PASSWORD + "'");
                conn.Open();
                conn.StateChange += new System.Data.StateChangeEventHandler(conn_StateChange);
            }
        }
Similar to something i did.
03/27/2010 18:16 Korvacs#9
If you guys want to discuss SQL please make a new thread in general.
03/27/2010 19:37 dextercsar#10
I add this but now my console dont save items xDD
03/28/2010 00:57 yes5090#11
1st thanks for ur job
2nd i did this and i have erorr in this part

Quote:
Locked = I.ReadInt32();
03/28/2010 11:19 ImmuneOne#12
Quote:
Originally Posted by yes5090 View Post
1st thanks for ur job
2nd i did this and i have erorr in this part
That's because you didn't change the definition from bool to int yet, which also means you didn't follow my tutorial.

[Only registered and activated users can see links. Click Here To Register...]
03/28/2010 14:48 -impulse-#13
Create a new character and it won't error...
That's because the binary reader will read beyond the item when trying to get the lock value as it didn't save with the lock...so it will cut 4 bytes which probably belong to the next item...and the next item's id won't be even found in database ... anyway because every item read with 4 bytes more than it should it will give error: Unable to read beyond the stream , or something...and as I said, just create a new character and it will work...Remove other characters ...
03/28/2010 19:09 yes5090#14
Quote:
Originally Posted by ImmuneOne View Post
That's because you didn't change the definition from bool to int yet, which also means you didn't follow my tutorial.

[Only registered and activated users can see links. Click Here To Register...]
No iam Already followed ur tutorial and i changed the changed the definition from bool to int :(
03/28/2010 21:25 Paralyzer[GM]#15
Seeing as I HATE no I mean it I HATE to say this but....

This save is not his work....
He copied it from his old post that some douchbag made that suxed balls.....
He hasnt tested either


ImmuneOne sorry bro had to say