CREATE TRIGGER [TRIGGER NAME] ON [dbo].[USERDATA]
FOR UPDATE
AS
Begin
if update([exp])
begin
declare @oldExp int
declare @newExp int
declare @strUserId char(21)
select @strUserId = strUserId, @oldExp = [exp] from deleted
select @newExp = [exp] from inserted
if( @newExp < 0 )
begin
declare @exp70 int
select @exp70 = exp from LEVEL_UP where [level]=70
update userData
set exp = cast((@oldExp - @exp70*0.05) as int)
where strUserId = @strUserId
end
end
End
作用:当70级死后.人物经验成为负值.人物上线后.会直接血为0.不能发出任何操作..通过执行上面的代码.可以解决这个问题...希望对大家有所帮助.分享才会发展.. |