Results 1 to 12 of 12

Thread: function RndWorld(wType: integer): integer;

  1. #1
    Join Date
    Jan 2008
    Location
    UK
    Posts
    500
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default function RndWorld(wType: integer): integer;

    Just a simple function that may be usefull to some of you, do with it what you will..

    function RndWorld(wType: integer): integer;

    Returns a world number based on input:
    1 Returns a random Valid World member/Non Member.
    2 Returns a random Free Play World
    3 Returns a random Members World.

    Can be easily used with functions like SmartSetupEX(); to load a valid world.

    Uses Worlds.ini so that any world changes will always be up to date.

    Does not return any Special/Reserved World.

    SCAR Code:
    {*******************************************************************************
    function RndWorld(wType: integer): integer;
    By: PriSoner
    Description: Returns a random world number. Uses worlds.ini to get a world count
                   and check if world is members or free.
    Options: Enter 1 to return any valid random world.
                     2 to return any valid Free Play World
                     3 to return any valid Members World
    *******************************************************************************}

    function RandWorld(wType: integer): integer;
    var winipath: String;
          rndcount: integer;
    begin
        if (wType > 0) and (wType < 4) then
        begin
            winipath := AppPath + 'includes\SRL\SCSS\worlds.ini';
            rndcount := StrToInt(ReadINI('Worlds', 'Count', winipath));
            case wType of
                1: repeat
                       result := Random(rndcount) + 1;
                   until (ReadINI('World' + IntToStr(result), 'Type', winipath) = 'Free') or
                         (ReadINI('World' + IntToStr(result), 'Type', winipath) = 'Members');
                2: repeat
                       result := Random(rndcount) + 1;
                   until (ReadINI('World' + IntToStr(result), 'Type', winipath) = 'Free');
                3: repeat
                       result := Random(rndcount) + 1;
                   until (ReadINI('World' + IntToStr(result), 'Type', winipath) = 'Members');
            end;
            writeln('Your Randomly Chosen World is: ' + IntToStr(result));
        end else
        begin
            writeln('function RandWorld: Incorrect value! Valid Range is 1 to 3. Terminating Script!');
            TerminateScript;
        end;
    end;
    For the Ultimate Monk Fisher: Ultra Monkfish n Bank Click Here


  2. #2
    Join Date
    Aug 2007
    Location
    Emo-land
    Posts
    1,109
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Nice work, I'll just stick with my
    Case Random(#ofWorlds)
    repeat
    until(Nworld <> OWorld)
    sort of thing for now, as it works so yea.

    I am so pissed that you cant change from F2P to P2P on SMART!

  3. #3
    Join Date
    Jan 2008
    Location
    UK
    Posts
    500
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    It just makes it easy to maintain and impliment while keeping the program size and memory usage down.

    I also notice with your big list, that it contains some of the Special/Test/Reserved Worlds like World 120 which at best would mean that the if a player accidentally gets it as a world their efforts and time would go unrewarded and at worst they may end up getting banned.
    For the Ultimate Monk Fisher: Ultra Monkfish n Bank Click Here


  4. #4
    Join Date
    Jan 2007
    Location
    Kansas
    Posts
    3,760
    Mentioned
    1 Post(s)
    Quoted
    3 Post(s)

    Default

    I really appreciate you PriSoner. You have helped people on numerous occasions and contribute to the community quite often. Thanks for all you do.


  5. #5
    Join Date
    Jan 2008
    Location
    UK
    Posts
    500
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thank you. It's always nice to feel appreciated. and your kind words are very appreciated!
    For the Ultimate Monk Fisher: Ultra Monkfish n Bank Click Here


  6. #6
    Join Date
    Aug 2007
    Location
    Emo-land
    Posts
    1,109
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    What do you mean special/test/reserved?!

  7. #7
    Join Date
    Jan 2008
    Location
    UK
    Posts
    500
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    If you look at the world list via the runescape client or on the Jagex Website you will notice that out of a possible 159 worlds only 146 are listed.

    This means that the average joe would not be able to access the non-listed world without having to subvert the system a little (and it aint hard).

    Some of these worlds are beta worlds used to test and deploy new updates, some of these worlds have full functionality and some don't count anything you do as permanent.

    If you log into one of these worlds you will also notice that there are very few people about. Some would say this makes it perfect for scripters, however I am of the opinion that it makes it very obvious to jagex who to keep an eye on.

    From Jagex's point of view, who would be in one of these worlds other than the invited or folk trying to subvert the system. After all the worlds are not available using the official client or via their website.

    Worlds.ini only contains the worlds accessible via the client which made it perfect for my uses.. plus the fact that I didn't fancy sorting through all the worlds myself!
    For the Ultimate Monk Fisher: Ultra Monkfish n Bank Click Here


  8. #8
    Join Date
    Aug 2007
    Location
    Emo-land
    Posts
    1,109
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    So if these test worlds are not displayed, then when I created my list it was entirely safe. I'm not just using SelectWorld(Random(150)) you know :P

  9. #9
    Join Date
    Jan 2008
    Location
    UK
    Posts
    500
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I know, I know.. Relax I'm not having a pop at you...

    It was just that when you mentioned your function I trotted over to have a look at it.. it's a big list of members worlds and a big list of f2p worlds to randomly choose from based on a boolean.

    The first thing I noticed was that in one of the lists you had World 120 which is a special world, I didn't check for any others at the time but after a cursory glance now the rest look like they are probably ok...

    It may be that at the time you created your list of worlds, world 120 may have been ok, or you may have added it accidentally, I don't know, but what I do know is that it's definitely not ok now.

    One of the handy additions in SRL12 was the worlds.ini file, I thought i'd make use of it as intended and created this easy small function.

    Because I noticed your list had world 120 in it i just used it to highlight the usefulness of using a central database like this because any changes can be updated quickly throughout all scripts that reference the file..

    No Offence Intended!
    For the Ultimate Monk Fisher: Ultra Monkfish n Bank Click Here


  10. #10
    Join Date
    Jul 2007
    Location
    Norway.
    Posts
    1,938
    Mentioned
    3 Post(s)
    Quoted
    0 Post(s)

    Default

    You know what, I've used your function in several varieties (sp?) and just saw I've not rep'ed you for this. This is great work, and you truly deserve it. In my upcoming script (which I'll be releasing in not too long, [G.A.R.] I'm using your function in a creative way. I've edited it only to include members worlds:

    SCAR Code:
    {*******************************************************************************
    function RndWorld: Integer;
    By: PriSoner, slight edit by EvilChicken!
    Description: Returns a random members world number. Uses worlds.ini to get a
                 world count and checks if world is members or free.
    *******************************************************************************}

    function RandWorld: Integer;
    var
      WiniPath: string;
      RndCount: Integer;

    begin
      WiniPath := AppPath + 'includes\SRL\SCSS\worlds.ini';
      RndCount := StrToInt(ReadINI('Worlds', 'Count', winipath));
      repeat
        Result := Random(Rndcount) + 1;
      until ReadINI('World' + IntToStr(Result), 'Type', winipath) = 'Members';
      Wait(300 + random(200));
    end;

    .. and I'm using this not only at startup, but also in my worldswitcher. (SelectWorld(RandWorld)). So, this function has helped me in a couple ways. It is great to have people like you here at SRl, PriSoner.

    As I said, rep for you.

    Edit: To fix the problem of using world that aren't listed, I switch worlds every startup before logging in. Then it can only pick worlds that are viewed.

  11. #11
    Join Date
    Sep 2007
    Posts
    415
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    hmm, i had heard it had been done before but didn't know where, this is probably a lot faster than mine since it doesn't get all of them..good work PriSoner
    Quote Originally Posted by That guy that wrote forefeathers
    <munklez>haha im too lazy, girls annoy me
    <munklez> they always wanna like, do stuff
    <munklez> and i just wanna program
    <munklez> and they always take all my money

  12. #12
    Join Date
    Jan 2008
    Location
    UK
    Posts
    500
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by EvilChicken! View Post
    You know what, I've used your function in several varieties (sp?) and just saw I've not rep'ed you for this. This is great work, and you truly deserve it. In my upcoming script (which I'll be releasing in not too long, [G.A.R.] I'm using your function in a creative way. I've edited it only to include members worlds:

    .. and I'm using this not only at startup, but also in my worldswitcher. (SelectWorld(RandWorld)). So, this function has helped me in a couple ways. It is great to have people like you here at SRl, PriSoner.

    As I said, rep for you.
    Thank you very much.. It's always nice to feel appreciated and comments like yours really help make the effort all worth while.

    Quote Originally Posted by EvilChicken! View Post
    Edit: To fix the problem of using world that aren't listed, I switch worlds every startup before logging in. Then it can only pick worlds that are viewed.
    This function will only return listed worlds.. (well as long as worlds.ini is current)

    Quote Originally Posted by drizzt View Post
    hmm, i had heard it had been done before but didn't know where, this is probably a lot faster than mine since it doesn't get all of them..good work PriSoner
    There's nothing wrong with yours, we all have different ways of doing things. I created this function, like you because I needed it and I didn't find anything else that did what I wanted. Mine uses less memory, is faster but randomly stabs at worlds until it finds a valid one and then uses that, yours builds a list of valid worlds first and then picks a random valid world first time.. Each method has it's advantages depending on the individual script. Of course I prefer mine though

    I added to your rep for your function though!
    For the Ultimate Monk Fisher: Ultra Monkfish n Bank Click Here


Thread Information

Users Browsing this Thread

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

Similar Threads

  1. function SendKeyboard(FKey:Integer; Text:String): Integer;
    By Daniel in forum Research & Development Lounge
    Replies: 4
    Last Post: 07-18-2007, 04:28 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
  •