XP 스크립트

=begin
  title  WebTime class
 
  author jubin-park
  refer  EFE's WinHttp Request
  date   2015.12.12
  syntax Ruby (XP/VX/VXA)
=end

class WebTime < Time
  def self.new;  now() end
  def self.year; now.year() end
  def self.mon;  now.mon() end
  def self.mday; now.mday() end
  def self.hour; now.hour() end
  def self.min;  now.min() end
  def self.sec;  now.sec() end
  def self.now
    n = 0; data = String.new
    t_p = Time.now
    req = s2u(EFE.request('www.webtour.com', '/GInfo/time.asp?Code=A', 999999))
    # 실패 시 로컬 시간 반환
    return Time.now if req == "\000"
    t_l = Time.now
    req.scan(/<td width="134">(.*)<\/td>/) do |w|
      n += 1
      if n == 20
        data << $1
        break
      end
    end
    req = nil
    data = data.scan /(\d+)\/(\d+)\/(\d+) 오(전|후) (\d+):(\d+):(\d+)/
    # 실패 시 로컬 시간 반환
    return Time.now if data == []
    data.flatten!
    data[3] = 0  if data[3] == '전' # 오전 +0
    data[3] = 12 if data[3] == '후' # 오후 +12
    data[4] = 0  if data[3] == 0 && data[4] == '12' # 오전 12시 = 오전 0시
    data[4] = 0  if data[3] == 12 && data[4] == '12' # 오후 12시 = 오후 0시
    for i in 0...data.size
      data[i] = data[i].to_i
    end
    data[0] += 2000
    data[4] += data[3] # AM/PM 적용 뒤
    data.delete_at(3) # 삭제
    data[1] = case data[1] # 달
    when 1; 'jan'
    when 2; 'feb'
    when 3; 'mar'
    when 4; 'apr'
    when 5; 'may'
    when 6; 'jun'
    when 7; 'jul'
    when 8; 'aug'
    when 9; 'sep'
    when 10; 'oct'
    when 11; 'nov'
    when 12; 'dec'
    end
    return Time.local(*data) + (t_l - t_p) # 오차값 가산
  end
end

=begin
===============================================================================
 EFE's Request Script
 Version: RGSS & RGSS2 & RGSS3
 Special thanks : Ryex, Gustavo Bicalho, Kubiwa Taicho
===============================================================================
 This script will allow to request to some servers WITHOUT posting. (Only GET)
--------------------------------------------------------------------------------
Used WINAPI functions:

WinHTTPOpen
WinnHTTLConnect
WinHTTPOpenRequest
WinHTTPSendRequest
WinHTTPReceiveResponse
WinHttpQueryDataAvailable
WinHttpReadData

Call:

EFE.request(host, path, post, port)

host : "www.rpgmakervxace.net" (without http:// prefix)
path : "/forum/login.php" ( the directory path of your php file )
post : "username=kfdsfdsl&password=24324234"
port : 80 is default.

=end

module EFE
  WinHttpOpen = Win32API.new('winhttp','WinHttpOpen',"PIPPI",'I')
  WinHttpConnect = Win32API.new('winhttp','WinHttpConnect',"PPII",'I')
  WinHttpOpenRequest = Win32API.new('winhttp','WinHttpOpenRequest',"PPPPPII",'I')
  WinHttpSendRequest = Win32API.new('winhttp','WinHttpSendRequest',"PIIIIII",'I')
  WinHttpReceiveResponse = Win32API.new('winhttp','WinHttpReceiveResponse',"PP",'I')
  WinHttpQueryDataAvailable = Win32API.new('winhttp', 'WinHttpQueryDataAvailable', "PI", "I")
  WinHttpReadData = Win32API.new('winhttp','WinHttpReadData',"PPIP",'I')
 
  # I took this method from Gustavo Bicalho's WebKit script. Special thanks him.
  def self.to_ws(str)
    str = str.to_s();
    wstr = "";
    for i in 0..str.size
      wstr += str[i,1]+"\0";
    end
    wstr += "\0";
    return wstr;
  end
 
  def self.request(host, path, buf, post="",port=80)
    p = path
    if(post != "")
      p = p + "?" + post
    end
    p = p.to_s
    pwszUserAgent = ''
    pwszProxyName = ''
    pwszProxyBypass = ''
    httpOpen = WinHttpOpen.call(pwszUserAgent, 0, pwszProxyName, pwszProxyBypass, 0)
    if httpOpen
      httpConnect = WinHttpConnect.call(httpOpen, to_ws(host), port, 0)
      if httpConnect
        httpOpenR = WinHttpOpenRequest.call(httpConnect, nil, to_ws(p), "", '',0,0)
        if httpOpenR
          httpSendR = WinHttpSendRequest.call(httpOpenR, 0, 0 , 0, 0,0,0)
          if httpSendR
            httpReceiveR = WinHttpReceiveResponse.call(httpOpenR, nil)
            if httpReceiveR
              received = 0
              httpAvailable = WinHttpQueryDataAvailable.call(httpOpenR, received)
              if httpAvailable
                ali = ' ' * buf
                n = 0
                httpRead = WinHttpReadData.call(httpOpenR, ali, buf, o=[n].pack('i!'))
                n=o.unpack('i!')[0]
                return ali[0, n]
              else
                p("Error about query data available")
              end
            else
              p("Error when receiving response")
            end
          else
            p("Error when sending request")
          end
        else
          p("Error when opening request")
        end
      else
        p("Error when connecting to the host")
      end
    else
      p("Error when opening connection")
    end
  end
end

## Encoding

MultiByteToWideChar = Win32API.new('kernel32', 'MultiByteToWideChar', 'llplpl', 'l')
WideCharToMultiByte = Win32API.new('kernel32', 'WideCharToMultiByte', 'llplplpp', 'l')

def s2u(text)
  len = MultiByteToWideChar.call(0, 0, text, -1, nil, 0)
  buf = '\0' * (len*2)
  MultiByteToWideChar.call(0, 0, text, -1, buf, buf.size/2)
  len = WideCharToMultiByte.call(65001, 0, buf, -1, nil, 0, nil, nil)
  ret = '\0' * len
  WideCharToMultiByte.call(65001, 0, buf, -1, ret, ret.size, nil, nil)
  return ret.delete('\000')
end

 

-------

 

여기서 보시면, 오프라인 상태에서도 컴퓨터 내부의 시간을 자동적으로 취득해옵니다..

잠시 잠깐 질문이라면, 오프라인 상태에서는 컴퓨터 내부 시간을 취득하지 않고,  게임 내부의 변수에 일정 값을 주는 것으로 바꾸던지.

아니면, 자동 게임 종료가 되거나, 게임도중 오프라인 상태라도 같은 상황이 되게끔 하려면... 어떻게 해야하나요 ㅠ

질문 요약하면... 오프라인상태에서는 시간을 취득하지 않고, 게임이 종료되거나, 게임 내부의 변수에 값을 대입하는 상태로 가려면 어떻게 해야합니까 ㅠ..?

Comment '1'
  • ?
    이우 2016.05.24 02:18

    혹시나 필요하신 분들이 있다면 가져다 쓰심이 좋기도하고, 또 제 궁금증을 해결할겸 겸겸히 하여 여기에도 글을 올렸습니다.

     

    >>재질문.. 여기서 보시면, 오프라인 상태에서도 컴퓨터 내부의 시간을 자동적으로 취득해옵니다..

    잠시 잠깐 질문이라면, 오프라인 상태에서는 컴퓨터 내부 시간을 취득하지 않고, 게임 내부의 변수에 일정 값을 주는 것으로 바꾸던지.

    아니면, 자동 게임 종료가 되거나, 게임도중 오프라인 상태라도 같은 상황이 되게끔 하려면... 어떻게 해야하나요 ㅠ

    질문 요약하면... 오프라인상태에서는 시간을 취득하지 않고, 게임이 종료되거나, 게임 내부의 변수에 값을 대입하는 상태로 가려면 어떻게 해야합니까 ㅠ..?


List of Articles
번호 분류 제목 글쓴이 날짜 조회 수
공지 스크립트 자료 게시물 작성시 주의사항 습작 2012.12.24 6153
61 기타 Near Fantastica's SDK Test Bed 3 file 백호 2009.02.22 885
60 메뉴 Customizable Ring Menu by SephirothSpawn 백호 2009.02.22 884
59 기타 SG_Settings Control by sandgolem 백호 2009.02.22 884
58 기타 [XP/VX/VXA] Drago Core Engine Alkaid 2014.02.13 883
57 아이템 Easy Item & Gold Gain by SephirothSpawn (SDK호환) 백호 2009.02.22 880
56 기타 아래 스크립트에 대한 Guillaume777님의 개량판입니다. 백호 2009.02.22 880
55 기타 Dynamic Stores by Astro_mech@rmxp.net 1 file 백호 2009.02.22 878
» 온라인 인터넷 웹 상에서의 시간을 취득하는 스크립트 1 이우 2016.05.24 872
53 메뉴 1-Scene CMS 1.03 by LegACy@rmxp.org (SDK호환) file 백호 2009.02.22 871
52 기타 Difficulty Options by SephirothSpawn 백호 2009.02.22 869
51 기타 RM2K Facesets, Inn & Windowskin Colors by DerVVulfman@rmxp.org 1 file 백호 2009.02.22 866
50 스킬 [KGC] Skill Grouping 백호 2009.02.21 861
49 이동 및 탈것 SG_Wait for Move Completion Fix by sandgolem (SDK호환) 백호 2009.02.22 860
48 기타 Introduction & optional Splash 2.1 by SephirothSpawn (SDK호환) 1 백호 2009.02.22 860
47 기타 Quick Animations by SephirothSpawn (SDK호환) 백호 2009.02.22 851
46 기타 [XP/VX/VXA] Map Screenshot by LiTTleDRAgo 1 Alkaid 2014.02.13 850
45 아이템 SG_Escape Only Items by sandgolem (SDK호환) 백호 2009.02.22 850
44 이동 및 탈것 Memorize Location R2 by dubealex file 백호 2009.02.22 846
43 기타 Sized Events 0.1 by Toby@rmxp.org file 백호 2009.02.22 845
42 스킬 Grouping and Detail (Items/Skills) 1 file 백호 2009.02.21 839
Board Pagination Prev 1 ... 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 Next
/ 52