Ejemplo n.º 1
0
        /// <summary>
        /// 定时器计时
        /// </summary>
        private static void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            if (!Activity.hasInitialize)
            {
                return;
            }

            bool hasSend = false;

            lock (Activity.dataList)
            {
                for (int i = 0; i < Activity.dataList.Count;)
                {
                    ActivityData data = Activity.dataList[i];

                    if ((DateTime.Now - data.UpdateTime).TotalDays >= 7)
                    {
                        hasSend = true;
                        Activity.dataList.RemoveAt(i);
                        Log.AddLog(data.ServerId + " 活动更新时间太早 " + data.UpdateTime.ToShortDateString());
                        continue;
                    }

                    if (DateTime.Now >= data.UpdateTime &&
                        GMCommand.Execute(data.Address, data.ServerId, "0", Encoding.UTF8.GetBytes("2"), data.Buffer) &&
                        GMCommand.Execute(data.Address, data.ServerId, "0", string.Format("SDATE({0},{1},{2})", data.UpdateTime.Year, data.UpdateTime.Month, data.UpdateTime.Day), ""))
                    {
                        Log.AddLog("定时更新:" + DateTime.Now);
                        Log.AddLog("年:" + data.UpdateTime.Year);
                        Log.AddLog("月:" + data.UpdateTime.Month);
                        Log.AddLog("日:" + data.UpdateTime.Day);
                        hasSend = true;
                        Activity.dataList.RemoveAt(i);
                    }
                    else
                    {
                        ++i;
                    }
                }

                if (hasSend)
                {
                    Activity.SendUpdate();
                }
            }
        }
        /// <summary>
        /// 定时器计时
        /// </summary>
        private static void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            if (Broadcast.dataList.Count == 0)
            {
                return;
            }

            lock (Broadcast.dataList)
            {
                foreach (var server in Broadcast.dataList)
                {
                    foreach (var data in server.BroadcastDataList)
                    {
                        if (++data.Accumulation >= data.IntervalSecond)
                        {
                            data.Accumulation = 0;
                            GMCommand.Execute(server.Address, server.ServerId, "0", string.Format("SC(\"{0}\")", data.Content), "");
                        }
                    }
                }
            }
        }
        /// <summary>
        /// 定时器计时
        /// </summary>
        private static void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            if (!PVPReward.hasInitialize)
            {
                return;
            }

            bool hasSend = false;

            lock (PVPReward.dataList)
            {
                for (int i = 0; i < PVPReward.dataList.Count; ++i)
                {
                    PVPRewardData data = PVPReward.dataList[i];

                    if (data.gift != 0 &&
                        (DateTime.Now - data.UpdateTime).TotalDays >= 7)
                    {
                        data.gift = 0;
                        hasSend   = true;
                        Log.AddLog(data.ServerId + " PVP奖励更新时间太早 " + data.UpdateTime.ToShortDateString());
                        continue;
                    }

                    if (data.gift != 0 &&
                        DateTime.Now >= data.UpdateTime &&
                        GMCommand.Execute(data.Address, data.ServerId, "0", string.Format("RPVP({0})", data.gift), ""))
                    {
                        data.gift = 0;
                        hasSend   = true;
                    }
                }

                if (hasSend)
                {
                    PVPReward.SendUpdate();
                }
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// 执行GM命令
 /// </summary>
 /// <param name="address">发送地址</param>
 /// <param name="serverId">服务器编号</param>
 /// <param name="playerId">玩家编号</param>
 /// <param name="command">命令</param>
 /// <param name="operate">操作</param>
 /// <returns>是否成功</returns>
 public static bool Execute(string address, string serverId, string playerId, string command, string operate)
 {
     return(GMCommand.Execute(address, serverId, playerId, Encoding.UTF8.GetBytes(command), Encoding.UTF8.GetBytes(operate)));
 }