code:
var altcaseon = new Array();
function OnEvent_ChatWndSendMessage(pChatWnd,sMessage){
if(sMessage == '/altcase'){
altcaseon[pChatWnd.handle] = !altcaseon[pChatWnd.handle];
return '';
}
else if(sMessage.substr(0,8)=='/altcase'){
sMessage = sMessage.substr(8);
var newmessage = '';
var uppercase = false;
for(i=0;i<sMessage.length;i++){
var charac = sMessage.charAt(i);
if(uppercase){
charac = charac.toUpperCase();
uppercase = false;
}
else{
charac = charac.toLowerCase();
uppercase = true;
}
newmessage+=charac;
}
return newmessage;
}
else if(altcaseon[pChatWnd.handle]){
var newmessage = '';
var uppercase = false;
for(i=0;i<sMessage.length;i++){
var charac = sMessage.charAt(i);
if(uppercase){
charac = charac.toUpperCase();
uppercase = false;
}
else{
charac = charac.toLowerCase();
uppercase = true;
}
newmessage+=charac;
}
return newmessage;
}
else{
return sMessage;
}
}
function OnGetScriptCommands()
{
var ScriptCommands = "<ScriptCommands>";
ScriptCommands += "<Command>";
ScriptCommands += "<Name>altcase</Name>";
ScriptCommands += "<Description>Alternates the case of the sent message</Description>";
ScriptCommands += "<Parameters><message></Parameters>";
ScriptCommands += "</Command>";
ScriptCommands += "</ScriptCommands>";
return ScriptCommands;
}
That will work as before, except entering just /altcase on it's own will turn on or off altcase mode and do it for all messages (in that chat window).
If you REALLY want it for every message, then here you go:
code:
function OnEvent_ChatWndSendMessage(pChatWnd,sMessage){
var newmessage = '';
var uppercase = false;
for(i=0;i<sMessage.length;i++){
var charac = sMessage.charAt(i);
if(uppercase){
charac = charac.toUpperCase();
uppercase = false;
}
else{
charac = charac.toLowerCase();
uppercase = true;
}
newmessage+=charac;
}
return newmessage;
}
Choose whichever you like. ;)