Little help with a code??? -> ANOTHER HELP - 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: Little help with a code??? -> ANOTHER HELP (/showthread.php?tid=72795)
Little help with a code??? -> ANOTHER HELP by MicroWay on 03-19-2007 at 02:29 AM
Hello people,
Me and my "very good, excelent and briliant skills" on coding tryed to do a very-simple timed status changer, BUT, of course, Plus! didn't accept it (the code it's wrong).
code: function OnEvent_Initialize(MessengerStart)
{
MsgPlus.AddTimer("Statuz", 300000);
}
function onEvent_Timer(timerID)
{
if(timerID == "Statuz")
{
Messenger::MyStatus = 2
}
Can someone try to teach where are the errors, please???
Edit: Forgot to say that I tryed to find answers by using the search function, but nothing...
RE: Little help with a code??? by deAd on 03-19-2007 at 02:32 AM
This should work:
code: function OnEvent_Initialize(MessengerStart)
{
MsgPlus.AddTimer("Statuz", 300000);
}
function OnEvent_Timer(timerID)
{
if(timerID == "Statuz")
{
Messenger.MyStatus = 2;
}
}
EDIT: Fixed something I didn't notice before
RE: Little help with a code??? by MicroWay on 03-19-2007 at 02:48 AM
Cool!!! Thanks!!!
I was caught by an "::" and a missing "}"
I'll try to improve it... If I had any other problems, I'll post it here...
RE: Little help with a code??? -> ANOTHER HELP by MicroWay on 03-19-2007 at 10:37 PM
Hello... I have another problem
I updated it, but the comand isn't being recognized...
Please, take a look (the same question as before)
code: function OnGetScriptCommands(){
var ScriptCommands = "<ScriptCommands>";
ScriptCommands += "<Command>";
ScriptCommands += "<Name>sleep</Name>";
ScriptCommands += "<Description>Tempo para a contagem</Description>";
ScriptCommands += "<Parameters><Tempo em minutos></Parameters>";
ScriptCommands += "</Command>";
ScriptCommands += "</ScriptCommands>";
return ScriptCommands;
}
function OnEvent_ChatWndSendMessage(ChatWnd, Message) {
if (Message.substr(0, 7) == "/sleep "){
var tyme = Message.substr(Message.search(' ')*60000);
sleeptime();
return "";
}
function sleeptime()
{
MsgPlus.AddTimer("Statuz", tyme);
MsgPlus.DisplayToast("Status Changer", "Timer iniciado: "+tyme+" milisegundos para Offline");
}
function OnEvent_Timer(timerID)
{
if(timerID == "Statuz")
{
Messenger.MyStatus = 2;
}
}
}
RE: RE: Little help with a code??? -> ANOTHER HELP by markee on 03-19-2007 at 10:41 PM
code: function OnGetScriptCommands(){
var ScriptCommands = "<ScriptCommands>";
ScriptCommands += "<Command>";
ScriptCommands += "<Name>sleep</Name>";
ScriptCommands += "<Description>Tempo para a contagem</Description>";
ScriptCommands += "<Parameters><Tempo em minutos></Parameters>";
ScriptCommands += "</Command>";
ScriptCommands += "</ScriptCommands>";
return ScriptCommands;
}
function OnEvent_ChatWndSendMessage(ChatWnd, Message) {
if (Message.substr(0, 7) == "/sleep "){
var tyme = Message.substr(Message.search(' ')*60000);
sleeptime();
return "";
}
}
function sleeptime()
{
MsgPlus.AddTimer("Statuz", tyme);
MsgPlus.DisplayToast("Status Changer", "Timer iniciado: "+tyme+" milisegundos para Offline");
}
function OnEvent_Timer(timerID)
{
if(timerID == "Statuz")
{
Messenger.MyStatus = 2;
}
}
You just added a bracket to the end where it should have been earlier
RE: Little help with a code??? -> ANOTHER HELP by MicroWay on 03-19-2007 at 10:45 PM
Thanks for that...
But now on the Debbuging, it has an error on Line 23 ("tyme" isn't defined... The function OnEvent_ChatWndSendMessage results in an error)...
Maybe the multiplication by 60000 it's wong???
here is the line 23:
MsgPlus.AddTimer("Statuz", tyme);
EDIT:
Forgot to say that I wanted to make the script start working when "/sleep <number>" is typed. This number should be in minutes. So, with the time selected, it'll change the status to AppearOfline
RE: Little help with a code??? -> ANOTHER HELP by markee on 03-19-2007 at 11:09 PM
That is because you are storing tyme as a local variable rather than a global one and you are not parsing it to the other function. Try this code instead....
code: function OnGetScriptCommands(){
var ScriptCommands = "<ScriptCommands>";
ScriptCommands += "<Command>";
ScriptCommands += "<Name>sleep</Name>";
ScriptCommands += "<Description>Tempo para a contagem</Description>";
ScriptCommands += "<Parameters><Tempo em minutos></Parameters>";
ScriptCommands += "</Command>";
ScriptCommands += "</ScriptCommands>";
return ScriptCommands;
}
function OnEvent_ChatWndSendMessage(ChatWnd, Message) {
if (Message.substr(0, 7) == "/sleep "){
var tyme = Message.substr(Message.search(' ')*60000);
sleeptime(tyme);
return "";
}
}
function sleeptime(tyme)
{
MsgPlus.AddTimer("Statuz", tyme);
MsgPlus.DisplayToast("Status Changer", "Timer iniciado: "+tyme+" milisegundos para Offline");
}
function OnEvent_Timer(timerID)
{
if(timerID == "Statuz")
{
Messenger.MyStatus = 2;
}
}
RE: Little help with a code??? -> ANOTHER HELP by TheGuruSupremacy on 03-19-2007 at 11:34 PM
FIXED
quote: Originally posted by markee
function OnGetScriptCommands(){
var ScriptCommands = "<ScriptCommands>";
ScriptCommands += "<Command>";
ScriptCommands += "<Name>sleep</Name>";
ScriptCommands += "<Description>Tempo para a contagem</Description>";
ScriptCommands += "<Parameters><Tempo em minutos></Parameters>";
ScriptCommands += "</Command>";
ScriptCommands += "</ScriptCommands>";
return ScriptCommands;
}
function OnEvent_ChatWndSendMessage(ChatWnd, Message) {
if (Message.substr(0, 7) == "/sleep "){
var tyme = Message.substr(Message.search(' '))*60000;//------>PAY ATTENTION HERE
sleeptime(tyme);
return "";
}
}
function sleeptime(tyme)
{
MsgPlus.AddTimer("Statuz", tyme);
MsgPlus.DisplayToast("Status Changer", "Timer iniciado: "+tyme+" milisegundos para Offline");
}
function OnEvent_Timer(timerID)
{
if(timerID == "Statuz")
{
Messenger.MyStatus = 2;
}
}
RE: Little help with a code??? -> ANOTHER HELP by MicroWay on 03-20-2007 at 12:17 AM
Thanks all people for helping me!!!
It's working now!!!!
|