markee
Veteran Member
Posts: 1622 Reputation: 50
36 / /
Joined: Jan 2006
|
RE: A Radio Code script
Have a try at this:
code: var letters = {
"a":"ALPHA",
"b":"BRAVO",
"c":"CHARLIE",
"d":"DELTA",
"e":"ECHO",
"f":"FOXTROT",
"g":"GOLF",
"h":"HOTEL",
"i":"INDIA",
"j":"JULIET",
"k":"KELO",
"l":"LIMA",
"m":"MIKE",
"n":"NOVEMBER",
"o":"OSCAR",
"p":"PAP",
"q":"QUEBEC",
"r":"ROMEO",
"s":"SIRREA",
"t":"TANGO",
"u":"UNIFORM",
"v":"VICTOR",
"w":"WHISKEY",
"x":"XRAY",
"y":"YANKEE",
"z":"ZULU",
"1":"ONE",
"2":"TWO",
"3":"THREE",
"4":"FOUR",
"5":"FIVE",
"6":"SIX",
"7":"SEVEN",
"8":"EIGHT",
"9":"NINE",
"0":"ZERO"
}
function OnEvent_ChatWndSendMessage(ChatWnd, sMessage){
if (/^\/rdocde(?:\s+([\s\S]*)|$)/i.exec(sMessage) !== null) {
var parameter = RegExp.$1.toLowerCase();
for(key in letters){
Debug.Trace(key+"\t"+letters[key]);
//remove this line if you want double spaces at the end of words
parameter = parameter.replace(RegExp(key+"\b","g"),letters[key]);
parameter = parameter.replace(RegExp(key,"g"),letters[key]+" ");
}
ChatWnd.SendMessage(parameter);
return "";
}
}
function OnGetScriptCommands(){
return "<ScriptCommands><Command><Name>Radio Code</Name><Description>Convert your message to radio code</Description><Parameters>Message</Parameters></Command>";
}
|
|