Results 1 to 9 of 9

Thread: InChat

  1. #1
    Join Date
    Jul 2008
    Posts
    136
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default InChat

    Ok i am making an auto responder for my script.

    It responds if someone asks for their woodcutting levels.
    So if someone asks " What is ur wc lvl ? "
    It will respond by saying " My wood cutting level is 5 ( or watever )"

    But what i want to do is check that if i have already responded. Cuz the auto responder will be in my Anti Ban ( loop ). So if someone asks in the chat it will keep going on . Is there a way around it ?

  2. #2
    Join Date
    Jun 2008
    Location
    San Diego, California
    Posts
    276
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Here ya go. This should work.
    SCAR Code:
    program New;
    {.Include SRL\SRL.scar}
    var
    TalkedAlready: Boolean;

    procedure AntiBan;
    begin
      If InChat('WoodCutting Level')then//edit what you want it to read, accordingly..
      begin
        If TalkedAlready = True then Exit;
        TypeSend('My woodcutting level is 99');//edit this accordingly  
        TalkedAlready := True;
      end;
    end;


    begin
    TalkedAlready := False; // Make sure you call this
    //before the script starts running or after a load so
    //it has a chance to talk.
    AntiBan;
    end.
    Tell me if it works for you
    Current Project: All In 1 Falador Script - 20% DONE

  3. #3
    Join Date
    Jul 2008
    Posts
    136
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    That could work. But i am looking for another way. Thanx though.

  4. #4
    Join Date
    Jun 2008
    Location
    San Diego, California
    Posts
    276
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Like? Do you have any ideas of what you want? Please specify what you want and you'll get more help.
    Current Project: All In 1 Falador Script - 20% DONE

  5. #5
    Join Date
    Dec 2006
    Location
    Sydney, New South Wales, Australia
    Posts
    4,603
    Mentioned
    15 Post(s)
    Quoted
    42 Post(s)

    Default

    Quote Originally Posted by Shermanator
    SCAR Code:
    TalkedAlready := False; // Make sure you call this
    //before the script starts running or after a load so
    //it has a chance to talk.
    Lol, no you don't. All booleans are set to false at the start of a script, all intergers are set to 0 at the start of a script and all strings are set to '' at the start of a script
    You may contact me with any concerns you have.
    Are you a victim of harassment? Please notify me or any other staff member.

    | SRL Community Rules | SRL Live Help & Chat | Setting up Simba | F.A.Q's |

  6. #6
    Join Date
    May 2007
    Location
    Netherlands, Amersfoort
    Posts
    2,701
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    This is an example of a pritty fast auto responder, and easy to set up. It is NOT working at the moment, but when srl 21 gets released it will work perfectly again.

    SCAR Code:
    Var
      LastRespond: String;
      HowManyResponds, SetTime: Integer;
      TheQuestion, TheRespond: array of array of String;

    Procedure SetupResponds; // ADD RESPONDS FOR BETTER ANTI BAN !
    begin
      HowManyResponds := 2;  {<-- SETUP CORRECT !!}
      SetArrayLength(TheQuestion, HowManyResponds); SetArrayLength(TheRespond, HowManyResponds); // you can better space bar this out of screen, but don't remove it

      TheQuestion[0] := ['noob'];
      TheRespond[0]  := ['Im not a noob!', 'your the noob', 'look in the mirror', 'noob noob', 'no way noob', 'your more noob', 'whoes noob?'];

      TheQuestion[1] := ['respond'];
      TheRespond[1]  := ['what to say?', 'i dont have anything to say', 'no im bussy'];
    end;

    Function TheResponder: boolean; // created by MasterKill
    var
      I, II, Rand, CurTime: Integer;
      Text, Name, MakeRespond: String;
      TextP: TPoint;
      Awnser: TStringArray;
    begin
      CurTime := GetSystemTime;
      If (CurTime - SetTime < 20000) Then Exit;
      For I := 8 DownTo 4 Do
      Begin
        TextP := TextCoords(I);
        If findcolor(x, y, 16711680, TextP.x, TextP.y, TextP.x + 200, TextP.y + 14) Then
        Begin
          Text := LowerCase(Trim(GetTextAtEx(x - 3, textp.y - 2, 0, SmallChars, False, False, -1, 1, 16711680, 60, False, tr_allChars)));
          If (Text = LastRespond) Then
          Exit;
          LastRespond := Text;
          Name := GetBlackText(I);
          If (Pos(Players[CurrentPlayer].nick, Name) <> 0) then Exit;
          Break;
        End;
        If (I = 4) Then Exit;
      End;
      For I := 0 To HowManyResponds - 1 Do
      begin
        For II := 0 To High(TheQuestion[I]) Do
        begin
          If (Pos(TheQuestion[I][II], Text) <> 0) then
          begin
            WriteLn('MasterKill Respond:');
            WriteLn('/ ' + Name + ' ' + Text);
            Rand := Random(High(TheRespond[I]));
            TypeSend(TheRespond[I][Rand]);
            WriteLn('/ ' + Players[CurrentPlayer].Name + ': ' + TheRespond[I][Rand]);
            Result := True;
            SetTime := GetSystemTime;
            exit;
          end;
        end;
      end;
    end;

    Begin
      MarkTime(SetTime);// dont forget to call this one
      SetupResponds;
      TheResponder;
    End.

    btw, It won't respond twice to the same thing in a row

    I hope this helped you, good luck scripting.

  7. #7
    Join Date
    Jan 2007
    Posts
    8,876
    Mentioned
    123 Post(s)
    Quoted
    327 Post(s)

    Default

    Quote Originally Posted by Dan's The Man View Post
    Lol, no you don't. All booleans are set to false at the start of a script, all intergers are set to 0 at the start of a script and all strings are set to '' at the start of a script
    I think he means before calling the procedure if you already called the procedure from beforehand.

  8. #8
    Join Date
    Jul 2008
    Posts
    136
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by MasterKill View Post
    This is an example of a pritty fast auto responder, and easy to set up. It is NOT working at the moment, but when srl 21 gets released it will work perfectly again.

    SCAR Code:
    Var
      LastRespond: String;
      HowManyResponds, SetTime: Integer;
      TheQuestion, TheRespond: array of array of String;

    Procedure SetupResponds; // ADD RESPONDS FOR BETTER ANTI BAN !
    begin
      HowManyResponds := 2;  {<-- SETUP CORRECT !!}
      SetArrayLength(TheQuestion, HowManyResponds); SetArrayLength(TheRespond, HowManyResponds); // you can better space bar this out of screen, but don't remove it

      TheQuestion[0] := ['noob'];
      TheRespond[0]  := ['Im not a noob!', 'your the noob', 'look in the mirror', 'noob noob', 'no way noob', 'your more noob', 'whoes noob?'];

      TheQuestion[1] := ['respond'];
      TheRespond[1]  := ['what to say?', 'i dont have anything to say', 'no im bussy'];
    end;

    Function TheResponder: boolean; // created by MasterKill
    var
      I, II, Rand, CurTime: Integer;
      Text, Name, MakeRespond: String;
      TextP: TPoint;
      Awnser: TStringArray;
    begin
      CurTime := GetSystemTime;
      If (CurTime - SetTime < 20000) Then Exit;
      For I := 8 DownTo 4 Do
      Begin
        TextP := TextCoords(I);
        If findcolor(x, y, 16711680, TextP.x, TextP.y, TextP.x + 200, TextP.y + 14) Then
        Begin
          Text := LowerCase(Trim(GetTextAtEx(x - 3, textp.y - 2, 0, SmallChars, False, False, -1, 1, 16711680, 60, False, tr_allChars)));
          If (Text = LastRespond) Then
          Exit;
          LastRespond := Text;
          Name := GetBlackText(I);
          If (Pos(Players[CurrentPlayer].nick, Name) <> 0) then Exit;
          Break;
        End;
        If (I = 4) Then Exit;
      End;
      For I := 0 To HowManyResponds - 1 Do
      begin
        For II := 0 To High(TheQuestion[I]) Do
        begin
          If (Pos(TheQuestion[I][II], Text) <> 0) then
          begin
            WriteLn('MasterKill Respond:');
            WriteLn('/ ' + Name + ' ' + Text);
            Rand := Random(High(TheRespond[I]));
            TypeSend(TheRespond[I][Rand]);
            WriteLn('/ ' + Players[CurrentPlayer].Name + ': ' + TheRespond[I][Rand]);
            Result := True;
            SetTime := GetSystemTime;
            exit;
          end;
        end;
      end;
    end;

    Begin
      MarkTime(SetTime);// dont forget to call this one
      SetupResponds;
      TheResponder;
    End.

    btw, It won't respond twice to the same thing in a row

    I hope this helped you, good luck scripting.
    Thank You =] When is Srl v 21 coming out ?, and could you explain to me how it works.

  9. #9
    Join Date
    May 2007
    Location
    Netherlands, Amersfoort
    Posts
    2,701
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    um ok.

    first off the script has to find the "blue text" of course, so I made a For To Do loop to check the last 4 lines. First I used If FindColor to check if there is any text at that line at all, a fail safe to make it way faster. When findcolor detects any blue text, then you'll have to get the text.

    Runescape did change the text coords laterly so thats why its not working atm, but that will be fixed in srl 21.

    now that we have found the text we need to check some things first. To check if where not respond to ourself we need to get the name also wich is in black text:
    SCAR Code:
    Name := GetBlackText(I); // I results the linenumber where the text is found
          If (Pos(Players[CurrentPlayer].nick, Name) <> 0) then Exit;
    pos() is a function that checks if a string is in the mainstring. So if you players nickname is in the "name" it will exit the respond function.

    of course we can now break the first For To Do loop, and start the ectual responding.


    as you can see I used an array of array of string; for the responds list. This basicly is a duble array. So in SetupResponds;, you have to declare how many responds you have, set the array lenght, and declare the responds themself. take a look at the procedure and you'll know what i'm talking about.

    back to the responder.
    Now that we have the last chat line, we have to check if there are any things in to respond to. Becouse we have an array of array of string, we also need to use a dubble loop. I used vars I and II. the first loop involes the Question[I][], this loops goes trough all questions. now we are going to check if there are any of the questions in the actual "text" we picked earlyer. The second loop of those to include the String variables where the question are declared. so in this loop we are going to check if the Question[I][II] is in the scring.
    SCAR Code:
    For I := 0 To HowManyResponds - 1 Do // how many responds -1 else you get a runetime error [out of range]
      begin
        For II := 0 To High(TheQuestion[i]) Do // high() gets the biggest number of the array
        begin
          If (Pos(TheQuestion[i][II], Text) <> 0) then // check if the question is in the text.
          begin
    So if the question is in the text, we have to start the actual responding. For extra anti ban (wich is a must) we have multipile awnsers, and now we have to get one of those to responds with. First you get the array length of the String array of the awnser, and with that you randomize one of the responds:
    SCAR Code:
    WriteLn('MasterKill Respond:');
            WriteLn('/ ' + Name + ' ' + Text);
            Rand := Random(High(TheRespond[i]) + 1); // pick a random respond and remeber the random number
            TypeSend(TheRespond[i][Rand]); // respond :)
            WriteLn('/ ' + Players[CurrentPlayer].Name + ': ' + TheRespond[i][Rand]); // and remember :)
            Result := True;
    and that is how the respond is being made.

    I tried to explain my auto responder so good as I can, and I hope this helped you with scripting.

    Good luck!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Inchat Function Problem
    By Granti in forum OSR Help
    Replies: 21
    Last Post: 06-29-2007, 04:01 AM
  2. Tree chopping with InChat?!
    By Life's Shadow in forum OSR Help
    Replies: 4
    Last Post: 06-13-2007, 04:13 PM
  3. Find inchat
    By fugate in forum OSR Help
    Replies: 4
    Last Post: 04-15-2007, 05:22 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •