Results 1 to 4 of 4

Thread: Dectecting a Trade

  1. #1
    Join Date
    Jul 2012
    Posts
    15
    Mentioned
    0 Post(s)
    Quoted
    6 Post(s)

    Default Dectecting a Trade

    The thread title says it all, is there a way to check if a player has send you a trade request, or am i just going to have to search for the trade color?
    Thanks
    (this is in OSR)

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

    Default

    Blah := GetChatBoxText(lineofchat,Coloroftexthere);


    There's a better way to do this but I'm not at computer ATM sorry

  3. #3
    Join Date
    Feb 2013
    Location
    Narnia
    Posts
    615
    Mentioned
    8 Post(s)
    Quoted
    252 Post(s)

    Default

    Quote Originally Posted by imangry View Post
    The thread title says it all, is there a way to check if a player has send you a trade request, or am i just going to have to search for the trade color?
    Thanks
    (this is in OSR)
    C: > Simba > Includes > SRL-OSR > SRL > misc

    scroll to the bottom and double click trade and it will open up a simbascript defining all the OSR options for trading

  4. #4
    Join Date
    Jun 2012
    Location
    Howell, Michigan
    Posts
    1,585
    Mentioned
    34 Post(s)
    Quoted
    553 Post(s)

    Default

    Quote Originally Posted by ibot_dung11 View Post
    C: > Simba > Includes > SRL-OSR > SRL > misc

    scroll to the bottom and double click trade and it will open up a simbascript defining all the OSR options for trading
    Reading the include will definitely help a lot, Ill look through and post what I find, never used trading :P

    Simba Code:
    if HandleTrade then
    blahblahblah // Handles the trade, last function in include


    Simba Code:
    {*******************************************************************************
    function HandleTrade: Boolean;
    by: ZephyrsFury
    Description: Handles a trade.
    *******************************************************************************}

    function HandleTrade: Boolean;
    var
      TheTrader: string;
      Success: Boolean;
      TradeTime, Tx, Ty, ii, c: Integer;
    begin
      if (SomeoneTrades) then
      begin
        if (TimeFromMark(TradeMark) < 30000) then Exit;

        TheTrader := GetTradersName;
        WriteLn(TheTrader + ' wishes to trade.');

        if (InTradersArray(TheTrader, ii)) then
          if (TimeFromMark(Traders[ii].Time) < 5 * 60 * 1000) and (Traders[ii].Attempts >= 2) then
          begin
            WriteLn('We have had unsuccessful trades with ' + TheTrader + ' in the last 5 minutes, Exiting...');
            MarkTime(TradeMark);
            Exit;
          end;

        c := 0;
        while (TradeScreen <> 1) and (c < 3) do
        begin
          if (AcceptTrade) then Break;
          Inc(c);
          Wait(1000 + Random(1000));
        end;
        if (c >= 3) then
        begin
          Writeln('Could not open trade screen.');
          Exit;
        end;
       
        if (TradeScreen = 1) then
        begin
          MarkTime(TradeTime);
          WriteLn('Trading with ' + TheTrader);
          while (TimeFromMark(TradeTime) < 30000) do
          begin
            if (TradeScreen = 1) then
            begin
              if (PlayerAccepted) then
              begin
                WriteLn('Player has accepted, checking for items...');
                if (FindColor(Tx, Ty, srl_outline_black, 311, 76, 504, 292)) then
                begin
                  Accept;
                  WriteLn('Found items, accepted first tradescreen.');
                end else
                begin
                  WriteLn('Trader did not offer any items, Declining');
                  Break;
                end;
              end;
            end else
            if (TradeScreen = 2) then
            begin
              if (PlayerAccepted) then
              begin
                WriteLn('Player has accepted second tradescreen.');
                Accept;
                WriteLn('Accepted second tradescreen');
                Success := True;
              end;
            end else Break;
            Wait(1000 + Random(1000));
          end;
        end;

        if (not(Success)) then
        begin
          if (TimeFromMark(TradeTime) > 30000) then
            WriteLn('Trade time limit passed, declining.');
          while (TradeScreen <> 0) do
            Decline;
          WriteLn('Trade Failed');
          UpdateTradersArray(TheTrader, False);
          if (TalkAfterTrade) then
            if (InTradersArray(TheTrader, ii)) then
              if (Traders[ii].Attempts >= 2) then
                case Random(6) of
                  0: TypeSend(AddMistakes('don''t trade if you''ve got nothing to give me', 20));
                  1: TypeSend(AddMistakes('stop bothering me', 20));
                  2: TypeSend(AddMistakes('please stop trading with me', 20));
                  3: TypeSend(AddMistakes('stop trading with me', 20));
                  4: TypeSend(AddMistakes('stop trading if your not giving me any thing', 20));
                  5: TypeSend(AddMistakes('lol you can stop trading now', 20));
                end;
        end else
        begin
          if (TalkAfterTrade) then
            case Random(6) of
              0: TypeSend(AddMistakes('thanks', 20));
              1: TypeSend(AddMistakes('ty', 20));
              2: TypeSend(AddMistakes('wow thanks...', 20));
              3: TypeSend(AddMistakes('thanks a lot...', 20));
              4: TypeSend(AddMistakes('cool thanks', 20));
              5: TypeSend(AddMistakes('thanks very much', 20));
            end;
          WriteLn('Trade Successful!');
          UpdateTradersArray(TheTrader, True);
          Result := True;
        end;

        MarkTime(TradeMark);
        if SRL_HasProc(srl_OnFindTrade) then
          SRL_Procs[srl_OnFindTrade]();
      end;
    end;

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
  •