help auto tag item

08/23/2019 19:29 [GameAdvisor]Finn#1
Hi epvp, can i ask if someone help me to fix this..
i have Auto Tag using scroll item
example :

but the problem .. how can replace new tag if already have [King] Tag on charname? example my character already have [King] tag.. then i use again another auto tag item call [King-II] .. how can i replace [King] tag if already exist.. i hope have someone help me .. thanks in advance..
08/23/2019 23:56 sominus#2
May be you could use CHARINDEX() and SUBSTRING(), to remove the [King] tag (if exist), and then apply the new tag.

Try this test

Code:
DECLARE 
 [MENTION=984633]current[/MENTION]Nick NVARCHAR(30),
 [MENTION=4843871]NewNick[/MENTION] nvarchar(30),
 [MENTION=1332308]Closet[/MENTION]ag NVARCHAR(1),
 [MENTION=3014117]nickle[/MENTION]nght INT,
 [MENTION=4351196]TAGIN[/MENTION]dex INT

SET [MENTION=984633]current[/MENTION]Nick = '[King]Akira' --example nick

SET [MENTION=1332308]Closet[/MENTION]ag = ']' --no need to find the opening tag '[' 

set [MENTION=4351196]TAGIN[/MENTION]dex = CHARINDEX [MENTION=1332308]Closet[/MENTION]ag [MENTION=984633]current[/MENTION]Nick) --where is ']' in the string
set [MENTION=3014117]nickle[/MENTION]nght = len [MENTION=984633]current[/MENTION]Nick) --nick lenght

if [MENTION=4351196]TAGIN[/MENTION]dex > 0 --if current nick has a ']'
BEGIN
	set [MENTION=4843871]NewNick[/MENTION] = SUBSTRING [MENTION=984633]current[/MENTION]Nick, [MENTION=4351196]TAGIN[/MENTION]dex + 1, [MENTION=3014117]nickle[/MENTION]nght) --take the nick without the [xxx]
	set [MENTION=4843871]NewNick[/MENTION] = '[King II]' + [MENTION=4843871]NewNick[/MENTION] --apply a new tag
END
		ELSE --if current nick doesn't have a tag at all
				BEGIN
					set [MENTION=4843871]NewNick[/MENTION] = '[King I]'+ [MENTION=984633]current[/MENTION]nick
				END

print [MENTION=4843871]NewNick[/MENTION] --to check result
08/24/2019 00:37 Cups#3
Another way would be to make a seperate column which is only used for tags, and then in the procedure that selects character details, just concatenate the two strings to form a display name
08/24/2019 05:09 [GameAdvisor]Finn#4
Quote:
Originally Posted by sominus View Post
May be you could use CHARINDEX() and SUBSTRING(), to remove the [King] tag (if exist), and then apply the new tag.

Try this test

Code:
DECLARE 
 [MENTION=984633]current[/MENTION]Nick NVARCHAR(30),
 [MENTION=4843871]NewNick[/MENTION] nvarchar(30),
 [MENTION=1332308]Closet[/MENTION]ag NVARCHAR(1),
 [MENTION=3014117]nickle[/MENTION]nght INT,
 [MENTION=4351196]TAGIN[/MENTION]dex INT

SET [MENTION=984633]current[/MENTION]Nick = '[King]Akira' --example nick

SET [MENTION=1332308]Closet[/MENTION]ag = ']' --no need to find the opening tag '[' 

set [MENTION=4351196]TAGIN[/MENTION]dex = CHARINDEX [MENTION=1332308]Closet[/MENTION]ag [MENTION=984633]current[/MENTION]Nick) --where is ']' in the string
set [MENTION=3014117]nickle[/MENTION]nght = len [MENTION=984633]current[/MENTION]Nick) --nick lenght

if [MENTION=4351196]TAGIN[/MENTION]dex > 0 --if current nick has a ']'
BEGIN
	set [MENTION=4843871]NewNick[/MENTION] = SUBSTRING [MENTION=984633]current[/MENTION]Nick, [MENTION=4351196]TAGIN[/MENTION]dex + 1, [MENTION=3014117]nickle[/MENTION]nght) --take the nick without the [xxx]
	set [MENTION=4843871]NewNick[/MENTION] = '[King II]' + [MENTION=4843871]NewNick[/MENTION] --apply a new tag
END
		ELSE --if current nick doesn't have a tag at all
				BEGIN
					set [MENTION=4843871]NewNick[/MENTION] = '[King I]'+ [MENTION=984633]current[/MENTION]nick
				END

print [MENTION=4843871]NewNick[/MENTION] --to check result
i removed all MENTION and /MENTION and try to insert on action_log_e but got error..

can you help me how to work this? thanks bro..

Quote:
Originally Posted by Cups View Post
Another way would be to make a seperate column which is only used for tags, and then in the procedure that selects character details, just concatenate the two strings to form a display name
can you help me how to do that sir Cups.. thank you..
08/24/2019 19:07 SnickQ#5
Quote:
Originally Posted by [GameAdvisor]Finn View Post

can you help me how to work this? thanks bro..



can you help me how to do that sir Cups.. thank you..
You really need help with that basic thing?

Quote:
ALTER TABLE Chars
ADD CharName_OLD varchar(30); --Name it as you want
Quote:

DECLARE @CNAme varchar(30)
DECLARE @CNAme_OLD varchar(30)

SET @CNAme = (SELECT CharName FROM PS_GameData.dbo.Chars WHERE CharID = @ChariD)
SET @CNAme_OLD = (SELECT CharName_OLD FROM PS_GameData.dbo.Chars WHERE CharID = @ChariD)

if(@ActionType=112 AND @value2=101015)
BEGIN

UPDATE PS_GameData.dbo.Chars SET CharName_OLD = @CNAme WHERE CharID = @ChariD

UPDATE PS_GameData.dbo.Chars SET CharName = '[King]' + @CNAme_OLD WHERE CharID = @ChariD
UPDATE PS_GameData.dbo.Guilds SET MasterName = '[King]' + @CNAme_OLD WHERE MasterCharID = @ChariD
UPDATE PS_GameData.dbo.FriendChars SET FriendName = '[King]' + @CNAme_OLD WHERE FriendID = @ChariD
END
And when player want change name then change CharName_OLD without tag and CharName with tag
08/24/2019 22:02 [GameAdvisor]Finn#6
Quote:
Originally Posted by SnickQ View Post
You really need help with that basic thing?





And when player want change name then change CharName_OLD without tag and CharName with tag
i try this but they have a problem..
- on first use of item no effect on CharName because no value CharName_OLD and they change only on first use
- on 2nd use of item its effect the Change of CharName because they already have value on CharName_OLD
- on 3rd time to use i change the Tag to [KingII] as test if i make another tag item and when i use.. its effect the change of CharName to [KingII]myCharname..
- on fourth time to use Tag called [God] as test again if i make 3rd tag item but the result is [God]+my CharName_OLD = [God][KingII]myCharname..


so that's the problem on this code sir.. i think on this code if we add CharName_OLD table if we make a new character they copy the CharName too on CharName_OLD so if we use item tag they effect on first use.. and about 3rd and so on.. tag item they give a problem like on fourth time i use..
but thanks for this.. i hope they can fixed also..
08/25/2019 00:56 SnickQ#7
Add Tag columin

Quote:

ALTER TABLE Chars
ADD Tag varchar(30);
And try this:

Quote:

DECLARE @CNAme varchar(30)
DECLARE @Tag varchar(30) = (SELECT Tag FROM PS_GameData.dbo.Chars WHERE CharID = @ChariD)
DECLARE @CNAme_OLD varchar(30) = (SELECT CharName_OLD FROM PS_GameData.dbo.Chars WHERE CharID = @ChariD)

SET @CNAme = (SELECT CharName FROM PS_GameData.dbo.Chars WHERE CharID = @ChariD)

if(@ActionType=112 AND @value2=101015)
BEGIN

if exists (Select Tag from Chars where CharID=@CharID and Tag is null)
begin
UPDATE PS_GameData.dbo.Chars
SET CharName_OLD = @CNAme
Where CharID = @CharID

UPDATE PS_GameData.dbo.Chars SET Tag = '[King]' WHERE CharID = @ChariD
UPDATE PS_GameData.dbo.Chars SET CharName = '[King]' + @CNAme WHERE CharID = @ChariD
UPDATE PS_GameData.dbo.Guilds SET MasterName = '[King]' + @CNAme WHERE MasterCharID = @ChariD
UPDATE PS_GameData.dbo.FriendChars SET FriendName = '[King]' + @CNAme WHERE FriendID = @ChariD
end


if (@Tag ='[King]')
begin

UPDATE PS_GameData.dbo.Chars SET CharName = '[KingII]' + @CNAme_OLD WHERE CharID = @ChariD
UPDATE PS_GameData.dbo.Guilds SET MasterName = '[KingII]' + @CNAme_OLD WHERE MasterCharID = @ChariD
UPDATE PS_GameData.dbo.FriendChars SET FriendName = '[KingII]' + @CNAme_OLD WHERE FriendID = @ChariD
UPDATE PS_GameData.dbo.Chars SET Tag = '[KingII]' WHERE CharID = @ChariD
end

if (@Tag ='[KingII]')
begin

UPDATE PS_GameData.dbo.Chars SET CharName = '[KingIII]' + @CNAme_OLD WHERE CharID = @ChariD
UPDATE PS_GameData.dbo.Guilds SET MasterName = '[KingIII]' + @CNAme_OLD WHERE MasterCharID = @ChariD
UPDATE PS_GameData.dbo.FriendChars SET FriendName = '[KingIII]' + @CNAme_OLD WHERE FriendID = @ChariD
UPDATE PS_GameData.dbo.Chars SET Tag = '[KingIII]' WHERE CharID = @ChariD
end

END
08/25/2019 04:35 [GameAdvisor]Finn#8
Quote:
Originally Posted by SnickQ View Post
Add Tag columin



And try this:
No work sir.. i use the items 5x but still no change and i check chars table still no value on CharName_OLD and Tag even i use the item 5x
08/25/2019 12:17 Mike__#9
I made something like this before and i guess you can figure it out from here.


Note: My suggestion is to create a new table that will save the original character's name prior to adding TAGS because with this type of editing that you are doing, it will edit the actual Character Name, thus, if player for example has name 'MIKE' then get that [TAG]MIKE', then when someone uses the created a new character or rename to while your tag system is applied, 'MIKE' name they will taken.

Good luck!
08/25/2019 12:47 [GameAdvisor]Finn#10
Thanks to all reply i already figure out how its work properly using @[Only registered and activated users can see links. Click Here To Register...] codes..

First i go on PS_GameData.dbo.Chars and make new table called CharName_OLD then
Second i go PS_GameData.dbo.usp.Create_Char_R and add CharName_OLD on INSERT and @[Only registered and activated users can see links. Click Here To Register...] on VALUES so if i make new Character New Table have my CharName too..

then i go to PS_GameLog.usp.Action_Log_E and Insert This

Now its work properly.. and thanks to all people helping me,
08/25/2019 14:49 SnickQ#11
No need to use Create_Char for it
In my code was mistake
It was:
Quote:
if exists (Select Tag from Chars where CharID=@CharID and Tag is null)
But shoul be:
Quote:
if exists (Select Tag from PS_GameData.dbo.Chars where CharID=@CharID and Tag is null)
I tested it as query with PS_GameData and i forgot it is PS_GameLog
08/25/2019 15:52 [GameAdvisor]Finn#12
Quote:
Originally Posted by SnickQ View Post
No need to use Create_Char for it
In my code was mistake
It was:


But shoul be:


I tested it as query with PS_GameData and i forgot it is PS_GameLog
yes sir but i think that is for 1 tag item only..
because i want to make different item with different tag so that's why i add on Create_Char so its automatic add new CharName on CharName_OLD table

and i already test with different tag item and its work..
08/25/2019 17:09 SnickQ#13
In your case you have to add to Name Stone Change update part

Open Proc [dbo].[usp_Save_Char_Name_E]

and find this:
Quote:
UPDATE Chars SET CharName=@NewCharName,RenameCnt=RenameCnt-1,OldCharName=@OldCharName WHERE CharID=@CharID AND Del=0
IF @@ERROR <> 0
BEGIN
GOTO ERROR_ROLLBACK
END
And change it to:

Quote:
UPDATE Chars SET CharName=@NewCharName,RenameCnt=RenameCnt-1,OldCharName=@OldCharName, CharName_OLD = @NewCharName WHERE CharID=@CharID AND Del=0
IF @@ERROR <> 0
BEGIN
GOTO ERROR_ROLLBACK
END

DECLARE @Tag varchar(30) = (Select Tag from Chars where CharID = @CharID)

if exists (Select Tag from Chars where CharID=@CharID and Tag is not null)
begin
UPDATE PS_GameData.dbo.Chars
SET CharName = @Tag + @NewCharName
Where CharID = @CharID
end
With this when players use Name Stone their tag will be added automatically but to see it they have to re open game.exe
08/25/2019 17:37 [GameAdvisor]Finn#14
Quote:
Originally Posted by SnickQ View Post
In your case you have to add to Name Stone Change update part

Open Proc [dbo].[usp_Save_Char_Name_E]

and find this:


And change it to:



With this when players use Name Stone their tag will be added automatically but to see it they have to re open game.exe
Thanks sir.. you help me lot..

i choose to use this only.. because name change stone is normal change name.. so i make it different on tag item.. so if player want to removed their tag.. he can use name change stone..

08/25/2019 17:55 SnickQ#15
Quote:
Originally Posted by [GameAdvisor]Finn View Post
Thanks sir.. you help me lot..

i choose to use this only.. because name change stone is normal change name.. so i make it different on tag item.. so if player want to removed their tag.. he can use name change stone..
You can make a new stone that will remove the tag