Selamlar







[b]Merhaba arkadaşlar,







Bir çok arkadaşımızın clanları procedure ile güncellediği için clan kolluklarında bug oluşmaktadır ( g0 iken belli bir süre sonra g5 ve kolluk yanıyor şeklinde ) Bunun için sizinle sorunsuz procedureleri paylaşıyorum.







RANK_KNIGHTS









PHP- Kodu:

<div class="alt2" dir="ltr" style="

margin: 0px;

padding: 6px;

border: 1px inset;

width: 640px;

height: 498px;

text-align: left;

overflow: auto">





/*

Author*****:*Bilinmiyor

Edit****:*ThirtySeven

*/

CREATE*PROCEDURE*[dbo].[RANK_KNIGHTS]

AS



SET*NOCOUNT*ON

DECLARE*@KnightsIndex*smallint

DECLARE*@SumLoyalty*int

DECLARE*RKJob*CURSOR*FOR



SELECT*IDNum*FROM*KNIGHTS



OPEN*RKJob

FETCH*NEXT*FROM*RKJob

INTO*@KnightsIndex

WHILE*@@fetch_status*=*0*



BEGIN

if*@SumLoyalty*is*null

begin

****SET*@SumLoyalty*=*0

end

****SELECT*@SumLoyalty=Sum(Loyalty)*FROM*USERDATA* WHERE*Authority****255*And*Knights*=*@KnightsIndex *and*City**255*

****IF*@SumLoyalty**0

********UPDATE*KNIGHTS*SET*Points*=*@SumLoyalty*WH ERE*IDNum*=*@KnightsIndex



****FETCH*NEXT*FROM*RKJob

****INTO*@KnightsIndex

END

CLOSE*RKJob

DEALLOCATE*RKJob

SET*NOCOUNT*OFF



UPDATE*KNIGHTS*SET*Ranking=0*WHERE*Ranking>0



EXEC*KNIGHTS_RATING_UPDATE*



DECLARE*@Knights_1*smallint

DECLARE*@Knights_2*smallint

DECLARE*@Knights_3*smallint

DECLARE*@Knights_4*smallint

DECLARE*@Knights_5*smallint



SELECT*@Knights_1*=*shIndex*FROM*KNIGHTS_RATING*WH ERE*nRank=1

SELECT*@Knights_2*=*shIndex*FROM*KNIGHTS_RATING*WH ERE*nRank=2

SELECT*@Knights_3*=*shIndex*FROM*KNIGHTS_RATING*WH ERE*nRank=3

SELECT*@Knights_4*=*shIndex*FROM*KNIGHTS_RATING*WH ERE*nRank=4

SELECT*@Knights_5*=*shIndex*FROM*KNIGHTS_RATING*WH ERE*nRank=5



UPDATE*KNIGHTS*SET*Ranking*=*1*WHERE*IDNum=@Knight s_1

UPDATE*KNIGHTS*SET*Ranking*=*2*WHERE*IDNum=@Knight s_2

UPDATE*KNIGHTS*SET*Ranking*=*3*WHERE*IDNum=@Knight s_3

UPDATE*KNIGHTS*SET*Ranking*=*4*WHERE*IDNum=@Knight s_4

UPDATE*KNIGHTS*SET*Ranking*=*5*WHERE*IDNum=@Knight s_5



if*exists*(select***from*sysobjects*where*id*=***o bject_id(N'[dbo].[KARUS_KNIGHTS_RATING]')*and*OBJECTPROPERTY(id,***N'IsUserTable')*=*1)

drop*table*[dbo].[KARUS_KNIGHTS_RATING]

if*exists*(select***from*sysobjects*where*id*=***o bject_id(N'[dbo].[ELMORAD_KNIGHTS_RATING]')*and*OBJECTPROPERTY(id,***N'IsUserTable')*=*1)

drop*table*[dbo].[ELMORAD_KNIGHTS_RATING]

GO*











UPDATE_KNIGHTS









PHP- Kodu:

<div class="alt2" dir="ltr" style="

margin: 0px;

padding: 6px;

border: 1px inset;

width: 640px;

height: 498px;

text-align: left;

overflow: auto">





/*

Author*****:*Bilinmiyor

Edit****:*ThirtySeven

*/



CREATE*PROCEDURE*UPDATE_KNIGHTS



@nRet********smallint*OUTPUT,*

@Type********tinyint,

@UserId*****char(21),*

@KnightsIndex****smallint,

@Domanation****tinyint



AS





DECLARE*@Row*tinyint*

DECLARE*@Members*tinyint

DECLARE*@UserMembers*tinyint

DECLARE*@KnightsNumber*smallint

DECLARE*@ViceChief_1*char(21)

DECLARE*@ViceChief_2*char(21)

DECLARE*@ViceChief_3*char(21)

****SET*@Row*=*0

****SET*@KnightsNumber*=*0



****SELECT*@Row*=*COUNT(*)*FROM*KNIGHTS*WHERE*IDNu m*=*@KnightsIndex

****

****IF*@Row*=*0

****BEGIN

********SET*@nRet*=**7

********RETURN

****END

**

****IF*@Type*=*18

********BEGIN

************IF*EXISTS*(SELECT*strUserId*FROM*KNIGH TS_USER*WHERE*strUserId*=*@UserId)

************BEGIN

****************ROLLBACK*TRAN*

****************SET*@nRet*=**5

****************RETURN

************END

********END



****SELECT*@Members*=*Members,*@ViceChief_1=ViceCh ief_1,***@ViceChief_2=ViceChief_2,*@ViceChief_3=Vi ceChief_3*FROM*KNIGHTS*WHERE***IDNum*=*@KnightsInd ex

****IF*@Type*=*18

********BEGIN

************SELECT*@UserMembers*=*COUNT(*)*FROM*US ERDATA*WHERE*Knights*=*@KnightsIndex

************IF*@Members*>=*36*or*@UserMembers*>=*3 6*

************BEGIN

****************SET*@nRet*=**8

****************RETURN

************END

********END

****ELSE*

********BEGIN

************IF*@Members*>*36

************BEGIN

****************SET*@nRet*=**8

****************RETURN

************END

********END



****SELECT*@Row*=*COUNT(*)*FROM*USERDATA*WHERE*str UserId*=*@UserId

****IF*@Row*=*0*

****BEGIN

********SET*@nRet*=**2

********RETURN

****END



--SELECT*@ViceChief_1=ViceChief_1,*@ViceChief_2=Vice Chief_2,***@ViceChief_3=ViceChief_3**FROM*KNIGHTS* WHERE*IDNum*=*@KnightsIndex****



BEGIN*TRAN****

****IF*@Type*=*18********************--*JOIN

********BEGIN

********UPDATE*KNIGHTS*SET*Members*=*Members*+*1*W HERE*IDNum*=*@KnightsIndex

********INSERT*INTO*KNIGHTS_USER*(*sIDNum,*strUser ID**)*VALUES*****(@KnightsIndex,**@UserId*)

********UPDATE*USERDATA*SET*Knights=@KnightsIndex* WHERE*strUserId*=*@UserId

********END

****ELSE*IF*@Type*=*19*or*@Type*=*20*or*@Type*=*23 ****--*WITHDRAW,*REMOVE,*REJECT

********BEGIN

************IF*@Members* Tüm Programlar > Microsoft SQL Server > Query Analyzer ‘ a giriyoruz.



2 SQL Server’ a bağlanıyoruz ve açılan ekranda ” master ” yerine ” DBmizi ” seçiyoruz.



3 Seçtikten sonra aşağıdaki kodu kopyalayıp , yapıştırıyoruz ve F5 yaparak kodumuzu uyguluyoruz.