Author Topic: What's wrong with this code?  (Read 1707 times)

As i'm learning TorqueScript, I've always had trouble with this line. I'm learning from ThinInvisible's old post, and I'm trying to create a roulette game in chat by myself. With this code failing, it makes the roulette game impossible, because of the clientCmdChatMessage being necessary to it. Here it is!
(Yes, I know chatbots are annoying unless they're only a calculator. Yes I will delete it after it works.)

package chatBot {
function clientCmdChatMessage(%a,%b,%c,%msg,%cp,%name,%cs,%msg) {
if (%msg $= "testing testing 123") {
  if (%name $= "Ark7") {
  commandToServer('messageSent',"Your testing is win!");
     }
}
}
};
activatePackage(chatBot);

Forgot to include this, but it functions properly, executes on the game's start properly, but when executed, all chat is not printed onto the screen. It forces me to read people's chat via the console. When I give it the phrase "testing testing 123", I check console and it outputs the proper text, directly after mine.

you didn't parent the function at the begginning or end of the function you need to include parent::clientCmdChatMessage(%a,%b,%c,%msg,%cp,%name,%cs,%msg);
because when you modify default functions you will overwrite them unless you parent it, parenting is like calling all the normal code that it would normally do plus any add-ons that added modifications to the function aswell

Also, your using the %msg variable in the function statement twice. Honestly, I don't know what that will do, but use different variable names for each argument.

Other than that (and what Swollow said), I cant see anything wrong.

Also, your using the %msg variable in the function statement twice.
Is there some guide that people are following that gives these variable name, or something?
Because almost every time a new scripter is writing something that modifies this function (it's almost always a chatbot, too) they make this mistake

Is there some guide that people are following that gives these variable name, or something?
Because almost every time a new scripter is writing something that modifies this function (it's almost always a chatbot, too) they make this mistake
there was a chatbot floating around that people were modifying
they never got any decent knowledge about it and i guess it was deliberately sabotaged.

Is there some guide that people are following that gives these variable name, or something?
Because almost every time a new scripter is writing something that modifies this function (it's almost always a chatbot, too) they make this mistake
The funniest part about this to me is that the person who's code they stole didn't even know what the first 3 arguments are so they just bullstuffted it to %a %b %c. Quality example!

The funniest part about this to me is that the person who's code they stole didn't even know what the first 3 arguments are so they just bullstuffted it to %a %b %c. Quality example!
not as bad as this one I found somewhere
clientCmdChatMessage(%wat,%lol,%m,%e,%pre,%name,%a2,%a3,%a4,%a5,%a6,%a7,%a8,%a9)

not as bad as this one I found somewhere
clientCmdChatMessage(%wat,%lol,%m,%e,%pre,%name,%a2,%a3,%a4,%a5,%a6,%a7,%a8,%a9)
I'm 100% sure you just made that up

there was a chatbot floating around that people were modifying
they never got any decent knowledge about it and i guess it was deliberately sabotaged.
it was an old forum tutorial example that actually was intentionally riddled with mistakes to avoid copy pasting just to have a chatbot
it actually explained what was going on but most people i guess just went for the broken example

it was an old forum tutorial example that actually was intentionally riddled with mistakes to avoid copy pasting just to have a chatbot
it actually explained what was going on but most people i guess just went for the broken example
I somehow doubt this. Both "msg" arguments ARE the message, just the first one is generally designated as %fmsg for "full message." The first three arguments are also almost entirely unimportant to any modifications of the function, so I find it very likely that the author of this beautiful line of code simply didn't care about the first three and forgeted up the double usage of message.

I'm 100% sure you just made that up
it was from an rtb addon I think chat notifier

Mhhhh... You know what, I'll go pick up on Python.

Mhhhh... You know what, I'll go pick up on Python.
Blockland doesn't use python....

I'm 100% sure you just made that up

it's from the name said sound add-on
that's exactly how it is