[Help Needed]Drop Event

02/18/2010 21:53 HardNotTo#1
I searched 2 forums for a fix for this and have not found anything so I came here. I have the following code for a drop event,(not my code, came with the source), and the event works fine, only problem is the event does not end until a server restart. Is there some way to make it end when the timer is over?

Code:
if (Cmd[0] == "/dropevent")
                        {
                            try
                            {
                                if (Program.DropEventTimer == null)
                                {
                                    bool start = true;
                                    if (Cmd[1].ToLower() == "dragonball")
                                    {
                                        Program.DropEventType = "dragonball";
                                        Program.SaveOldRate = DropRates.DragonBall;
                                        DropRates.DragonBall = (DropRates.DragonBall * int.Parse(Cmd[3]));
                                    }
                                    else if (Cmd[1].ToLower() == "meteor")
                                    {
                                        Program.DropEventType = "meteor";
                                        Program.SaveOldRate = DropRates.Meteor;
                                        DropRates.Meteor = (DropRates.Meteor * int.Parse(Cmd[3]));
                                    }
                                    else if (Cmd[1].ToLower() == "minicpbag")
                                    {
                                        Program.DropEventType = "minicpbag";
                                        Program.SaveOldRate = DropRates.CPMiniBag;
                                        DropRates.CPMiniBag = (DropRates.CPMiniBag == 0 ? 1 : DropRates.CPMiniBag * int.Parse(Cmd[3]));
                                    }
                                    else if (Cmd[1].ToLower() == "cpbag")
                                    {
                                        Program.DropEventType = "cpbag";
                                        Program.SaveOldRate = DropRates.CPBag;
                                        DropRates.CPBag = (DropRates.CPBag == 0 ? 1 : DropRates.CPBag * int.Parse(Cmd[3]));
                                    }
                                    else if (Cmd[1].ToLower() == "pointcard")
                                    {
                                        Program.DropEventType = "pointcard";
                                        Program.SaveOldRate = DropRates.PointCard;
                                        DropRates.PointCard = (DropRates.PointCard == 0 ? 1 : DropRates.PointCard * int.Parse(Cmd[3]));
                                    }
                                    else
                                        start = false;

                                    if (start)
                                    {
                                        Program.DropEventTimer = new System.Timers.Timer();
                                        Program.DropEventTimer.Interval = (int.Parse(Cmd[2]) * 60000);
                                        Program.DropEventTimer.Elapsed += new System.Timers.ElapsedEventHandler(Program.QuestDropDone);
                                        Program.DropEventTimer.Start();
                                        Game.World.SendMsgToAll("Server", "[Event] Server will drop " + Cmd[1] + "s " + Cmd[3] + "x for " + Cmd[2] + " minutes.", 2011, 0);
                                    }
                                    else
                                        GC.LocalMessage(2001, "Item name is not a dropevent!");
                                }
                                else
                                    GC.LocalMessage(2001, "There is a running event, you must wait it end to start a new!");
                            }
                            catch { GC.LocalMessage(2001, "Wrongs values!"); GC.LocalMessage(2001, "Format: /dropevent ItemName Minutes Timers"); GC.LocalMessage(2001, "Example: /dropevent dragonball 15 1000    its in up the rates to 1000x in 15 minutos."); }
                        }
02/18/2010 21:55 ~jochemke~#2
Probably there will be a way to let it end with a timer but since i'm not a pro i can't tell u . but maybe u can make a command to let it stop or not? :p
02/19/2010 00:13 pro4never#3
Why not just use a value for how many items you want to drop and then do a while loop saying while (amount > 0) and reduce amount by 1 each loop the drop code goes through?