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
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
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
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.
[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: