Results 1 to 17 of 17

Thread: How to add Auto Updater to all of your scripts

  1. #1
    Join Date
    Feb 2009
    Location
    Denmark.
    Posts
    359
    Mentioned
    12 Post(s)
    Quoted
    64 Post(s)

    Default How to add Auto Updater to all of your scripts

    Semtex Auto Updater Tutorial
    Last Updated: September 25th, 2015


    Introduction
    Hello, welcome to my very first tutorial. I decided to make this tutorial because the tutorials available regarding Auto Updater are somewhat outdated. I myself spent quite some time figuring out how it worked. Therefor I wanted to make this guide, so you would avoid spending the amount of time that I did. This tutorial will guide you step by step how to add Auto Updater to your script and how to manage your script.

    For this tutorial, we will be using GitHub. Our very own @The Mayor; provided the code we will be using in the actual script.

    Table of Contents
    • Step 1: Registering at GitHub
    • Step 2: Creating your repository
    • Step 3: Downloading and setting up GitHub Desktop
    • Step 4: The script and the code
    • Step 5: Maintaining Script updates


    Step 1: Registering at GitHub
    The first thing you need to do is go to https://github.com/ and register.

    On the front page in the right side, you will see three boxes labeled, Pick a username, your email and create a Password.

    It looks as follows:
    Expand to see picture

    Fill out the boxes. (Example for username could be SRL (Account name), like mine “SRLTest”)
    After you have filled out all three boxes, click “Sign up for GitHub”.
    The next page is where you choose a plan. Just click the green button Finish sign up at the bottom.

    You have now registered and before continuing, I recommend verifying your email address. Log unto your email and should have gotten two emails from GitHub. A welcome mail and the mail where you verify your email address. Open then one with verify email.


    You should now see something like this:
    Expand to see picture

    Click the button “Verify email Address”. We are now ready to continue.




    Step 2: Creating your repository
    When you log into GitHub it should look something like the picture below:
    Expand to see picture

    Click the green button “New repository”

    You can now see the following page:
    Expand to see picture

    Repository name, can be anything. For this example, we will name it “SRLScripts”. We will make folders for the script we are adding auto updater to later on.

    In the description box, you can fill out anything you want or nothing at all. I decided to leave it blank in this example, but you could write “All my SRL Scripts”.

    Leave it on public. If you choose private (only paying users can choose this option), no one would be able to see the content added to the repository.

    Now check the box “Initialize this repository with a README”. We will not be using it, but it is easier if we add it when we create the repository.

    When you have filled out all the information, click the green button “Create repository”. We have now created the repository.

    You should now see the following page:
    Expand to see picture

    In case you were wondering, a repository is a directory of files (In this case).

    Onward to the next step.




    Step 3: Downloading and setting up GitHub Desktop
    Click the following link https://desktop.github.com/
    Click the big blue button “Download GitHub Desktop” it should look like the following:
    Expand to see picture

    Double click the file when it is finished downloading and click Install. It will now download the required files for the installation (this could take some time depending on how high your bandwidth is).
    GitHub runs by itself when the installation is finished.

    You should now see the following:
    Expand to see picture

    Enter the username you chose earlier and the password you chose, and then click Log in.
    Just click Continue on the next page and finally click “dashboard” in the line: Head over to your dashboard to get started!”

    Now click the plus in the left top side and choose “Clone”. Click then one showing, it will have the name of the repository that we created earlier on, in this example it is SRLScripts. It should look like the following:
    Expand to see picture

    Click the button at the bottom “Clone SRLScripts (or whatever you named it)”. You will have to choose a directory. I use the default one, but you choose whatever. Wait for it to finish.

    Right click “SRLScripts (or whatever you named it) in the top left corner and choose open in explorer.
    Delete the README file and add a new folder. Name it after your script. I will name mine SemtexFishingGuild.
    Now make a new text file document within the newly created folder, name it “Version”.

    Open up the text document file and input version number of your script. In my case, it is 1.2
    It should look like this:
    Expand to see picture

    Save the file and close it.

    Now move your script within the folder, like this:
    Expand to see picture

    We are now ready to continue to the next step.




    Step 4: The script and the code
    The first thing you need to do is add a constant to your script.
    Like so:
    Simba Code:
    program SemtexFishingGuild;
    {$DEFINE SMART}
    {$i srl-6/srl.simba}
    {$i sps/lib/sps-rs3.simba}
    {$i srl-6/lib/misc/srlplayerform.simba}

    const
    Version = 1.2;

    The procedure for auto updating is like this:
    Simba Code:
    procedure getUpdate();
    var
      newFile: Integer;
      newVer: Extended;
    begin
      newVer := strToFloat(getPage('http://tomstewart.net/proxy.php?url=https://raw.githubusercontent.com/(GitHub Username Here)/(Repository Name Here)/master/(Script Name Folder Here)/version.txt'));
      printf('Current script Version: %f || Online script Version: %f', [Version, newVer]);

      if newVer > Version then
      begin
        printf('Updating (Script Name Here).simba from Version %f to %f', [Version, newVer]);
        newFile := rewriteFile(scriptPath + '(Script Name Here).simba', false);
        writeFileString(newFile, getPage('http://tomstewart.net/proxy.php?url=https://raw.githubusercontent.com/(GitHub Username Here)/(Repository Name Here)/master/(Script Name Folder Here)/(Script Name Here).simba'));
        closeFile(newFile);
        print('Please reopen this file');
        terminateScript();
      end;
    end;
    Fill in the (Name) in the throughout the code, with your own information. In my case the code would be like this:

    Another way of getting the URL that needs to be used is to, is by logging into the GitHub Webpage, enter "SRLScripts" under "Your Repositories".
    Then click the script folder, in my case it's SemtexFishingGuild.

    You should see 2-3 files here, Version.txt and scriptname.simba and the updater.

    Click on "scriptname.simba"

    Now click the button "Raw" and copy the URL from the page you are taken to.

    It is very important that you add the http:/ /tomstewart.net/proxy.php?url= in front of the URL.

    So the URL isn't just: https:/ /raw.githubusercontent.com/SRLTest/SRLScripts/master/SemtexFishingGuild/SemtexFishingGuild.simba

    but: http:/ /tomstewart.net/proxy.php?url=https://raw.githubusercontent.com/SRLTest/SRLScripts/master/SemtexFishingGuild/SemtexFishingGuild.simba

    If you don't add http:/ /tomstewart.net/proxy.php?url= then the script won't be able to get the data it needs.

    Simba Code:
    procedure getUpdate();
    var
      newFile: Integer;
      newVer: Extended;
    begin
      newVer := strToFloat(getPage('http://tomstewart.net/proxy.php?url=https://raw.githubusercontent.com/SRLTest/SRLScripts/master/SemtexFishingGuild/version.txt'));
      printf('Current script Version: %f || Online script Version: %f', [Version, newVer]);

      if newVer > Version then
      begin
        printf('Updating (Script Name Here).simba from Version %f to %f', [Version, newVer]);
        newFile := rewriteFile(scriptPath + 'SemtexFishingGuild.simba', false);
        writeFileString(newFile, getPage('http://tomstewart.net/proxy.php?url=https://raw.githubusercontent.com/SRLTest/SRLScripts/master/SemtexFishingGuild.simba'));
        closeFile(newFile);
        print('Please reopen this file');
        terminateScript();
      end;
    end;
    The next thing you need to do is call the procedure in your Setup loop.
    I call it here, at the begging of the Setup Loop and before all the playerform procedure etc.:

    Simba Code:
    clearDebug();
      getUpdate();
      getMap();
      initPlayerForm();
      runPlayerForm();
    Save the program and exit it.

    Now for the file you attach to your thread on Villavu.
    Start a new simba program.
    Put in the following code:

    Simba Code:
    program (Script Name Here)Updater;
    {$i srl-6/srl.simba}

    (* Auto-Updater file:

          Run to get latest version of the script.
          The script will appear in the same directory as this script.
                                                                              *)

    const
      Version = 0.0;

    procedure getUpdate();
    var
      newFile: Integer;
      newVer: Extended;
    begin
      newVer := strToFloat(getPage('http://tomstewart.net/proxy.php?url=https://raw.githubusercontent.com/(GitHub Username Here)/(Repository Name Here)/master/(Script Name Folder Here)/version.txt '));
      printf('Current script Version: %f || Online script Version: %f', [Version, newVer]);

      if newVer > Version then
      begin
        printf('Updating ' + 'SemtexFishingGuild.simba' + ' from Version %f to %f', [Version, newVer]);
        newFile := rewriteFile(scriptPath + '(Script Name Here).simba', false);
        writeFileString(newFile, getPage('http://tomstewart.net/proxy.php?url=https://raw.githubusercontent.com/(GitHub Username Here)/(Repository Name Here)/master/(Script Name Folder Here)/(Script Name Here).simba'));
        closeFile(newFile);
        print('New script saved to: ' + scriptPath);
        terminateScript();
      end;
    end;

    begin
      clearDebug();
      disableSRLLog := True;
      getUpdate();
    end.
    Fill in the (Name) in the throughout the code, with your own information. In my case the code would be like this:

    Simba Code:
    program SemtexFishingGuildUpdater;
    {$i srl-6/srl.simba}

    (* Auto-Updater file:

          Run to get latest version of the script.
          The script will appear in the same directory as this script.
                                                                              *)

    const
      Version = 0.0;

    procedure getUpdate();
    var
      newFile: Integer;
      newVer: Extended;
    begin
      newVer := strToFloat(getPage('http://tomstewart.net/proxy.php?url=https://raw.githubusercontent.com/ SRLTest/SRLScripts/master/SemtexFishingGuild/version.txt '));
      printf('Current script Version: %f || Online script Version: %f', [Version, newVer]);

      if newVer > Version then
      begin
        printf('Updating ' + 'SemtexFishingGuild.simba' + ' from Version %f to %f', [Version, newVer]);
        newFile := rewriteFile(scriptPath + 'SemtexFishingGuild.simba', false);
        writeFileString(newFile, getPage('http://tomstewart.net/proxy.php?url=https://raw.githubusercontent.com/ SRLTest/SRLScripts/master/SemtexFishingGuild/SemtexFishingGuild.simba '));
        closeFile(newFile);
        print('New script saved to: ' + scriptPath);
        terminateScript();
      end;
    end;

    begin
      clearDebug();
      disableSRLLog := True;
      getUpdate();
    end.
    Save the program within the Repository Directory, you chose in Step 3, where we created the Version text document and you put the script.

    Now you have created the means to auto update your script. HOWEVER GitHub have not yet received any of files you put in your script folder. We need to synchronize GitHub Desktop with the GitHub Website.

    Open up GitHub Desktop and go into you repository. Right under where it says Sync, click the larger ring there is and you will now see the following (with your information of course):
    Expand to see picture

    Fill out Summary and optionally Description.
    You write what changes you made since the last time you synchronized your script. In this case, it is the initial release.
    Click “Commit to Master” followed by clicking on “Sync”

    You can now attach the AutoUpdater file we created to your thread and you will never have to change again.




    Step 5: Maintaining Script updates
    The hard part is over and the rest is quite easy.
    When you need to update a script, all you have to do is change the version number in your Version.txt file, and make sure you change the program.simba file with all the changes you made.

    Remember to change the const version to the version number you wrote in the version.txt file.

    If I wanted to update my script, I would change the version.txt file to 1.3 and change the const within the script to 1.3.

    When you have made the desired changes, you will have to commit the changes and synchronize them just as you did in the last part of Step 4.

    Now you should know everything about adding auto updater to your script and maintaining new updates.

    Please feel free to ask questions if you are having trouble or just curious.
    If you have any suggestions to this guide, please share them as well

    I hope you like this guide and I wish you the best of luck with adding auto updater to all of your scripts!
    Last edited by Semtex; 09-25-2015 at 08:14 PM.

  2. #2
    Join Date
    Feb 2012
    Location
    Canada
    Posts
    1,164
    Mentioned
    26 Post(s)
    Quoted
    433 Post(s)

  3. #3
    Join Date
    Feb 2009
    Location
    Denmark.
    Posts
    359
    Mentioned
    12 Post(s)
    Quoted
    64 Post(s)

    Default

    Quote Originally Posted by StickToTheScript View Post
    Nice tutorial! Very useful to people who have wanted to use github, but havent bothered.
    My thought exactly :P

    i have never used GitHub, so it was a challenge learning how the heck it worked, but once i got that down it was really easy

    So i just wanted to help others achieve it even easier

  4. #4
    Join Date
    Sep 2014
    Posts
    447
    Mentioned
    10 Post(s)
    Quoted
    203 Post(s)

    Default

    +rep Great guide! Just fyi, you can also use pastebin

  5. #5
    Join Date
    Feb 2009
    Location
    Denmark.
    Posts
    359
    Mentioned
    12 Post(s)
    Quoted
    64 Post(s)

    Default

    Quote Originally Posted by yourule97 View Post
    +rep Great guide! Just fyi, you can also use pastebin
    Thanks

    Ah i didn't think about that :P

    does pastebin have the feature showing changes?

    EDIT: Next tutorial will be about how to add stats to any script, i just need to learn how before i can write a tutorial about it xD

    Just haven't had the time to learn it yet

  6. #6
    Join Date
    Aug 2014
    Location
    Australia
    Posts
    932
    Mentioned
    53 Post(s)
    Quoted
    495 Post(s)

    Default

    It's quite a lot faster to use a raw txt from Pastebin, but Github allows you to control old versions a lot better so it's great either way.

    Great tutorial, +rep to you my fine Sir.



    New to scripting? Procedures & Functions for Beginners
    Do you use your computer at night? Just get f.lux

  7. #7
    Join Date
    May 2007
    Posts
    526
    Mentioned
    12 Post(s)
    Quoted
    109 Post(s)

    Default

    I suggest using git cli instead. You might learn something

  8. #8
    Join Date
    Feb 2009
    Location
    Denmark.
    Posts
    359
    Mentioned
    12 Post(s)
    Quoted
    64 Post(s)

    Default

    Quote Originally Posted by Incurable View Post
    It's quite a lot faster to use a raw txt from Pastebin, but Github allows you to control old versions a lot better so it's great either way.

    Great tutorial, +rep to you my fine Sir.
    Thanks alot mate! i'll check it out and make a tutorial if i like it

    Quote Originally Posted by superuser View Post
    I suggest using git cli instead. You might learn something
    Git CLI looks alot like powershell and is rather advanced for beginners, but i suppose i could make a tutorial for it for intermediate or advanced scripting:P
    I never worked much with powershell, only CISCO IOS CLI but that's an entirely different thing!
    Last edited by Semtex; 09-26-2015 at 07:20 AM.

  9. #9
    Join Date
    Mar 2016
    Posts
    192
    Mentioned
    6 Post(s)
    Quoted
    91 Post(s)

    Default

    @Semtex it looks like http://tomstewart.net/proxy.php?url= doesn't work anymore :c. On one of my computers it works well when I just paste direct link, but on another I get this error:

    Code:
    Error: "" is an invalid float at line 72
    Execution failed.
    and it looks like getPage function also doesn't work on the 2nd computer. Any ideas why?


    PS great guide

  10. #10
    Join Date
    Dec 2013
    Location
    Pitcairn Island
    Posts
    288
    Mentioned
    20 Post(s)
    Quoted
    166 Post(s)

    Default

    Quote Originally Posted by scob View Post
    @Semtex it looks like http://tomstewart.net/proxy.php?url= doesn't work anymore :c. On one of my computers it works well when I just paste direct link, but on another I get this error:

    Code:
    Error: "" is an invalid float at line 72
    Execution failed.
    and it looks like getPage function also doesn't work on the 2nd computer. Any ideas why?


    PS great guide
    Mayor's site is no longer online, so use Frement's: http://static.frement.net/proxy.php?u=

  11. #11
    Join Date
    Mar 2016
    Posts
    192
    Mentioned
    6 Post(s)
    Quoted
    91 Post(s)

    Default

    Quote Originally Posted by Laquisha View Post
    Mayor's site is no longer online, so use Frement's: http://static.frement.net/proxy.php?u=
    Thanks, works great and thanks to @The Mayor ofc

    BTW why does it need proxy?

  12. #12
    Join Date
    Mar 2013
    Posts
    1,010
    Mentioned
    35 Post(s)
    Quoted
    620 Post(s)

    Default

    Quote Originally Posted by scob View Post
    Thanks, works great and thanks to @The Mayor ofc

    BTW why does it need proxy?
    Simba doesn't support https/ssl natively without some dll been shipped with it and wizzup doesn't want to ship a openssl plugin with simba since it would need constant updating (iirc)
    #slack4admin2016
    <slacky> I will build a wall
    <slacky> I will ban reflection and OGL hooking until we know what the hell is going on

  13. #13
    Join Date
    Mar 2016
    Posts
    192
    Mentioned
    6 Post(s)
    Quoted
    91 Post(s)

    Default

    Thanks for explanation @Harrier!

  14. #14
    Join Date
    Feb 2013
    Location
    The Boonies
    Posts
    203
    Mentioned
    9 Post(s)
    Quoted
    70 Post(s)

    Default

    I know this is an old thread, but I'm looking to do something like this once again - however it seems this tomstewart proxy stuff is no longer a thing, so this exact implementation is outdated - does anyone know of another url to route through for Github?

  15. #15
    Join Date
    Oct 2012
    Posts
    1,258
    Mentioned
    40 Post(s)
    Quoted
    588 Post(s)

    Default

    Quote Originally Posted by Lama View Post
    I know this is an old thread, but I'm looking to do something like this once again - however it seems this tomstewart proxy stuff is no longer a thing, so this exact implementation is outdated - does anyone know of another url to route through for Github?
    I didnt read the OP fully, but looking at the tomstewart part that seems to be just for getting HTTPS data via an HTTP connection. Simba I believe natively supports HTTPS now. Just tested on a simba I had installed and getpage worked for https github.

  16. #16
    Join Date
    Feb 2013
    Location
    The Boonies
    Posts
    203
    Mentioned
    9 Post(s)
    Quoted
    70 Post(s)

    Default

    Quote Originally Posted by acow View Post
    I didnt read the OP fully, but looking at the tomstewart part that seems to be just for getting HTTPS data via an HTTP connection. Simba I believe natively supports HTTPS now. Just tested on a simba I had installed and getpage worked for https github.
    Hmm it doesn't seem to be returning anything for me, just an empty string. Here's the link I'm using which is just a version.txt of my RoguesCooker.

  17. #17
    Join Date
    Oct 2012
    Posts
    1,258
    Mentioned
    40 Post(s)
    Quoted
    588 Post(s)

    Default

    Quote Originally Posted by Lama View Post
    Hmm it doesn't seem to be returning anything for me, just an empty string. Here's the link I'm using which is just a version.txt of my RoguesCooker.
    Interesting. Here's me trying it with simba 1100 https://i.imgur.com/N5jcu43.png
    Maybe I installed openssl stuff and have forgotten about it? Maybe other simba installs installed it? I have no idea.

    Olly might know more, I'll @him on discord.

    edit for anybody who reads this later: ssl was working on my end because I had another piece of software installed. simba was using the dlls from it for ssl.
    Last edited by acow; 07-18-2018 at 12:24 AM.

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
  •