Need explanation on addTaggedString in setPlayerName
by elvince · in Torque 3D Professional · 08/28/2009 (4:11 am) · 4 replies
Hi all,
In this function, we are setting the nameBase and PlayerName properties of Client.
When this function is used, the playername is clearly not what I input.
Ex: %name="Poser"
if I do an echo :
echo("\cp\c8" @ %name @ "\co"); => /cp/c11Poser/co
echo(%client.playerName);=> /c010
For reference the C++ function.
Sorry I have no clue if its a bug or that /Co10 refers to the tag string so if I want to have the real name I have to read the basename property and that playerName should be only used if we send the info to the client.
Thanks for your help,
In this function, we are setting the nameBase and PlayerName properties of Client.
When this function is used, the playername is clearly not what I input.
function GameConnection::setPlayerName(%client,%name)...
%client.playerName = addTaggedString("\cp\c8" @ %name @ "\co");Ex: %name="Poser"
if I do an echo :
echo("\cp\c8" @ %name @ "\co"); => /cp/c11Poser/co
echo(%client.playerName);=> /c010
For reference the C++ function.
ConsoleFunction( addTaggedString, const char*, 2, 2, "(string str)")
{
NetStringHandle s(argv[1]);
gNetStringTable->incStringRefScript(s.getIndex());
char *ret = Con::getReturnBuffer(10);
ret[0] = StringTagPrefixByte;
dSprintf(ret + 1, 9, "%d", s.getIndex());
return ret;
}Sorry I have no clue if its a bug or that /Co10 refers to the tag string so if I want to have the real name I have to read the basename property and that playerName should be only used if we send the info to the client.
Thanks for your help,
About the author
Recent Threads
#2
I'm not sure I follow you on this point.
I understand the /CX color, but this is case the playername="/c010"
and that's all.
So if I'm not sure how to use this variable. does the /c010 is refering to the taggedstring "10"? so if I use it on the network, it is translated, but if I want to echo it it's not usable?
More, I don't understand why the echo echo("\cp\c8" @ %name @ "\co"); = /cp/c11Poser/co means \c8 ove to \c11.
Thanks,
08/28/2009 (3:32 pm)
Aun,I'm not sure I follow you on this point.
I understand the /CX color, but this is case the playername="/c010"
and that's all.
So if I'm not sure how to use this variable. does the /c010 is refering to the taggedstring "10"? so if I use it on the network, it is translated, but if I want to echo it it's not usable?
More, I don't understand why the echo echo("\cp\c8" @ %name @ "\co"); = /cp/c11Poser/co means \c8 ove to \c11.
Thanks,
#3
Simply use detag() on any variable containing a tagged string and you should get the contents.
Any string that comes from the server is going to be tagged typically.
08/28/2009 (3:45 pm)
A tagged string should be handled by the engine for any data received over the network. So likely setPlayerName is called on the gameconnection when it receives the player info from the server. Not certain about this but it seems logical.Simply use detag() on any variable containing a tagged string and you should get the contents.
Any string that comes from the server is going to be tagged typically.
#4
I looked in TGEA Documentation to get advice
docs.garagegames.com/tgea/official/content/documentation/Scripting%20Reference/C...
The detag can only be used in the proper context, i.e. to parse values passed to a client command or to a server command.
So that means, if I want to use this on the server but this has not been send via a command this not usable.
Try to do a echo(detag(%client.playerName)); just after the addTaggedString and result is "".
Any idea why echo("cpc8" @ %name @ "co"); give /cp/c11Poser/co?
I thing I do understand better the use of those "network only" functions
08/28/2009 (4:13 pm)
Thanks BrettI looked in TGEA Documentation to get advice
docs.garagegames.com/tgea/official/content/documentation/Scripting%20Reference/C...
The detag can only be used in the proper context, i.e. to parse values passed to a client command or to a server command.
So that means, if I want to use this on the server but this has not been send via a command this not usable.
Try to do a echo(detag(%client.playerName)); just after the addTaggedString and result is "".
Any idea why echo("cpc8" @ %name @ "co"); give /cp/c11Poser/co?
I thing I do understand better the use of those "network only" functions
Torque 3D Owner Aun Taraseina
So you create a Gui Profile with
new GuiControlProfile (aProfile) { fontColors[1] = "0 255 0"; // --> color value for "/c1" fontColors[2] = "255 0 0"; // --> color value for "/c2" }Assign this profile to your "GuiMessageVectorCtrl"
So now when there's a text added to the "GuiMessageVectorCtrl" with
"/c1" it will appear in green. And if the color tag is "/c2" it will appear in red.
Hope that helps.
Aun.