Results 1 to 18 of 18

Thread: Getting player chat message

  1. #1
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default Getting player chat message

    Can anyone point me in the direct of saving what a player says? For example, if I wanted the script to Writeln everything that "nub_cake32" sais in public chat, how would I do that?
    Like if "Nub_cake32" sais:

    Nub_cake32: Hello, I am a noob

    Code:
    Hello, I am a noob
    Thanks in advance

  2. #2
    Join Date
    Dec 2011
    Location
    Toronto, Ontario
    Posts
    6,424
    Mentioned
    84 Post(s)
    Quoted
    863 Post(s)

    Default

    GetChatBoxText():String;

  3. #3
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Quote Originally Posted by Sin View Post
    GetChatBoxText():String;
    Can it look for what a specific player said?

  4. #4
    Join Date
    Dec 2011
    Location
    Toronto, Ontario
    Posts
    6,424
    Mentioned
    84 Post(s)
    Quoted
    863 Post(s)

    Default

    Im writing this w/o the compiler, please edit out any mistakes:

    Simba Code:
    function GetChatFromName(Name:String):String;
    var
      i:Integer;
    begin
      for i := 8 downto 1 do
      begin
        if FindChatBoxText(Name,i,clBlack) then
        begin
          Result := GetChatBoxText(i,clBlue);
          break;
        end;
      end;
    end;

    Im not sure how Explode works, so I probably (99%) sure that I did it wrong. You'll have to get someone to get the Explode() working correctly.

    EDIT:
    Nvm idk what im smoking, its edited to be correct.

  5. #5
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Quote Originally Posted by Sin View Post
    Im writing this w/o the compiler, please edit out any mistakes:

    Simba Code:
    function GetChatFromName(Name:String):String;
    var
      i:Integer;
    begin
      for i := 8 downto 1 do
      begin
        if FindChatBoxText(Name,i,clBlack) then
        begin
          Result := GetChatBoxText(i,clBlue);
          break;
        end;
      end;
    end;

    Im not sure how Explode works, so I probably (99%) sure that I did it wrong. You'll have to get someone to get the Explode() working correctly.

    EDIT:
    Nvm idk what im smoking, its edited to be correct.
    So Do I use it like:

    GetChatFromName(PlayerName)

    OR

    GetChatFromName(PlayerName,Stringvariablehere)

    Or what I keep getting errors

  6. #6
    Join Date
    Dec 2011
    Location
    Toronto, Ontario
    Posts
    6,424
    Mentioned
    84 Post(s)
    Quoted
    863 Post(s)

    Default

    Its a function that returns a string.
    You'll have to declare a string (var s:String), then

    s := GetChatFromName('Zezima');

  7. #7
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Quote Originally Posted by Sin View Post
    Its a function that returns a string.
    You'll have to declare a string (var s:String), then

    s := GetChatFromName('Zezima');
    ahh got it, if this works out I will reserect a funny script I found on powerbot back in 2010

    Edit, it is not working

    Said := GetChatFromName('Namehere')
    Writeln('' + Said)


    If i have a title does that effect it?

  8. #8
    Join Date
    Dec 2011
    Location
    Toronto, Ontario
    Posts
    6,424
    Mentioned
    84 Post(s)
    Quoted
    863 Post(s)

    Default



    Messed around with it a little:

    Simba Code:
    function GetChatFromName(Name:String):TStringArray;
    var
      i:Integer;
      TSA:array of String;
    begin
      SetLength(TSA,9);
      TSA[0] := '';
      for i := 1 to 8 do
      begin
        if FindChatBoxText(Name,i,clBlack) then
        begin
          TSA[i] := GetChatBoxText(i,clBlue);
          writeLn('In index ' + ToStr(i)+ ' ' + TSA[i]);
        end;
      end;
      Result := TSA;
    end;

    EDIT:

    The trivia game??????? OMG

  9. #9
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Quote Originally Posted by Sin View Post


    Messed around with it a little:

    Simba Code:
    function GetChatFromName(Name:String):TStringArray;
    var
      i:Integer;
      TSA:array of String;
    begin
      SetLength(TSA,9);
      TSA[0] := '';
      for i := 1 to 8 do
      begin
        if FindChatBoxText(Name,i,clBlack) then
        begin
          TSA[i] := GetChatBoxText(i,clBlue);
          writeLn('In index ' + ToStr(i)+ ' ' + TSA[i]);
        end;
      end;
      Result := TSA;
    end;

    EDIT:

    The trivia game??????? OMG
    Edit, got it. You will see

  10. #10
    Join Date
    Dec 2011
    Location
    Toronto, Ontario
    Posts
    6,424
    Mentioned
    84 Post(s)
    Quoted
    863 Post(s)

    Default

    Uh...... IDK?
    Im just running stock settings lol.

  11. #11
    Join Date
    Jun 2007
    Location
    The land of the long white cloud.
    Posts
    3,702
    Mentioned
    261 Post(s)
    Quoted
    2006 Post(s)

  12. #12
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    This is going to be so funny stock up on throwaway accounts boys lolol.


    If I get into SRL mems I will release it myself there, if not I will ask a member+ too

  13. #13
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Quote Originally Posted by Sin View Post
    Uh...... IDK?
    Im just running stock settings lol.
    Sorry about double post, but it is now just compiling and then ending..

    I'm using

    Simba Code:
    Begin
      SetupSRL;
      GetChatFromName('myname')
    End.

    As my main loop :/ I got it to work one time but now it does not

  14. #14
    Join Date
    Dec 2011
    Location
    Toronto, Ontario
    Posts
    6,424
    Mentioned
    84 Post(s)
    Quoted
    863 Post(s)

    Default

    Umm... It's public chat, chat is blue, name is correct right?

  15. #15
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Quote Originally Posted by Sin View Post
    Umm... It's public chat, chat is blue, name is correct right?
    Yea, I tried using spaces instead of underscores and underscores instead of spaces

    Output:

    Code:
    Compiled successfully in 686 ms.
    SRL Compiled in 0 msec
    Paired with SMART[2728]
    Successfully executed.

    also, when i try to not use smart and drag target to smart it closes out of smart


    EDIT: Ok, I figured out it can't find names with spaces, but how do I make it filters the boxes that don't have their name in it?

  16. #16
    Join Date
    Dec 2011
    Location
    Toronto, Ontario
    Posts
    6,424
    Mentioned
    84 Post(s)
    Quoted
    863 Post(s)

    Default

    SRL Compiled in 0 msec
    Paired with SMART[8784]
    Asking Question: What is the village of NPCS called north of Falador?
    In index 1
    In index 2
    In index 3
    In index 4
    In index 5
    In index 6
    In index 7
    In index 8 Goblin village
    Correct Answer: Player1645?
    Successfully executed.
    I think it's glitching for you >_<

  17. #17
    Join Date
    Feb 2012
    Location
    Wonderland
    Posts
    1,988
    Mentioned
    41 Post(s)
    Quoted
    272 Post(s)

    Default

    Here's a little snippet I made a while back:
    Simba Code:
    {$include_once srl/srl.simba}
      {$include_once srl/srl/misc/debug.simba}

    function GetChatBoxTextAnyColor(Line: Integer): array of string;
    var
      TempCTS, i: Integer;
      P: TPoint;
      B: TBox;
      clearTPA, res: TPointArray;
      Area51Colors: TIntegerArray;
    begin
      P := TextCoords(Line);
      TempCTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(3);
      B := IntToBox(MCX1 + 5, P.y, MCX2 - 19, P.y + 13);
      FindColorsTolerance(clearTPA, 7705763, B.X1, B.Y1, B.X2, B.Y2, 22);
      ReturnPointsNotInTPAWrap(clearTPA, B, res);

      debugTPA(res, '');
      Area51Colors := GetColors(res);
      ClearSameIntegers(Area51Colors);
      SetArrayLength(result, Length(Area51Colors));

      B := GetTPABounds(res);
      for i := 0 to high(Area51Colors) do
        result[i] := Trim(GetTextAtExWrap(B.X1 - 1, P.y, B.X2 + 1, P.y + 13,
                                      0, 5, 2, Area51Colors[i], 0, SmallChars));
      ColorToleranceSpeed(1);
      ColorToleranceSpeed(TempCTS);
    end;

    function GetCBTxt(line: integer): string;
    begin
      result := Implode(' ', GetChatBoxTextAnyColor(line));
      {
      remove := ['', '', '', '', '', '', '', '', '', ''];
      for i := 0 to high(remove) do
        result := ReplaceWrap(result, remove[i], '', []);
      }

    end;

    begin
      SetupSRL;
      Writeln(GetCBTxt(8));
    end.

    Note, I didn't bother filtering out the unidentifiable characters from the string (doesn't make much a difference unless you actually need to use the strings later on).

  18. #18
    Join Date
    Dec 2011
    Location
    Toronto, Ontario
    Posts
    6,424
    Mentioned
    84 Post(s)
    Quoted
    863 Post(s)

    Default

    Got my script working!


    I just need more questions.

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
  •