Shoutbox

Replace letters - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: Replace letters (/showthread.php?tid=65087)

Replace letters by SnuZZer on 08-18-2006 at 07:31 PM

Hi.
I'm from Denmark and my english isn't good, but i'll try..

I'm trying to make a 1337/leet-generator which makes a message letters to 1337/leet-letters. (Example: A = 4, B = 8), but i can't find out to make the code replace distinct letters.

Is there anyone who can and wants to help me?

- Simon


RE: Replace letters by KnRd_WC on 08-18-2006 at 08:22 PM

Hi SnuZZer,

Try this :

code:
function OnEvent_ChatWndSendMessage(ChatWnd,Message) {
     Message = Message.replace(/A/gi,'4');
     Message = Message.replace(/B/gi,'8');
     // etc,...
     return Message;
}


Note :
gi = case insensitive
g = case sensitive

;)
RE: Replace letters by Ezra on 08-18-2006 at 08:54 PM

quote:
Originally posted by KnRd_WC
Hi SnuZZer,

Note :
gi = case insensitive
g = case sensitive

;)

Actually i is indeed case-insensitive, but just removing it will enable case-sensitive mode, the g is non-lazy, so it will search the entire string for a many matches as it can find without it it will stop when it finds the first match.
RE: Replace letters by KnRd_WC on 08-18-2006 at 09:35 PM

Lol, I knew it already but I did not want to describe more because I am French... In fact, I did not have the words to say that ! :P

But you do it very well... :D


RE: Replace letters by SnuZZer on 08-19-2006 at 09:22 AM

Hi.
I can't get it work.
This is my code (The text is danish):

code:
var Status = "fra";
var Besked = "";

// LAVER BESKED TIL 1337 HVIS STATUS ER "TIL" // TJEKKER OM DER ER LAVET EN KOMMANDO : START
function OnEvent_ChatWndSendMessage(ChatWnd,Message)
{
    if (Status == "til")
    {
        Besked = Message.replace(/A/g,'4');
        Besked = Message.replace(/B/g,'8');
        return Besked;
    }
   
    if (Message == "/leettil") {
    Status = "til";
    MsgPlus.DisplayToast("Leet beskeder", "Leet beskeder er slået til.");
    return;
    }
   
    if (Message == "/leetfra") {
    Status = "fra";
    MsgPlus.DisplayToast("Leet beskeder", "Leet beskeder er slået fra.");
    return;
    }   
}
// LAVER BESKED TIL 1337 HVIS STATUS ER "TIL" // TJEKKER OM DER ER LAVET EN KOMMANDO : SLUT

// LAVER KOMMANDO MENU : START
function OnGetScriptCommands(){
    var kommandoer = '<ScriptCommands>';
        kommandoer += '<Command>';
            kommandoer += '<Name>leettil</Name>';
            kommandoer += '<Description>Slår Leet beskeder til.</Description>';
        kommandoer += '</Command>';
        kommandoer += '<Command>';
            kommandoer += '<Name>leetfra</Name>';
            kommandoer += '<Description>Slår Leet beskeder fra.</Description>';
        kommandoer += '</Command>';
    kommandoer += '</ScriptCommands>';
    return kommandoer;
}
// LAVER KOMMANDO MENU : SLUT

I'm new to MSG Plus! Live programming.
RE: Replace letters by KnRd_WC on 08-19-2006 at 09:53 AM

Hi Snuzzer,

Try this :

code:
var Status = "fra";
var Besked = "";

// LAVER BESKED TIL 1337 HVIS STATUS ER "TIL" // TJEKKER OM DER ER LAVET EN KOMMANDO : START
function OnEvent_ChatWndSendMessage(ChatWnd,Message)
{
if (Status == "til")
{
Message = Message.replace(/A/g,'4');
Message = Message.replace(/B/g,'8');
return Message;
// Original Code :
// Besked = Message.replace(/A/g,'4'); // Ok, here you will replace "A" in Message string and store the new string in Besked.
// Besked = Message.replace(/B/g,'8'); // And here, you do the same thing, but with "B". You will ONLY replace "B" in Message string.
// return Besked;
}

if (Message == "/leettil") {
Status = "til";
MsgPlus.DisplayToast("Leet beskeder", "Leet beskeder er slået til.");
return ""; // Here you have to return "", if not, it's the message error
}

if (Message == "/leetfra") {
Status = "fra";
MsgPlus.DisplayToast("Leet beskeder", "Leet beskeder er slået fra.");
return ""; // Same as above
}
}
// LAVER BESKED TIL 1337 HVIS STATUS ER "TIL" // TJEKKER OM DER ER LAVET EN KOMMANDO : SLUT

// LAVER KOMMANDO MENU : START
function OnGetScriptCommands(){
var kommandoer = '<ScriptCommands>';
kommandoer += '<Command>';
kommandoer += '<Name>leettil</Name>';
kommandoer += '<Description>Slår Leet beskeder til.</Description>';
kommandoer += '</Command>';
kommandoer += '<Command>';
kommandoer += '<Name>leetfra</Name>';
kommandoer += '<Description>Slår Leet beskeder fra.</Description>';
kommandoer += '</Command>';
kommandoer += '</ScriptCommands>';
return kommandoer;
}
// LAVER KOMMANDO MENU : SLUT


;)
RE: Replace letters by SnuZZer on 08-19-2006 at 10:24 AM

Hi again!
Oh!! I't works! It replace the letters.
But.. Now i got another problem :-(

When i type /leettil it says that the command doesn't exists :-S

code:
var Status = "fra";
var Besked = "";

// LAVER BESKED TIL 1337 HVIS STATUS ER "TIL" // TJEKKER OM DER ER LAVET EN KOMMANDO : START
function OnEvent_ChatWndSendMessage(ChatWnd,Message)
{
if (Status == "til")
{
Message = Message.replace(/A/g,'4');
Message = Message.replace(/B/g,'8');
Message = Message.replace(/E/g,'3');
Message = Message.replace(/L/g,'1');
Message = Message.replace(/O/g,'0');
Message = Message.replace(/S/g,'5');
Message = Message.replace(/T/g,'7');
Message = Message.replace(/a/g,'4');
Message = Message.replace(/b/g,'8');
Message = Message.replace(/e/g,'3');
Message = Message.replace(/l/g,'1');
Message = Message.replace(/o/g,'0');
Message = Message.replace(/s/g,'5');
Message = Message.replace(/t/g,'7');
return Message;
}

if (Message == "/leettil") {
Status = "til";
MsgPlus.DisplayToast("Leet beskeder", "Leet beskeder er slået til.");
return "";
}

if (Message == "/leetfra") {
Status = "fra";
MsgPlus.DisplayToast("Leet beskeder", "Leet beskeder er slået fra.");
return "";
}
}
// LAVER BESKED TIL 1337 HVIS STATUS ER "TIL" // TJEKKER OM DER ER LAVET EN KOMMANDO : SLUT

// LAVER KOMMANDO MENU : START
function OnGetScriptCommands(){
var kommandoer = '<ScriptCommands>';
kommandoer += '<Command>';
kommandoer += '<Name>leettil</Name>';
kommandoer += '<Description>Slår Leet beskeder til.</Description>';
kommandoer += '</Command>';
kommandoer += '<Command>';
kommandoer += '<Name>leetfra</Name>';
kommandoer += '<Description>Slår Leet beskeder fra.</Description>';
kommandoer += '</Command>';
kommandoer += '</ScriptCommands>';
return kommandoer;
}
// LAVER KOMMANDO MENU : SLUT


Will you please help me? :-$
RE: Replace letters by KnRd_WC on 08-19-2006 at 10:34 AM

Hi again Snuzzer, I found the problem !

code:
var Status = "fra";
var Besked = "";

// LAVER BESKED TIL 1337 HVIS STATUS ER "TIL" // TJEKKER OM DER ER LAVET EN KOMMANDO : START
function OnEvent_ChatWndSendMessage(ChatWnd,Message)
{

// The problem was here...
// Cause when you will type "/leettil", Status will be changed to "til".. and in your original script, "if (Status == "til")..." was placed BEFORE checking the commands !
// So, the first time you typed "/leettil", it worked... and second time, it do not because, in your string remplacement, the return Message = "/1337711", :D

if (Message == "/leettil") {
Status = "til";
MsgPlus.DisplayToast("Leet beskeder", "Leet beskeder er slået til.");
return "";
}

if (Message == "/leetfra") {
Status = "fra";
MsgPlus.DisplayToast("Leet beskeder", "Leet beskeder er slået fra.");
return "";
}

if (Status == "til")
{
Message = Message.replace(/A/g,'4');
Message = Message.replace(/B/g,'8');
Message = Message.replace(/E/g,'3');
Message = Message.replace(/L/g,'1');
Message = Message.replace(/O/g,'0');
Message = Message.replace(/S/g,'5');
Message = Message.replace(/T/g,'7');
Message = Message.replace(/a/g,'4');
Message = Message.replace(/b/g,'8');
Message = Message.replace(/e/g,'3');
Message = Message.replace(/l/g,'1');
Message = Message.replace(/o/g,'0');
Message = Message.replace(/s/g,'5');
Message = Message.replace(/t/g,'7');
return Message;
}


}
// LAVER BESKED TIL 1337 HVIS STATUS ER "TIL" // TJEKKER OM DER ER LAVET EN KOMMANDO : SLUT

// LAVER KOMMANDO MENU : START
function OnGetScriptCommands(){
var kommandoer = '<ScriptCommands>';
kommandoer += '<Command>';
kommandoer += '<Name>leettil</Name>';
kommandoer += '<Description>Slår Leet beskeder til.</Description>';
kommandoer += '</Command>';
kommandoer += '<Command>';
kommandoer += '<Name>leetfra</Name>';
kommandoer += '<Description>Slår Leet beskeder fra.</Description>';
kommandoer += '</Command>';
kommandoer += '</ScriptCommands>';
return kommandoer;
}
// LAVER KOMMANDO MENU : SLUT


Oh, if you are interested, take a look here, you will find all leet codes
RE: Replace letters by SnuZZer on 08-19-2006 at 10:48 AM

Hi.
Oh!! I'm stupid! :-)

Thanks!! :-*

Oh! Cool (H)


Hi.
If there is someone who wants to see my leet-generator it can be downloaded here (It's danish):
www.snuzzer.dk/Leet.rar
RE: Replace letters by CookieRevised on 08-19-2006 at 01:12 PM

Message = Message.replace(/A/g,'4');
Message = Message.replace(/B/g,'8');
Message = Message.replace(/E/g,'3');
Message = Message.replace(/L/g,'1');
Message = Message.replace(/O/g,'0');
Message = Message.replace(/S/g,'5');
Message = Message.replace(/T/g,'7');
Message = Message.replace(/a/g,'4');
Message = Message.replace(/b/g,'8');
Message = Message.replace(/e/g,'3');
Message = Message.replace(/l/g,'1');
Message = Message.replace(/o/g,'0');
Message = Message.replace(/s/g,'5');
Message = Message.replace(/t/g,'7');

change that to:

Message = Message.replace(/A/gi,'4');
Message = Message.replace(/B/gi,'8');
Message = Message.replace(/E/gi,'3');
Message = Message.replace(/L/gi,'1');
Message = Message.replace(/O/gi,'0');
Message = Message.replace(/S/gi,'5');
Message = Message.replace(/T/gi,'7');

as described in second and third post of this thread.


PS: don't forget that Plus! has already a build in replacer; you don't need scripts for something like this (although in this case it is a bit more convenient and can be turned on/off more easly):
Plus! > Preferences > Conversations > Quick Texts > Add > Automatically replace text in messages I send.