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 메시지 Taylor's Simple Message System 2000 Alkaid 2020.07.05 241
1020 제작도구 [XP/VX/VXA] Doodad's Editor by newold Alkaid 2020.07.12 382
1019 이름입력 한글조합입력기(영어가능) file 조규진1 2019.11.10 492
1018 전투 전투중에 장비들 교체하기 file 레이스89 2017.08.19 592
1017 기타 [All RGSS] FileTest (Unicode) file Cheapmunk 2014.12.29 611
1016 맵/타일 맵연결 스크립트 (데모첨부) file 게임애호가 2018.06.15 686
1015 기타 에어리어 설정 by RPG Advocate 백호 2009.02.22 709
1014 기타 Boat Script 백호 2009.02.21 729
1013 기타 Localization by ForeverZer0, KK20 습작 2013.04.26 738
1012 기타 Materia System file 백호 2009.02.21 749
1011 기타 Real-Time Day Night 3 백호 2009.02.22 751
1010 스킬 SG_Escape Only Skills by sandgolem (SDK호환) 백호 2009.02.22 752
1009 기타 killer님 요청하신 스크립트 두번째입니다. 나뚜루 2009.02.21 759
1008 기타 Letter by Letter Message Window by slipknot@rmxp.org (SDK호환) 1 file 백호 2009.02.22 760
1007 기타 Advanced Gold display by Dubealex 1 백호 2009.02.22 761
1006 스킬 Skill Requirements by SephirothSpawn (SDK호환) file 백호 2009.02.22 763
1005 기타 Sphere Grid System file 백호 2009.02.21 765
1004 기타 AMS-Advanced Message Script Edited by Dubleax 3 file 백호 2009.02.21 765
1003 스킬 SG_Skill Break by sandgolem (SDK호환) 백호 2009.02.22 772
1002 기타 Activation_system file 백호 2009.02.22 775
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