khanhdu

script bank

Aug 8th, 2018
440
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 3.41 KB | None | 0 0
  1. =begin
  2.   Bank Script by TheUnproPro
  3. =end
  4.  
  5. $txt="Chào Mừng Tới Ngân Hàng Ba Con Sói "
  6.  
  7.  
  8.  
  9. class Bank_Window_Gold < Window_Base
  10.   def initialize
  11.     super(0, 96, window_width, fitting_height(1))
  12.     if $game_variables[10001] == nil
  13.       $game_variables[10001]=0
  14.     end
  15.     refresh
  16.   end
  17.  
  18.   def window_width
  19.     return 260
  20.   end
  21.  
  22.   def refresh
  23.     contents.clear
  24.     text=sprintf("Số Tiền Đã Gửi: %d", $game_variables[10001])
  25.     draw_text(0, 0, window_width, line_height, text)
  26.   end
  27.   def open
  28.     refresh
  29.     super
  30.   end
  31.   def update
  32.     super
  33.     refresh
  34.   end
  35. end
  36.  
  37. class TextWindow < Window_Base
  38.   def initialize
  39.     super(0, Graphics.height-160, Graphics.width, 160)
  40.     refresh
  41.   end
  42.   def refresh
  43.     contents.clear
  44.     text=$txt
  45.     draw_text(0, 0, Graphics.width, line_height, text)
  46.   end
  47.   def update
  48.     super
  49.     refresh
  50.   end
  51. end
  52.  
  53. class InfoDisplay < Window_Base
  54.   def initialize
  55.     super(0, 48, Graphics.width, 48)
  56.     refresh
  57.   end
  58.   def refresh
  59.     contents.clear
  60.     draw_text(0, 0, Graphics.width, line_height, "Số Tiền ?")
  61.   end
  62. end
  63.  
  64. class SelectAmount < Window_Base
  65.   def initialize
  66.     super(0, Graphics.height-200, 300, 48)
  67.     refresh
  68.   end
  69.  
  70.   def refresh
  71.     contents.clear
  72.     text=sprintf("%d")
  73.   end
  74. end
  75.  
  76.  
  77. class Choices_For_Bank < Window_HorzCommand
  78.   def window_width
  79.     return Graphics.width
  80.   end
  81.   def make_command_list
  82.     add_command("Gửi Tiền", :deposite)
  83.     add_command("Rút Tiền", :withdraw)
  84.     add_command("Trở Về", :back)
  85.   end
  86. end
  87.  
  88. class Scene_Bank < Scene_MenuBase
  89.   def start
  90.     super
  91.     make_gold_windows
  92.     make_display_window
  93.     make_command_windows
  94.     make_info_window
  95.   end
  96.  
  97.   def make_gold_windows
  98.     @gold=Window_Gold.new
  99.     @gold2=Bank_Window_Gold.new
  100.     @gold2.x=160
  101.     @gold2.y=0
  102.   end
  103.  
  104.   def make_command_windows
  105.     @command_window=Choices_For_Bank.new(0,  Graphics.height-64)
  106.     @command_window.opacity=0
  107.     @command_window.set_handler(:deposite, method(:deposite))
  108.     @command_window.set_handler(:withdraw, method(:withdraw))
  109.     @command_window.set_handler(:back, method(:back))
  110.     @num_win = Window_NumberInput.new(@txt_window)
  111.     $game_message.num_input_digits_max=5
  112.     $game_message.num_input_variable_id=10000
  113. end
  114.   def make_display_window
  115.     @txt_window = TextWindow.new
  116.   end
  117.  
  118.   def make_info_window
  119.     @info_window = InfoDisplay.new
  120.     @info_window.hide
  121.   end
  122.  
  123.   def deposite
  124.     $TYPE=0
  125.     @info_window.show
  126.     @num_win.start
  127.   end
  128.  
  129.   def withdraw
  130.     $TYPE=1
  131.     @info_window.show
  132.     @num_win.start
  133.   end
  134.  
  135.   def update
  136.     super
  137.     if $reactivate==1
  138.       @command_window.activate
  139.       @gold.refresh
  140.       $reactivate=0
  141.       @info_window.hide
  142.       $game_variables[10001]
  143.     end
  144.   end
  145.  
  146.   def back
  147.     @txt_window.dispose
  148.     return_scene
  149.   end
  150.  
  151. end
  152.  
  153. class Window_NumberInput < Window_Base
  154.   alias do_ok process_ok
  155.   def process_ok
  156.     do_ok
  157.     $reactivate=1
  158.     case $TYPE
  159.       when 0
  160.       if $game_variables[10000] <= $game_party.gold
  161.         $game_variables[10001]+=$game_variables[10000]
  162.         $game_party.lose_gold($game_variables[10000])
  163.       end
  164.       when 1
  165.         if $game_variables[10000] <= $game_variables[10001]
  166.         $game_variables[10001]-=$game_variables[10000]
  167.         $game_party.gain_gold($game_variables[10000])
  168.       end
  169.     end
  170.   end
  171. end
Add Comment
Please, Sign In to add comment