Advertisement
Faherya

Access Key - [RGSS3]

Feb 25th, 2018
381
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 3.63 KB | None | 0 0
  1. =begin =========================================================================
  2. --------------------------------------------------------------------------------
  3.  Access key 1.0.0.1
  4.  Author: Faherya
  5. --------------------------------------------------------------------------------
  6.  This code allows you to distribute access keys manually. It is recommended
  7.  only for demo distribution, trial versions and other situations in which the
  8.  number of copies distributed will be controlled.
  9. --------------------------------------------------------------------------------
  10.  Instructions:
  11.  First, you must create your access keys. The file can be created in any text
  12.  editor and all key files NEED to have the same name. Here is an example:
  13.  
  14.   # Thank you for purchasing your copy of {GAME NAME}!
  15.   # Here is your access key:
  16.   key = {
  17.     :accKey => 106839
  18.   }
  19.  
  20.  You can upload your game normally. Then distribute the access files one by
  21.  one. These files must be in the same directory as the game executable.
  22. --------------------------------------------------------------------------------
  23. Terms of Use:
  24. Free for non-commercial projects. For commercial use please contact.
  25. --------------------------------------------------------------------------------
  26. Credits and Acknowledgments:
  27. Alisson
  28. Kyo Panda
  29. MayLeone
  30. starlight dream
  31. TheoAllen
  32.  
  33. If they want, these people can use the code in commercial projects freely.
  34.  
  35. For more codes access centrorpg.com !
  36. --------------------------------------------------------------------------------
  37. =end
  38. # ------------------------------------------------------------------------------
  39. # Normally your keys should be saved only in .rvdata2 format, highly
  40. # recommended thing, but if you prefer to use another this fix
  41. # allows you to use different formats.
  42.  
  43. class << Marshal
  44.   alias :marshall_load:load
  45.   def load(port, proc = nil)
  46.     marshall_load(port, proc)
  47.   rescue TypeError
  48.     if port.kind_of?(File)
  49.       port.rewind
  50.       port.read
  51.     else
  52.       port
  53.     end
  54.   end
  55. end unless Marshal.respond_to?(:marshall_load)
  56.  
  57. #-------------------------------------------------------------------------------
  58. class Scene_Key < Scene_Base
  59. #-------------------------------------------------------------------------------  
  60. # Setup Instructions:
  61. # Below is a verification structure. Each line beginning with "when" checks for
  62. # a possible key. To add new keys just copy and paste this and the subsequent
  63. # line by modifying the numerical value by your key.
  64. # Remember one thing:
  65. #  - All key files NEED to have the same name.
  66.   def start
  67.     super
  68.     # Verifying that the file exists:
  69.     if File.exists?("Key.rvdata2")# This is the file name and format.
  70.       # Reading the file:
  71.       key = eval(load_data("Key.rvdata2"))
  72.       # Start verification:
  73.       case key[:accKey]
  74.         # These keys are just examples. I recommend you use random numbers.
  75.         when 000000
  76.           validate_key
  77.         when 000001
  78.           validate_key
  79.         # [...]  
  80.         else # Invalid key
  81.           msgbox "Invalid key."
  82.           exit
  83.       end
  84.     else # The key file does not exist.
  85.       msgbox "File not found."
  86.       exit
  87.     end
  88.   end
  89.   # Validate Key
  90.   def validate_key
  91.       SceneManager.call(Scene_Title)
  92.     end
  93. #-------------------------------------------------------------------------------
  94. end
  95. #-------------------------------------------------------------------------------
  96. # Modifying the SceneManager:
  97. module SceneManager  
  98.   def self.first_scene_class
  99.     $BTEST ? Scene_Battle : Scene_Key
  100.   end
  101. end
  102. #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement