Author Topic: Trouble with changing text color  (Read 1789 times)

This might seem like a stupid question, but I've been having trouble making a simple addon. It adds the channel before your message and I've been trying to make it so the channel name is a different color. Everything I've done hasn't worked. Any help would be greatly appreciated.

Also is there a way to include a bunch of strings without having to make multiple variables for each one?

Code: [Select]
package Chat
{
    function serverCmdOOC(%client,%msg)
    {
        %msg = "\c2 [OOC]:\c6" @ %msg;
        Parent::serverCmdMessageSent(%Client , %msg);
    }
};
ActivatePackage(Chat);


Pretty sure serverCmdMessageSent recolors it back to white and yellow.

Code: [Select]
package Chat
{
    function serverCmdOOC(%client,%msg)
    {
        messageAll('',"\c2[OOC]:\c3" SPC %client.name @ "\c6:" SPC %msg);
    }
};
ActivatePackage(Chat);

Pretty sure that would work

Pretty sure serverCmdMessageSent recolors it back to white and yellow.

Code: [Select]
package Chat
{
    function serverCmdOOC(%client,%msg)
    {
        messageAll('',"\c2[OOC]:\c3" SPC %client.name @ "\c6:" SPC %msg);
    }
};
ActivatePackage(Chat);

Pretty sure that would work

Thanks, I honestly don't know much about what I'm doing in torque. Well besides basics so thanks for the help.


So to do more than one string I'll have to use multiple %msg variables?



Thanks, I honestly don't know much about what I'm doing in torque. Well besides basics so thanks for the help.


So to do more than one string I'll have to use multiple %msg variables?



That's a major pet peeve with me and Blockland, creating new chat functions is nearly impossible because of the way strings work, you can't just get the rest of them without declaring them in the function.  To get more than the first word you would have to do:

serverCmdOOC(%client,%msg,%msg1,%msg2,%msg3,etc);

edit;
hold the phone, I may have figured something out

I was thinking maybe an array?

Aha!

I've cracked my own little case.

If you edit echo %msg in serverCmdMessageSent it will return the full string of what the player said, thus meaning you have the entire phrase, you can then send this out to another function just doing functionname(%msg);

Let me write up a quick way to do this

Alright, I've done it

Code: [Select]
package Testing
{
function serverCmdMessageSent(%Client,%msg)
{
if(!%client.chat)
{
functionName(%msg);
}
else
{
parent::serverCmdMessageSent(%Client,%msg);
}
}

function functionName(%msg)
{
messageAll('',%msg);
}
};
ActivatePackage(Testing);

Doing this, if %Client.chat is set to one it will allow the player to talk normally through chat, if it is any other value it will route to using "functionName" and it will also return the full amount of words.

So how would I make it so you change the style of chat? Add server commands to change the client.chat variable?

If you mean the font, then just do "<font:[FONTNAME]:[SIZE]>Your message here.".

I meant like make it so it uses different functions for chat, like

Code: [Select]
package Testing
{
function serverCmdMessageSent(%Client,%msg)
{
if(%client.chat == 1)
{
OOC_Chat(%client,%msg);
}
if(%client.chat == 0)
{
parent::serverCmdMessageSent(%Client,%msg);
}
}

function OOC_Chat(%client,%msg)
{
messageAll('',"\c2[OOC]:\c3" SPC %client.name @ "\c6:" SPC %msg);
}
   
    function serverCmdOOC(%client,%msg)
    {
        %client.chat = 1;
        serverCmdMessageSent(%client,%msg);
        %client.chat = 0;
    }
};
ActivatePackage(Testing);


The OOC part still has %msg as just the first string, but not doing /ooc works completely fine.
« Last Edit: March 17, 2013, 11:45:01 AM by devildogelite »

Made a new topic since the question is a lot different than the original one.
« Last Edit: March 17, 2013, 09:57:30 PM by devildogelite »