网站地图 设为首页 加入收藏
 
红月私服中心 下载中心 发布红月 技术资料 发布家族 游戏IP生成   开区服务  
红月任意设置战争开始时间的储存
文章作者:管理员 文章来源:红月私服中心-Www.hy45.Net 更新时间:2012-7-2 18:42:30 

 

/****** Object:  Stored Procedure dbo.RMS_ARMY_DECLAREWAR    Script Date: 2004-5-13 11:21:06 ******/

CREATE PROCEDURE RMS_ARMY_DECLAREWAR 
 @ArmyID1 int,
 @ArmyID2 int,
 @WarKind1 int,
 @WarKind2 int,
 @WarPlace int,
 @WarStartHour int,
 @WarDuration int
AS
set nocount on
begin transaction RMS_ARMY_DECLAREWAR  
 
 declare @AllianceID1 int
 declare @AllianceID2 int
 declare @CheckArmyID int
 declare @RowCount int
 declare @IsCorrectWar int
 declare @IsAlliance1 int
 declare @IsAlliance2 int
 declare @GameID varchar(14)
 set @IsCorrectWar=1
 set @CheckArmyID=0
 set @IsAlliance1=0
 set @IsAlliance2=0

 if @WarKind1=2 or @WarKind2=2 -- Army hall War
 begin
  select @CheckArmyID=ArmyID from tblAgitList1 where AgitNumber=@WarPlace
 end
 else if @WarKind1=4 or @WarKind2=4 -- Shop War
 begin
  select @CheckArmyID=ArmyID from tblArmyShopList1 where ShopNumber=@WarPlace
 end
 else if @WarKind1=6 or @WarKind2=6 -- HQ War
 begin
  select @CheckArmyID=ArmyID from tblArmyBase1
 end

 if  (@WarKind1=0 and @WarKind2=0) or ( (@WarKind1=2 or @WarKind1=4 or @WarKind1=6)  and @CheckArmyID=@ArmyID1) or ( (@WarKind2=2 or @WarKind2=4 or @WarKind2=6) and @CheckArmyID=@ArmyID2)
 begin
  select @AllianceID1=AllianceID from tblArmyAllianceList1 where ArmyID=@ArmyID1
  if @@ROWCOUNT!=0
  begin
   set @IsAlliance1=1
   select @RowCount=count(*) from tblArmyWarList1 where ArmyID in (select ArmyID from tblArmyAllianceList1 where AllianceID=@AllianceID1)
   if @RowCount!=0
   begin
    set @IsCorrectWar=0
   end
  end
  else
  begin
   select @RowCount=count(*) from tblArmyWarList1 where ArmyID=@ArmyID1
   if @RowCount!=0
   begin
    set @IsCorrectWar=0
   end
  end
  select @AllianceID2=AllianceID from tblArmyAllianceList1 where ArmyID=@ArmyID2
  if @@ROWCOUNT!=0
  begin
   set @IsAlliance2=1
   select @RowCount=count(*) from tblArmyWarList1 where ArmyID in (select ArmyID from tblArmyAllianceList1 where AllianceID=@AllianceID2)
   if @RowCount!=0
   begin
    set @IsCorrectWar=0
   end
  end
  else
  begin
   select @RowCount=count(*) from tblArmyWarList1 where ArmyID=@ArmyID2
   if @RowCount!=0
   begin
    set @IsCorrectWar=0
   end
  end
  if (@IsCorrectWar=1) and datepart(hour,GetDate())>=20 and datepart(hour,GetDate())<=21
  begin
   declare @WarBegin datetime
   declare @WarEnd datetime
   set @WarBegin=GetDate()
   set @WarBegin=dateadd(hour,@WarStartHour,@WarBegin)
   set @WarEnd=dateadd(hour,@WarDuration,@WarBegin)
   if @WarKind1=6 or @WarKind2=6
   begin
    insert tblArmyWarList1 values(@ArmyID1,@ArmyID2,@WarBegin,@WarEnd,@WarKind1,@WarPlace,0,0,'','','','',0)
    insert tblArmyWarList1 values(@ArmyID2,@ArmyID1,@WarBegin,@WarEnd,@WarKind2,@WarPlace,0,0,'','','','',0)
   end
   else
   begin
    insert tblArmyWarList1 values(@ArmyID1,@ArmyID2,@WarBegin,@WarEnd,@WarKind1,@WarPlace,0,1000,'','','','',0)
    insert tblArmyWarList1 values(@ArmyID2,@ArmyID1,@WarBegin,@WarEnd,@WarKind2,@WarPlace,0,1000,'','','','',0)
   end
   EXEC RMS_ARMY_WRITEWARLOG @ArmyID1=@ArmyID1,@ArmyID2=@ArmyID2,@LogKind='WarDeclaration'
   declare @FromArmyName varchar(10)
   declare @FromArmyCommander varchar(14)
   declare @ToArmyName varchar(10)
   set @FromArmyName=''
   set @FromArmyCommander=''
   set @ToArmyName=''
   Select @FromArmyName=Name,@FromArmyCommander=Commander from tblArmyList1 where ID=@ArmyID1
   Select @ToArmyName=Name from tblArmyList1 where ID=@ArmyID2
  
   Declare @MailContent varchar(400)
   if @WarKind1=2 or @WarKind2=2
   begin
    declare @AgitChar varchar(30)
    if @WarPlace>20 and @WarPlace<=40
    begin
     set @WarPlace=@WarPlace-20
     set @AgitChar='Freedom Camp Army Hall '+CAST(@WarPlace AS varchar)
    end
    else
    begin
     set @AgitChar='Liberation Camp Army Hall '+CAST(@WarPlace AS varchar)
    end
    set @MailContent=
@FromArmyName+' Army Commander '+@FromArmyCommander+'
has targeted '+@ToArmyName+' Army for war.
War will be:
From: '+convert(varchar,@WarBegin, 120)+'
To:   '+convert(varchar,@WarEnd, 120)+'
War target is '+@ToArmyName+' Army''s
'+@AgitChar+'.'
   end
   else if @WarKind1=0 and @WarKind2=0
   begin
    set @MailContent=
@FromArmyName+' Army Commander '+@FromArmyCommander+'
has targeted '+@ToArmyName+' Army for war.
War will be:
From: '+convert(varchar,@WarBegin, 120)+'
To:   '+convert(varchar,@WarEnd, 120)
   end
   else if @WarKind1=4 or @WarKind2=4
   begin
    declare @ShopOwner varchar(30)
    declare @ShopNumber int
    set @ShopNumber=@WarPlace
    set @ShopOwner=''
    if @ShopNumber=1
    begin
     set @ShopOwner='Street 1 Shop'
    end
    else if @ShopNumber=2
    begin
     set @ShopOwner='Street 1 Weapon Shop'
    end
    else if @ShopNumber=3
    begin
     set @ShopOwner='Street 1 Runaway Girl'
    end
    else if @ShopNumber=4
    begin
     set @ShopOwner='Street 1 Old Lady 2'
    end
    else if @ShopNumber=5
    begin
     set @ShopOwner='Street 2 Store'
    end
    else if @ShopNumber=6
    begin
     set @ShopOwner='Street 2 Weapon Shop'
    end
    else if @ShopNumber=7
    begin
     set @ShopOwner='Street 2 Runaway Girl'
    end
    else if @ShopNumber=8
    begin
     set @ShopOwner='Street 3 Shop'
    end
    else if @ShopNumber=9
    begin
     set @ShopOwner='Street 3 Geographer'
    end
    else if @ShopNumber=10
    begin
     set @ShopOwner='Street 3 Old Lady 1'
    end
    else if @ShopNumber=11
    begin
     set @ShopOwner='Street 3 Runaway Girl'
    end
    else if @ShopNumber=12
    begin
     set @ShopOwner='Street 3 Old Lady 2'
    end
    else if @ShopNumber=13
    begin
     set @ShopOwner='Downtown 1 Archeologist'
    end
    else if @ShopNumber=14
    begin
     set @ShopOwner='Downtown 1 Shop'
    end
    else if @ShopNumber=15
    begin
     set @ShopOwner='Downtown 2 Grocer 1'
    end
    else if @ShopNumber=16
    begin
     set @ShopOwner='Downtown 2 Grocer 2'
    end
    else if @ShopNumber=17
    begin
    set @ShopOwner='Downtown 2 Weapon Shop 1'
    end
    else if @ShopNumber=18
    begin
     set @ShopOwner='Downtown 2 Archeologist'
    end
    else if @ShopNumber=19
    begin
     set @ShopOwner='Downtown 3 Weapon Shop1'
    end
    else if @ShopNumber=20
    begin
     set @ShopOwner='Downtown 3 Weapon Shop 2'
    end
    else if @ShopNumber=21
    begin
     set @ShopOwner='Downtown 3 Geographer'
    end
    else if @ShopNumber=22
    begin
     set @ShopOwner='Downtown 4 Grocer'
    end
    else if @ShopNumber=23
    begin
     set @ShopOwner='Himalaya Shop'
    end
    else if @ShopNumber=24
    begin
     set @ShopOwner='Himalay Food Shop'
    end
    set @MailContent=
@FromArmyName+' Army Commander '+@FromArmyCommander+'
has declared war on '+@ToArmyName+'.
War will be:
From: '+convert(varchar,@WarBegin, 120)+'
To:   '+convert(varchar,@WarEnd, 120)+'
War location will be '+@ShopOwner+'
that is owned by the'
+@ToArmyName+' Army.'
   end
   else if @WarKind1=6 or @WarKind2=6
   begin
    set @MailContent=
@FromArmyName+' Army Commnader '+@FromArmyCommander+'
has declared war on '+@ToArmyName+'.
War will be:
From: '+convert(varchar,@WarBegin, 120)+'
To:   '+convert(varchar,@WarEnd, 120)+'
War location will be '+@ToArmyName+'
Army''s HQ.'
   end

   if @IsAlliance1=1
   begin
    DECLARE ArmyMemberList CURSOR
    FOR
     SELECT RegularSoldier FROM tblArmyMemberList1 WHERE ArmyID in (SELECT ArmyID FROM tblArmyAllianceList1 WHERE AllianceID=@AllianceID1)
 
    OPEN ArmyMemberList
    FETCH FROM ArmyMemberList INTO @GameID
    WHILE @@FETCH_STATUS =0
    BEGIN
     EXEC RMS_SENDMAIL @Recipient=@GameID,@Sender='ArmyAdmin',@Title='Declaration of War',@Line=6,@MailContent=@MailContent,@Item=''
     FETCH FROM ArmyMemberList INTO @GameID
    END
    CLOSE ArmyMemberList
    DEALLOCATE ArmyMemberList
   end
   else
   begin
    DECLARE ArmyMemberList CURSOR
    FOR
     SELECT RegularSoldier FROM tblArmyMemberList1 WHERE ArmyID=@ArmyID1     OPEN ArmyMemberList
    FETCH FROM ArmyMemberList INTO @GameID
    WHILE @@FETCH_STATUS =0
    BEGIN
     EXEC RMS_SENDMAIL @Recipient=@GameID,@Sender='ArmyAdmin',@Title='Declaration of War',@Line=6,@MailContent=@MailContent,@Item=''
     FETCH FROM ArmyMemberList INTO @GameID
    END
    CLOSE ArmyMemberList
    DEALLOCATE ArmyMemberList
   end
   if @IsAlliance2=1
   begin
    DECLARE ArmyMemberList CURSOR
    FOR
     SELECT RegularSoldier FROM tblArmyMemberList1 WHERE ArmyID in (SELECT ArmyID FROM tblArmyAllianceList1 WHERE AllianceID=@AllianceID2)
 
    OPEN ArmyMemberList
    FETCH FROM ArmyMemberList INTO @GameID
    WHILE @@FETCH_STATUS =0
    BEGIN
     EXEC RMS_SENDMAIL @Recipient=@GameID,@Sender=ArmyAdmin,@Title='Declaration of War',@Line=6,@MailContent=@MailContent,@Item=''
     FETCH FROM ArmyMemberList INTO @GameID
    END
    CLOSE ArmyMemberList
    DEALLOCATE ArmyMemberList
   end
   else
   begin
    DECLARE ArmyMemberList CURSOR
    FOR
     SELECT RegularSoldier FROM tblArmyMemberList1 WHERE ArmyID=@ArmyID2
 
    OPEN ArmyMemberList
    FETCH FROM ArmyMemberList INTO @GameID
    WHILE @@FETCH_STATUS =0
    BEGIN
     EXEC RMS_SENDMAIL @Recipient=@GameID,@Sender='ArmyAdmin',@Title='Declaration of War',@Line=6,@MailContent=@MailContent,@Item=''
     FETCH FROM ArmyMemberList INTO @GameID
    END
    CLOSE ArmyMemberList
    DEALLOCATE ArmyMemberList
   end
   if @IsAlliance1=1
   begin
    DECLARE ArmyCommanderList CURSOR
    FOR
     SELECT Commander FROM tblArmyList1 WHERE ID in  (SELECT ArmyID FROM tblArmyAllianceList1 WHERE AllianceID=@AllianceID1)
 
    OPEN ArmyCommanderList
 
    FETCH FROM ArmyCommanderList INTO @GameID
    WHILE @@FETCH_STATUS =0
    BEGIN
     EXEC RMS_SENDMAIL @Recipient=@GameID,@Sender='ArmyAdmin',@Title='Declaration of War',@Line=6,@MailContent=@MailContent,@Item=''
     FETCH FROM ArmyCommanderList INTO @GameID
    END
    CLOSE ArmyCommanderList
    DEALLOCATE ArmyCommanderList
   end
   else
   begin
    DECLARE ArmyCommanderList CURSOR
    FOR
     SELECT Commander FROM tblArmyList1 WHERE ID=@ArmyID1
 
    OPEN ArmyCommanderList
 
    FETCH FROM ArmyCommanderList INTO @GameID
    WHILE @@FETCH_STATUS =0
    BEGIN
     EXEC RMS_SENDMAIL @Recipient=@GameID,@Sender='ArmyAdmin',@Title='Declaration of War',@Line=6,@MailContent=@MailContent,@Item=''
     FETCH FROM ArmyCommanderList INTO @GameID
    END
    CLOSE ArmyCommanderList
    DEALLOCATE ArmyCommanderList
   end
   if @IsAlliance2=1
   begin
    DECLARE ArmyCommanderList CURSOR
    FOR
     SELECT Commander FROM tblArmyList1 WHERE ID in  (SELECT ArmyID FROM tblArmyAllianceList1 WHERE AllianceID=@AllianceID2)
 
    OPEN ArmyCommanderList
 
    FETCH FROM ArmyCommanderList INTO @GameID
    WHILE @@FETCH_STATUS =0
    BEGIN
     EXEC RMS_SENDMAIL @Recipient=@GameID,@Sender='ArmyAdmin',@Title='Declaration of War',@Line=6,@MailContent=@MailContent,@Item=''
     FETCH FROM ArmyCommanderList INTO @GameID
    END
    CLOSE ArmyCommanderList
    DEALLOCATE ArmyCommanderList
   end
   else
   begin
    DECLARE ArmyCommanderList CURSOR
    FOR
     SELECT Commander FROM tblArmyList1 WHERE ID=@ArmyID2
 
    OPEN ArmyCommanderList
 
    FETCH FROM ArmyCommanderList INTO @GameID
    WHILE @@FETCH_STATUS =0
    BEGIN
     EXEC RMS_SENDMAIL @Recipient=@GameID,@Sender='ArmyAdmin',@Title='Declaration of War',@Line=6,@MailContent=@MailContent,@Item=''
     FETCH FROM ArmyCommanderList INTO @GameID
    END
    CLOSE ArmyCommanderList
    DEALLOCATE ArmyCommanderList
   end
  end
 end
commit transaction RMS_ARMY_DECLAREWAR

GO


 

浏览次数:1
最新文章
· 红月任意设置战争开始时间的储存...
· 红月秘密基地禁止蓝名数据库存储过程...
· 阅读红月数据库存储过程及功能代码说明...
· 红月特装兑换生化之一...
· 4.502版本红月私服完成任务...
· 红月客户端及外挂脚本的漏洞...
· 用15改生化升级存储过程加入一套K生化...
· 红月私服魔法药水使用代码...
· 空中城市进太阳神殿坐标...
· PHP环境架设...
热门文章
· 红月技能点属性上限...
· 红月私服角色之说...
· 3.8C红月私服限制部分外挂的方法...
· 调皮外挂不能正常使用...
· 升华原版升级代码...
· 红月服务器如何做到冲卡的...
· 红月NPC各地点坐标...
· 地图能否PK的设置...
· 红月外挂不能使用新解决办法...
· 积分计算方式...
关于我们 开区服务 网站帮助 全部私服
 
CopyRight @2010 hy45.net, Inc. All Rights Reserved  

备案登记号:苏ICP备11017169号-1