[Re-Release]Met/Db Bank

07/16/2009 03:01 JustChillin#1
Did it, this time dbs and mets store seperate.
1. You need to "Design" your Sql table, i dont know a command for this but heres the manual way.
A. Open up Navicat(what i use)
B. Go to the Character table
C. Go to File/ Design Table
D. Click on Add field
E. Name the field Name: MetPoint,Type: int,Lenght: 11,Decimals: 0, Not Null.
F. Add a second one for DbPoint

Put this in NpcTalk.cs(obviously)

Code:
#region MetBank
                case 65221://Met/DbBank
                    {
                        if (LinkBack == 0)
                        {
                            Text("Hey, Would you like to Deposit or Withdraw today?", CSocket);
                            Link("Deposit", 5, CSocket);
                            Link("Withdraw", 6, CSocket);
                            End(CSocket);
                        }
                        else if (LinkBack == 5)
                        {
                            Text("What would you like to Deposit today?", CSocket);
                            Link("Meteor", 1, CSocket);
                            Link("Meteor Scroll", 2, CSocket);
                            Link("DragonBall", 3, CSocket);
                            Link("Dragonball Scroll", 4, CSocket);
                            End(CSocket);
                        }
                        else if (LinkBack == 6)
                        {
                            Text("What would you like to Withdraw today?", CSocket);
                            Text("You currently have " + CSocket.Client.MetPoint + " Mets", CSocket);
                            Text("You currently have " + CSocket.Client.DbPoint + " Dbs", CSocket);
                            Link("Meteor", 7,CSocket);
                            Link("MeteorScroll", 8, CSocket);
                            Link("Dragonball", 9 , CSocket);
                            Link("Dragonball scroll", 10, CSocket);
                            End(CSocket);
                        }
                        else if (LinkBack == 1)
                        {
                            int GMUID = 0;
                            int GMcount = 0;

                            foreach (Struct.ItemInfo Item in CSocket.Client.Inventory.Values)
                            {
                                if (Item.ItemID == 1088001)
                                {
                                    GMUID = Item.UID;
                                    GMcount++;
                                }
                            }
                            if (GMcount >= 1)
                            {
                                MetPoint(+1, CSocket);
                                CSocket.Client.Inventory.Remove(GMUID);
                                CSocket.Send(ConquerPacket.ItemUsage(GMUID, 255, Struct.ItemUsage.RemoveItem));
                                Database.Database.DeleteItem(GMUID);
                                Database.Database.SaveMetPoint(CSocket);
                                Text("You now have " + CSocket.Client.MetPoint + " Mets", CSocket);
                                Link("Thanks", 255, CSocket);
                                Link("I have more", 5, CSocket);
                                End(CSocket);
                            }
                            else
                            {
                                Text("You Dont have any mets", CSocket);
                                Link("Ok", 255, CSocket);
                                End(CSocket);
                            }
                        }
                        else if (LinkBack == 2)
                        {
                            int GMUID = 0;
                            int GMcount = 0;

                            foreach (Struct.ItemInfo Item in CSocket.Client.Inventory.Values)
                            {
                                if (Item.ItemID == 720027)
                                {
                                    GMUID = Item.UID;
                                    GMcount++;
                                }
                            }
                            if (GMcount >= 1)
                            {
                                MetPoint(+10, CSocket);
                                CSocket.Client.Inventory.Remove(GMUID);
                                CSocket.Send(ConquerPacket.ItemUsage(GMUID, 255, Struct.ItemUsage.RemoveItem));
                                Database.Database.DeleteItem(GMUID);
                                Database.Database.SaveMetPoint(CSocket);
                                Text("You now have " + CSocket.Client.MetPoint + " Mets", CSocket);
                                Link("Thanks", 255, CSocket);
                                Link("I have more", 5, CSocket);
                                End(CSocket);
                            }
                            else
                            {
                                Text("You Dont have any metscrolls", CSocket);
                                Link("Ok", 255, CSocket);
                                End(CSocket);
                            }
                        }
                        else if (LinkBack == 3)
                        {
                            int GMUID = 0;
                            int GMcount = 0;

                            foreach (Struct.ItemInfo Item in CSocket.Client.Inventory.Values)
                            {
                                if (Item.ItemID == 1088000)
                                {
                                    GMUID = Item.UID;
                                    GMcount++;
                                }
                            }
                            if (GMcount >= 1)
                            {
                                DbPoint(+1, CSocket);
                                CSocket.Client.Inventory.Remove(GMUID);
                                CSocket.Send(ConquerPacket.ItemUsage(GMUID, 255, Struct.ItemUsage.RemoveItem));
                                Database.Database.DeleteItem(GMUID);
                                Database.Database.SaveDbPoint(CSocket);
                                Text("You now have " + CSocket.Client.DbPoint + " Dbs", CSocket);
                                Link("Thanks", 255, CSocket);
                                Link("I have more", 5, CSocket);
                                End(CSocket);
                            }
                            else
                            {
                                Text("You Dont have any dragonballs", CSocket);
                                Link("Ok", 255, CSocket);
                                End(CSocket);
                            }
                        }
                        else if (LinkBack == 4)
                        {
                            int GMUID = 0;
                            int GMcount = 0;

                            foreach (Struct.ItemInfo Item in CSocket.Client.Inventory.Values)
                            {
                                if (Item.ItemID == 720028)
                                {
                                    GMUID = Item.UID;
                                    GMcount++;
                                }
                            }
                            if (GMcount >= 1)
                            {
                                DbPoint(+10, CSocket);
                                CSocket.Client.Inventory.Remove(GMUID);
                                CSocket.Send(ConquerPacket.ItemUsage(GMUID, 255, Struct.ItemUsage.RemoveItem));
                                Database.Database.DeleteItem(GMUID);
                                Database.Database.SaveDbPoint(CSocket);
                                Text("You know have " + CSocket.Client.DbPoint + " Dbs", CSocket);
                                Link("Thanks", 255, CSocket);
                                Link("I have more", 5, CSocket);
                                End(CSocket);
                            }
                            else
                            {
                                Text("You Dont have any dragonball scrolls", CSocket);
                                Link("Ok", 255, CSocket);
                                End(CSocket);
                            }
                        }
                        else if (LinkBack == 7)
                            {
                                if (CSocket.Client.MetPoint >= 1)
                                {
                                    MetPoint(-1, CSocket);
                                    AddItem(1088001, 0, 0, 0, 0, 0, 0, 0, 0, 0, CSocket);
                                    Database.Database.SaveMetPoint(CSocket);
                                    Text("Here you go!", CSocket);
                                    Link("Thanks!", 255, CSocket);
                                    Link("I want more!", 6, CSocket);
                                    End(CSocket);
                                }
                                else
                                {
                                    Text("You dont have enough points", CSocket);
                                    Link("O well", 255, CSocket);
                                    End(CSocket);
                                }
                            }
                        else if (LinkBack == 8)
                        {
                            if (CSocket.Client.MetPoint >= 10)
                            {
                                MetPoint(-10, CSocket);
                                AddItem(720027, 0, 0, 0, 0, 0, 0, 0, 0, 0, CSocket);
                                Database.Database.SaveMetPoint(CSocket);
                                Text("Here you go!", CSocket);
                                Link("Thanks!", 255, CSocket);
                                Link("I want more!", 6, CSocket);
                                End(CSocket);
                            }
                            else
                            {
                                Text("You dont have enough points", CSocket);
                                Link("O well", 255, CSocket);
                                End(CSocket);
                            }
                        }
                        else if (LinkBack == 9)
                        {
                            if (CSocket.Client.DbPoint >= 1)
                            {
                                DbPoint(-1, CSocket);
                                AddItem(1088000, 0, 0, 0, 0, 0, 0, 0, 0, 0, CSocket);
                                Database.Database.SaveDbPoint(CSocket);
                                Text("Here you go!", CSocket);
                                Link("Thanks!", 255, CSocket);
                                Link("I want more!", 6, CSocket);
                                End(CSocket);
                            }
                            else
                            {
                                Text("You dont have enough points", CSocket);
                                Link("O well", 255, CSocket);
                                End(CSocket);
                            }
                        }
                        else if (LinkBack == 10)
                        {
                            if (CSocket.Client.DbPoint >= 10)
                            {
                                DbPoint(-10, CSocket);
                                AddItem(720028, 0, 0, 0, 0, 0, 0, 0, 0, 0, CSocket);
                                Database.Database.SaveDbPoint(CSocket);
                                Text("Here you go!", CSocket);
                                Link("Thanks!", 255, CSocket);
                                Link("I want more!", 6, CSocket);
                                End(CSocket);
                            }
                            else
                            {
                                Text("You dont have enough points", CSocket);
                                Link("O well", 255, CSocket);
                                End(CSocket);
                            }
                        }
                        break;
                    }
#endregion MetBank
Put this at the bottom of NpcTalk.cs

Code:
        public static void MetPoint(int value, ClientSocket CSocket)
        {
            CSocket.Client.MetPoint += value;
            CSocket.Send(ConquerPacket.Status(CSocket, 2, CSocket.Client.MetPoint, Struct.StatusTypes.MetPoint));
        }
Along with this
Code:
public static void DbPoint(int value, ClientSocket CSocket)
        {
            CSocket.Client.DbPoint += value;
            CSocket.Send(ConquerPacket.Status(CSocket, 2, CSocket.Client.DbPoint, Struct.StatusTypes.DbPoint));
        }
Find this code in Database.cs.

Code:
Client.WHMoney = Convert.ToInt32(DR["WHMoney"]);
And insert this right below it.

Code:
Client.MetPoint = Convert.ToInt32(DR["MetPoint"]);
Client.DbPoint = Convert.ToInt32(DR["DbPoint"]);
Insert in to Database.cs. Thanks to Kinishi88 for this code.
Code:
        public static void SaveMetPoint(ClientSocket CSocket)
        {
            MySqlCommand Cmd = new MySqlCommand("UPDATE `characters` SET `MetPoint` = " + CSocket.Client.MetPoint + " WHERE `CharID` = " + CSocket.Client.ID + "", DatabaseConnection.NewConnection());
            Cmd.ExecuteNonQuery();
            Cmd.Connection.Close();
            Cmd.Connection.Dispose();
            Cmd.Dispose();
        }
And this
Code:
public static void SaveDbPoint(ClientSocket CSocket)
        {
            MySqlCommand Cmd = new MySqlCommand("UPDATE `characters` SET `DbPoint` = " + CSocket.Client.DbPoint + " WHERE `CharID` = " + CSocket.Client.ID + "", DatabaseConnection.NewConnection());
            Cmd.ExecuteNonQuery();
            Cmd.Connection.Close();
            Cmd.Connection.Dispose();
            Cmd.Dispose();
        }
There you go. Dont flame me, just simply doing what noone else would do.
Dont tell me i copyed and pasted from the original poster because that is me.
07/16/2009 03:07 n0mansland#2
=O You're duddz? Cool good to see it's back up.. Should help people starting out figure out how to do definitions for like HousePoints, PrizePoints and anything custom they want to do.
07/16/2009 05:45 pro4never#3
Great job: I fixed it myself ages ago but this will help nubs out ^^ It's such a great example to learn from cause it contains so many useful npc functions.
07/17/2009 04:51 JustChillin#4
Quote:
Originally Posted by pro4never View Post
Great job: I fixed it myself ages ago but this will help nubs out ^^ It's such a great example to learn from cause it contains so many useful npc functions.
Quote:
Originally Posted by n0mansland View Post
=O You're duddz? Cool good to see it's back up.. Should help people starting out figure out how to do definitions for like HousePoints, PrizePoints and anything custom they want to do.
Yeah i dont think people relize how much this code can teach them, no one must really wanna learn like it do :S