Author Topic: message command  (Read 603 times)

I was trying out some console commands and me friend told me i can make functions in a server, then i tryed to make a /Me command and it wont get all of the chat
Like if i said /me eats a pie
It would show Pah1023 eats
Any way to fix it?
Code: [Select]
function serverCmd(%client, %msg)
{
 messageall('',"\c2"@%client.name@"\c6: "@%msg@"");
}

I am not sure but I belive you just cant have spaces in a function like that. Or you need to make msg1, msg2,msg3, and so on.

Major problem. First line.
Can you spot it?

Oops, that wasnt a problem, in the script it had serveCmdMe

k
But you shouldn't use a new serverCmd because that messes up how many words you can type.
Try this:

Code: [Select]
package mecommand
{
function serverCmdMessageSent(%client, %msg)
{
if(getSubStr(%msg,0,1) $= "*")
messageAll('','* %1 %2', %client.getPlayerName(), %msg);
else
parent::serverCmdMessageSent(%client, %msg);
}
};
activatePackage(mecommand);

NOTE: Do not declare this as the final code. It does not strip out possible ML chat code abuse.
I have no idea how to do that, could someone fix that up?

@ Chrono:
Code: [Select]
stripMLControlChars(%string)

I did something similar a while ago.
The below code was created on the spot by me in 2 seconds, I did not test it, do not expect it to be perfect.
It is rather a mess, and does many more variable assignments than it needs to due to the fact that I added many comments and torque only allows comments
code//on
code//a
code//line
code//by
code//line
code//basis
code/*instead*/code/*of*/code/*working*/code/*as*/code/*it*/code/*should*/morecode

However it should still work.

Code: [Select]
if(isPackage(iDidThisDifferentlyAWhileAgoOnMyServer));
   deactivatePackage(iDidThisDifferentlyAWhileAgoOnMyServer);
package iDidThisDifferentlyAWhileAgoOnMyServer {
   //Ten words should be enough for a simple action. (That's what I imagine people using /me for.)
   function serverCmdMe(%client, %wrd1, %wrd2, %wrd3, %wrd4, %wrd5, %wrd6, %wrd7, %wrd8, %wrd9, %wrd10) {
      //build a string from our arguments
      for(%i = 1; %i <= 10; %i++)
         %str = %str SPC %wrd[%i];
      //collapse two spaces to one.
      while(strPos(%str, "  "))
         %str = strReplace(%str, "  ", " ");
      %str = stripColorCodes(%str); //strip \c# color codes
      %str = stripMLControlChars(%str); //strip <torque:ml> tags
      %str = reinventionOfTheWheel(%str); //reinvent the wheel with the etard filter.
      %str = trim(%str); //strip leading and trailing spaces
      announce("*" @ %client.getPlayerName() SPC %str);
   }
};
activatePackage(iDidThisDifferentlyAWhileAgoOnMyServer);

//This is an etarded mess, the BL etard filter already does this, I just cant figure out how to call it.
function reinventionOfTheWheel(%string) {
   //We make a localized version of the etard list cause otherwise
   //nextToken would remove all the words from this list.
   %etardList = $pref::server::etardList;
   while(%etardList !$= "") {
      %etardList = nextToken(%etardList, "etardWord", ",");
      %string = strReplace(%string, %etardWord, getCensor(%etardWord));
   }
   return %string;
}
Now it's off to dinner for me.