//======================================================================================= // Nuisance filter - by Mental Trousers as part of the Tribes scripting documents at // http://planetstarsiege.com/mt/ //======================================================================================= // // This script is based on my first ever script for tribes. At the time, their was // nothing available to filter out all of the idiots that spammed. They really annoyed // me. So I wrote one that filtered it all out. Unfortunately it was extremely // inefficient and induced unnecesary lag. This version is alot more efficient and doesn't // screw your ping time up. However the message must match exactly otherwise it will not // be muted, meaning anyone that has altered their messages even slightly will still be // able to say things that are on the nuisance message list. They wont be able to spam // though. // // Things covered in this script // ----------------------------- // // Attaching to an event queue // Catching messages // Using the arrays // Scheduling actions/commands // // How this filter works // --------------------- // // When a message for the client comes in, the eventClientMessage event queue is // triggered. One of the functions in that queue is the Nuisance::filter one, which I // enter into the queue using event::attach (see last line of file). When attaching to the // eventClientMessage queue, returning mute will prevent the message being displayed. // // Nuisance filter then obtains the client number for this client (thats you, the one // reading this). It then checks if the client who is the message is this one, if so then // we let the message display by returning true. // // If the message isn't from this client, we then check to see it is one of the preset // nuisance messages that annoy everyone except the cretin saying it. To do this we need // to strip the players name off the front of the message using the inbuilt string // functions string::findSubStr and string::getSubStr // // If the message isn't a preset one, then we enter the entire message (with the persons // name that sent it) into an array, using the message as the index. We set this entry to // true and then schedule a call to clear that entry after the value of $releaseTime // seconds. Something to "" is practically the same as releasing memory using "free" or // whatever in C++ // //======================================================================================= // These are the preset messages to be filtered out. You can change them or add new ones. // However make sure that you use THE ENTIRE MESSAGE as the index, as there is no // checking done for partial messages or certain words. $nuisanceMsg["Doh!"] =True; $nuisanceMsg["Oops!"] =True; $nuisanceMsg["Shazbot!"] =True; $nuisanceMsg["Damnit!"] =True; $nuisanceMsg["Ah Crap!"] =True; $nuisanceMsg["Duh."] =True; $nuisanceMsg["You Idiot!"]=True; //Important messages that we don't want to mute $importantMsg["Shield On"] =True; $importantMsg["Shield Off"]=True; // The amount of time to wait before the message can be repeated $releaseTime=5; function Nuisance::filter (%client, %msg) { // echo ("function Nuisance::filter ("@%client@", "@%msg@")"); //Gets the unique client id number for this client. %thisClient = getManagerId(); // If the message isn't sent by this client then do the other checks if (%thisClient!=%client) { // Check to see if someone is spamming if ($clientsMsg[%msg]) // Spamming - send notification to console and mute the bugger { echo ("message muted by function Nuisance::filter ()"); return mute; } // all messages have the client name at the front followed by a :. I find that // and then grab everything after that +1 (theres a space following the :) %strip = string::findSubStr(%msg, ":"); %message = string::getSubStr(%msg, %strip+1, 80); // Check for the nuisance messages if ($nuisanceMsg[%message]) // nuisance message - send notification to console and mute the bugger { echo ("message muted by function Nuisance::filter ()"); return mute; } // Check to make sure we don't want to ever stop this message being shown. else if (!$importantMsg[%msg]) // This message isn't a nuisance one and hasn't been sent recently, so make // an entry in the $clientsMsg[] and then schedule to clear it. Schedule takes // a console command as one arguement, complete with ; on the end. Use \ as the // escape character, just like in C { $clientsMsg[%msg]=true; schedule ("$clientsMsg[\""@%msg@"\"]=\"\";", $releaseTime); } } // if this is executed then the message is sent by this client !! else return true; } // Here I attach my function for filtering out the annoying messages to the // eventClientMessage event queue. This queue means that alot of scripts can work // side by side without having to fiddle the onClientMessage function all of the time. event::attach (eventClientMessage, Nuisance::filter, %client, %msg);