Uso files muemu update 13 y aun tengo errores
ERROR: Msg 2714, Level 16, State 2, Procedure trg_Kill_Death, Line 37
There is already an object named 'trg_Kill_Death' in the database.
QUERY:
--DROP TRIGGER trg_Kill_Death
CREATE TRIGGER trg_Kill_Death ON Character AFTER UPDATE
AS
SET NOCOUNT ON
SET XACT_ABORT ON
DECLARE @AccountID AS Varchar (20)
DECLARE @New_Kill AS INT
DECLARE @Old_Kill AS INT
DECLARE @New_Dead AS INT
DECLARE @Old_Dead AS INT
DECLARE @Cant_WP AS INT
DECLARE @WP_Res AS INT
DECLARE @Reward AS INT
DECLARE @Punish AS INT
DECLARE @Currency AS Varchar(20)
SET @Currency = 'WCoinP' -- Escribir la moneda que va a entregar. Revisar en Table.CashShopData
SET @Reward = 40 -- Colocar aquí la cantidad de coins que ganará el usuario al sumar Kills (Cuando mata)
SET @Punish = 20 -- Colocar aquí la cantidad de coins que perderá el usuario al sumar Deads (Cuando muere)
SET @AccountID = (SELECT AccountID FROM inserted)
SET @Old_Kill = (SELECT Kills FROM deleted Where AccountID = @AccountID)
SET @New_Kill = (SELECT Kills FROM inserted Where AccountID = @AccountID)
SET @Old_Dead = (SELECT Deads FROM deleted Where AccountID = @AccountID)
SET @New_Dead = (SELECT Deads FROM inserted Where AccountID = @AccountID)
SET @Cant_WP = (@New_Kill - @Old_Kill) * @Reward - (@New_Dead - @Old_Dead) * @Punish
Update CashShopData SET @Currency = @Currency + @Cant_WP Where AccountID = @AccountID
SET @WP_Res = (SELECT @Currency FROM CashShopData WHERE AccountID = @AccountID)
IF @WP_Res <= 0
UPDATE CashShopData set @Currency = 0 WHERE AccountID = @AccountID
GO