Results 1 to 9 of 9

Thread: Chat.scar SetChat(); Fixed

  1. #1
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default Chat.scar SetChat(); Fixed

    Well, the current one doesn't work when you want to turn a chat type off because the 'ff' text can't be found (I posted about that bug a while ago, but I don't think anything could have been done). I tried messing around with font bitmap, but had no luck, so I fixed SetChat. I also added constants as you'll see, and made the function return a boolean.

    Old
    SCAR Code:
    {*******************************************************************************
    procedure SetChat(state: String; chat: Integer);
    By: Wizzup?, WT-Fakawi, Starblaster100 & N1ke!
    Description: Sets Chat to desired state
      Chat:  Game  Public  Private  Clan  Trade  Assist
              0       1       2       3     4       5
    *******************************************************************************}

    procedure SetChat(state: string; chat: Integer);
    var
       x, y, mx, Color: Integer;
    begin
      case chat of
        0: mx := 90;
        1: mx := 145;
        2: mx := 200;
        3: mx := 260;
        4: mx := 320;
        5: mx := 373;
        else
        begin
          srl_Warn('SetChat', 'chat(' + IntToStr(chat) + ') does not exist.', warn_AllVersions);
          Exit;
        end;
      end;
      State := LowerCase(State);
      case State of
        'on', 'all': Color := 65280;
        'off': Color := 255;
        'hide': Color := 16776960;
        'friends', 'filter': Color := 65535;
        else srl_Warn('SetChat', state + ' does not exist.', warn_AllVersions);
      end;
      State := Capitalize(State);
      if not FindColor(x, y, Color, mx - 10, 486, mx + 10, 506) then
      begin
        Mouse(mx, 496, 8, 8, False);
        Wait(450 + Random(175));
        ChooseOption(State);
      end;
    end;

    New
    SCAR Code:
    const
      CHAT_GAME    = 0;
      CHAT_PUBLIC  = 1;
      CHAT_PRIVATE = 2;
      CHAT_CLAN    = 3;
      CHAT_TRADE   = 4;
      CHAT_ASSIST  = 5;

    {*******************************************************************************
    procedure SetChat(state: String; chat: Integer);
    By: Wizzup?, WT-Fakawi, Starblaster100, N1ke! & Coh3n
    Description: Sets Chat to desired state
      Chat:  Game  Public  Private  Clan  Trade  Assist
              0       1       2       3     4       5
    *******************************************************************************}

    function SetChat(state: string; chat: Integer): Boolean;
    var
       x, y, mx, Color: Integer;
    begin
      mx := 90 + (chat * 55);

      if (not InRange(chat, CHAT_GAME, CHAT_ASSIST) then
      begin
        srl_Warn('SetChat', 'chat(' + IntToStr(chat) + ') does not exist.', warn_AllVersions);
        Exit;
      end;

      case Lowercase(State) of
        'on', 'all': Color := 65280;
        'off': Color := 255;
        'hide': Color := 16776960;
        'friends', 'filter': Color := 65535;
        else
          srl_Warn('SetChat', state + ' does not exist.', warn_AllVersions);
      end;

      if (not FindColor(x, y, Color, mx - 10, 486, mx + 10, 506)) then
      begin
        Mouse(mx, 496, 4, 4, False);
        Wait(RandomRange(50, 150));

        if (Lowercase(State) = 'off') then
        begin
          case chat of
            CHAT_PUBLIC: Mouse(mx, 496 - 33, 8, 3, True);
            CHAT_PRIVATE..CHAT_ASSIST: Mouse(mx, 496 - 20, 8, 3, True);
          end;

          Wait(RandomRange(50, 150));
          Result := FindColor(x, y, Color, mx - 10, 486, mx + 10, 506);
        end else
          Result := WaitOption(Capitalize(State), 300);
      end;
    end;
    I did test 15-20 times turning the chats on/off/etc, so it does work.

    Comments?
    Last edited by Wanted; 03-10-2010 at 07:01 AM.

  2. #2
    Join Date
    Jul 2007
    Location
    Right now? Chair.
    Posts
    8,488
    Mentioned
    3 Post(s)
    Quoted
    12 Post(s)

    Default

    Lovely.

    ~RM

    I & I know Zion. It is in the spirit, body and mind of every one of us
    RMouse(obj: TMSIObject): boolean;

  3. #3
    Join Date
    Mar 2007
    Posts
    4,810
    Mentioned
    3 Post(s)
    Quoted
    3 Post(s)

    Default

    Couldn't this:

    SCAR Code:
    case chat of
        CHAT_GAME:    mx := 90;
        CHAT_PUBLIC:  mx := 145;
        CHAT_PRIVATE: mx := 200;
        CHAT_CLAN:    mx := 260;
        CHAT_TRADE:   mx := 320;
        CHAT_ASSIST:  mx := 373;
        else

    Be:

    SCAR Code:
    mx := 90 + (Chat * 55);

    Or would that mess everything up?

  4. #4
    Join Date
    Dec 2006
    Location
    Houston, TX USA
    Posts
    4,791
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Meh, chat is outdated all together... I've never really liked it.

    I've been using this in my scripts

    SCAR Code:
    {*******************************************************************************
    function CurrentChat: string;
    By: IceFire908
    Description: Returns the current chat you have open.
    *******************************************************************************}


    function CurrentChat: string;
    var
      Ch: TStringArray;
      M: TPoint;
      I: Byte;
    begin
      Result := 'unknown';
      GetMousePos(M.X, M.Y);
      if (PointInBox(M, IntToBox(3, 481, 404, 503))) then
        MMouse(M.X, M.Y - 33, 5, 5);
      for I := 0 to 6 do
        if (GetColor(9 + (57 * I), 484) <> 5399409) then
          Break;
      Ch := ['all', 'game', 'public', 'private', 'clan', 'trade', 'assist'];
      if (not (InRange(I, 0, 6))) then
        Exit;
      Result := Ch[I];
    end;

    {*******************************************************************************
    function CurrentChatStatus(Chat: string): string;
    By: IceFire908
    Description: Returns the current chat status.
    *******************************************************************************}


    function CurrentChatStatus(Chat: string): string;
    var
      St, Ch: TStringArray;
      C: TIntegerArray;
      M, T: TPoint;
      I: Integer;
      II: Byte;
      S: TBox;
    begin
      Result := 'unknown';
      GetMousePos(M.X, M.Y);
      if (PointInBox(M, IntToBox(3, 481, 404, 503))) then
        MMouse(M.X, M.Y - 33, 5, 5);
      if (LowerCase(Chat) = 'all') then
      begin
        if (CurrentChat = 'all') then
          Result := 'on'
        else
          Result := 'off';
        Exit;
      end;
      C := [65280, 65535, 255, 16776960]
      St := ['on', 'friends', 'off', 'hide'];
      Ch := ['game', 'public', 'private', 'clan', 'trade', 'assist'];
      if (not (InStrArrEx(LowerCase(Chat), Ch, I))) then
        Exit;
      S := IntToBox(71 + (57 * I), 492, 107 + (57 * I), 501);
      T := Point((S.X1 + S.X2) div 2, (S.Y1 + S.Y2) div 2);
      for II := 0 to 3 do
        if (FindColorSpiral(T.X, T.Y, C[II], S.X1, S.Y1, S.X2, S.Y2)) then
          if ((Ch[I] = 'game') and (C[II] = 65535)) then
            Result := 'filter'
          else
            if ((Ch[I] = 'game') and (C[II] = 65280)) then
              Result := 'all'
            else
              Result := St[II];
    end;

    {*******************************************************************************
    function SetChatEx(Chat, Status: string): Boolean;
    By: IceFire908
    Description: Sets the chat to desired status.
    *******************************************************************************}


    function SetChatEx(Chat, Status: string): Boolean;
    var
      Ch: TStringArray;
      Cha, Sta: string;
      C, M: TPoint;
      I: Integer;
    begin
      GetMousePos(M.X, M.Y);
      if (PointInBox(M, IntToBox(3, 481, 404, 503))) then
        MMouse(M.X, M.Y - 33, 5, 5);
      Cha := LowerCase(Chat);
      Sta := LowerCase(Status);
      Result := (CurrentChatStatus(Cha) = Sta);
      if (Result) then
        Exit;
      Ch := ['all', 'game', 'public', 'private', 'clan', 'trade', 'assist'];
      if (not (InStrArrEx(Cha, Ch, I))) then
        Exit;
      C := Point(33 + (56 * I), 492);
      if (((Cha = 'all') and (Sta = 'on')) or (Sta = 'view')) then
      begin
        if (not (CurrentChat = Cha)) then
          Mouse(C.X, C.Y, 5, 5, True);
        Result := True;
        Exit;
      end;
      Mouse(C.X, C.Y, 5, 5, False);
      Wait(200 + Random(100));
      Result := ChooseOption(Capitalize(Status));
    end;

  5. #5
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    Quote Originally Posted by Rasta Magician View Post
    Lovely.

    ~RM
    Well thank you.

    Quote Originally Posted by Naum View Post
    Couldn't this:

    SCAR Code:
    case chat of
        CHAT_GAME:    mx := 90;
        CHAT_PUBLIC:  mx := 145;
        CHAT_PRIVATE: mx := 200;
        CHAT_CLAN:    mx := 260;
        CHAT_TRADE:   mx := 320;
        CHAT_ASSIST:  mx := 373;
        else

    Be:

    SCAR Code:
    mx := 90 + (Chat * 55);

    Or would that mess everything up?
    No, that would work. I just replaced the numbers with constants. Didn't even look at the values.


    Quote Originally Posted by IceFire908 View Post
    Meh, chat is outdated all together... I've never really liked it.
    It shouldn't be now. Although I didn't look through the rest of the functions. Just the SetChat ones.

  6. #6
    Join Date
    Apr 2007
    Location
    Perth, Australia
    Posts
    3,926
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    I don't think this ever got added so I'm adding it now. Thanks Cohen.

  7. #7
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    Quote Originally Posted by ZephyrsFury View Post
    I don't think this ever got added so I'm adding it now. Thanks Cohen.
    No problem.

  8. #8
    Join Date
    Oct 2006
    Location
    MI USA
    Posts
    3,166
    Mentioned
    6 Post(s)
    Quoted
    11 Post(s)

    Default

    Were there some recent changes to Chat.Scar that causes the AutoResponders to reply to themselves ? I'm using Masterkill's SARS...


  9. #9
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    Quote Originally Posted by RAM View Post
    Were there some recent changes to Chat.Scar that causes the AutoResponders to reply to themselves ? I'm using Masterkill's SARS...
    Not sure, the only I changed was the SetChats procedure.

Thread Information

Users Browsing this Thread

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

Posting Permissions

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