Results 1 to 19 of 19

Thread: Learning To Code

  1. #1
    Join Date
    Nov 2014
    Posts
    8
    Mentioned
    0 Post(s)
    Quoted
    10 Post(s)

    Question Learning To Code

    Read through quite a bit of material and can't find where it answers this so here goes the first post:

    Rafiki allows the user to create a player list - that I get. It loads profiles etc but is there a way to enable an automultiplayer?

    For example: A script that rotates between accounts to prevent babysitting... E.g. If a script fails due to an unexpected glitch... Sign onto another account and begin the same script (or a different script for that matter)...

    Couldn't find anything on it and figured a clear answer on multiplayer being IMPLEMENTED and in use would make a REALLY useful tutorial!

    P.S. Read Mayor and Coh3n but didn't get the answer from their threads - maybe I'm missing something really obvious!

    If anyone can post a solution using Rafiki or by code - that would be fantastic!

    Further note: Not posting much on here as don't want to spam post anything that is not useful e.g. 'ugh, that script is great'... So using my 30 posts slowly to try to be more productive that the normal learner...

  2. #2
    Join Date
    Dec 2011
    Location
    East Coast, USA
    Posts
    4,231
    Mentioned
    112 Post(s)
    Quoted
    1869 Post(s)

    Default

    I plan on making a tutorial about adding multiplayer, but until then I can just paste you some code:

    Player setup:
    Simba Code:
    playerNames  = ['']; //Put your player's names (or nicknames, if you set them) here.
    playerFile   = 'default'; //Put your playerfile's name here. Default is 'default'.
    desiredWorld = 0; //Enter your desired world number here.

    Player init:
    Simba Code:
    players.setup(playerForm.PlayerNames, playerForm.playerFile);

    currentPlayer := randomRange(low(playerForm.playerNames), high(playerForm.playerNames)); //randomize the player we start with

    Player switching:
    Simba Code:
    procedure setupNextPlayer();
    begin
      players[currentPlayer].logout();
      players.randomNext(false); //don't manually increment currentPlayer, .next() does that for us
      players[currentPlayer].login();
      wait(randomRange(5000, 10000));
      mainscreen.setAngle(MS_ANGLE_HIGH);
      exitTreasure();
    end;

    If you have any questions about what any of that does or how to use it, quote me or send me a PM
    GitLab projects | Simba 1.4 | Find me on IRC or Discord | ScapeRune scripts | Come play bot ScapeRune!

    <BenLand100> we're just in the transitional phase where society reclassifies guns as Badâ„¢ before everyone gets laser pistols

  3. #3
    Join Date
    Nov 2014
    Posts
    8
    Mentioned
    0 Post(s)
    Quoted
    10 Post(s)

    Default

    Quote Originally Posted by KeepBotting View Post
    I plan on making a tutorial about adding multiplayer, but until then I can just paste you some code:

    Player setup:
    Simba Code:
    playerNames  = ['']; //Put your player's names (or nicknames, if you set them) here.
    playerFile   = 'default'; //Put your playerfile's name here. Default is 'default'.
    desiredWorld = 0; //Enter your desired world number here.

    Player init:
    Simba Code:
    players.setup(playerForm.PlayerNames, playerForm.playerFile);

    currentPlayer := randomRange(low(playerForm.playerNames), high(playerForm.playerNames)); //randomize the player we start with

    Player switching:
    Simba Code:
    procedure setupNextPlayer();
    begin
      players[currentPlayer].logout();
      players.randomNext(false); //don't manually increment currentPlayer, .next() does that for us
      players[currentPlayer].login();
      wait(randomRange(5000, 10000));
      mainscreen.setAngle(MS_ANGLE_HIGH);
      exitTreasure();
    end;

    If you have any questions about what any of that does or how to use it, quote me or send me a PM
    That would be fantastic! (A tutorial)- if there were 3 players each called P1, P2, P3 and they each signed on 2 hours each in an order. Then the randomNext becomes? Also not entirely sure what the 'Treasure' function is?

    So say P1 - P3 were to be on for set hours, would that be generated by the random range? Or is that the wait before a log on? If it is then how would you random range the rough timings between the players? E.g. the 2 hours approx with differences to allow for a more variable and more human seeming interaction?

    By the way - thank you! This is very helpful and I'm sure will be used by other new learners... Especially on the early development stages!

  4. #4
    Join Date
    Feb 2007
    Location
    Alberta, Canada
    Posts
    4,615
    Mentioned
    50 Post(s)
    Quoted
    429 Post(s)

    Default

    Quote Originally Posted by JimmyRSTW View Post
    That would be fantastic! (A tutorial)- if there were 3 players each called P1, P2, P3 and they each signed on 2 hours each in an order. Then the randomNext becomes? Also not entirely sure what the 'Treasure' function is?

    So say P1 - P3 were to be on for set hours, would that be generated by the random range? Or is that the wait before a log on? If it is then how would you random range the rough timings between the players? E.g. the 2 hours approx with differences to allow for a more variable and more human seeming interaction?

    By the way - thank you! This is very helpful and I'm sure will be used by other new learners... Especially on the early development stages!
    To get each sign-in to have a randomly generated working time does involve slightly more complicated code than KB posted above. It will require having a timer which starts when the player logs in, and generating a working time for each person. I'll give you a little sample below:

    Global variables required would be:

    Simba Code:
    workingTimer : TTimeMarker;
      workTime : Integer;

    and then your next player function could be something like the following:

    Simba Code:
    procedure goToNext();
    begin
      if workingTimer.getTime() > workTime then
      begin
        players.Next(True); // The true is to keep the current player Active
        setupPlayer(); //This would be a procedure you write to set up the camera, etc.
      end;
    end;

    There are a few logic things I'll remind you to keep an eye on though. If you have variables you want to prepare per player (ie logs chopped per account) then you will need to figure out a system that saves the variable per player. It's more complicated than I would expect for your first time around but it's good to think about where you're going too.

    For a full example, feel free to look at my evergreen script (link in signature). Near the bottom I have a rester function which combines switching players, resting, and sleeping all into one procedure. It's more complicated than the code I posted above but the logic is all the same.

    Scripts: Edgeville Chop & Bank, GE Merchanting Aid
    Tutorials: How to Dominate the Grand Exchange

    Quote Originally Posted by YoHoJo View Post
    I like hentai.

  5. #5
    Join Date
    Mar 2013
    Location
    Argentina
    Posts
    758
    Mentioned
    27 Post(s)
    Quoted
    365 Post(s)

    Default

    Quote Originally Posted by JimmyRSTW View Post
    That would be fantastic! (A tutorial)- if there were 3 players each called P1, P2, P3 and they each signed on 2 hours each in an order. Then the randomNext becomes? Also not entirely sure what the 'Treasure' function is?

    So say P1 - P3 were to be on for set hours, would that be generated by the random range? Or is that the wait before a log on? If it is then how would you random range the rough timings between the players? E.g. the 2 hours approx with differences to allow for a more variable and more human seeming interaction?

    By the way - thank you! This is very helpful and I'm sure will be used by other new learners... Especially on the early development stages!
    "the treasure function" is a SRL procedure that closes the treasure hunter thingy that appears when you log in!

    the other question was answered by garret above

  6. #6
    Join Date
    Nov 2014
    Posts
    8
    Mentioned
    0 Post(s)
    Quoted
    10 Post(s)

    Default

    Quote Originally Posted by 3Garrett3 View Post
    To get each sign-in to have a randomly generated working time does involve slightly more complicated code than KB posted above. It will require having a timer which starts when the player logs in, and generating a working time for each person. I'll give you a little sample below:

    Global variables required would be:

    Simba Code:
    workingTimer : TTimeMarker;
      workTime : Integer;

    and then your next player function could be something like the following:

    Simba Code:
    procedure goToNext();
    begin
      if workingTimer.getTime() > workTime then
      begin
        players.Next(True); // The true is to keep the current player Active
        setupPlayer(); //This would be a procedure you write to set up the camera, etc.
      end;
    end;

    There are a few logic things I'll remind you to keep an eye on though. If you have variables you want to prepare per player (ie logs chopped per account) then you will need to figure out a system that saves the variable per player. It's more complicated than I would expect for your first time around but it's good to think about where you're going too.

    For a full example, feel free to look at my evergreen script (link in signature). Near the bottom I have a rester function which combines switching players, resting, and sleeping all into one procedure. It's more complicated than the code I posted above but the logic is all the same.
    Alright - I can see the logic in preventing members that don't post not allowing to send a pm... I was going to PM you Garrett as I have looked at that and love the way that the evergreen script is written - would you mind if I related questions I'm having to it here in respect to not only the multiplayer but to the general working of the script and the logic behind it? Alternatively I could mail you an annotated version of the script (with your permission) with the questions beside the script in commented blue capitlization? If that is alright then let me know - it is so well laid out and comprises some of the functions that would be useful to learn in relation to early on scripts and has the advanced element that would really improve functionality to get to the next step in scripting...

    I would also like to thank KeepBotting for their reply - i'll be learning as much information as possible and be asking as many questions as possible in this early stage - if anything they serve to let new members know what to do if they hit a certain issue...

  7. #7
    Join Date
    Feb 2007
    Location
    Alberta, Canada
    Posts
    4,615
    Mentioned
    50 Post(s)
    Quoted
    429 Post(s)

    Default

    Quote Originally Posted by JimmyRSTW View Post
    Alright - I can see the logic in preventing members that don't post not allowing to send a pm... I was going to PM you Garrett as I have looked at that and love the way that the evergreen script is written - would you mind if I related questions I'm having to it here in respect to not only the multiplayer but to the general working of the script and the logic behind it? Alternatively I could mail you an annotated version of the script (with your permission) with the questions beside the script in commented blue capitlization? If that is alright then let me know - it is so well laid out and comprises some of the functions that would be useful to learn in relation to early on scripts and has the advanced element that would really improve functionality to get to the next step in scripting...

    I would also like to thank KeepBotting for their reply - i'll be learning as much information as possible and be asking as many questions as possible in this early stage - if anything they serve to let new members know what to do if they hit a certain issue...
    Yeah, I'm not sure what the post count requirement for PMs is, but it shouldn't be too much. Soon enough you'll be able to PM specific questions if you want. Until then, you can just post in this thread when you have questions (keep in mind double posting is frowned upon), be sure to quote my post so that I get a notification for it. Like I said, I don't think the requirement for PMs is very high, so when you hit that limit you can feel free to PM me a copy of my script with your questions included if you'd like. If we get to the point where you've made it through the entire script and don't have enough posts then I can give you an email that you could send it to instead.

    Scripts: Edgeville Chop & Bank, GE Merchanting Aid
    Tutorials: How to Dominate the Grand Exchange

    Quote Originally Posted by YoHoJo View Post
    I like hentai.

  8. #8
    Join Date
    Mar 2013
    Location
    Argentina
    Posts
    758
    Mentioned
    27 Post(s)
    Quoted
    365 Post(s)

    Default

    if im not mistaken the PM restriction is 5 posts?

  9. #9
    Join Date
    Nov 2014
    Posts
    8
    Mentioned
    0 Post(s)
    Quoted
    10 Post(s)

    Default

    Quote Originally Posted by undorak7 View Post
    if im not mistaken the PM restriction is 5 posts?
    It's ten dude! Thanks to all that replied, I'm currently reading and will just update/edit this post when I've done more reading on this! (So as not to grease my way up to the posts)

  10. #10
    Join Date
    Jun 2007
    Location
    The land of the long white cloud.
    Posts
    3,702
    Mentioned
    261 Post(s)
    Quoted
    2006 Post(s)

    Default

    Quote Originally Posted by KeepBotting View Post
    I plan on making a tutorial about adding multiplayer, but until then I can just paste you some code:

    Player setup:
    Simba Code:
    playerNames  = ['']; //Put your player's names (or nicknames, if you set them) here.
    playerFile   = 'default'; //Put your playerfile's name here. Default is 'default'.
    desiredWorld = 0; //Enter your desired world number here.

    Player init:
    Simba Code:
    players.setup(playerForm.PlayerNames, playerForm.playerFile);

    currentPlayer := randomRange(low(playerForm.playerNames), high(playerForm.playerNames)); //randomize the player we start with
    This tutorial is definitely needed! Although, you shouldn't setup players this way as the playerForm no longer requires a playerFile as Rafiki saves your army info in the settings xml as an encrypted string. players.setup(playerForm.players) is all that is needed if using the SPF.

  11. #11
    Join Date
    Dec 2011
    Location
    East Coast, USA
    Posts
    4,231
    Mentioned
    112 Post(s)
    Quoted
    1869 Post(s)

    Default

    Quote Originally Posted by JimmyRSTW View Post
    I would also like to thank KeepBotting for their reply - i'll be learning as much information as possible and be asking as many questions as possible in this early stage - if anything they serve to let new members know what to do if they hit a certain issue...
    You're welcome - if you come across a problem that you don't want/need to post, feel free to add my Skype and I'll do my utmost to answer.

    Quote Originally Posted by The Mayor View Post
    This tutorial is definitely needed! Although, you shouldn't setup players this way as the playerForm no longer requires a playerFile as Rafiki saves your army info in the settings xml as an encrypted string. players.setup(playerForm.players) is all that is needed if using the SPF.
    Interesting, thanks - didn't know this. Would this still be the case if I wasn't using the srlplayerform? I generally don't use forms but I'd like to keep my code to standards.
    GitLab projects | Simba 1.4 | Find me on IRC or Discord | ScapeRune scripts | Come play bot ScapeRune!

    <BenLand100> we're just in the transitional phase where society reclassifies guns as Badâ„¢ before everyone gets laser pistols

  12. #12
    Join Date
    Feb 2007
    Location
    Alberta, Canada
    Posts
    4,615
    Mentioned
    50 Post(s)
    Quoted
    429 Post(s)

    Default

    Quote Originally Posted by JimmyRSTW View Post
    It's ten dude! Thanks to all that replied, I'm currently reading and will just update/edit this post when I've done more reading on this! (So as not to grease my way up to the posts)
    Any updates on your progress?

    Scripts: Edgeville Chop & Bank, GE Merchanting Aid
    Tutorials: How to Dominate the Grand Exchange

    Quote Originally Posted by YoHoJo View Post
    I like hentai.

  13. #13
    Join Date
    Nov 2014
    Posts
    8
    Mentioned
    0 Post(s)
    Quoted
    10 Post(s)

    Default

    Quote Originally Posted by 3Garrett3 View Post
    Any updates on your progress?

    Thanks for the question buddy! I'm working on things right now and I'll have a few questions by tomorrow night that I'll update here if you don't mind giving me a hand? Also read basically all of the interesting threads made over the past year... Gunner's story is interesting for all that haven't heard it.

  14. #14
    Join Date
    Feb 2007
    Location
    Alberta, Canada
    Posts
    4,615
    Mentioned
    50 Post(s)
    Quoted
    429 Post(s)

    Default

    Quote Originally Posted by JimmyRSTW View Post
    Thanks for the question buddy! I'm working on things right now and I'll have a few questions by tomorrow night that I'll update here if you don't mind giving me a hand? Also read basically all of the interesting threads made over the past year... Gunner's story is interesting for all that haven't heard it.
    Yeah I'll be on a little bit on the weekend I expect. I'll be on probably every evening next week though so I'll be able to help out eventually, don't hold your breath though. Feel free to post here and other people will be able to help if I don't get on right away. If it's specific questions about my script and stuff, you can still post here and I'll answer when I'm on or if you ever get to 10 posts you can PM me

    Also, yeah lots of pretty cool stuff on here to read. Lots of smart people, lots of good stories.

    Scripts: Edgeville Chop & Bank, GE Merchanting Aid
    Tutorials: How to Dominate the Grand Exchange

    Quote Originally Posted by YoHoJo View Post
    I like hentai.

  15. #15
    Join Date
    Nov 2014
    Posts
    8
    Mentioned
    0 Post(s)
    Quoted
    10 Post(s)

    Default

    Quote Originally Posted by 3Garrett3 View Post
    Yeah I'll be on a little bit on the weekend I expect. I'll be on probably every evening next week though so I'll be able to help out eventually, don't hold your breath though. Feel free to post here and other people will be able to help if I don't get on right away. If it's specific questions about my script and stuff, you can still post here and I'll answer when I'm on or if you ever get to 10 posts you can PM me

    Also, yeah lots of pretty cool stuff on here to read. Lots of smart people, lots of good stories.
    Is there a way to 'draw' without SMART while doing ATPAs? If not then is there a work around?

  16. #16
    Join Date
    Feb 2007
    Location
    Alberta, Canada
    Posts
    4,615
    Mentioned
    50 Post(s)
    Quoted
    429 Post(s)

    Default

    Quote Originally Posted by JimmyRSTW View Post
    Is there a way to 'draw' without SMART while doing ATPAs? If not then is there a work around?
    There's smartImage.debugATPA(ATPA)

    You'll find the drop down list when you type "smartImage." will give lots of cool functions.

    Scripts: Edgeville Chop & Bank, GE Merchanting Aid
    Tutorials: How to Dominate the Grand Exchange

    Quote Originally Posted by YoHoJo View Post
    I like hentai.

  17. #17
    Join Date
    Nov 2014
    Posts
    8
    Mentioned
    0 Post(s)
    Quoted
    10 Post(s)

    Default

    Quote Originally Posted by 3Garrett3 View Post
    There's smartImage.debugATPA(ATPA)

    You'll find the drop down list when you type "smartImage." will give lots of cool functions.
    Checked that out - is there a way to disable graphics without the use of SMART? Although I don't think that is an option I figured there may be a chance... Slim to none. Also - when doing a SPS map is there a general size of the amount of points that is ideal - does it affect compile time if there are too many?

    Another question - on a map that is beyone your field of vision - say of spawn point, but it is in the vision of when you move further down the map (the point of spawn still visible and the destination still visible - is the .png of the visible field of vision alright if it becomes visible for SPS to read it?

    E.g. location a to b
    location a and b visible on .png
    however on spawn to location, location b not visible, only when moving towards location b does it become visible..

    Hopefully that makes sense! Appreciate the help Garrette!

  18. #18
    Join Date
    Dec 2011
    Location
    East Coast, USA
    Posts
    4,231
    Mentioned
    112 Post(s)
    Quoted
    1869 Post(s)

    Default

    Quote Originally Posted by JimmyRSTW View Post
    Checked that out - is there a way to disable graphics without the use of SMART? Although I don't think that is an option I figured there may be a chance... Slim to none.
    If by disabling graphics you mean disabling rendering, there's no way to do that, with or without SMART

    Quote Originally Posted by JimmyRSTW View Post
    Also - when doing a SPS map is there a general size of the amount of points that is ideal - does it affect compile time if there are too many?
    The optimum size of an SPS map includes all areas that the player could possibly see.

    i.e. at any given time, during the runtime of your script, the player's current minimap should be fully encompassed by your SPS map

    Quote Originally Posted by JimmyRSTW View Post
    Another question - on a map that is beyone your field of vision - say of spawn point, but it is in the vision of when you move further down the map (the point of spawn still visible and the destination still visible - is the .png of the visible field of vision alright if it becomes visible for SPS to read it?

    E.g. location a to b
    location a and b visible on .png
    however on spawn to location, location b not visible, only when moving towards location b does it become visible..
    You're talking about a situation like this (with the fog dictating what is or isn't visible, point A being spawn, and points B and C being the rest of the path)



    Thussly, you'd spawn at point A and begin to walk to point C - however you'd click point B first as point C isn't yet visible.

    If so, then yes, that's fine.
    GitLab projects | Simba 1.4 | Find me on IRC or Discord | ScapeRune scripts | Come play bot ScapeRune!

    <BenLand100> we're just in the transitional phase where society reclassifies guns as Badâ„¢ before everyone gets laser pistols

  19. #19
    Join Date
    Feb 2007
    Location
    Alberta, Canada
    Posts
    4,615
    Mentioned
    50 Post(s)
    Quoted
    429 Post(s)

    Default

    KeepBotting did a good job replying, but I'll try to add my 2 cents as well.

    Quote Originally Posted by JimmyRSTW View Post
    Checked that out - is there a way to disable graphics without the use of SMART? Although I don't think that is an option I figured there may be a chance... Slim to none. Also - when doing a SPS map is there a general size of the amount of points that is ideal - does it affect compile time if there are too many?
    I don't understand exactly what you mean by disable graphics? Do you mean disable debug? If so, you can write the following:

    Simba Code:
    procedure paintDebug(what: string; ATPA: T2DPointArray = []);
    begin
      {$IFDEF SMART}
        if players[currentPlayer].booleans[B_ENABLE_DEBUG] then
        try
          case lowercase(what) of
            'atpa': smartImage.debugATPA(ATPA);
            'box': smartImage.drawBox(mainScreen.playerBox, false, clWhite);
            'clear': smartImage.clearArea(mainScreen.getBounds());
          end;
        except
        end;
      {$ENDIF}
    end;

    The above is an example from TheMayor's GAO script. It will only do debugging if it is using SMART.

    For your SPS question, the number of points on your path will not affect compile time or walking. I usually make them about 1/2 of the minimap area (outlined in the SPS path program). If you mean the SPS map size, yes making a big map will slow down walking because it will have to search through a larger area to determine where you are.


    Quote Originally Posted by JimmyRSTW View Post
    Another question - on a map that is beyone your field of vision - say of spawn point, but it is in the vision of when you move further down the map (the point of spawn still visible and the destination still visible - is the .png of the visible field of vision alright if it becomes visible for SPS to read it?
    E.g. location a to b
    location a and b visible on .png
    however on spawn to location, location b not visible, only when moving towards location b does it become visible..
    With this, I don't really know what you mean. As long as all A, B, and Spawn are visible on the SPS map (the .png file) you will be fine. It's best to ensure that the path you want to walk is not near the edges of the image, because SPS has to compare with the surroundings and it reduces accuracy if you're walking near the edge of the .png map.

    If that's not what you mean, please clarify a little bit and I'll try my best to answer.

    Scripts: Edgeville Chop & Bank, GE Merchanting Aid
    Tutorials: How to Dominate the Grand Exchange

    Quote Originally Posted by YoHoJo View Post
    I like hentai.

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
  •