Results 1 to 6 of 6

Thread: [REQ] Trade: Check & Accept Function

  1. #1
    Join Date
    Jun 2007
    Location
    Belgium - Eke
    Posts
    66
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default [REQ] Trade: Check & Accept Function

    function TradeCheckAccept( TradeWith : String): Boolean;

    I'm in need of a function that checks for trade requests and compares the name of the player that wants to trade to the TradeWith String. The TradeWith string contains the name of the player that the function must accept trade requests from.
    It has to be able to pick out the right trade request when there are multiple traderequests by different players in a short time.

    Don't make a function that accepts trades form anyone and then checks if it is the right player, that would be to slow.

    I tried to make this myself, but failed

    Thx in advance

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

    Default

    Oh sounds fun.... Good for you I'm rather bored atm... I'll see what I can do.

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

    Default

    check out amount.scar and trade.scar you'll see you have all you need in there.

    Open Trade, Get Trader Name. GetTextAtEx can also be useful, search for the name you want in the text box, then move to it and if uptext('trade'); then click on it.

    ~RM

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

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

    Default

    Quote Originally Posted by Rasta Magician View Post
    check out amount.scar and trade.scar you'll see you have all you need in there.

    Open Trade, Get Trader Name. GetTextAtEx can also be useful, search for the name you want in the text box, then move to it and if uptext('trade'); then click on it.

    ~RM
    He doesn't want to open the trade then check.

    EDIT:

    SCAR Code:
    function TradeCheckAccept(TradeWith: TStringArray): Boolean;
    var
      k, c, Tx, Ty: Integer;
      TP: TPoint;
      Text, Name: string;
      CPts: TPointArray;
    begin
      if (not(LoggedIn)) then Exit;
      for k := 8 downto 1 do
      begin
        TP := TextCoords(k);
        if (FindColor(Tx, Ty, 8388736, TP.x, TP.y, TP.x + 200, TP.y + 14)) then
        begin
          WriteLn('Found Trade');
          Text := Trim(GetTextAtEx(TP.x - 2, TP.y - 2, 0, SmallChars,
                  False, False, 0, 1, 8388736, 60, False, tr_allChars));
          Name :=  Copy(Text, 1, Pos('wi', Text) - 1);
          WriteLn(Name + ' wishes to trade');
          if (not(InStrArr(Name, TradeWith, True))) then Continue;
          WriteLn(Name + ' was in TradeWith array, trading...');
          FindColorsTolerance(CPts, 8388736, TP.x, TP.y, TP.x + 200, TP.y + 14, 0);
          MiddleTPAEx(CPts, Tx, Ty);
          c := 0;
          while (not(TradeScreen)) do
          begin
            Mouse(Tx, Ty, 50, 5, True);
            Wait(5000);
            Inc(c);
            if (c >= 5) then
            begin
              WriteLn('Could not open bank screen');
              Exit;
            end;
          end;
          Result := True;
          Exit;
        end;
      end;

    I used an array instead of a single string because I believe it would be more useful. So to use it:

    SCAR Code:
    if (TradeCheckAccept(['tradewithme', 'imonthelist', 'this function is leet'])) then WriteLn('Blah blah');

    Tell me if it doesn't work. I haven't tested it.

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

    Default

    i don't understand what this line does:
    SCAR Code:
    if (not(InStrArr(Name, TradeWith, True))) then Continue;

    what does the continue do? could you please explain it to me?

    ~RM

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

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

    Default

    Quote Originally Posted by Rasta Magician View Post
    i don't understand what this line does:
    SCAR Code:
    if (not(InStrArr(Name, TradeWith, True))) then Continue;

    what does the continue do? could you please explain it to me?

    ~RM
    If the name of the person trading is not in the TradeWith array, it skips the part where it opens the trade (the mouseclick and the wait) and goes to the next line in the chatbox and looks for another trade.

    The continue is used in a loop. When it is called, it skips the rest of the loop and goes back to the beginning. So in this script:

    SCAR Code:
    for i := 0 to 10 do
    begin
      if (i mod 2 = 1) then Continue;
      WriteLn(IntToStr(i));
    end;

    it will only print the even numbers because when it is an odd number it skips the WriteLn and goes back to the start.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. My Trade Procedure, Function
    By Ransom in forum RS3 Outdated / Broken Scripts
    Replies: 8
    Last Post: 01-13-2007, 06:08 PM

Posting Permissions

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