[Release]Same Account PVP Stat Transfer SQL Edition

01/24/2014 01:02 BodySalvage#1
I made this script awhile back and used it a lot. Its been a very useful tool and I decided it was time to share it. This will simply transfer all kills and deaths from 1 character to another on the same account.

1. The Script
Code:
/* ////////////////////////////////////
Same Account PVP Stat Transfer
Created By : [DEV]Lube - Hack and Slash Shaiya
Date : 03/11/2011
//////////////////////////////////// */

/* ////////////////////////////////
        DECLARE VARIABLES 
	       DO NOT EDIT
//////////////////////////////// */
DECLARE @FromChar varchar(30),
		@ToChar varchar(30),
		@FromK1 int,
		@FromK2 int,
		@UserUID1 int,
		@UserUID2 int,
		@ReturnMessage varchar(255),
		@ErrorRet int

/* ////////////////////////////////
 ***   EDIT THE NAMES HERE   ***
//////////////////////////////// */
SET @FromChar='OldChar'
SET @ToChar='NewChar'

/* ////////////////////////////////
    DO NOT EDIT BELOW THIS LINE 
    UNLESS YOU KNOW WHAT YOUR 
	DOING. GO TO THE BOTTOM AND 
	SELECT OUTPUT FORMAT
//////////////////////////////// */
SET @ErrorRet=0
SET @FromChar=LTRIM(RTRIM(@FromChar));
SET @UserUID1=(SELECT UserUID FROM PS_GameData.dbo.Chars WHERE CharName COLLATE Latin1_General_CS_AS =@FromChar AND Del=0)
IF(@@ERROR<>0)
 BEGIN
  SET @ReturnMessage ='From character name is either not alive or spelled wrong. Try again.'
  SET @ErrorRet=1
 END 
SET @ToChar=LTRIM(RTRIM(@ToChar));
SET @UserUID2=(SELECT UserUID FROM PS_GameData.dbo.Chars WHERE CharName COLLATE Latin1_General_CS_AS =@ToChar AND Del=0) 
IF(@@ERROR<>0)
 BEGIN
  SET @ReturnMessage ='To character name is either not alive or spelled wrong. Try again.'
  SET @ErrorRet=2
 END
IF(@UserUID1=@UserUID2)
 BEGIN
  SET @FromK1=(SELECT K1 FROM PS_GameData.dbo.Chars WHERE CharName COLLATE Latin1_General_CS_AS =@FromChar) 
  SET @FromK2=(SELECT K2 FROM PS_GameData.dbo.Chars WHERE CharName COLLATE Latin1_General_CS_AS =@FromChar)
  UPDATE PS_GameData.dbo.Chars SET K1=K1+@FromK1, K2=K2+@FromK2 WHERE CharName COLLATE Latin1_General_CS_AS =@ToChar 
  IF @@ERROR <> 0
   BEGIN
	SET @ReturnMessage= 'Failed to add kills and deaths to ' +@ToChar
	SET @ErrorRet=3
   END
  ELSE
   BEGIN
	UPDATE PS_GameData.dbo.Chars SET K1=0, K2=0 WHERE CharName COLLATE Latin1_General_CS_AS =@FromChar 
	IF @@ERROR <> 0
	 BEGIN
	  SET @ReturnMessage= 'Failed to remove kills and deaths from ' +@FromChar
	  SET @ErrorRet=4
	 END
	ELSE
	 BEGIN
	  SET @ReturnMessage= 'SUCCESS - Kills : ' + CONVERT(varchar,@FromK1) + ' Deaths : ' + CONVERT(varchar,@FromK2) + ' - Has been transfered To : ' + @ToChar + ' From : ' +@FromChar
	  SET @ErrorRet=0
	 END
   END
 END
ELSE
 BEGIN
  SET @ReturnMessage='Both characters must be on the same account to transfer kills and deaths.'
  SET @ErrorRet=5
 END
/* ////////////////////////////////
	      SELECT OUTPUT 
       COMMENT THE LINE YOU 
	   DO NOT WANT TO USE
//////////////////////////////// */
PRINT @ReturnMessage
--SELECT @ErrorRet AS ReturnError
2. Usage

A. Character Names

To use this, locate this block of code...

Code:
/* ////////////////////////////////
 ***   EDIT THE NAMES HERE   ***
//////////////////////////////// */
SET @FromChar='OldChar'
SET @ToChar='NewChar'

/* ////////////////////////////////
Change the 2 names to the desired names. @FromChar will have all kills and deaths transferred to the @ToChar

B. Script Reply

Next you need to decide the style of output for this script. It has both text and error code replies.

Find this section at the bottom of the script.
Code:
/* ////////////////////////////////
	      SELECT OUTPUT 
       COMMENT THE LINE YOU 
	   DO NOT WANT TO USE
//////////////////////////////// */
PRINT @ReturnMessage
--SELECT @ErrorRet AS ReturnError
Add -- before the output you wish to NOT have displayed.

Thats it, a really simple but effective tool to transfer pvp stats between characters on the same account. I hope you enjoy.
01/24/2014 02:04 epicmyth#2
Tyvm for sharing, this will be an awesome option to offer other players
01/24/2014 08:52 bar2eldad#3
Thank you . Really Useful
Another Option for Player's
01/25/2014 11:59 Stureplan#4
That's a nice release now, I appreciate you still keep releasing useful stuff. Cheers!
02/03/2014 17:52 _Diavolino_#5
Its interesting, but when you transfert kill you should reset the stat and status of your rank, i means you transfert the kill and death from toon to an other one the oldtoon that is getting rank previoutly and got his point of rank untill he doesnt reset his points he will still get his points and to make new rank more easy ... in fact when you make the transfert 2 things : make reinitialisation of stat + rank status or when you make it delete old char...
so you could in both way add some function to make it.

Regards