Shoutbox

Problem With String Lengths - 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: Problem With String Lengths (/showthread.php?tid=89141)

Problem With String Lengths by Master Jake on 02-12-2009 at 10:56 PM

Hi! I'm trying to do something to change people's messages. I know I can only see it on my screen but I still want it cause its cool. This is what I have so far.

code:
var gayMessages = new Array("I'm Gay!", "Did you know I'm homosexual now?", "Yes, I finally came out of the closet.", "I know it's shocking, but I really am gay..!", "My life sucks now that I'm gay :(", "Please don't tell anyone I'm gay!!!", "Can I suck your weener?", "I wish I was as cool as you....");

function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MsgKind)
{
    if (Origin != Messenger.MyName)
    {
        Debug.Trace(Message);
       
        var randnum = Math.floor(Math.random()*gayMessages.length)
        Message = gayMessages[randnum];
        return Message;
    }
}


The problem with this? It only writes out as many characters of the new message as they originally typed. So if they type "hello" and it gets the message "I know it's shucking, but I really am gay..!" then it will only display "I kno" because thats 5 letters and their original message "hello" was 5 letters. I need it to display the whole, regardless.
RE: Problem With String Lengths by pollolibredegrasa on 02-12-2009 at 11:21 PM

As explained in the scripting documentation:

quote:
It is important to remember that the new message cannot be longer than the original one (use Message.length) and will be cut if necessary.

AFAIK, there is no workaround either, so what you want is not possible.
RE: Problem With String Lengths by matty on 02-13-2009 at 04:19 AM

Also you need to use gayMessages.length-1 because the Array is 0 based but length isn't because it is the total number of items in the array.