• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

Update Checker

1,748
Posts
14
Years
  • Simply put, this script just checks if the game needs to be updated when you start it up.

    The instructions are located within the script, please make sure you follow them.

    NOTE: Make sure your webpage/thread/ect. contains "Version = 1.0.0 or whatever your version is."

    NOTE: This does not actually update the game if needed, it only tells the player to update the game if there is a newer version.

    NOTE: The Version may only contain numbers and decimal points.

    EDIT: I added dragonnite's suggestion on adding to download the update (Instructions are in the comments to set it up) (I also didn't test this with an actual zip/rar/7z/exe file but in theory it should work, if to doesn't please let me know and I'll fix it)

    Code:
    ################################################################################
    # Version Check
    # By Hansiec
    ################################################################################
    # Checks your current game version and compares it to the latest
    #
    # Instructions:
    # 1. Copy your Thread URL (or the url that will contain the current version of
    #     your game, examples are: PokeCommunity threads, Wikis, and your own Website)
    #
    # 2. Paste the URL in step 1 into the "ThreadURL" variable below.
    #
    # 3. Make sure that anywhere in your given URL it contains "Version = VersionID"
    #
    # 4. Edit the "GameVersion" variable below to the version of the game.
    #
    # 5. Edit the "UpdateMessage" variable below if you want a custom warning when the
    #     game needs an update
    #
    # 6. Test it out (it should automatically check updates at the startup of the
    #     game)
    #
    # 7. If you want to automatically download updates, add in your given URL
    #     "DownloadUrl = "DirectDownloadLinkToGame" " (there must be double quotes around your actual link)
    #
    #
    #
    ################################################################################
    
    
    ThreadURL = "Game URL Here"
    
    GameVersion = "Game Version Here"
    
    UpdateMessage = "There is an update available for this game, please download" +
      " the latest version to experience the game's full potential."
    
    UpdateDownloadedMessage = "The update has been downloaded, plase look in the" + 
      "game folder for the file"
    
    def pbCheckVersion
      string = pbDownloadToString(ThreadURL).downcase
      
      if string.include?("version=")
        string = string.split("version=")[1]
        string = string[/([0-9\.]+)/]
      elsif string.include?("version = ")
        string = string.split("version = ")[1]
        string = string[/([0-9\.]+)/]
      elsif $DEBUG
        print "The given URL is either invalid or does not contain " +
          "the data for finding the current version (it should be Version = "+
          "CurrentVersion)."
      end
      
      if string == GameVersion
        return true
      end
      
      Kernel.pbMessage(_INTL(UpdateMessage))
      return false
      
    rescue
      return true
    end
    
    def pbDownloadUpdate
      string = pbDownloadToString(ThreadURL).downcase
      
      if string.include?("downloadurl=")
        string = string.split("downloadurl=")[1]
        string = string[/([a-zA-z0-9\.\\\/ :]+)/]
      elsif string.include?("downloadurl = ")
        string = string.split("downloadurl = ")[1]
        string = string[/([a-zA-z0-9\.\\\/ :]+)/]
      else
        return
      end
    
      string.gsub!("\\", "/")
      split = string.split("/")
      
      pbDownloadData(string, split[split.length - 1])
      Kernel.pbMessage(_INTL(UpdateDownloadedMessage))
    end
    
    if !pbCheckVersion
      pbDownloadUpdate
    end

    For anyone looking for an example on how the version and download URLs should look like on your Thread/Wiki/ect. here's one:

    Code:
    Version = 1.0.0
    DownloadURL = "http://myWebHost.com/Downloads/MyGame.zip"
     
    Last edited:

    xKushGene

    Pokemon Xellent
    7
    Posts
    7
    Years
  • Can u add a function, that if the script needs more than 5-10 seconds to go to the site for searching Version = VersionID the game instantly start? Because if my site is down, than nobody can play the game cuz the game checks as my site is online for searching "Version = VersionID"
     
    87
    Posts
    8
    Years
    • Seen Jul 24, 2016
    Simply put, this script just checks if the game needs to be updated when you start it up.

    The instructions are located within the script, please make sure you follow them.

    NOTE: Make sure your webpage/thread/ect. contains "Version = 1.0.0 or whatever your version is."

    NOTE: This does not actually update the game if needed, it only tells the player to update the game if there is a newer version.

    NOTE: The Version may only contain numbers and decimal points.

    EDIT: I added dragonnite's suggestion on adding to download the update (Instructions are in the comments to set it up) (I also didn't test this with an actual zip/rar/7z/exe file but in theory it should work, if to doesn't please let me know and I'll fix it)

    Code:
    ################################################################################
    # Version Check
    # By Hansiec
    ################################################################################
    # Checks your current game version and compares it to the latest
    #
    # Instructions:
    # 1. Copy your Thread URL (or the url that will contain the current version of
    #     your game, examples are: PokeCommunity threads, Wikis, and your own Website)
    #
    # 2. Paste the URL in step 1 into the "ThreadURL" variable below.
    #
    # 3. Make sure that anywhere in your given URL it contains "Version = VersionID"
    #
    # 4. Edit the "GameVersion" variable below to the version of the game.
    #
    # 5. Edit the "UpdateMessage" variable below if you want a custom warning when the
    #     game needs an update
    #
    # 6. Test it out (it should automatically check updates at the startup of the
    #     game)
    #
    # 7. If you want to automatically download updates, add in your given URL
    #     "DownloadUrl = "DirectDownloadLinkToGame" " (there must be double quotes around your actual link)
    #
    #
    #
    ################################################################################
    
    
    ThreadURL = "Game URL Here"
    
    GameVersion = "Game Version Here"
    
    UpdateMessage = "There is an update available for this game, please download" +
      " the latest version to experience the game's full potential."
    
    UpdateDownloadedMessage = "The update has been downloaded, plase look in the" + 
      "game folder for the file"
    
    def pbCheckVersion
      string = pbDownloadToString(ThreadURL).downcase
      
      if string.include?("version=")
        string = string.split("version=")[1]
        string = string[/([0-9\.]+)/]
      elsif string.include?("version = ")
        string = string.split("version = ")[1]
        string = string[/([0-9\.]+)/]
      elsif $DEBUG
        print "The given URL is either invalid or does not contain " +
          "the data for finding the current version (it should be Version = "+
          "CurrentVersion)."
      end
      
      if string == GameVersion
        return true
      end
      
      Kernel.pbMessage(_INTL(UpdateMessage))
      return false
      
    rescue
      return true
    end
    
    def pbDownloadUpdate
      string = pbDownloadToString(ThreadURL).downcase
      
      if string.include?("downloadurl=")
        string = string.split("downloadurl=")[1]
        string = string[/([a-zA-z0-9\.\\\/ :]+)/]
      elsif string.include?("downloadurl = ")
        string = string.split("downloadurl = ")[1]
        string = string[/([a-zA-z0-9\.\\\/ :]+)/]
      else
        return
      end
    
      string.gsub!("\\", "/")
      split = string.split("/")
      
      pbDownloadData(string, split[split.length - 1])
      Kernel.pbMessage(_INTL(UpdateDownloadedMessage))
    end
    
    if !pbCheckVersion
      pbDownloadUpdate
    end

    For anyone looking for an example on how the version and download URLs should look like on your Thread/Wiki/ect. here's one:

    Code:
    Version = 1.0.0
    DownloadURL = "http://myWebHost.com/Downloads/MyGame.zip"

    Actually It does not work how it should for me :D. Its true it detects the game version but it wont download anything. I used a direct Link and didnt download at all.
    Sorry bad english
     

    Zeak6464

    Zeak #3205 - Discord
    1,101
    Posts
    11
    Years
  • Actually It does not work how it should for me :D. Its true it detects the game version but it wont download anything. I used a direct Link and didnt download at all.
    Sorry bad english

    make sure you did this step :

    DownloadURL = ""http://myWebHost.com/Downloads/MyGame.zip""
    (there must be double quotes around your actual link)
     

    xKushGene

    Pokemon Xellent
    7
    Posts
    7
    Years
  • Im learning ruby but my knowledge is not so big. So I ask the communty,
    can u make an if statement, if the player has no Internet than the Update Checker doesnt check if an update is available? Cuz if internet is hanging or website is down, than the game just answers "Script is hanging" and player without internet can't play the game cuz Update check.

    It would be very nice :)
     
    Back
    Top