|
存储过程RMS_SENDSPECIALITEMAIL每次只能发一种特殊物品。
根据语法规则写了一个可发多个的。
使用方法:
EXEC RMS_SENDSPECIALITEMMAILX '发信人','收信人',‘标题’,'内容',种类数,物品1编号,物品1数量,物品2编号,物品2数量,物品3编号,物品3数量,物品4编号,物品4数量,物品5编号,物品5数量
根据种类数,发几种就写几组 编号,数量 即可。
代码如下:
- USE [RedMoon]
- GO
- /****** Object: StoredProcedure [dbo].[RMS_SENDSPECIALITEMMAILX] Script Date: 03/04/2020 19:39:46 ******/
- IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[RMS_SENDSPECIALITEMMAILX]') AND type in (N'P', N'PC'))
- DROP PROCEDURE [dbo].[RMS_SENDSPECIALITEMMAILX]
- GO
- USE [RedMoon]
- GO
- /****** Object: StoredProcedure [dbo].[RMS_SENDSPECIALITEMMAILX] Script Date: 03/04/2020 19:39:46 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE PROCEDURE [dbo].[RMS_SENDSPECIALITEMMAILX]
- @Sender varchar(14),
- @Recipient varchar(14),
- @Title varchar(80),
- @Content varchar(1000),
- @Count int,
- @ItemIndex1 int = 0,
- @ItemCount1 int = 0,
- @ItemIndex2 int = 0,
- @ItemCount2 int = 0,
- @ItemIndex3 int = 0,
- @ItemCount3 int = 0,
- @ItemIndex4 int = 0,
- @ItemCount4 int = 0,
- @ItemIndex5 int = 0,
- @ItemCount5 int = 0
- AS
- set nocount on
- declare @ItemIndex int, @ItemCount int
- declare @MailCount int
- declare @Time datetime
- set @MailCount = 0
- set @Time=cast(convert(varchar, GetDate(), 120) as datetime)
- If @Count>5 OR @Count<0 OR @Count=1 return
- begin transaction sendmorespcitem
- select @MailCount = count(*) from tblMail1 where Recipient =@Recipient and Time = @Time
- while @MailCount > 0
- begin
- set @MailCount = 0
- set @Time = dateadd(second, 1, @Time)
- select @MailCount = count(*) from tblMail1 where Recipient = @Recipient and Time = @Time
- end
- if @Count > 1
- begin
- set @ItemIndex = @ItemIndex1
- set @ItemCount = @ItemCount1
- while @ItemCount>0
- begin
- insert tblSpecialItem1 (ItemKind, ItemIndex, ItemDurability, Position, Map, X, Y, TileKind, GameID, WindowKind, WindowIndex, MiscTime) values (6, @ItemIndex, 5, 2, 1, 100, 100, 1, @Recipient, 100, 0, @Time)
- set @ItemCount=@ItemCount -1
- end
- set @ItemIndex = @ItemIndex2
- set @ItemCount = @ItemCount2
- while @ItemCount>0
- begin
- insert tblSpecialItem1 (ItemKind, ItemIndex, ItemDurability, Position, Map, X, Y, TileKind, GameID, WindowKind, WindowIndex, MiscTime) values (6, @ItemIndex, 5, 2, 1, 100, 100, 1, @Recipient, 100, 1, @Time)
- set @ItemCount=@ItemCount -1
- end
- end
- if @Count > 2 and @ItemIndex3 != 0 and @ItemCount3 != 0
- begin
- set @ItemIndex = @ItemIndex3
- set @ItemCount = @ItemCount3
- while @ItemCount>0
- begin
- insert tblSpecialItem1 (ItemKind, ItemIndex, ItemDurability, Position, Map, X, Y, TileKind, GameID, WindowKind, WindowIndex, MiscTime) values (6, @ItemIndex, 5, 2, 1, 100, 100, 1, @Recipient, 100, 2, @Time)
- set @ItemCount=@ItemCount -1
- end
- end
- if @Count > 3 and @ItemIndex4 != 0 and @ItemCount4 != 0
- begin
- set @ItemIndex = @ItemIndex4
- set @ItemCount = @ItemCount4
- while @ItemCount>0
- begin
- insert tblSpecialItem1 (ItemKind, ItemIndex, ItemDurability, Position, Map, X, Y, TileKind, GameID, WindowKind, WindowIndex, MiscTime) values (6, @ItemIndex, 5, 2, 1, 100, 100, 1, @Recipient, 100, 3, @Time)
- set @ItemCount=@ItemCount -1
- end
- end
- if @Count > 4 and @ItemIndex5 != 0 and @ItemCount5 != 0
- begin
- set @ItemIndex = @ItemIndex5
- set @ItemCount = @ItemCount5
- while @ItemCount>0
- begin
- insert tblSpecialItem1 (ItemKind, ItemIndex, ItemDurability, Position, Map, X, Y, TileKind, GameID, WindowKind, WindowIndex, MiscTime) values (6, @ItemIndex, 5, 2, 1, 100, 100, 1, @Recipient, 100, 4, @Time)
- set @ItemCount=@ItemCount -1
- end
- end
- insert tblMail1 (Time, Recipient, Sender, ReadOrNot, Title, Line, Content, Item) values(@Time, @Recipient,@Sender, 0, @Title, 20, @Content, '')
- commit transaction sendmorespcitem
- GO
复制代码
|
|