Register for your free account! | Forgot your password?

You last visited: Today at 05:15

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

Advertisement



[Release]Another lotto script

Discussion on [Release]Another lotto script within the CO2 PServer Guides & Releases forum part of the CO2 Private Server category.

Reply
 
Old   #1

 
Kiyono's Avatar
 
elite*gold: 20
Join Date: Jun 2006
Posts: 3,296
Received Thanks: 925
[Release]Another lotto script

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
Attached Files
File Type: rar lotterytable_+_UD_DOC_FF_GARMENTs.rar (283.6 KB, 325 views)
Kiyono is offline  
Thanks
8 Users
Old 06/10/2009, 18:52   #2
 
danielachraf's Avatar
 
elite*gold: 20
Join Date: Mar 2008
Posts: 958
Received Thanks: 494
Nice code .. Going to try it
danielachraf is offline  
Old 06/10/2009, 19:27   #3
 
nTL3fTy's Avatar
 
elite*gold: 0
Join Date: Jun 2005
Posts: 692
Received Thanks: 353
I believe this is interchangeable and would remove the typecasting here:
Code:
Structs.Struct.PrizeInfo Price = (Structs.Struct.PrizeInfo)Nano.Lottery[PriceIndex];
to
Code:
Structs.Struct.PrizeInfo Price = Nano.Lottery[PriceIndex];
Replace:
Code:
public static ArrayList Lottery = new ArrayList();
with:
Code:
public static List<Struct.PrizeInfo> Lottery = new List<Struct.PrizeInfo>();
nTL3fTy is offline  
Thanks
2 Users
Old 06/10/2009, 21:44   #4
 
$HaDoW's Avatar
 
elite*gold: 0
Join Date: Sep 2007
Posts: 285
Received Thanks: 78
Update the SQL File
$HaDoW is offline  
Old 06/10/2009, 22:57   #5
 
danielachraf's Avatar
 
elite*gold: 20
Join Date: Mar 2008
Posts: 958
Received Thanks: 494
ok .. Works fine .. i restarted the pc and open the project and saw this error :
Quote:
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
and the error
Quote:
No overload for method 'IntemInfo' takes '12' arguments
and i closed the proj and open the server , i didn't find anything wrong in lottery or in the game
danielachraf is offline  
Old 06/10/2009, 23:00   #6
 
Zeroxelli's Avatar
 
elite*gold: 0
Join Date: May 2008
Posts: 1,769
Received Thanks: 1,143
Remove
Code:
, Item.Progress
It's because he added my WuxingOven code, he has item progress. Most people don't have that code.
Zeroxelli is offline  
Thanks
1 User
Old 06/10/2009, 23:41   #7

 
Kiyono's Avatar
 
elite*gold: 20
Join Date: Jun 2006
Posts: 3,296
Received Thanks: 925
Quote:
Originally Posted by Zeroxelli View Post
Remove
Code:
, Item.Progress
It's because he added my WuxingOven code, he has item progress. Most people don't have that code.
Most people should just add your awesome code =)
Kiyono is offline  
Old 06/10/2009, 23:45   #8
 
Zeroxelli's Avatar
 
elite*gold: 0
Join Date: May 2008
Posts: 1,769
Received Thanks: 1,143
Quote:
Originally Posted by Kiyono View Post
Most people should just add your awesome code =)
True

Unfortunately, people like to add things one at a time. Instead of try and get everything done then compile. Human nature, but it leads to a lot of errors xD
Zeroxelli is offline  
Old 06/11/2009, 00:01   #9

 
Kiyono's Avatar
 
elite*gold: 20
Join Date: Jun 2006
Posts: 3,296
Received Thanks: 925
I found a bug xD the items disappear if you log out lol
Oh well cba to fix it cause I'm sleepy.
Kiyono is offline  
Old 06/11/2009, 00:22   #10
 
Zeroxelli's Avatar
 
elite*gold: 0
Join Date: May 2008
Posts: 1,769
Received Thanks: 1,143
You didn't fix update item?
Zeroxelli is offline  
Old 06/11/2009, 02:08   #11
 
m4l4ria's Avatar
 
elite*gold: 0
Join Date: Jan 2009
Posts: 45
Received Thanks: 8
I have Three Error
The Name 'InventoryContains' does not exist in the current context
The Name 'ReturnUID' does not exist in the current context
The Name 'RandomController' does not exist in the current context
m4l4ria is offline  
Old 06/11/2009, 17:19   #12

 
Kiyono's Avatar
 
elite*gold: 20
Join Date: Jun 2006
Posts: 3,296
Received Thanks: 925
Fixed the little bug, items save now.
Kiyono is offline  
Old 06/12/2009, 00:10   #13
 
elite*gold: 0
Join Date: Oct 2008
Posts: 430
Received Thanks: 176
Sorry to be a pain, getting a small error with this.

The type name 'PrizeInfo' does not exist in the type 'CoEmu_v2_GameServer.Structs.Struct'

Anyone able to help me fix this?
Incariuz is offline  
Old 06/12/2009, 02:46   #14
 
danielachraf's Avatar
 
elite*gold: 20
Join Date: Mar 2008
Posts: 958
Received Thanks: 494
The new update is full of errors
edit:i didn't find any error in the old one ..
danielachraf is offline  
Old 06/12/2009, 02:52   #15
 
elite*gold: 0
Join Date: Oct 2008
Posts: 430
Received Thanks: 176
well I originaly had a bunch of errors, but the majority were easily fixed. 2 were fixed by reverting 1 of the lines back to the old code, but I dunno what to do with the last error I posted.
Incariuz is offline  
Reply


Similar Threads Similar Threads
[Release] Lotto
05/31/2009 - CO2 PServer Guides & Releases - 16 Replies
Koio did most of this code credits to him not me, also place this into NpcTalk.cs in CoEmu source. case 926://Lucky Box Coded by koio and alil by Epic-Chaos case 925: case 927: case 928: case 929: case 930:



All times are GMT +1. The time now is 05:15.


Powered by vBulletin®
Copyright ©2000 - 2025, 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 ©2025 elitepvpers All Rights Reserved.