Register for your free account! | Forgot your password?

You last visited: Today at 01:29

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

Advertisement



[Re-Release]Met/Db Bank

Discussion on [Re-Release]Met/Db Bank within the CO2 PServer Guides & Releases forum part of the CO2 Private Server category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Jun 2009
Posts: 140
Received Thanks: 12
[Re-Release]Met/Db Bank

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.
JustChillin is offline  
Thanks
3 Users
Old 07/16/2009, 03:07   #2
 
n0mansland's Avatar
 
elite*gold: 0
Join Date: Aug 2008
Posts: 780
Received Thanks: 255
=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.
n0mansland is offline  
Old 07/16/2009, 05:45   #3
 
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,376
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.
pro4never is offline  
Old 07/17/2009, 04:51   #4
 
elite*gold: 0
Join Date: Jun 2009
Posts: 140
Received Thanks: 12
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
JustChillin is offline  
Reply


Similar Threads Similar Threads
[Release] Met/db bank using input fields
02/12/2010 - CO2 PServer Guides & Releases - 14 Replies
So I was bored and re-wrote my met/db bank that I made for my 1.0 server and converted it for use with CoEmu. I ended up changing some stuff around so that it works with met/db scrolls also. As far as I know there is no better, more complete system released publicly. It may not be perfect but it's close. I don't actually run a server so there could be some bugs that I didn't run into while testing it for a few minutes so keep your eyes open. Main Npc text (using lady luck simply because...



All times are GMT +2. The time now is 01:29.


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.