CREATE PROCEDURE RMS_USEMYSTERYPILL
@GameID varchar(14),
@WindowKind int,
@WindowIndex int
AS
set nocount on
declare @RemoveMysteryPillError int, @IncreaseBonusError int, @InsertLogError int,@STotalBonus int
set @RemoveMysteryPillError = 1
set @IncreaseBonusError = 1
set @InsertLogError = 1
begin transaction
select @STotalBonus=STotalBonus from tblGameID1 where GameID = @GameID
if @STotalBonus<15000
delete tblSpecialItem1 where ID in (select top 1 ID from tblSpecialItem1 where ItemKind = 6 AND ItemIndex = 66 AND Position = 1 AND GameID = @GameID AND WindowKind = @WindowKind AND WindowIndex = @WindowIndex)
if @@ROWCOUNT > 0 and @@ERROR = 0
begin
set @RemoveMysteryPillError = 0
end
update tblGameID1 set Bonus2 = Bonus2 + 4, STotalBonus = STotalBonus + 4 where GameID = @GameID
set @IncreaseBonusError = @@ERROR
set @STotalBonus = 0
select @STotalBonus = STotalBonus from tblGameID1 where GameID = @GameID
insert tblBonus2Log1 (GameID, STotalBonus, Kind) values (@GameID, @STotalBonus, 4)
set @InsertLogError = @@ERROR
if @RemoveMysteryPillError = 0 AND @IncreaseBonusError = 0 AND @InsertLogError = 0
begin
commit transaction
end
else
begin
rollback transaction
end
GO