Results 1 to 8 of 8

Thread: Reading ':' in chatbox?

  1. #1
    Join Date
    Mar 2007
    Posts
    5,125
    Mentioned
    275 Post(s)
    Quoted
    901 Post(s)

    Default Reading ':' in chatbox?

    Hey all.

    Trying to make a little script just to help out with my Clan.

    Aim of the script is for the user to type "@Follow" in the clan chat and the account would do a "MMToMS" and scan for all the players until it found who typed '@Follow' in the clan message, Problem is, when reading the chatbox, ':' is returning as '?'

    eg:
    Code:
    [Clan Name] PlayerName: @Follow
    Would return in Simba as:

    Code:
    ?Clan Name] PlayerName? @Follow
    Current code being used;

    Simba Code:
    function GetLastClanMsg: string;
    var
      P: TPoint;
      cArr: TPointArray;
      B: TBox;
    begin
      Result := '';
      P := TextCoords(8);
      if (FindColorsTolerance(cArr, 0, MCX1, P.y, MCX2, P.y + 13, 255)) then
      begin
        B := GetTPABounds(cArr);
        result := Trim(GetTextAtExWrap(b.x1-1,p.y,B.x2+1,p.y+13,0,5,2,0,255,SmallChars));
      end;
    end;

    ^^ from chat.simba (modified to read all colors)

    Simba Code:
    Writeln(GetLastClanMsg);

    Output:
    Simba Code:
    ?Clan Name] PlayerName? @Follow
    ^^ removed real clan name and real playername

    Any help on what to do to solve this issue?

    E: I have tried the Replace funtion with no luck

    Simba Code:
    Tmp := Replace(GetLastClanMsg, '?', '');
    writeln(Tmp);
    Last edited by Justin; 10-16-2012 at 08:27 AM.

    Forum account issues? Please send me a PM

  2. #2
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    try
    Simba Code:
    TheName:=Between(']', '?', GetLastClanMsg);

  3. #3
    Join Date
    Mar 2007
    Posts
    5,125
    Mentioned
    275 Post(s)
    Quoted
    901 Post(s)

    Default

    Quote Originally Posted by riwu View Post
    try
    Simba Code:
    TheName:=Between(']', '?', GetLastClanMsg);
    Didn't work for me.

    I have made a really dirty way of doing this...

    Simba Code:
    function GetLastClanMsg: string;
    var
      P: TPoint;
      cArr: TPointArray;
      B: TBox;
    begin
      Result := '';
      P := TextCoords(8);
      if (FindColorsTolerance(cArr, 0, MCX1, P.y, MCX2, P.y + 13, 255)) then
      begin
        B := GetTPABounds(cArr);
        result := Trim(GetTextAtExWrap(b.x1-1,p.y,B.x2+1,p.y+13,0,5,2,0,255,SmallCharsNS));
      end;
    end;

    Simba Code:
    Tmp := GetLastClanMsg;
    Tmp := Replace(Tmp,'..',':');
    Tmp := Replace(Tmp,'[','');
    Tmp := Replace(Tmp,']','');
    FinalMsg := Replace(Tmp,'CLAN NAME ','/');
    if ((Pos('@Follow', FinalMsg) > 0) or ((Pos('@follow', FinalMsg) > 0))) then
    begin
    Writeln(FinalMsg);
    Writeln('@Follow command activated by : ' + Between('/', ':', FinalMsg));
    FindClanMember;
    Wait(60000);
    end;

    Forum account issues? Please send me a PM

  4. #4
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    Well i didn't know what other weird characters you can get.
    Can just be
    Pos('@follow',Lowercase(FinalMsg));
    With Between function what's in front doesn't really matter actually, just need to make sure the symbol after Clan Name is same as substring 1.

  5. #5
    Join Date
    Feb 2006
    Posts
    3,044
    Mentioned
    4 Post(s)
    Quoted
    21 Post(s)

    Default

    So what you are trying to do is to get the name of the Player who typed "@Follow"?

    ~Home

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

    Default

    Kinda new to RegEx's, but I think;

    Simba Code:
    procedure doStuff();
    var
      thestring:string;
    begin
      thestring := GetLastClanMsg;
      if ExecRegExpr('@{1}Follow|@{1}follow', thestring) then // if we find @Follow or @follow in thestring, then we'll evaluate to true.
        writeln('true');
    end;

    might be what you are looking for?

  7. #7
    Join Date
    Mar 2007
    Posts
    5,125
    Mentioned
    275 Post(s)
    Quoted
    901 Post(s)

    Default

    Quote Originally Posted by Home View Post
    So what you are trying to do is to get the name of the Player who typed "@Follow"?

    ~Home
    Correct, but the problem was that SmallChars didn't read : correctly, using SmallCharsNS and replacing '..' (what SmallCharsNS picks up : as) with : worked.

    I know its a dirty code but it works

    Forum account issues? Please send me a PM

  8. #8
    Join Date
    Jul 2011
    Location
    /home/litoris
    Posts
    2,226
    Mentioned
    0 Post(s)
    Quoted
    159 Post(s)

    Default

    You could also use a DTM/bitmap of the whole message, but seems like you have a fix.
    Miner & Urn Crafter & 07 Chicken Killer
    SPS BlindWalk Tutorial

    Working on: Nothing

    teacher in every art, brought the fire that hath proved to mortals a means to mighty ends

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
  •