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
1021 액터 (killer님 요청)자동회복 스크립트 3 나뚜루 2009.02.22 2572
1020 기타 (T-RPG) 데미지 표시 시의 폰트를 설정 백호 2009.02.22 1348
1019 메뉴 1-Scene CMS 1.03 by LegACy@rmxp.org (SDK호환) file 백호 2009.02.22 871
1018 메뉴 1-Scene CMS 1.1 by LegACy@rmxp.org (SDK호환) file 백호 2009.02.22 953
1017 메뉴 1-Scene CMS 1.16 by LegACy (SDK호환) 3 file 백호 2009.02.22 1564
1016 메시지 1문자식 표시랑 따랑소리 나는 스크립트 8 백호 2009.02.22 2303
1015 메뉴 1인 캐릭터 메뉴 스크립트 27 file - 하늘 - 2009.08.06 4789
1014 메뉴 1인용 메뉴 스크립트 6 WMN 2008.03.17 2450
1013 메뉴 3D Menu Script 7 현문 2010.10.06 4077
1012 기타 3d 렌더링스크립트 어렵게 찾음 9 라구나 2011.03.05 3610
1011 이동 및 탈것 3D 캐릭 스크립트 7 백호 2009.02.22 3443
1010 기타 3D스크립트 48 file ok하승헌 2010.02.18 3808
1009 기타 4방향 마우스 스크립트 12 file 아방스 2009.02.28 2662
1008 기타 8방향 마우스 스크립트 10 file 아방스 2009.02.28 4063
1007 이동 및 탈것 8방향 스크립트 12 file 백호 2009.02.21 2412
1006 이동 및 탈것 8방향 이동 & 대쉬 스크립트 5 백호 2009.02.21 1701
1005 이동 및 탈것 8방향움직임과 8방향 캐릭터칩 호환 2 file 백호 2009.02.21 2273
1004 이동 및 탈것 8방향이동 9 캉쿤 2011.09.19 2527
1003 이동 및 탈것 8방향이동, Shift키 누르면 대쉬 63 WinHouse 2010.06.12 4023
1002 전투 A-battle 수정 file 백호 2009.02.21 1155
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ... 52 Next
/ 52