--1. declare variables which are needed:
DECLARE @[I][B][URL="http://forum.ragezone.com/members/1333344765.html"]name[/URL][/B][/I] varchar(50) --the player name
DECLARE @[I][B][URL="http://forum.ragezone.com/members/508752.html"]TaG[/URL][/B][/I]lessname varchar(50) --the name without tag example: <Co>Peter => @[I][B][URL="http://forum.ragezone.com/members/508752.html"]TaG[/URL][/B][/I]lessname shall be Peter then
DECLARE @[I][B][URL="http://forum.ragezone.com/members/508752.html"]TaG[/URL][/B][/I] varchar(50) --shall take the tag <Co> for example
DECLARE @[I][B][URL="http://forum.ragezone.com/members/1333344765.html"]name[/URL][/B][/I]tag varchar(50)
DECLARE @[I][B][URL="http://forum.ragezone.com/members/185162.html"]honor[/URL][/B][/I]p int --shall check the actual honor points of a player
set @[I][B][URL="http://forum.ragezone.com/members/185162.html"]honor[/URL][/B][/I]p =(select HUPoint from Player where PID=@PID)
--2. check the players tag =>SUBSTRING(Name, 1, 5) will take the digits 1-5 of the name. Example <Co>Peter would be: <Co>P with <God>Peter it would be <God>
SET @[I][B][URL="http://forum.ragezone.com/members/508752.html"]TaG[/URL][/B][/I] = (SELECT SUBSTRING(Name, 1, 5) FROM Player where PID=@PID) --add your reborn tags with 3 digits in the <>
IF @[I][B][URL="http://forum.ragezone.com/members/508752.html"]TaG[/URL][/B][/I]='<God>')
begin
set @[I][B][URL="http://forum.ragezone.com/members/508752.html"]TaG[/URL][/B][/I]lessname=(SELECT SUBSTRING(Name, 6, 10) FROM Player where PID=@PID)
update Player set Name @[I][B][URL="http://forum.ragezone.com/members/508752.html"]TaG[/URL][/B][/I]lessname where PID=@PID
SET @[I][B][URL="http://forum.ragezone.com/members/1333430648.html"]Var[/URL][/B][/I]= 1
end
SET @[I][B][URL="http://forum.ragezone.com/members/508752.html"]TaG[/URL][/B][/I] = (SELECT SUBSTRING(Name, 1, 4) FROM Player where PID=@PID)
IF @[I][B][URL="http://forum.ragezone.com/members/508752.html"]TaG[/URL][/B][/I]='<GS>' OR @[I][B][URL="http://forum.ragezone.com/members/508752.html"]TaG[/URL][/B][/I]='<Co>' OR @[I][B][URL="http://forum.ragezone.com/members/508752.html"]TaG[/URL][/B][/I]='<Ca>' OR @[I][B][URL="http://forum.ragezone.com/members/508752.html"]TaG[/URL][/B][/I]='<Mj>' OR @[I][B][URL="http://forum.ragezone.com/members/508752.html"]TaG[/URL][/B][/I]='<Ch>') --add your reborn tags with 2 digits in the <>
begin
set @[I][B][URL="http://forum.ragezone.com/members/508752.html"]TaG[/URL][/B][/I]lessname=(SELECT SUBSTRING(Name, 5, 10) FROM Player where PID=@PID)
update Player set Name @[I][B][URL="http://forum.ragezone.com/members/508752.html"]TaG[/URL][/B][/I]lessname where PID=@PID
SET @[I][B][URL="http://forum.ragezone.com/members/1333430648.html"]Var[/URL][/B][/I]= 1
end
SET @[I][B][URL="http://forum.ragezone.com/members/508752.html"]TaG[/URL][/B][/I] = (SELECT SUBSTRING(Name, 1, 3) FROM Player where PID=@PID)
IF @[I][B][URL="http://forum.ragezone.com/members/508752.html"]TaG[/URL][/B][/I]='<S>' OR @[I][B][URL="http://forum.ragezone.com/members/508752.html"]TaG[/URL][/B][/I]='<L>' OR @[I][B][URL="http://forum.ragezone.com/members/508752.html"]TaG[/URL][/B][/I]='<C>' OR @[I][B][URL="http://forum.ragezone.com/members/508752.html"]TaG[/URL][/B][/I]='<G>' OR @[I][B][URL="http://forum.ragezone.com/members/508752.html"]TaG[/URL][/B][/I]='<M>') --add your reborn tags with 1 digit in the <>
begin
set @[I][B][URL="http://forum.ragezone.com/members/508752.html"]TaG[/URL][/B][/I]lessname=(SELECT SUBSTRING(Name, 4, 10) FROM Player where PID=@PID)
update Player set Name @[I][B][URL="http://forum.ragezone.com/members/508752.html"]TaG[/URL][/B][/I]lessname where PID=@PID
SET @[I][B][URL="http://forum.ragezone.com/members/1333430648.html"]Var[/URL][/B][/I]= 1
end
IF @[I][B][URL="http://forum.ragezone.com/members/1333375725.html"]Type[/URL][/B][/I] = 109 AND @[I][B][URL="http://forum.ragezone.com/members/858809.html"]ReM[/URL][/B][/I]ain = 5001 ) --GS Item
begin
UPDATE Player SET Name='<GS>'+[Name] where PID=@PID
end
IF @[I][B][URL="http://forum.ragezone.com/members/1333375725.html"]Type[/URL][/B][/I] = 109 AND @[I][B][URL="http://forum.ragezone.com/members/858809.html"]ReM[/URL][/B][/I]ain = 3380 AND @[I][B][URL="http://forum.ragezone.com/members/185162.html"]honor[/URL][/B][/I]p = 0 ) --Co --the check if @[I][B][URL="http://forum.ragezone.com/members/185162.html"]honor[/URL][/B][/I]p = 0 or = 1 in next ones it will check if you have the tag before your next tag. If you have <Co> the first time you get 1 honor point (Update Player SET HUPoint=1 WHERE PID=@PID). So you can not get the <S> tag before you had the <Co> tag etc.
begin
SET @[I][B][URL="http://forum.ragezone.com/members/508752.html"]TaG[/URL][/B][/I]lessname=(SELECT SUBSTRING(Name, 1, 10) FROM Player where PID=@PID)
SET @[I][B][URL="http://forum.ragezone.com/members/508752.html"]TaG[/URL][/B][/I] = '<Co>'
SET @[I][B][URL="http://forum.ragezone.com/members/1333430648.html"]Var[/URL][/B][/I] = 1
Update Player SET HUPoint=1 WHERE PID=@PID
end
ELSE IF @[I][B][URL="http://forum.ragezone.com/members/1333375725.html"]Type[/URL][/B][/I] = 109 AND @[I][B][URL="http://forum.ragezone.com/members/858809.html"]ReM[/URL][/B][/I]ain = 3381 AND @[I][B][URL="http://forum.ragezone.com/members/185162.html"]honor[/URL][/B][/I]p = 1 ) --S
begin
SET @[I][B][URL="http://forum.ragezone.com/members/508752.html"]TaG[/URL][/B][/I]lessname=(SELECT SUBSTRING(Name, 1, 10) FROM Player where PID=@PID)
SET @[I][B][URL="http://forum.ragezone.com/members/508752.html"]TaG[/URL][/B][/I] = '<S>'
SET @[I][B][URL="http://forum.ragezone.com/members/1333430648.html"]Var[/URL][/B][/I] = 1
Update Player SET HUPoint=2 WHERE PID=@PID
end
ELSE IF @[I][B][URL="http://forum.ragezone.com/members/1333375725.html"]Type[/URL][/B][/I] = 109 AND @[I][B][URL="http://forum.ragezone.com/members/858809.html"]ReM[/URL][/B][/I]ain = 3382 AND @[I][B][URL="http://forum.ragezone.com/members/185162.html"]honor[/URL][/B][/I]p = 2 ) --L
begin
SET @[I][B][URL="http://forum.ragezone.com/members/508752.html"]TaG[/URL][/B][/I]lessname=(SELECT SUBSTRING(Name, 1, 10) FROM Player where PID=@PID)
SET @[I][B][URL="http://forum.ragezone.com/members/508752.html"]TaG[/URL][/B][/I] = '<L>'
SET @[I][B][URL="http://forum.ragezone.com/members/1333430648.html"]Var[/URL][/B][/I] = 1
Update Player SET HUPoint=3 WHERE PID=@PID
end
ELSE IF @[I][B][URL="http://forum.ragezone.com/members/1333375725.html"]Type[/URL][/B][/I] = 109 AND @[I][B][URL="http://forum.ragezone.com/members/858809.html"]ReM[/URL][/B][/I]ain = 3383 AND @[I][B][URL="http://forum.ragezone.com/members/185162.html"]honor[/URL][/B][/I]p = 3 ) --Ca
begin
SET @[I][B][URL="http://forum.ragezone.com/members/508752.html"]TaG[/URL][/B][/I]lessname=(SELECT SUBSTRING(Name, 1, 10) FROM Player where PID=@PID)
SET @[I][B][URL="http://forum.ragezone.com/members/508752.html"]TaG[/URL][/B][/I] = '<Ca>'
SET @[I][B][URL="http://forum.ragezone.com/members/1333430648.html"]Var[/URL][/B][/I] = 1
Update Player SET HUPoint=4 WHERE PID=@PID
end
ELSE IF @[I][B][URL="http://forum.ragezone.com/members/1333375725.html"]Type[/URL][/B][/I] = 109 AND @[I][B][URL="http://forum.ragezone.com/members/858809.html"]ReM[/URL][/B][/I]ain = 3384 AND @[I][B][URL="http://forum.ragezone.com/members/185162.html"]honor[/URL][/B][/I]p = 4 ) --Mj
begin
SET @[I][B][URL="http://forum.ragezone.com/members/508752.html"]TaG[/URL][/B][/I]lessname=(SELECT SUBSTRING(Name, 1, 10) FROM Player where PID=@PID)
SET @[I][B][URL="http://forum.ragezone.com/members/508752.html"]TaG[/URL][/B][/I] = '<Mj>'
SET @[I][B][URL="http://forum.ragezone.com/members/1333430648.html"]Var[/URL][/B][/I] = 1
Update Player SET HUPoint=5 WHERE PID=@PID
end
ELSE IF @[I][B][URL="http://forum.ragezone.com/members/1333375725.html"]Type[/URL][/B][/I] = 109 AND @[I][B][URL="http://forum.ragezone.com/members/858809.html"]ReM[/URL][/B][/I]ain = 3385 AND @[I][B][URL="http://forum.ragezone.com/members/185162.html"]honor[/URL][/B][/I]p = 5 ) --C
begin
SET @[I][B][URL="http://forum.ragezone.com/members/508752.html"]TaG[/URL][/B][/I]lessname=(SELECT SUBSTRING(Name, 1, 10) FROM Player where PID=@PID)
SET @[I][B][URL="http://forum.ragezone.com/members/508752.html"]TaG[/URL][/B][/I] = '<C>'
SET @[I][B][URL="http://forum.ragezone.com/members/1333430648.html"]Var[/URL][/B][/I] = 1
Update Player SET HUPoint=6 WHERE PID=@PID
end
ELSE IF @[I][B][URL="http://forum.ragezone.com/members/1333375725.html"]Type[/URL][/B][/I] = 109 AND @[I][B][URL="http://forum.ragezone.com/members/858809.html"]ReM[/URL][/B][/I]ain = 3386 AND @[I][B][URL="http://forum.ragezone.com/members/185162.html"]honor[/URL][/B][/I]p = 6 ) --G
begin
SET @[I][B][URL="http://forum.ragezone.com/members/508752.html"]TaG[/URL][/B][/I]lessname=(SELECT SUBSTRING(Name, 1, 10) FROM Player where PID=@PID)
SET @[I][B][URL="http://forum.ragezone.com/members/508752.html"]TaG[/URL][/B][/I] = '<G>'
SET @[I][B][URL="http://forum.ragezone.com/members/1333430648.html"]Var[/URL][/B][/I] = 1
Update Player SET HUPoint=7 WHERE PID=@PID
end
ELSE IF @[I][B][URL="http://forum.ragezone.com/members/1333375725.html"]Type[/URL][/B][/I] = 109 AND @[I][B][URL="http://forum.ragezone.com/members/858809.html"]ReM[/URL][/B][/I]ain = 3387 AND @[I][B][URL="http://forum.ragezone.com/members/185162.html"]honor[/URL][/B][/I]p = 7 ) --M
begin
SET @[I][B][URL="http://forum.ragezone.com/members/508752.html"]TaG[/URL][/B][/I]lessname=(SELECT SUBSTRING(Name, 1, 10) FROM Player where PID=@PID)
SET @[I][B][URL="http://forum.ragezone.com/members/508752.html"]TaG[/URL][/B][/I] = '<M>'
SET @[I][B][URL="http://forum.ragezone.com/members/1333430648.html"]Var[/URL][/B][/I] = 1
Update Player SET HUPoint=8 WHERE PID=@PID
end
ELSE IF @[I][B][URL="http://forum.ragezone.com/members/1333375725.html"]Type[/URL][/B][/I] = 109 AND @[I][B][URL="http://forum.ragezone.com/members/858809.html"]ReM[/URL][/B][/I]ain = 3388 AND @[I][B][URL="http://forum.ragezone.com/members/185162.html"]honor[/URL][/B][/I]p = 8 ) --Ch
begin
SET @[I][B][URL="http://forum.ragezone.com/members/508752.html"]TaG[/URL][/B][/I]lessname=(SELECT SUBSTRING(Name, 1, 10) FROM Player where PID=@PID)
SET @[I][B][URL="http://forum.ragezone.com/members/508752.html"]TaG[/URL][/B][/I] = '<Ch>'
SET @[I][B][URL="http://forum.ragezone.com/members/1333430648.html"]Var[/URL][/B][/I] = 1
Update Player SET HUPoint=9 WHERE PID=@PID
end
ELSE IF @[I][B][URL="http://forum.ragezone.com/members/1333375725.html"]Type[/URL][/B][/I] = 109 AND @[I][B][URL="http://forum.ragezone.com/members/858809.html"]ReM[/URL][/B][/I]ain = 3389 AND @[I][B][URL="http://forum.ragezone.com/members/185162.html"]honor[/URL][/B][/I]p = 9 ) --God
begin
SET @[I][B][URL="http://forum.ragezone.com/members/508752.html"]TaG[/URL][/B][/I]lessname=(SELECT SUBSTRING(Name, 1, 10) FROM Player where PID=@PID)
SET @[I][B][URL="http://forum.ragezone.com/members/508752.html"]TaG[/URL][/B][/I] = '<God>'
SET @[I][B][URL="http://forum.ragezone.com/members/1333430648.html"]Var[/URL][/B][/I] = 1
Update Player SET HUPoint=10 WHERE PID=@PID
end
--in the end of SP:
declare @PIDI int
SET @[I][B][URL="http://forum.ragezone.com/members/1333344765.html"]name[/URL][/B][/I]tag = (SELECT TOP 1 Player.Name from Player where HUPoint > 0 AND Name NOT LIKE '<%' ORDER by PID DESC)
SET @PIDI = (SELECT PID FROM Player WHERE Name @[I][B][URL="http://forum.ragezone.com/members/1333344765.html"]name[/URL][/B][/I]tag)
IF @[I][B][URL="http://forum.ragezone.com/members/185162.html"]honor[/URL][/B][/I]p = 1) --if any mistake happened during the namechanging, in these cases the tag will be set correctly again.
begin
SET @[I][B][URL="http://forum.ragezone.com/members/508752.html"]TaG[/URL][/B][/I] = '<Co>'
end
ELSE IF @[I][B][URL="http://forum.ragezone.com/members/185162.html"]honor[/URL][/B][/I]p = 2)
begin
SET @[I][B][URL="http://forum.ragezone.com/members/508752.html"]TaG[/URL][/B][/I] = '<S>'
end
ELSE IF @[I][B][URL="http://forum.ragezone.com/members/185162.html"]honor[/URL][/B][/I]p = 3)
begin
SET @[I][B][URL="http://forum.ragezone.com/members/508752.html"]TaG[/URL][/B][/I] = '<L>'
end
ELSE IF @[I][B][URL="http://forum.ragezone.com/members/185162.html"]honor[/URL][/B][/I]p = 4)
begin
SET @[I][B][URL="http://forum.ragezone.com/members/508752.html"]TaG[/URL][/B][/I] = '<Ca>'
end
ELSE IF @[I][B][URL="http://forum.ragezone.com/members/185162.html"]honor[/URL][/B][/I]p = 5)
begin
SET @[I][B][URL="http://forum.ragezone.com/members/508752.html"]TaG[/URL][/B][/I] = '<Mj>'
end
ELSE IF @[I][B][URL="http://forum.ragezone.com/members/185162.html"]honor[/URL][/B][/I]p = 6)
begin
SET @[I][B][URL="http://forum.ragezone.com/members/508752.html"]TaG[/URL][/B][/I] = '<C>'
end
ELSE IF @[I][B][URL="http://forum.ragezone.com/members/185162.html"]honor[/URL][/B][/I]p = 7)
begin
SET @[I][B][URL="http://forum.ragezone.com/members/508752.html"]TaG[/URL][/B][/I] = '<G>'
end
ELSE IF @[I][B][URL="http://forum.ragezone.com/members/185162.html"]honor[/URL][/B][/I]p = 8)
begin
SET @[I][B][URL="http://forum.ragezone.com/members/508752.html"]TaG[/URL][/B][/I] = '<M>'
end
ELSE IF @[I][B][URL="http://forum.ragezone.com/members/185162.html"]honor[/URL][/B][/I]p = 9)
begin
SET @[I][B][URL="http://forum.ragezone.com/members/508752.html"]TaG[/URL][/B][/I] = '<Ch>'
end
ELSE IF @[I][B][URL="http://forum.ragezone.com/members/185162.html"]honor[/URL][/B][/I]p = 10)
begin
SET @[I][B][URL="http://forum.ragezone.com/members/508752.html"]TaG[/URL][/B][/I] = '<God>'
end
ELSE IF @[I][B][URL="http://forum.ragezone.com/members/185162.html"]honor[/URL][/B][/I]p = 100)
begin
SET @[I][B][URL="http://forum.ragezone.com/members/508752.html"]TaG[/URL][/B][/I] = '<GS>'
end
IF @[I][B][URL="http://forum.ragezone.com/members/185162.html"]honor[/URL][/B][/I]p <> 0)
begin
Update Player set Name @[I][B][URL="http://forum.ragezone.com/members/508752.html"]TaG[/URL][/B][/I] + @[I][B][URL="http://forum.ragezone.com/members/1333344765.html"]name[/URL][/B][/I]tag WHERE HUPoint > 0 AND Name NOT LIKE '<%' AND PID=@PIDI --this is the actual namechange where the @[I][B][URL="http://forum.ragezone.com/members/508752.html"]TaG[/URL][/B][/I] defined depending on how many honor points you have will be set in front of the @[I][B][URL="http://forum.ragezone.com/members/1333344765.html"]name[/URL][/B][/I]tag which is defined above. WHERE HUPoint >0 only and Name NOT LIKE '<%' will check if you already have a nametag by mistake.
INSERT INTO BuffRemain ( [PID], [Type], [Remain] ) VALUES ( @PID, @[I][B][URL="http://forum.ragezone.com/members/1333375725.html"]Type[/URL][/B][/I], @[I][B][URL="http://forum.ragezone.com/members/858809.html"]ReM[/URL][/B][/I]ain )
end
ELSE
begin
INSERT INTO BuffRemain ( [PID], [Type], [Remain] ) VALUES ( @PID, @[I][B][URL="http://forum.ragezone.com/members/1333375725.html"]Type[/URL][/B][/I], @[I][B][URL="http://forum.ragezone.com/members/858809.html"]ReM[/URL][/B][/I]ain )
end
end