[Release]Another lotto script

06/12/2009 03:10 mejo33#16
i have problem witch if i added in nano.cs
Quote:
public static List<Struct.PrizeInfo> Lottery = new List<Struct.PrizeInfo>();
Quote:
Error 1 The type name 'PrizeInfo' does not exist in the type 'CoEmu_v2_GameServer.Structs.Struct' D:\Documents and Settings\Mejo\Pulpit\CoEmu v2\CoEmu v2\CoEmu v2 GameServer\Nano.cs 44 35 CoEmu v2 GameServer
06/12/2009 15:22 Kiyono#17
Well I just put PrizeInfo beneath ItemInfo and it worked.

Code:
public class ItemInfo
		{
			public int UID;
			public int ItemID;
			public int Plus;
            public int Progress;
			public int Bless;
			public int Enchant;
			public int Soc1;
			public int Soc2;
			public int Dura;
			public int MaxDura;
			public int Position;
			public int Color = 4;
		}
        public class PrizeInfo
        {
            public int ItemID;
            public int Plus;
            public int Soc1;
            public int Soc2;
            public int Chance;
            public string Description;
            public int Message;    
        }
06/12/2009 22:08 mejo33#18
thanks
06/29/2009 14:29 m7med#19
I HAVE 2 ERRORS
1-
Error 1 The name 'InventoryContains' does not exist in the current context \Handlers\NpcTalk.cs 3185 33 CoEmu v2 GameServer
2-
Error 2 The name 'ReturnUID' does not exist in the current context Handlers\NpcTalk.cs 3232 43 CoEmu v2 GameServer
07/01/2009 12:13 pro4never#20
Quote:
Originally Posted by m7med View Post
I HAVE 2 ERRORS
1-
Error 1 The name 'InventoryContains' does not exist in the current context \Handlers\NpcTalk.cs 3185 33 CoEmu v2 GameServer
2-
Error 2 The name 'ReturnUID' does not exist in the current context Handlers\NpcTalk.cs 3232 43 CoEmu v2 GameServer
Srry to bump a semi old thread but your problem is the lotto ticket. Most servers don't have lotto tickets anyways so the simple fix for that is to just remove those sections of code.


Thus making the npctalk section...


Code:
case 923:// Lady Luck enter
                    {
                        if (LinkBack == 0)
                        {
                          
                                Text("And I charge you only 27 CPs for each admission. Come on, Try your luck right now!", CSocket);
                                Link("Wow, good deal!", 1, CSocket);
                                Link("No Thanks!", 255, CSocket);
                                Face(30, CSocket);
                                End(CSocket);
                            
                        }
                        else if (LinkBack == 1)
                        {
                            if (CSocket.Client.Level >= 70)
                            {
                                if (CSocket.Client.CPs >= 27)
                                {
                                    CSocket.Client.LotteryBox = true;
                                    Teleport(700, 50, 50, 0, CSocket);
                                    CPs(-27, CSocket);
                                }
                                else
                                {
                                    Text("I'm sorry you do not have the required CPs.", CSocket);
                                    Link("Okay, I will be back when I have 27 CPs.", 255, CSocket);
                                    Face(30, CSocket);
                                    End(CSocket);
                                }
                            }
                            else
                            {
                                Text("I'm sorry you do not have the required Level 70.", CSocket);
                                Link("Okay, I will be back when I have level 70.", 255, CSocket);
                                Face(30, CSocket);
                                End(CSocket);
                            }
                        }

                        else
                        {
                            Text("I'm sorry you do not have the required Level 70.", CSocket);
                            Link("Okay, I will be back when I have level 70.", 255, CSocket);
                            Face(30, CSocket);
                            End(CSocket);
                        }
                        break;
                    }
                    case 924:
                    {
                        if (LinkBack == 0)
                        {
                            if (CSocket.Client.LotteryBox == true)
                            {
                                Text("Don't you want to pick a box?", CSocket);
                                Link("Well duh ofcourse I want.", 255, CSocket);
                                Face(20, CSocket);
                                End(CSocket);
                            }
                            else
                            {
                                Text("Want to leave?", CSocket);
                                Link("Yes", 1, CSocket);
                                Link("No", 255, CSocket);
                                Face(20, CSocket);
                                End(CSocket);
                            }
                        }
                        else if (LinkBack == 1)
                        {
                            Teleport(1036, 211, 196, 0, CSocket);
                        }
                        break;
                    }
                    case 925:
                    case 926:
                    case 927:
                    case 928:
                    case 929:
                    case 930:
                    case 931:
                    case 932:
                    case 933:
                    case 934:
                    case 935:
                    case 936:
                    case 937:
                    case 938:
                    case 939:
                    case 940:
                    case 942:
                    case 943:
                    case 944:
                    case 945:
                    {
                        int PriceIndex = Nano.Rand.Next(0, Nano.Lottery.Count - 1);

                        Structs.Struct.PrizeInfo Price = Nano.Lottery[PriceIndex];
                        if (CSocket.Client.LotteryBox == true)
                        {
                            CSocket.Client.LotteryBox = false;
                            if (Price.ItemID == 1)
                            {
                                CSocket.Send(ConquerPacket.Chat(0, "SYSTEM", CSocket.Client.Name, "Too bad, you haven't won anything.", Struct.ChatType.Top));
                            }
                            else
                            {
                                List<Struct.ItemData> ItemData = new List<Struct.ItemData>();
                                foreach (KeyValuePair<int, Struct.ItemData> Items in Nano.Items)
                                    ItemData.Add(Items.Value);
                                string ItemName = Nano.Items[Price.ItemID].Name;
                                Struct.ItemInfo Item = new Struct.ItemInfo();
                                Item.Progress = Item.Bless = Item.Enchant = Item.Position = Item.Color = 0;
                                Item.Dura = 1;
                                Item.UID = Nano.Rand.Next(1, 9999999);
                                Item.ItemID = Price.ItemID;
                                Item.Plus = Price.Plus;
                                Item.Soc1 = Price.Soc1;
                                Item.Soc2 = Price.Soc2;
                                CSocket.Client.Inventory.Add(Item.UID, Item);
                                CSocket.Send(ConquerPacket.ItemInfo(Item.UID, Item.ItemID, Item.Plus, Item.Bless, Item.Enchant, Item.Soc1, Item.Soc2, Item.Dura, Item.MaxDura, Item.Position, Item.Color));
                                Database.Database.NewItem(Item, CSocket);

                                CSocket.Send(ConquerPacket.Chat(0, "SYSTEM", CSocket.Client.Name, "You have won a " + ItemName + ".", Struct.ChatType.Top));

                                if (Price.Message == 1)
                                {
                                    CSocket.Send(ConquerPacket.Chat(0, "SYSTEM", "ALLUSERS", CSocket.Client.Name + " is so lucky to win a(n) " + Price.Description + ItemName + ".", Struct.ChatType.Talk));
                                }
                            }
                        }
                        break;
                    }
Script is working for me now. Rates are REALLY high but I assume I can change that by adding stuff into database. I'll work on that latter.
07/13/2009 20:51 Osiris123#21
I can't find the NpcTalk.cs file =.=
07/14/2009 06:36 Jay1029#22
I got 4 errors at the end lol
07/27/2009 01:27 gawdin#23
This is causing my server to close on me, how would i go about fixing it?
Code:
public static void GetPrizes()
        {
            MySqlCommand Cmd = new MySqlCommand("SELECT * FROM `lotteryitems`", DatabaseConnection.NewConnection());
            MySqlDataReader DR = Cmd.ExecuteReader(CommandBehavior.CloseConnection);
            while (DR.Read())
            {
                Struct.PrizeInfo Item = new Struct.PrizeInfo();
                Item.ItemID = Convert.ToInt32(DR["ItemID"]);
                Item.Plus = Convert.ToInt32(DR["Plus"]);
                Item.Chance = Convert.ToInt32(DR["Chance"]);
                Item.Soc1 = Convert.ToInt32(DR["Soc1"]);
                Item.Soc2 = Convert.ToInt32(DR["Soc2"]);
                Item.Description = Convert.ToString(DR["Description"]);
                Item.Message = Convert.ToInt32(DR["Message"]);

                for (int i = 0; i < Item.Chance; i++)
                {
                    Nano.Lottery.Add(Item);
                }
            }
            Console.WriteLine("[GameServer] Loaded " + Nano.Lottery.Count + " lottery prizes from the DB.");
            DR.Close();
            Cmd.Dispose();
        }
Actually this is placed this in the wrong area, I currently had it under the [(public static void StartServer()] directly under [Struct.LoadTNpcs();] where should this be placed?
Code:
		Database.Database.GetPrizes();
12/17/2009 15:38 .Ryu#24
@Elerlompoms #Reported thats not even on topic
That is so not cool dude...
12/18/2009 03:52 Mjnorman#25
Quote:
Originally Posted by Kiyono View Post
NPCTalk.cs:
Code:
case 923:// Lady Luck enter
                    {
                        if (LinkBack == 0)
                        {
                            if (InventoryContains(710212, 1, CSocket))
                            {
                                Text("I see that you have a lottery ticket, do you want to do the lottery in exchange for the ticket?", CSocket);
                                Link("Yes", 2, CSocket);
                                Link("No", 255, CSocket);
                                Face(30, CSocket);
                                End(CSocket);
                            }
                            else
                            {
                                Text("And I charge you only 27 CPs for each admission. Come on, Try your luck right now!", CSocket);
                                Link("Wow, good deal!", 1, CSocket);
                                Link("No Thanks!", 255, CSocket);
                                Face(30, CSocket);
                                End(CSocket);
                            }
                        }
                        else if (LinkBack == 1)
                        {
                            if (CSocket.Client.Level >= 70)
                            {
                                if (CSocket.Client.CPs >= 27)
                                {
                                    CSocket.Client.LotteryBox = true;
                                    Teleport(700, 50, 50, 0, CSocket);
                                    CPs(-27, CSocket);
                                }
                                else
                                {
                                    Text("I'm sorry you do not have the required CPs.", CSocket);
                                    Link("Okay, I will be back when I have 27 CPs.", 255, CSocket);
                                    Face(30, CSocket);
                                    End(CSocket);
                                }
                            }
                            else
                            {
                                Text("I'm sorry you do not have the required Level 70.", CSocket);
                                Link("Okay, I will be back when I have level 70.", 255, CSocket);
                                Face(30, CSocket);
                                End(CSocket);
                            }
                        }
                        else if (LinkBack == 2)
                        {
                            if (CSocket.Client.Level >= 70)
                            {
                                int uid = ReturnUID(710212, CSocket);
                                CSocket.Client.Inventory.Remove(uid);
                                CSocket.Send(ConquerPacket.ItemUsage(uid, 255, Struct.ItemUsage.RemoveItem));
                                Database.Database.DeleteItem(uid);
                                CSocket.Client.LotteryBox = true;
                                Teleport(700, 50, 50, 0, CSocket);
                            }
                        }
                        else
                        {
                            Text("I'm sorry you do not have the required Level 70.", CSocket);
                            Link("Okay, I will be back when I have level 70.", 255, CSocket);
                            Face(30, CSocket);
                            End(CSocket);
                        }
                        break;
                    }
                case 924:
                    {
                        if (LinkBack == 0)
                        {
                            if (CSocket.Client.LotteryBox == true)
                            {
                                Text("Don't you want to pick a box?", CSocket);
                                Link("Well duh ofcourse I want.", 255, CSocket);
                                Face(20, CSocket);
                                End(CSocket);
                            }
                            else
                            {
                                Text("Want to leave?", CSocket);
                                Link("Yes", 1, CSocket);
                                Link("No", 255, CSocket);
                                Face(20, CSocket);
                                End(CSocket);
                            }
                        }
                        else if (LinkBack == 1)
                        {
                            Teleport(1036, 211, 196, 0, CSocket);
                        }
                        break;
                    }
                case 925:
                case 926:
                case 927:
                case 928:
                case 929:
                case 930:
                case 931:
                case 932:
                case 933:
                case 934:
                case 935:
                case 936:
                case 937:
                case 938:
                case 939:
                case 940:
                case 942:
                case 943:
                case 944:
                case 945:
                    {
                        int PriceIndex = Nano.Rand.Next(0, Nano.Lottery.Count - 1);

                        Structs.Struct.PrizeInfo Price = Nano.Lottery[PriceIndex];
                        if (CSocket.Client.LotteryBox == true)
                        {
                            CSocket.Client.LotteryBox = false;
                            if (Price.ItemID == 1)
                            {
                                CSocket.Send(ConquerPacket.Chat(0, "SYSTEM", CSocket.Client.Name, "Too bad, you haven't won anything.", Struct.ChatType.Top));
                            }
                            else
                            {
                                List<Struct.ItemData> ItemData = new List<Struct.ItemData>();
                                foreach (KeyValuePair<int, Struct.ItemData> Items in Nano.Items)
                                    ItemData.Add(Items.Value);
                                string ItemName = Nano.Items[Price.ItemID].Name;
                                Struct.ItemInfo Item = new Struct.ItemInfo();
                                Item.Progress = Item.Bless = Item.Enchant = Item.Position = Item.Color = 0;
                                Item.Dura = 1;
                                Item.UID = Nano.Rand.Next(1, 9999999);
                                Item.ItemID = Price.ItemID;
                                Item.Plus = Price.Plus;
                                Item.Soc1 = Price.Soc1;
                                Item.Soc2 = Price.Soc2;
                                CSocket.Client.Inventory.Add(Item.UID, Item);
                                CSocket.Send(ConquerPacket.ItemInfo(Item.UID, Item.ItemID, Item.Plus, Item.Progress, Item.Bless, Item.Enchant, Item.Soc1, Item.Soc2, Item.Dura, Item.MaxDura, Item.Position, Item.Color));
Database.Database.NewItem(Item, CSocket);

                                CSocket.Send(ConquerPacket.Chat(0, "SYSTEM", CSocket.Client.Name, "You have won a " + ItemName + ".", Struct.ChatType.Top));

                                if (Price.Message == 1)
                                {
                                    CSocket.Send(ConquerPacket.Chat(0, "SYSTEM", "ALLUSERS", CSocket.Client.Name + " is so lucky to win a(n) " + Price.Description + ItemName + ".", Struct.ChatType.Talk));
                                }
                            }
                        }
                    break;
            }
Character.cs
Code:
public bool LotteryBox = false;
Item.cs
Code:
public class PrizeInfo
        {
            public int ItemID;
            public int Plus;
            public int Soc1;
            public int Soc2;
            public int Chance;
            public string Description;
            public int Message;    
        }
Nano.cs
Code:
public static List<Struct.PrizeInfo> Lottery = new List<Struct.PrizeInfo>();
Then search for:
Code:
public static void StartServer()
And add:
Code:
Database.Database.GetPrizes();
DataBase.cs
Code:
public static void GetPrizes()
        {
            MySqlCommand Cmd = new MySqlCommand("SELECT * FROM `lotteryitems`", DatabaseConnection.NewConnection());
            MySqlDataReader DR = Cmd.ExecuteReader(CommandBehavior.CloseConnection);
            while (DR.Read())
            {
                Struct.PrizeInfo Item = new Struct.PrizeInfo();
                Item.ItemID = Convert.ToInt32(DR["ItemID"]);
                Item.Plus = Convert.ToInt32(DR["Plus"]);
                Item.Chance = Convert.ToInt32(DR["Chance"]);
                Item.Soc1 = Convert.ToInt32(DR["Soc1"]);
                Item.Soc2 = Convert.ToInt32(DR["Soc2"]);
                Item.Description = Convert.ToString(DR["Description"]);
                Item.Message = Convert.ToInt32(DR["Message"]);

                for (int i = 0; i < Item.Chance; i++)
                {
                    Nano.Lottery.Add(Item);
                }
            }
            Console.WriteLine("[GameServer] Loaded " + Nano.Lottery.Count + " lottery prizes from the DB.");
            DR.Close();
            Cmd.Dispose();
        }
Then just execute the SQl file to add the lotteryitems table.

Credits:
CoFuture Reloaded source by Future (leavemealone)


#Updated
#Updated
#Updated
#Bug fixed, items save now.
#New table, garments can be won.
#Probably the last update.
#Updated
:rtfm:

nice release
03/31/2010 20:27 PuN|SheR#26
How to use this script?
06/01/2010 01:56 masternek#27
do u guys have any idea, on how to make like a quest guy, only give reward of the quest one time? cause in ym server, when ppl finish the quests, they can claim their prizes unlimited times x_x pls help..
06/01/2010 16:44 Kiyono#28
Quote:
Originally Posted by masternek View Post
do u guys have any idea, on how to make like a quest guy, only give reward of the quest one time? cause in ym server, when ppl finish the quests, they can claim their prizes unlimited times x_x pls help..
Just use a bool so that when they finish the quest that the bool turns to true and after they claimed the prize it changes to false.
09/14/2010 14:49 salem rey#29
ahh... its good but the old script is still nice :D thanks anyway i like the thread coz its usefull..