Hide chat messages (client side)?

Author Topic: Hide chat messages (client side)?  (Read 2361 times)

So I wanted to make a chatbot but people say they're really spammy. Because of that I want to make it so that it hides the chat command I put in. The problem is, though, that I don't know how I would begin to do that.

My current code is
Code: [Select]
package chatbot
{
function NMH_Type::Send(%this)
{
                parent::Send(%this);
%text = %this.getValue();
if(%text $= "hello") //&& %name $= $pref::Player::NetName)
{
commandToServer('messageSent',"Chatbot: Hi");
}
}
};

activatePackage(chatbot);

Is it possible to do this?
« Last Edit: June 26, 2015, 12:54:42 PM by Gsterman »

First thing to note: anything after a return statement will not happen, since it exits the function when you use that.

Before the parent, put %text there instead because during the parent it will reset the value to none.

Wait until the end to parent it and return if it passes your if checks, so it won't actually send it.

Thank you all! It works perfectly now

Unlocking since I have another question, is it possible to get a number from a string, or convert a string to a number?

What are you trying to do? You can put just a number in a string and use it.

Torque does't have any datatypes, a variable is a variable

"4" == 4


Also, don't lock coding help threads

If people say "they're really spammy", making your own messages not show up isn't the solution to that problem, but only reduces the total amount of messages in half (average case). The bot is still going to send messages to the server, potentially advocating it for being "spammy" still. Am I missing something?

Torque does't have any datatypes, a variable is a variable

"4" == 4


Also, don't lock coding help threads

From the "Syntax Guide":

Quote
TorqueScript implicitly supports several variable data-types: numbers, strings, booleans, arrays and vectors.

I know what you mean, though. I wish types were stored alongside variables, since ambiguous cases make it hard to determine what function to call on what type of object. Usually you only hear this about classes with virtual function members that make it so you don't need to know what type it is, and you just call the operation on them. This can be done in TS but having to wrap each primitive type in a slow, bloaty object on creation just isn't going to cut it. There are better ways but in the end its just a petty workaround like always.

It's also silly how they put engine types inside usage definitions too, but it's just a mnemonic I suppose. This language really doesn't belong with this engine.
« Last Edit: June 26, 2015, 09:20:02 PM by Val »

If people say "they're really spammy", making your own messages not show up isn't the solution to that problem, but only reduces the total amount of messages in half (average case). The bot is still going to send messages to the server, potentially advocating it for being "spammy" still. Am I missing something?
it sounds like the bot only displays messages to him, and not to the server

it sounds like the bot only displays messages to him, and not to the server

Quote
Code: [Select]
commandToServer('messageSent',"Chatbot: Hi");


I actually changed that later to print it only to me

You should post the fixed code so that if other people have similar issues they can look at your code to learn from.

Code: [Select]
package chatbot
{
function NMH_Type::Send(%this)
{
%text = %this.getValue();
if(%text $= "hello")
{
NewChatSO.addLine("Hi");
                        canvas.popdialog(newmessagehud);
                        return;
}
                parent::Send(%this);
}
};

activatePackage(chatbot);
« Last Edit: June 27, 2015, 06:28:48 PM by Gsterman »

You could also replace the popDialog and the return with
Code: [Select]
%this.setValue("");