What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » problem with Arrays

problem with Arrays
Author: Message:
darkriven
New Member
*


Posts: 2
Joined: Feb 2007
O.P. problem with Arrays
hi :)
I'm working on something like a bot.
It worked to answer people, but he simply answered everytime someone wrote a message. Now I've created the function GetStatus and the Array botstatus to save who i have answered this message yet. The bot should simply answer the sentence the first time someone wrote something.
(It should answer again if the state changed since the first answer)

Here is the code:
I don't work anymore :(

code:
var gChatWnd;
var wo = "weg";
var back = "";
var botstatus = new Array();

function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind)
{
    var tmpstatus;
    tmpstatus=GetStatus(ChatWnd.Handle);
    if(Messenger.MyName != Origin)
    {
    if(tmpstatus==0)
    {
          switch(Messenger.MyStatus)
            {
           case 7:
               ChatWnd.SendMessage("[Automessage] Hi " + Origin + "! Flo ist gerade " + wo + ". Er ist voraussichtlich wieder da um:" + back );
               break;
           case 8:
               ChatWnd.SendMessage("[Automessage] Hi " + Origin + "! Flo ist gerade am Telefon. Das dauert voraussichtlich bis um:" + back);
               break;
           case 4:
               ChatWnd.SendMessage("[Automessage] Hi " + Origin + "! Flo ist gerade beschäftigt. Er hat voraussichtlich wieder Zeit um:" + back);
               break;
           case 9:
               ChatWnd.SendMessage("[Automessage] Hi " + Origin + "! Flo ist gerade beim essen. Er ist voraussichtlich wieder da um:" + back);
               break;
           case 5:
               ChatWnd.SendMessage("[Automessage] Hi " + Origin + "! Flo ist mal kurz " + wo + ". Er ist voraussichtlich wieder da um:" + back );
               break;
          }
    }
    }

}


function GetStatus(windowhandle){
    var Status=0;
    for ( String arg : botstatus ){
    if(arg==windowhandle)
    Status=1;
    }
    if(Status==0)
    botstatus[botstatus.length]=windowhandle;
    return Status;
}

02-07-2007 04:25 PM
Profile E-Mail PM Find Quote Report
Squelettor
Junior Member
**

Avatar

Posts: 49
Joined: Jul 2006
RE: problem with Arrays
quote:
Originally posted by darkriven

code:
for ( String arg : botstatus )



code:

for (var i=0; i<botstatus.length; i++ )


The all script :

code:
var gChatWnd;
var wo = "weg";
var back = "";
var botstatus = new Array();

function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind)
{
  Debug.Trace("OnEvent_ChatWndReceiveMessage : beginning");
  if(Messenger.MyName != Origin)
  {
    var tmpstatus=GetStatus(ChatWnd.Handle);
    if(tmpstatus==0)
    {
      switch(Messenger.MyStatus)
      {
        case 7:
          ChatWnd.SendMessage("[Automessage] Hi " + Origin + "! Flo ist gerade " + wo + ". Er ist voraussichtlich wieder da um:" + back );
          break;
        case 8:
          ChatWnd.SendMessage("[Automessage] Hi " + Origin + "! Flo ist gerade am Telefon. Das dauert voraussichtlich bis um:" + back);
          break;
        case 4:
          ChatWnd.SendMessage("[Automessage] Hi " + Origin + "! Flo ist gerade beschäftigt. Er hat voraussichtlich wieder Zeit um:" + back);
          break;
        case 9:
          ChatWnd.SendMessage("[Automessage] Hi " + Origin + "! Flo ist gerade beim essen. Er ist voraussichtlich wieder da um:" + back);
          break;
        case 5:
          ChatWnd.SendMessage("[Automessage] Hi " + Origin + "! Flo ist mal kurz " + wo + ". Er ist voraussichtlich wieder da um:" + back );
          break;
      }
    }
  }
  Debug.Trace("OnEvent_ChatWndReceiveMessage : end");
}

function GetStatus(windowhandle)
{
  Debug.Trace("GetStatus : beginning");
  var Status=0;
  for (var i=0; i<botstatus.length; i++ )
  {
    if(botstatus[i]==windowhandle)
    {
      Status=1;
    }
  }
  if(Status==0)
  {
    botstatus[botstatus.length]=windowhandle;
  }
  Debug.Trace("Status : " + Status);
  Debug.Trace("GetStatus : end");
  return Status;
}


This post was edited on 02-08-2007 at 02:23 PM by Squelettor.
02-08-2007 02:23 PM
Profile PM Find Quote Report
darkriven
New Member
*


Posts: 2
Joined: Feb 2007
O.P. RE: problem with Arrays
thanks :D
now it works fine :)
02-08-2007 02:55 PM
Profile E-Mail PM Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On