Results 1 to 22 of 22

Thread: Get Amount OSR

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

    Default Get Amount OSR

    Im trying to get the amount of some stackable items but the GetAmout(x,y) doesnt return 0's and the FindCoins(x,y,inv) wont return coin amounts greater then 99,999. I thought i read some where how to fix the GetAmount but cant find the thread.

    Help?
    Thanks

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

    Default

    have you tried using, GetAmountBox function?

  3. #3
    Join Date
    Nov 2012
    Posts
    2,351
    Mentioned
    55 Post(s)
    Quoted
    603 Post(s)

    Default

    Post some full client screenshots of coins, in loss-less format, that don't return right values, and I'll look into it for you,

    Edit - in Fonts folder, does your "0" in StatChars07 look the this?
    Attached Images Attached Images
    Last edited by DannyRS; 04-14-2013 at 08:40 PM.


    Programming is like trying keep a wall of shifting sand up, you fix one thing but somewhere else starts crumbling

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

    Default

    Quote Originally Posted by Le Jingle View Post
    have you tried using, GetAmountBox function?
    i believe that only works if the Invtentory spot is defined, but that isnt very "free" of user input if you know what i mean. the less they have to do the better :P

    Quote Originally Posted by DannyRS View Post
    Post some full client screenshots of coins, in loss-less format, that don't return right values, and I'll look into it for you,

    Edit - in Fonts folder, does your "0" in StatChars07 look the this?
    yes, it looks exactly like that "0". sorry but whats loss-less format? still rather new to simba lol

    EDIT: heres my code for the coins
    Code:
    procedure FindCoinAmount;
    begin
      if FindCoins(x, y, 'inv') then
      begin
        writeln('Coins found: '+ ToStr(GetAmount(x, y)));
      end
      else
        writeln('Coins not found! Logging out...');
        Logout;
        terminatescript;
    end;
    and for the get item
    Code:
    procedure FindTicketAmount;
    begin
      if FindObjEx(i, j, ['se','rchery', 'icket'], [ticketcolor1, ticketcolor2, ticketcolor3], 5, 50, MIX1, MIY1, MIX2, MIY2) then
      begin
        MMouse(i,j,5,5);
        ticketintial := GetAmount(i,j);
        writeln('You have ' + ToStr(GetAmount(i,j)) + ' tickets.');
      end
      else
      begin
      ticketintial := 0;
      writeln('You have 0 tickets.');
      end;
    end;
    Last edited by Sk1nyNerd; 04-15-2013 at 04:54 AM.

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

    Default

    Quote Originally Posted by ibot_dung11 View Post
    i believe that only works if the Invtentory spot is defined, but that isnt very "free" of user input if you know what i mean. the less they have to do the better :P



    yes, it looks like exactly like that "0". sorry but whats loss-less format? still rather new to simba lol
    .png so the image isn't deluded

  6. #6
    Join Date
    Nov 2012
    Posts
    2,351
    Mentioned
    55 Post(s)
    Quoted
    603 Post(s)

    Default

    Quote Originally Posted by ibot_dung11 View Post
    i believe that only works if the Invtentory spot is defined, but that isnt very "free" of user input if you know what i mean. the less they have to do the better :P
    Post a screenshot of Smart with tickets in inventory, and I'll write you a function to return amount without any user input or mouse moving


    Programming is like trying keep a wall of shifting sand up, you fix one thing but somewhere else starts crumbling

  7. #7
    Join Date
    Mar 2006
    Location
    Belgium
    Posts
    3,564
    Mentioned
    111 Post(s)
    Quoted
    1475 Post(s)

    Default

    Quote Originally Posted by ibot_dung11 View Post
    saaaweet! haha



    thanks
    the coin function appears to be working now.
    maybe remove your username


    also
    GetAmountBox(Invbox(i)) works better imo. i = slotplace. example: Slot 1 = InvBox(1)
    Last edited by Justin; 04-17-2013 at 12:44 AM. Reason: removed pic for username

    Creds to DannyRS for this wonderful sig!

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

    Default

    Quote Originally Posted by Sjoe View Post
    maybe remove your username


    also
    GetAmountBox(Invbox(i)) works better imo. i = slotplace. example: Slot 1 = InvBox(1)
    shit haha please remove, ill update pic in a bit, at the gym. also I want the item to be free and not localized

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

    Default

    notrreadingthezeros.png

    so sometimes it finds the amount of coins and sometimes it does not also as you can see it returns the number of tickets without the zeros

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

    Default

    Made an alternative solution based off the image you posted:

    Simba Code:
    function GetAmountBox2(b: TBox): Integer;
    var
      i, m, x, y: Integer;
      s: string; // string transformed into Integer
      c: TIntegerArray; // Colors of gold money text
    begin
      Result := 0;
      if not FindColor(x, y, SRL_OUTLINE_BLACK, b.X1, b.Y1, b.X2, b.Y2) then
        Exit;

      c := [65535, 65278, 16777215, 8453888];
      for i := 0 to high(c) do
      begin
        s := GetTextAtExWrap(b.X1, b.Y1, b.X2, b.Y2, 0, 5, 2, c[i], 0, StatChars);
        if (Length(s) > 0) then
          Break;
      end;
      // Multiply result if there's a K or M (ex. 500K or 50M)
      if (Pos('K', s) > 0) then
        m := 1000
      else if (Pos('M', s) > 0) then
        m := 1000000;
      // Replace mis-read o's or O's with zero's.
      s := ReplaceRegExpr('[oO]', s, '0', True);
      s := ReplaceRegExpr('[^0-9]', s, '', True); // Trim non-numbers from string
      // Thus
      Result := (StrToIntDef(GetNumbers(s), 1) * m);
    end;

    Works from my tests, to account for the mis-read zero's as upper case O's.

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

    Default

    Quote Originally Posted by Le Jingle View Post
    have you tried using, GetAmountBox function?
    tried it just to see and it doesnt return the 0's either
    Quote Originally Posted by Le Jingle View Post
    Made an alternative solution based off the image you posted:

    Simba Code:
    function GetAmountBox2(b: TBox): Integer;
    var
      i, m, x, y: Integer;
      s: string; // string transformed into Integer
      c: TIntegerArray; // Colors of gold money text
    begin
      Result := 0;
      if not FindColor(x, y, SRL_OUTLINE_BLACK, b.X1, b.Y1, b.X2, b.Y2) then
        Exit;

      c := [65535, 65278, 16777215, 8453888];
      for i := 0 to high(c) do
      begin
        s := GetTextAtExWrap(b.X1, b.Y1, b.X2, b.Y2, 0, 5, 2, c[i], 0, StatChars);
        if (Length(s) > 0) then
          Break;
      end;
      // Multiply result if there's a K or M (ex. 500K or 50M)
      if (Pos('K', s) > 0) then
        m := 1000
      else if (Pos('M', s) > 0) then
        m := 1000000;
      // Replace mis-read o's or O's with zero's.
      s := ReplaceRegExpr('[oO]', s, '0', True);
      s := ReplaceRegExpr('[^0-9]', s, '', True); // Trim non-numbers from string
      // Thus
      Result := (StrToIntDef(GetNumbers(s), 1) * m);
    end;

    Works from my tests, to account for the mis-read zero's as upper case O's.
    cool! so I could see this procedure actually being done would I do writeln(Result); ? and to use this for tge tickets I would just change the colors?
    the goal of the coins is to make sure there's enough to play a competition so greater than 200gp else logout and the tickets is to determine the exp gained and tickets gained. will there be a osr update that fixes this or should I replace the above function with the default coinamount for future reference. ill obviously have to put this in my code so it works for others aswell
    Last edited by Sk1nyNerd; 04-17-2013 at 12:26 AM.

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

    Default

    Quote Originally Posted by ibot_dung11 View Post
    tried it just to see and it doesnt return the 0's either

    cool! so I could see this procedure actually being done would I do writeln(Result); ? and to use this for tge tickets I would just change the colors?
    the goal of the coins is to make sure there's enough to play a competition so greater than 200gp else logout and the tickets is to determine the exp gained and tickets gained. will there be a osr update that fixes this or should I replace the above function with the default coinamount for future reference. ill obviously have to put this in my code so it works for others aswell
    The above function reads the text colors of all stacks of items (not just coins) - at least that's what it should do afaik.
    So, you shouldn't have to change any ``colors'' in it, as it should read them already. (if it doesn't let me know and post a .png of the non read stacked item)

    As for an update to OSR, I'll look into it more and potentially yes to having this function replaced/update the current one.

    -Lj

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

    Default

    Quote Originally Posted by Le Jingle View Post
    The above function reads the text colors of all stacks of items (not just coins) - at least that's what it should do afaik.
    So, you shouldn't have to change any ``colors'' in it, as it should read them already. (if it doesn't let me know and post a .png of the non read stacked item)

    As for an update to OSR, I'll look into it more and potentially yes to having this function replaced/update the current one.

    -Lj
    k, I understand this now. b is the inventory slot the item is located in then? like the orginal getamountbox

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

    Default

    Quote Originally Posted by Le Jingle View Post
    The above function reads the text colors of all stacks of items (not just coins) - at least that's what it should do afaik.
    So, you shouldn't have to change any ``colors'' in it, as it should read them already. (if it doesn't let me know and post a .png of the non read stacked item)

    As for an update to OSR, I'll look into it more and potentially yes to having this function replaced/update the current one.

    -Lj
    so I played around with all the options and yours worked but it did not work for values that did not have a K or M, just a simple math mistake.
    if m doesnt equal 1000 or 1000000 then it must be 0 so the result s was being multiplied by 0. the edit version is below.
    thanks Lj!

    when s does not contain a K or M
    getamountallthreeoptions.png

    when s does contain a K or M (notice the orginal GetAmountBox works correctly because there are no 0's in the coins but does not for the tickets which has 0's)
    getamountallthreeoptions2.png

    my edit, when s does not contain a K or M
    myedittoyourcode.png


    my easy edit
    Code:
    function GetAmountBox2(b: TBox): Integer;
    var
      i, m, x, y: Integer;
      s: string; // string transformed into Integer
      c: TIntegerArray; // Colors of gold money text
    begin
      Result := 0;
      if not FindColor(x, y, SRL_OUTLINE_BLACK, b.X1, b.Y1, b.X2, b.Y2) then
        Exit;
    
      c := [65535, 65278, 16777215, 8453888];
      for i := 0 to high(c) do
      begin
      s := GetTextAtExWrap(b.X1, b.Y1, b.X2, b.Y2, 0, 5, 2, c[i], 0, StatChars);
      //Multiply result by 1 if there is not a K or M (ex. 10)
      if (Length(s) > 0) then
        m := 1;
        Break
      end;
      // Multiply result if there's a K or M (ex. 500K or 50M)
      if (Pos('K', s) > 0) then
        m := 1000
      else if (Pos('M', s) > 0) then
        m := 1000000;
      // Replace mis-read o's or O's with zero's.
      s := ReplaceRegExpr('[oO]', s, '0', True);
      s := ReplaceRegExpr('[^0-9]', s, '', True); // Trim non-numbers from string
      // Thus
      Result := (StrToIntDef(GetNumbers(s), 1) * m);
    end;
    EDIT:
    there for, the GetAmount(x,y) is now GetAmount2(x,y)
    Code:
    function GetAmount2(x, y: integer): integer;
    begin
      result := getAmountBox2(invBox(coordsToItem(x, y)));
    end;
    Last edited by Sk1nyNerd; 04-21-2013 at 11:42 PM.

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

    Default

    Quote Originally Posted by DannyRS View Post
    Post a screenshot of Smart with tickets in inventory, and I'll write you a function to return amount without any user input or mouse moving
    how would you return the amount with out any mouse moving?? it moves the mouse to the item location every time and its sketchy up the wall

  16. #16
    Join Date
    Nov 2012
    Posts
    2,351
    Mentioned
    55 Post(s)
    Quoted
    603 Post(s)

    Default

    Quote Originally Posted by ibot_dung11 View Post
    how would you return the amount with out any mouse moving?? it moves the mouse to the item location every time and its sketchy up the wall
    Post a screenshot I can write it, and I'll show you, it's hard to explain, I'd rather just show you


    Programming is like trying keep a wall of shifting sand up, you fix one thing but somewhere else starts crumbling

  17. #17
    Join Date
    Jan 2012
    Posts
    1,104
    Mentioned
    18 Post(s)
    Quoted
    211 Post(s)

    Default

    GetAmountBox works fine for me, make sure it uses StatChars07, not StatChars. To get the box use InvSlotToBox (or whatever its called).

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

    Default

    Quote Originally Posted by DannyRS View Post
    Post a screenshot I can write it, and I'll show you, it's hard to explain, I'd rather just show you
    use one from above? :P

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

    Default

    so i think ive come to the conclusion if i want to find a specific object anywhere in my inventory and get that amount without the mouse moving over the object i have to use a findobjtpamulti type deal with the getamount. would this work? just curious before i start to pull my hair out if it doesnt lol
    thanks

    View my OSR Script Repository!


    Botted to max
    Guides: How to Report Bugs to the Scripter
    ~~~~ Moved to Java. Currently Lurking ~~~~

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

    Default

    I forget what, but I've tested it and it works fine for me.

    I think what shatterhand said is spot on, I forget if I ended up changing the zero in the statchars07 file or not, but it should work as long as the statchars07 is properly used in the includes.

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

    Default

    ya the getamount works but im trying to see if an item is in my inventory or not so ive been using the FindObjEx function so it can find the object anywhere in my inv, but it moves my mouse to the obj if it finds it and checks the uptext, so im wondering if i use the findobjtpamulti if it would produce the same result without moving my mouse to the object. its unnecssary for me to check the uptext

    EDIT: noticed the findobjtpamulti uses uptext also... stopped bein an idiot and trying to over engineer it and just used a DTM. thanks
    Last edited by Sk1nyNerd; 04-22-2013 at 02:54 AM.

    View my OSR Script Repository!


    Botted to max
    Guides: How to Report Bugs to the Scripter
    ~~~~ Moved to Java. Currently Lurking ~~~~

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

    Default

    i was having troubles with the P07 include and using the previous GetAmountBox, developed earlier in the thread, with it but I was able to edit it some more and now it works in the P07 include when ran with smart8- if anyone is intrested. sorry if grave digging, thought it would be useful to post on a relavent topic. idk maybe dannyrs will put it in the P07 include even though its about dead but i just called it GetAmountBox2

    Code:
    function GetAmountBox2(b: TBox): Integer; //Author Le Jingle, edited by ibot_dung11
    var
      i, m, x, y: Integer;
      s: string; //String transformed into Integer
      c: TIntegerArray; //Colors of gold money text
    begin
      Result := 0;
      if not FindColor(x, y, 65536, b.X1, b.Y1, b.X2, b.Y2) then
        Exit;
    
      c := [65535, 65278, 16777215, 8453888];
    
      for i := 0 to high(c) do
      begin
        s := GetTextAtExWrap(b.X1-2, b.Y1-2, b.X2+3, b.Y2+2, 0, 5, 2, c[i], 0, StatChars); //A box to read the 5 possible digits 
    
        if (Length(s) > 0) then
          begin
            m := 1; //Multiply result by 1 if there is not a K or M (ex. 100)
            if (Pos('K', s) > 0) then //Multiply result if there's a K or M (ex. 500K or 50M)
              m := 1000;
            if (Pos('M', s) > 0) then
              m := 1000000;
            Break;
          end;
      end;
    
      s := ReplaceRegExpr('[oO]', s, '0', True); //Replace mis-read o's or O's with zero's.
      s := ReplaceRegExpr('[^0-9]', s, '', True); //Trim non-numbers from string
    
      Result := (StrToIntDef(GetNumbers(s), 1) * m); //Thus
    end;
    
    function GetAmount2(x, y: integer): integer; //Author: Coh3n, edited by ibot_dung11
    begin
      result := GetAmountBox2(invBox(coordsToItem(x, y)));
    end;
    Last edited by Sk1nyNerd; 05-27-2013 at 10:31 PM.

    View my OSR Script Repository!


    Botted to max
    Guides: How to Report Bugs to the Scripter
    ~~~~ Moved to Java. Currently Lurking ~~~~

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
  •