jueves, 1 de abril de 2010

Cambiar lvl de creacion del DL

Este es un script que crea un trigger que lo que hace es cambiar en nivel de creacion del DarkLord.


USE MuOnline
IF EXISTS (SELECT Name FROM sysobjects
WHERE name = 'DarkLordPreserve' AND type = 'TR')
DROP TRIGGER DarkLordPreserve
GO

CREATE TRIGGER DarkLordPreserve ON Character INSTEAD OF INSERT
AS
BEGIN
DECLARE
@CharnameExist varchar(10),
@MaxCharLevel smallint,
@InsAccountID varchar(10),
@InsName nvarchar(50),
@InscLevel smallint,
@InsLevelUpPoint int,
@InsClass tinyint,
@InsExperience int,
@InsStrength smallint,
@InsDexterity smallint,
@InsVitality smallint,
@InsEnergy smallint,
@InsMoney int,
@InsLife real,
@InsMaxLife real,
@InsMana real,
@InsMaxMana real,
@InsMapNumber smallint,
@InsMapPosX smallint,
@InsMapPosY smallint,
@InsMapDir tinyint,
@InsMDate smalldatetime,
@InsLDate smalldatetime,
@InsDbVersion tinyint

SELECT
@InsAccountID = AccountID,
@InsName = Name,
@InscLevel = cLevel,
@InsLevelUpPoint = LevelUpPoint,
@InsClass = Class,
@InsExperience = Experience,
@InsStrength = Strength,
@InsDexterity = Dexterity,
@InsVitality = Vitality,
@InsEnergy = Energy,
@InsMoney = Money,
@InsLife = Life,
@InsMaxLife = MaxLife,
@InsMana = Mana,
@InsMaxMana = MaxMana,
@InsMapNumber = MapNumber,
@InsMapPosX = MapPosX,
@InsMapPosY = MapPosY,
@InsMapDir = MapDir,
@InsMDate = MDate,
@InsLDate = LDate,
@InsDbVersion = DbVersion
FROM inserted


-- Find Max Level
SELECT @MaxCharLevel = MAX(cLevel) FROM Character WHERE (AccountId = @InsAccountID)

-- Get one Random Character Name from DB
SELECT TOP 1 @CharnameExist = Name FROM Character

-- Put DarkLord Class Number Here
IF (@InsClass = 64)
BEGIN
-- Put desired minimum level of character that has to exist here
IF (@MaxCharLevel < 220)
BEGIN
SET @InsName = @CharnameExist
END
IF (@MaxCharLevel IS NULL)
BEGIN
SET @InsName = @CharnameExist
END
END

-- Insert the Query
INSERT INTO Character
(
AccountID, Name, cLevel, LevelUpPoint, Class, Experience, Strength, Dexterity, Vitality, Energy,
Money, Life, MaxLife, Mana, MaxMana, MapNumber, MapPosX, MapPosY, MapDir, MDate,LDate,DbVersion
)
VALUES
(
@InsAccountID, @InsName, @InscLevel, @InsLevelUpPoint, @InsClass, @InsExperience,
@InsStrength, @InsDexterity, @InsVitality, @InsEnergy, @InsMoney, @InsLife, @InsMaxLife,
@InsMana, @InsMaxMana, @InsMapNumber, @InsMapPosX, @InsMapPosY, @InsMapDir, @InsMDate, @InsLDate, @InsDbVersion
)
END

0 comentarios: