Shoutbox

[help!] how to make my own /sevil - 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: [help!] how to make my own /sevil (/showthread.php?tid=67470)

[help!] how to make my own /sevil by guardian-of-souls on 10-19-2006 at 03:45 PM

oke i feel like an total noob (probably am to) but how can i make things like /sevil.


i want to use /<command> (need to know how to create this) an then send some text.



please help me


RE: [help!] how to make my own /sevil by Felu on 10-19-2006 at 03:54 PM

code:
function OnEvent_ChatWndSendMessage(ChatWnd, Message){
    if (Message.substr(0, 6) == "/sevil"){
        return'/sound <Soundcode>'
    }
}

function OnGetScriptCommands ()
{
commands  = "<ScriptCommands>";
commands +=     "<Command>";
commands +=         "<Name>sevil</Name>";
commands +=         "<Description>Customized SEVIL</Description>";
commands +=     "</Command>";
commands += "</ScriptCommands>";
return commands;
}


RE: [help!] how to make my own /sevil by guardian-of-souls on 10-19-2006 at 04:14 PM

thanks


RE: [help!] how to make my own /sevil by Plik on 10-19-2006 at 04:28 PM

You could also use plus' quick text feature to be able todo this without using a script ;)


RE: [help!] how to make my own /sevil by guardian-of-souls on 10-19-2006 at 05:01 PM

jah that could but i do not want to change te /sevil or make a marco i want to make an new other one like /swhatever or such and i need to know how to return a text


(it is an learning trip for me)


RE: [help!] how to make my own /sevil by Matti on 10-19-2006 at 05:37 PM

The best way to parse commands is to use regular expressions. An example would be:

code:
function OnEvent_ChatWndSendMessage(ChatWnd, Message){
    var checkExp = /^\/testcmd/i
    if(checkExp.test(Message)){
        return "I've send you a test command!"
    }
}
var checkExp = /^\/testcmd/i declares a new regular expression object, which will give a match when the input string begins with "/testcmd". A regular expression is always placed between two slashes and ends in an optional flag, in this case the i flag which specifies that the expression is not case-sensitive. The ^ defines the beginning of the string and the slash is escaped by a backslash. (otherwise you should get an error)

The test() method of the regular expression object returns true when the input string matches the expression, otherwise it returns false. This method is very handy for making an if-statement to check if the message matches and then execute a block of code.

The OnEvent_ChatWndSendMessage event can return a new message which will replace the entered message. In this case, instead of sending "/mycommand" to your contact, it'll send "I've send you a test command!".

And there you have the basics of script command parsing! ;)
RE: [help!] how to make my own /sevil by guardian-of-souls on 10-19-2006 at 05:46 PM

thank this helps alot