SQL buffmagic ~ namechange

off@kal. - on@gw2/d3 :)
Decennium
Joined
May 30, 2009
Messages
773
Reaction score
481
hey guys, im out of idea how i get it worked, so here is my question.

im goin to do a new sys for kal, and have only one think left, is the namechange (like reborn but only via sql path)

how it should work =>

eat item ingame with type & remain, and update the name in player.db to <xx>name.

is not a big deal, but i never was an sql pro, so i hope some1 can help me out :-) thanks
 
This is my honor tag and GS system:
Code:
;GS item:
(item (name 3350)(Desc 3350) (Index 3353) (Image "itemgs")(class general etc)(code 4 8 0 0)(country 2)(use 1)(plural 1)(cooltime 100)(buy 0)(effect 23)(specialty (Buff 109 5001 0) ))
;Honor tags:
;tags
;1 Corporal <Co>
(item (name 3380)(Desc 3380) (Index 3380) (Image "itemhonorCo")(class general etc)(code 4 8 0 0)(country 2)(use 1)(plural 1)(cooltime 100)(buy 0)(effect 23)(specialty (Buff 109 3380 0) ))
;5 Sergeant <S>
(item (name 3381)(Desc 3381) (Index 3381) (Image "itemhonorS")(class general etc)(code 4 8 0 0)(country 2)(use 1)(plural 1)(cooltime 100)(buy 0)(effect 23)(specialty (Buff 109 3381 0) ))
;10 Lieutenant <L>
(item (name 3382)(Desc 3382) (Index 3382) (Image "itemhonorL")(class general etc)(code 4 8 0 0)(country 2)(use 1)(plural 1)(cooltime 100)(buy 0)(effect 23)(specialty (Buff 109 3382 0) ))
;15 Captain <Ca>
(item (name 3383)(Desc 3383) (Index 3383) (Image "itemhonorCa")(class general etc)(code 4 8 0 0)(country 2)(use 1)(plural 1)(cooltime 100)(buy 0)(effect 23)(specialty (Buff 109 3383 0) ))
;20 Major <Mj>
(item (name 3384)(Desc 3384) (Index 3384) (Image "itemhonorMj")(class general etc)(code 4 8 0 0)(country 2)(use 1)(plural 1)(cooltime 100)(buy 0)(effect 23)(specialty (Buff 109 3384 0) ))
;25 Colonel <C>
(item (name 3385)(Desc 3385) (Index 3385) (Image "itemhonorC")(class general etc)(code 4 8 0 0)(country 2)(use 1)(plural 1)(cooltime 100)(buy 0)(effect 23)(specialty (Buff 109 3385 0) ))
;30 General <G>
(item (name 3386)(Desc 3386) (Index 3386) (Image "itemhonorG")(class general etc)(code 4 8 0 0)(country 2)(use 1)(plural 1)(cooltime 100)(buy 0)(effect 23)(specialty (Buff 109 3386 0) ))
;50 Marshal <M>
(item (name 3387)(Desc 3387) (Index 3387) (Image "itemhonorM")(class general etc)(code 4 8 0 0)(country 2)(use 1)(plural 1)(cooltime 100)(buy 0)(effect 23)(specialty (Buff 109 3387 0) ))
;100 Champion <Ch>
(item (name 3388)(Desc 3388) (Index 3388) (Image "itemhonorCh")(class general etc)(code 4 8 0 0)(country 2)(use 1)(plural 1)(cooltime 100)(buy 0)(effect 23)(specialty (Buff 109 3388 0) ))
;200 God <God>
(item (name 3389)(Desc 3389) (Index 3389) (Image "itemhonorGod")(class general etc)(code 4 8 0 0)(country 2)(use 1)(plural 1)(cooltime 100)(buy 0)(effect 23)(specialty (Buff 109 3389 0) ))
SP:
Code:
--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

So what is this part doing at all? 1. it differs your name + your tag into different vars. 2. It will set the TaG depending on what tag you should get. 3. it changes the name to tag +name.

Any questions? hope this helped. Some stuff of this is not necessary at all but i like to ensure and doublecheck some stuffs.

Kind Regards,

Uppa
 
Upvote 0
Back