Selamlar,
Direk Konuya Giriyorum
-- Eklenecek Kodlar
Kod:
DELETE FROM MAGIC WHERE MagicNum = 504001
INSERT INTO ITEM VALUES (800074000,'NP Increase Scroll(+0)',255,15,0,0,0,0,0,1,10,2000,0,0,0,504001,0,70,99,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)
INSERT INTO MAGIC VALUES (504001,'NP Increase Scroll(+0)','General','Increase NP by %50',0,0,0,1,702,1,0,0,0,0,9,800074000,0,180,100,4,0,25,1,0)
INSERT INTO MAGIC_TYPE4 VALUES (504001,'NP Increase Scroll(+0)','Increase NP by Main Magic Table Description Value',1,0,1800,100,100,0,100,100,100,0,100,0,100,100,100,0,0,0,0,0,0,0,0,0,0,0,0)
-- Tablomuz
Kod:
CREATE TABLE [dbo].[USER_LOYALTY_INCREASES](
[ID] [numeric](18, 0) IDENTITY(1,1) NOT NULL,
[strUserId] [char](21) NULL,
[Loyalty] [int] NULL,
[Description] [char](500) NULL,
[Process] [tinyint] NULL,
[UpdateTime] [datetime] NULL,
CONSTRAINT [PK_USER_LOYALTY_INCREASES] PRIMARY KEY CLUSTERED
(
[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
CREATE TABLE [dbo].[USER_LOYALTY_INCREASES_TEMP](
[strUserId] [char](21) NULL,
[Loyalty] [int] NULL
) ON [PRIMARY]
-- Bir Kereye Mahsus Çalıştırağımız Kod (Mevcut NP leri Oluşturmak İçin)
Kod:
INSERT INTO USER_LOYALTY_INCREASES_TEMP SELECT strUserId,Loyalty FROM USERDATA
-- Prosedürümüz
Kod:
CREATE PROCEDURE UPDATE_USER_LOYALTY_INCREASES
@strUserId char(21)
AS
/*
Author : AKUMA
Update : 01.06.2009 - 15:52
*/
DECLARE @ID int
DECLARE @Loyalty int
DECLARE LOYALTY_INCREASES_CURSOR CURSOR FOR
SELECT ID,Loyalty FROM USER_LOYALTY_INCREASES WHERE Process = 0 AND strUserId = @strUserId
OPEN LOYALTY_INCREASES_CURSOR
FETCH NEXT FROM LOYALTY_INCREASES_CURSOR INTO @ID,@Loyalty
WHILE @@FETCH_STATUS = 0
BEGIN
UPDATE USERDATA SET Loyalty = Loyalty + @Loyalty WHERE strUserId = @strUserId
UPDATE USER_LOYALTY_INCREASES SET Process = 1 WHERE ID = @ID
FETCH NEXT FROM LOYALTY_INCREASES_CURSOR INTO @ID,@Loyalty
END
CLOSE LOYALTY_INCREASES_CURSOR
DEALLOCATE LOYALTY_INCREASES_CURSOR
-- Triggerimiz
Kod:
CREATE TRIGGER [dbo].[LOYALTY_INCREASES] ON [dbo].[USERDATA]
AFTER UPDATE AS
IF UPDATE(Loyalty)
BEGIN
/*
Author : AKUMA
Update : 01.06.2009 - 15:52
*/
DECLARE @strUserId char(21)
DECLARE @LoyaltyCurrent int
DECLARE @LoyaltyLast int
DECLARE @LoyaltyAdded int
DECLARE @LoyaltyDifference int
DECLARE @NPIncreasesScrollPercent int
DECLARE @NPIncreasesScrollPercentTemp char(400)
DECLARE @nSkill1 int
DECLARE @nSkill2 int
DECLARE @nSkill3 int
DECLARE @nSkill4 int
DECLARE @nSkill5 int
DECLARE @nSkill6 int
DECLARE @nSkill7 int
DECLARE @nSkill8 int
DECLARE @nSkill9 int
DECLARE @nSkill10 int
SELECT @strUserId = strUserId,@LoyaltyLast = Loyalty FROM INSERTED
SELECT @nSkill1 = nSkill1,@nSkill2 = nSkill2,@nSkill3 = nSkill3,@nSkill4 = nSkill4,@nSkill5 = nSkill5,@nSkill6 = nSkill6,@nSkill7 = nSkill7,@nSkill8 = nSkill8,@nSkill9 = nSkill9,@nSkill10 = nSkill10 FROM USER_SAVED_MAGIC WHERE strCharID = @strUserId
IF (@nSkill1 = 504001) OR (@nSkill2 = 504001) OR (@nSkill3 = 504001) OR (@nSkill4 = 504001) OR (@nSkill5 = 504001) OR (@nSkill6 = 504001) OR (@nSkill7 = 504001) OR (@nSkill8 = 504001) OR (@nSkill9 = 504001) OR (@nSkill10 = 504001)
BEGIN
SELECT @LoyaltyCurrent = Loyalty FROM USER_LOYALTY_INCREASES_TEMP WHERE strUserId = @strUserId
SET @LoyaltyDifference = (@LoyaltyLast - @LoyaltyCurrent)
SET @LoyaltyAdded = 0
IF CHARINDEX('-',@LoyaltyDifference) = 0
BEGIN
SELECT @NPIncreasesScrollPercentTemp = Description FROM MAGIC WHERE MagicNum = 504001
SET @NPIncreasesScrollPercent = SUBSTRING(@NPIncreasesScrollPercentTemp,CHARINDEX('%',@NPIncreasesScrollPercentTemp) + 1,2)
SET @LoyaltyAdded = ((@LoyaltyDifference) * @NPIncreasesScrollPercent) / 100
IF @LoyaltyAdded <> 0
BEGIN
INSERT INTO USER_LOYALTY_INCREASES (strUserId,Loyalty,Description,Process,UpdateTime)
VALUES (@strUserId,@LoyaltyAdded,'Mevcut National Point : ' + RTRIM(LTRIM(STR(@LoyaltyCurrent))) + ' / Son National Point : ' + RTRIM(LTRIM(STR(@LoyaltyLast))) + ' / Verilen NP Yüzdesi %' + RTRIM(LTRIM(STR(@NPIncreasesScrollPercent))) + ' / Verilen National Point : ' + RTRIM(LTRIM(STR(@LoyaltyAdded))),0,GETDATE())
UPDATE USER_LOYALTY_INCREASES_TEMP SET Loyalty = @LoyaltyLast WHERE strUserId = @strUserId
END
END
END
END
-- LOAD_USER_DATA ye AS'ten Sonra Eklenecek Olan
Kod:
-- # Loyalty Increases System Start # --
DECLARE @LIT tinyint
SELECT @LIT = COUNT(strUserId) FROM USER_LOYALTY_INCREASES_TEMP WHERE strUserId = @strUserId
IF @LIT = 0
INSERT INTO USER_LOYALTY_INCREASES_TEMP (strUserId,Loyalty) VALUES (@strUserId,(SELECT Loyalty FROM USERDATA WHERE strUserId = @strUserId))
EXEC UPDATE_USER_LOYALTY_INCREASES @strUserId
-- # Loyalty Increases System End # --
Gerekli Client Patch :
http://rapidshare.com/files/245876376/NPIncreasePatch.rarKOLAY GELSİN