Ejemplo n.º 1
0
        static bool HandleEventInfoCommand(StringArguments args, CommandHandler handler)
        {
            if (args.Empty())
            {
                return(false);
            }

            // id or [name] Shift-click form |color|Hgameevent:id|h[name]|h|r
            string id = handler.extractKeyFromLink(args, "Hgameevent");

            if (string.IsNullOrEmpty(id))
            {
                return(false);
            }

            if (!ushort.TryParse(id, out ushort eventId))
            {
                return(false);
            }

            var events = Global.GameEventMgr.GetEventMap();

            if (eventId >= events.Length)
            {
                handler.SendSysMessage(CypherStrings.EventNotExist);
                return(false);
            }

            GameEventData eventData = events[eventId];

            if (!eventData.isValid())
            {
                handler.SendSysMessage(CypherStrings.EventNotExist);
                return(false);
            }

            var    activeEvents = Global.GameEventMgr.GetActiveEventList();
            bool   active       = activeEvents.Contains(eventId);
            string activeStr    = active ? Global.ObjectMgr.GetCypherString(CypherStrings.Active) : "";

            string startTimeStr = Time.UnixTimeToDateTime(eventData.start).ToLongDateString();
            string endTimeStr   = Time.UnixTimeToDateTime(eventData.end).ToLongDateString();

            uint   delay    = Global.GameEventMgr.NextCheck(eventId);
            long   nextTime = Time.UnixTime + delay;
            string nextStr  = nextTime >= eventData.start && nextTime < eventData.end ? Time.UnixTimeToDateTime(Time.UnixTime + delay).ToShortTimeString() : "-";

            string occurenceStr = Time.secsToTimeString(eventData.occurence * Time.Minute);
            string lengthStr    = Time.secsToTimeString(eventData.length * Time.Minute);

            handler.SendSysMessage(CypherStrings.EventInfo, eventId, eventData.description, activeStr,
                                   startTimeStr, endTimeStr, occurenceStr, lengthStr, nextStr);
            return(true);
        }
Ejemplo n.º 2
0
        static bool HandleEventStopCommand(StringArguments args, CommandHandler handler)
        {
            if (args.Empty())
            {
                return(false);
            }

            // id or [name] Shift-click form |color|Hgameevent:id|h[name]|h|r
            string id = handler.extractKeyFromLink(args, "Hgameevent");

            if (string.IsNullOrEmpty(id))
            {
                return(false);
            }

            if (!ushort.TryParse(id, out ushort eventId))
            {
                return(false);
            }

            var events = Global.GameEventMgr.GetEventMap();

            if (eventId < 1 || eventId >= events.Length)
            {
                handler.SendSysMessage(CypherStrings.EventNotExist);
                return(false);
            }

            GameEventData eventData = events[eventId];

            if (!eventData.isValid())
            {
                handler.SendSysMessage(CypherStrings.EventNotExist);
                return(false);
            }

            var activeEvents = Global.GameEventMgr.GetActiveEventList();

            if (!activeEvents.Contains(eventId))
            {
                handler.SendSysMessage(CypherStrings.EventNotActive, eventId);
                return(false);
            }

            Global.GameEventMgr.StopEvent(eventId, true);
            return(true);
        }