Results 1 to 17 of 17

Thread: count amount of item in shop

  1. #1
    Join Date
    Nov 2006
    Posts
    1,103
    Mentioned
    0 Post(s)
    Quoted
    6 Post(s)

    Default count amount of item in shop

    well, i need a function that returns the amount of items in a shop, i already tried something, basicly what i did was i took the invcount function and changed the coordinates it clicks at... but it doesnt work, here it is:
    SCAR Code:
    function CountNPCtradeslot(var items: Integer; i: Integer): Boolean;
    var
      cc, a: Integer;
      iCount: string;
      ix, iy, row, col: Integer;
    begin
      row := i div 8;
      col := i - (row * 8) - 1;
      if (col < 0) then
      begin
        col := 7;
        row := row - 1;
      end;
      ix := 88 + (col * 47) + Random(7);
      iy := 76 + (row * 47) + Random(7);
      Result := True;
      cc := LoadChars2(AppPath + 'CharsChat2\fontsmall\');
      iCount := GetTextAtEx(ix, iy, 0, cc, False, False, 0,
        0, 65535, 10, True, tr_Digits)
        a := Pos('K', iCount);
      if a <> 0 then iCount := Copy(iCount, 1, Length(iCount) - 1) + '000';
      a := Pos('M', iCount);
      if a <> 0 then iCount := Copy(iCount, 1, Length(iCount) - 1) + '000000';
      if Trim(iCount) = '' then
      begin
        Result := False;
        iCount := '1';
      end;
      items := StrToInt(Trim(iCount));
    end;

    i want to use this in my rune buyer, so it know when to stop buying

    thanks

    ---iloveit8---

  2. #2
    Join Date
    Sep 2006
    Posts
    5,219
    Mentioned
    4 Post(s)
    Quoted
    1 Post(s)

    Default

    misc/amount.scar?

  3. #3
    Join Date
    Apr 2006
    Posts
    710
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    He doesn't want to count how many items there are in stack, he wants to count how many items there are in shop (like bronze axe, tinderbox, net...)

    Just like inventory but for shop window :-) It's nice idea, should be implemented to SRL when someone makes working procedure.

  4. #4
    Join Date
    Sep 2006
    Posts
    5,219
    Mentioned
    4 Post(s)
    Quoted
    1 Post(s)

    Default

    Ah ok. How about looking for 65536 in boxes?

  5. #5
    Join Date
    Nov 2006
    Posts
    1,103
    Mentioned
    0 Post(s)
    Quoted
    6 Post(s)

    Default

    i do want to know how many runes are in stack, but its in shop...

    function RuneAmount(area, runetype: string): Integer;
    //i wouldnt use shop for area here...
    //but you can

    but is says its not a good idea to do that... any other ideas?

  6. #6
    Join Date
    Sep 2006
    Posts
    5,219
    Mentioned
    4 Post(s)
    Quoted
    1 Post(s)

    Default

    Code:
    program New;
    {.include srl/srl.scar}
    {.include srl/srl/misc/amount.scar}
    
    begin
    setupsrl;
    writeln(inttostr(runeamount('shop','water')));
    end.
    that worked fine for me except for soul

  7. #7
    Join Date
    Nov 2006
    Posts
    1,103
    Mentioned
    0 Post(s)
    Quoted
    6 Post(s)

    Default

    ok thanks, i really apreciate your help my script might actually work(as if)

    ow and just for not starting a new thread again, i get an error in this function:

    SCAR Code:
    function CheckCash : Boolean;
    var
    Cashamount  : integer;
     begin
      if(coinamount(cashamount) < 3000) then //this line just after the ) is where the error is...
       begin
        result := false;
        if(shopscreen = true) then
         mouse(486, 41, 6, 6, true);
        logout;
        worldswitch;
        randomnextplayer(false);
       end else
        result := true;
     end;

  8. #8
    Join Date
    Sep 2006
    Posts
    5,219
    Mentioned
    4 Post(s)
    Quoted
    1 Post(s)

    Default

    coinamount('inventory')

  9. #9
    Join Date
    Nov 2006
    Posts
    1,103
    Mentioned
    0 Post(s)
    Quoted
    6 Post(s)

    Default

    ow lol, dunno where that cashamount came from... must have been that hard object 5 years ago.. cant really remember it though

    mh... there seems to be some prob in buysell.scar... i had to change point and find item in there... i think it is because it is already used somewhere else in srl... i changed it for now... but i wont be able to give my script to others...

  10. #10
    Join Date
    Sep 2006
    Posts
    5,219
    Mentioned
    4 Post(s)
    Quoted
    1 Post(s)

    Default

    There may be an interface change this month anyway, so don't worry about it for now.

  11. #11
    Join Date
    Nov 2006
    Posts
    1,103
    Mentioned
    0 Post(s)
    Quoted
    6 Post(s)

    Default

    so... basicly what you are saying is... that what i did the entire day was... useless? lol good to know was fun though, and learned something

  12. #12
    Join Date
    Sep 2006
    Posts
    5,219
    Mentioned
    4 Post(s)
    Quoted
    1 Post(s)

    Default

    I'm just saying don't worry about the little details for now.

  13. #13
    Join Date
    Nov 2006
    Posts
    1,103
    Mentioned
    0 Post(s)
    Quoted
    6 Post(s)

    Default

    it makes my script not run call it it a little detail lol

  14. #14
    Join Date
    Sep 2006
    Posts
    5,219
    Mentioned
    4 Post(s)
    Quoted
    1 Post(s)

    Default

    Ah ok, I thought it was like 1 coord or something.

    About editing your SRL and not being able to give to others: You can keep it as it is, working for you, and then if an update effects it, SRL should be fixed so it will work for anyone. In the mean time, you can put modified versions of SRL procedure in your script, just add an 8 to the end or something.

  15. #15
    Join Date
    Nov 2006
    Posts
    1,103
    Mentioned
    0 Post(s)
    Quoted
    6 Post(s)

    Default

    ok ill do that, now on that world switching part of it... im gonna have it log into a random world, and ones it went there, or the world is full, it wont choose that world anymore... not sure how to do that though:P but im gonna think of something first before im gonna ask for more help... i think i at least need an idea of how to do it:P else it would seem like cheating... and im already doing that lol

  16. #16
    Join Date
    Sep 2006
    Posts
    5,219
    Mentioned
    4 Post(s)
    Quoted
    1 Post(s)

    Default

    Well not trying that world ever again is easy, just have an array of world numbers, and pick a random 'good' one.

    Make a type like this

    type activeworld = record
    WorldNumber:integer;
    Active:boolean;
    end;

    Then array
    myworlds:array of activeworld;

    myworlds[0].WorldNumber:=16;
    myworlds[0].active:=true;
    etc

    Then

    repeat
    whichworld:=random(arraylength);
    until myworlds[whichworld].active;
    SCSSLoadWorld(myworlds[whichworld].WorldNumber,true)
    myworlds[whichworld].active:=false;

    Now this will work for a while, but I assume you want to only not back to that world for a while, until the store restocks. Now you have a few things to figure out. How long is a 'while'? How will worlds be put back into the 'good' world list? I'll let you figure that out, with a few hints.

    If you define 'while' as a time period, it will be more accurate but harder to write. If you define 'while' as 'after I've been to X number of worlds', it will be easier write, but less accurate. Hint: array containing last X worlds used, add a new one and bump off the oldest one.

    Remember that other people, legit and autoers, will be buying runes, so theres no guarantee that this will give you well stocked shops. It will give you a better chance, but it might be only a little better than picking a random world.

  17. #17
    Join Date
    Nov 2006
    Posts
    1,103
    Mentioned
    0 Post(s)
    Quoted
    6 Post(s)

    Default

    could i use a timemark for every world? like after an hour it becomes active again...(im using random players too) just for the sake of it, ill post my complete script until now
    SCAR Code:
    {.include srl/srl.scar}
    {.include srl/srl/misc/amount.scar}
    {.include srl/srl/skill/buysell.scar}
    const
    NumbahOfPlayer = 3;//amount of players
    Members = true;//like duh

    procedure WorldSwitch;
    begin

    end;

    procedure trade;
    begin

    end;

    var
    Cashamount  : integer;

    Procedure DeclarePlayers;
    begin
         NumberOfPlayers(NumbahOfPlayer);
         
         Players[0].Name     :='';
         Players[0].Pass     :='';
         Players[0].Nick     :='';
         Players[0].Active   := True;

         Players[1].Name     :='';
         Players[1].Pass     :='';
         Players[1].Nick     :='';
         Players[1].Active   := True;
         
         Players[2].Name     :='';
         Players[2].Pass     :='';
         Players[2].Nick     :='';
         Players[2].Active   := True;

         currentplayer := 0;

    end;


    function EnoughChaos: Boolean;
    begin
    if(runeamount('shop', 'chaos') > 10) then
     result := true else
     result := false;
    end;

    function EnoughDeath: Boolean;
    begin
    if(runeamount('shop', 'death') > 10) then
     result := true else
     result := false;
    end;

    function CheckCash : Boolean;
    var
    Cashamount  : integer;
     begin
      if(CoinAmount('inventory') < 3000) then
       begin
        result := false;
        if(ShopScreen = true) then
         Mouse(486, 41, 6, 6, true);
        Logout;
        WorldSwitch;
        RandomNextPlayer(false);
       end else
        result := true;
     end;

    procedure BuyRunes;
     begin
      repeat
       if(loggedin = false) then break;
       FindNormalRandoms;
       if(CheckCash = false) then break;
       Trade;
       if(EnoughChaos = true) then
        begin
         repeat
          buy(7, 10);
          if(CheckCash = false) then break;
         until(EnoughChaos = true);
        end;
       if(EnoughDeath = true) then
        begin
         repeat
          buy(8, 10);
          if(CheckCash = false) then break;
         until(EnoughDeath = true);
        end;
       mouse(486, 41, 6, 6, true);
       if(CheckCash = false) then break;
       Logout;
       WorldSwitch
       RandomNextPlayer(true);
      until(false);
    end;



    procedure ProgressReport;
    begin

    end;

    begin
    SetupSRL;
    declareplayers;
    OpenSCSS;
    WorldSwitch;
    repeat
    BuyRunes;
    until(players[currentplayer].active = false);
    end.

    i used until(players[currentplayer].active = false); for if all players are active = false to stop the script(only uses cpu for nothing, and power lol)

    it gives an out of range error (i never worked with arrays before, well never created them myself)

    SCAR Code:
    type activeworld = record
    WorldNumber:integer;
    Active:boolean;
    member:boolean;
    end;


    procedure WorldSwitch;
    var
    myworlds:array[0..131] of activeworld;// i forgot the [0..131] part lol...
    whichworld:integer;

    begin
    myworlds[0].WorldNumber:=1; //error is here... out of range
    myworlds[0].active:=true;
    myworlds[0].member:=true;

    myworlds[1].WorldNumber:=2;
    myworlds[1].active:=true;
    myworlds[1].member:=true;
    problem solved,
    now just one final thing, i need to deside at which shops i want the script to work...aubury(or whatever he is called) for sure...what do you guys think?

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Count DTM
    By marre in forum OSR Help
    Replies: 6
    Last Post: 11-29-2007, 02:20 PM
  2. I cant count :o
    By Puffo in forum OSR Help
    Replies: 2
    Last Post: 11-25-2007, 03:14 PM
  3. Need To Find Amount of Item In Shop
    By JNCR in forum OSR Help
    Replies: 11
    Last Post: 09-27-2007, 07:24 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
  •