赞 | 3 |
VIP | 333 |
好人卡 | 2 |
积分 | 1 |
经验 | 1450446 |
最后登录 | 2019-5-29 |
在线时间 | 615 小时 |
Lv1.梦旅人 66RPG站长
- 梦石
- 0
- 星屑
- 54
- 在线时间
- 615 小时
- 注册时间
- 2005-10-10
- 帖子
- 5734
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
一个简单的小脚本,可以用来统计自己的玩家总人数(进入游戏时候会显示:您是本游戏第X位玩家)
范例工程:
RMXP:
统计人数XP.rar
(264.42 KB, 下载次数: 957)
(脚本在最上面)
RMVX:
统计人数VX.rar
(329.64 KB, 下载次数: 344)
(脚本在【▼ 模块】这个里)
原理:
在玩家第一次进入游戏时候联网到66RPG的服务器,服务器会统计玩家人数并显示出来。
除了RM,其他游戏系统只要能用脚本,均可使用本系统。接口如下:
http://jump.66rpg.com/stat.php?uid=【你66RPG的UID】&gid=【你的游戏名字(最好英文)】
RMXP:脚本如下(由于里面有一张LOGO图,最好还是用范例工程):
- #==============================================================================
- # 下面几项请先设置
- # 其中$tj_66rpg_uid、$tj_game_name必须填,服务器会用这两项来判断是谁的什么游戏
- #
- # 脚本原理:
- # 第一次进入游戏时候检查是否有SaveX.rxdata这个文件,如果没有这个文件,则创建,
- # 并向服务器汇报新玩家登陆,返回玩家总人数并展示出来
- #==============================================================================
- #-------------------------------------------------------------------------
- # 在66RPG的uid,查看方法:登陆6R,点击自己头像,会进入自己的空间
- # 地址类似于:http://rpg.blue/space-uid-53287.html
- # 这个53287就是你的uid,也就是你在6R的注册编号
- #-------------------------------------------------------------------------
- $tj_66rpg_uid = 53287
- #-------------------------------------------------------------------------
- # 你的游戏名,不会显示给玩家,只在后台统计记录,最好用数字编号或英文
- #-------------------------------------------------------------------------
- $tj_game_name = "project_tongji_xp"
- #-------------------------------------------------------------------------
- # 播放TITLE音乐,用于在等待后台联网的时候让玩家先听着开头音乐
- #-------------------------------------------------------------------------
- begin
- Audio.bgm_play("Audio/BGM/064-Slow07", 100, 100)
- rescue
- end
- #-------------------------------------------------------------------------
- # 本环节确定时候的声效
- #-------------------------------------------------------------------------
- tj_decision = "Audio/SE/002-System02"
- #-------------------------------------------------------------------------
- # 字体在这里设置,因为本脚本在main执行前就需要显示文字
- #-------------------------------------------------------------------------
- Font.default_name = ["黑体","微軟正黑體","細明體","微软雅黑","宋体"]
- Font.default_size = 22
- #-------------------------------------------------------------------------
- # 一句话描述,随便写,别超过14个字
- #-------------------------------------------------------------------------
- tj_game_description = "本游戏为纯粹的测试工程"
- #---------------------------------------------------------
- # 开头时候读取的LOGO地址
- #---------------------------------------------------------
- tj_logo = "Graphics/Pictures/rgblogo"
- #==============================================================================
- # 下面這段腳本來自66RPG.com,用來向服务器汇报新玩家
- #==============================================================================
- class Get_Http_Info
- AGENT = "RGSS PLAYER"
- INTERNET_OPEN_TYPE_PRECONFIG = 0
- INTERNET_OPEN_TYPE_DIRECT = 1
- def Get_Http_Info.InternetOpen()
- io = Win32API.new('wininet', 'InternetOpen', %(p, l, p, p, l), 'l')
- hInternet = io.call(AGENT, INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0)
- return hInternet
- end
- def Get_Http_Info.InternetOpenUrl(hSession, url)
- iou = Win32API.new('wininet', 'InternetOpenUrl', %(l, p, p, l, l, l), 'l')
- hService = iou.call(hSession, url, nil, 0, 0, 0)
- return hService
- end
- def Get_Http_Info.InternetReadFile(hService)
- content = ""
- read_size = 1024 # 一次读入文件的尺寸
- irf = Win32API.new('wininet', 'InternetReadFile', %(l, p, i, p), 'i')
- while(true)
- buf = "\0" * read_size
- red = [0].pack('L')
- irf.call( hService, buf, read_size, red )
- if(red.unpack('L') == [0])
- #读到文件末端
- break
- end
- buf.delete!("\0")
- content += buf
- end
- return content
- end
- HTTP_QUERY_STATUS_CODE = 19
- def Get_Http_Info.HttpQueryInfo(hService)
- read_size = 1024
- buf = "\0" * read_size
- red = [read_size-1].pack('L')
- hqi = Win32API.new('wininet', 'HttpQueryInfo', %(l, l, p, p, p), 'i')
- isOk = hqi.call( hService, HTTP_QUERY_STATUS_CODE, buf, red, nil)
- buf.delete!("\0")
- return buf
- end
- def Get_Http_Info.InternetCloseHandle(hInternet)
- ich = Win32API.new('winInet', 'InternetCloseHandle', %(l), 'i')
- isOk = ich.call(hInternet)
- return isOk
- end
- HTTP_CODE_OK = "200"
- def Get_Http_Info.get_info(url)
- info = nil
- begin
- hInternet = InternetOpen()
- if(hInternet != 0)
- hService = InternetOpenUrl(hInternet, url)
- if(hService != 0)
- status_code = HttpQueryInfo(hService)
- if(status_code == HTTP_CODE_OK)
- info = InternetReadFile(hService)
- end
- InternetCloseHandle(hService)
- end
- InternetCloseHandle(hInternet)
- end
- rescue
- # 例外发生
- return nil
- end
- ary = []
- info.each_line do |line|
- next if line.empty?
- ary.push line
- end
- return ary[271].scan(/\w+<\/a>/)
- end
- def Get_Http_Info.get_html(url)
- info = nil
- begin
- hInternet = InternetOpen()
- if(hInternet != 0)
- hService = InternetOpenUrl(hInternet, url)
- if(hService != 0)
- status_code = HttpQueryInfo(hService)
- if(status_code == HTTP_CODE_OK)
- info = InternetReadFile(hService)
- end
- InternetCloseHandle(hService)
- end
- InternetCloseHandle(hInternet)
- end
- rescue
- # 例外发生
- return nil
- end
- return info
- end
-
- #------------------------------------------------------
- # 向66RPG网站发送新玩家
- #------------------------------------------------------
- def Get_Http_Info.add_click()
- url = "http://jump.66rpg.com/stat.php?uid=" + $tj_66rpg_uid.to_s + "&gid=" + $tj_game_name.to_s
- info = nil
- begin
- hInternet = InternetOpen()
- if(hInternet != 0)
- hService = InternetOpenUrl(hInternet, url)
- if(hService != 0)
- status_code = HttpQueryInfo(hService)
- if(status_code == HTTP_CODE_OK)
- info = InternetReadFile(hService)
- end
- InternetCloseHandle(hService)
- end
- InternetCloseHandle(hInternet)
- end
- rescue
- # 例外发生
- return nil
- end
- return info
- end
- end
- #==============================================================================
- # 下面这段是开头LOGO + 发送执行
- #==============================================================================
- if !File.exist?("SaveX.rxdata")
- temp_file = File.open("SaveX.rxdata", "wb")
- time_begin = Time.now.sec + Time.now.min
- logo_pic = Sprite.new
- begin
- logo_pic.bitmap = Bitmap.new(tj_logo)
- rescue
- logo_pic.bitmap = Bitmap.new(640, 480)
- logo_pic.bitmap.font.size = 18
- logo_pic.bitmap.font.color = Color.new(0, 0, 0)
- logo_pic.bitmap.fill_rect(0, 0, 640, 480, Color.new(255, 255, 255))
- logo_pic.bitmap.draw_text(0, 100, 640, 24, "制作自己的游戏 梦想世界 在你手中", 1)
- logo_pic.bitmap.draw_text(0, 130, 640, 24, "http://www.66RPG.com", 1)
- end
- logo_pic.opacity = 0
- for i in 0...20
- logo_pic.opacity += 15
- Graphics.update
- Input.update
- end
- infos = Get_Http_Info.add_click()
- infos = infos == nil ? "?" : infos.to_i.to_s
- now_time = Time.now.sec + Time.now.min
- while( now_time < time_begin + 4)
- Graphics.update
- Input.update
- now_time = Time.now.sec + Time.now.min
- break if now_time < time_begin
- end
- help_pic = Sprite.new
- help_pic.bitmap = Bitmap.new(640, 480)
- help_pic.bitmap.font.size = 18
- help_pic.bitmap.font.color = Color.new(0, 0, 0)
- help_pic.bitmap.fill_rect(0, 0, 640, 480, Color.new(255, 255, 255))
- help_pic.bitmap.draw_text(0, 100, 640, 24, "制作自己的游戏 梦想世界 在你手中", 1)
- help_pic.bitmap.draw_text(0, 130, 640, 24, "http://www.66RPG.com", 1)
- help_pic.bitmap.draw_text(0, 200, 640, 24, tj_game_description + ",你是本游戏第 " + infos + " 位玩家", 1)
- help_pic.bitmap.draw_text(0, 230, 640, 24, "游戏操作方式:纯键盘操作", 1)
- help_pic.bitmap.draw_text(0, 260, 640, 24, "角色移动:上、下、左、右 | 确定键:回车 | 取消键:ESC | 重启游戏:F12", 1)
- help_pic.bitmap.font.color = Color.new(160, 160, 160)
- help_pic.bitmap.draw_text(0, 360, 640, 24, "按回车键进入游戏", 1)
- help_pic.opacity = 0
- for i in 0...20
- logo_pic.opacity -= 15
- help_pic.opacity += 15
- Graphics.update
- Input.update
- end
- for i in 0...20 do Graphics.update end
- loop do
- Graphics.update
- Input.update
- if Input.trigger?(Input::C)
- begin
- Audio.se_play(tj_decision, 80, 100)
- rescue
- end
- break
- end
- end
- temp_file.write(infos.to_s)
- temp_file.close
- Graphics.freeze
- help_pic.dispose
- logo_pic.dispose
- end
复制代码
RMVX:脚本如下(由于里面有一张LOGO图,最好还是用范例工程):
- #==============================================================================
- # 下面几项请先设置
- # 其中$tj_66rpg_uid、$tj_game_name必须填,服务器会用这两项来判断是谁的什么游戏
- #
- # 脚本原理:
- # 第一次进入游戏时候检查是否有SaveX.rxdata这个文件,如果没有这个文件,则创建,
- # 并向服务器汇报新玩家登陆,返回玩家总人数并展示出来
- #==============================================================================
- #-------------------------------------------------------------------------
- # 在66RPG的uid,查看方法:登陆6R,点击自己头像,会进入自己的空间
- # 地址类似于:http://rpg.blue/space-uid-53287.html
- # 这个53287就是你的uid,也就是你在6R的注册编号
- #-------------------------------------------------------------------------
- $tj_66rpg_uid = 53287
- #-------------------------------------------------------------------------
- # 你的游戏名,不会显示给玩家,只在后台统计记录,最好用数字编号或英文
- #-------------------------------------------------------------------------
- $tj_game_name = "project_tongji_vx"
- #-------------------------------------------------------------------------
- # 播放TITLE音乐,用于在等待后台联网的时候让玩家先听着开头音乐
- #-------------------------------------------------------------------------
- begin
- Audio.bgm_play("Audio/BGM/Town5", 100, 100)
- rescue
- end
- #-------------------------------------------------------------------------
- # 本环节确定时候的声效
- #-------------------------------------------------------------------------
- tj_decision = "Audio/SE/Decision1"
- #-------------------------------------------------------------------------
- # 字体在这里设置,因为本脚本在main执行前就需要显示文字
- #-------------------------------------------------------------------------
- Font.default_name = ["黑体","微軟正黑體","細明體","微软雅黑","宋体"]
- Font.default_size = 20
- #-------------------------------------------------------------------------
- # 一句话描述,随便写,别超过14个字
- #-------------------------------------------------------------------------
- tj_game_description = "本游戏为测试工程"
- #---------------------------------------------------------
- # 开头时候读取的LOGO地址
- #---------------------------------------------------------
- tj_logo = "Graphics/System/rgblogo_vx"
- #==============================================================================
- # 下面這段腳本來自66RPG.com,用來向服务器汇报新玩家
- #==============================================================================
- class Get_Http_Info
- AGENT = "RGSS PLAYER"
- INTERNET_OPEN_TYPE_PRECONFIG = 0
- INTERNET_OPEN_TYPE_DIRECT = 1
- def Get_Http_Info.InternetOpen()
- io = Win32API.new('wininet', 'InternetOpen', %(p, l, p, p, l), 'l')
- hInternet = io.call(AGENT, INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0)
- return hInternet
- end
- def Get_Http_Info.InternetOpenUrl(hSession, url)
- iou = Win32API.new('wininet', 'InternetOpenUrl', %(l, p, p, l, l, l), 'l')
- hService = iou.call(hSession, url, nil, 0, 0, 0)
- return hService
- end
- def Get_Http_Info.InternetReadFile(hService)
- content = ""
- read_size = 1024 # 一次读入文件的尺寸
- irf = Win32API.new('wininet', 'InternetReadFile', %(l, p, i, p), 'i')
- while(true)
- buf = "\0" * read_size
- red = [0].pack('L')
- irf.call( hService, buf, read_size, red )
- if(red.unpack('L') == [0])
- #读到文件末端
- break
- end
- buf.delete!("\0")
- content += buf
- end
- return content
- end
- HTTP_QUERY_STATUS_CODE = 19
- def Get_Http_Info.HttpQueryInfo(hService)
- read_size = 1024
- buf = "\0" * read_size
- red = [read_size-1].pack('L')
- hqi = Win32API.new('wininet', 'HttpQueryInfo', %(l, l, p, p, p), 'i')
- isOk = hqi.call( hService, HTTP_QUERY_STATUS_CODE, buf, red, nil)
- buf.delete!("\0")
- return buf
- end
- def Get_Http_Info.InternetCloseHandle(hInternet)
- ich = Win32API.new('winInet', 'InternetCloseHandle', %(l), 'i')
- isOk = ich.call(hInternet)
- return isOk
- end
- HTTP_CODE_OK = "200"
- def Get_Http_Info.get_info(url)
- info = nil
- begin
- hInternet = InternetOpen()
- if(hInternet != 0)
- hService = InternetOpenUrl(hInternet, url)
- if(hService != 0)
- status_code = HttpQueryInfo(hService)
- if(status_code == HTTP_CODE_OK)
- info = InternetReadFile(hService)
- end
- InternetCloseHandle(hService)
- end
- InternetCloseHandle(hInternet)
- end
- rescue
- # 例外发生
- return nil
- end
- ary = []
- info.each_line do |line|
- next if line.empty?
- ary.push line
- end
- return ary[271].scan(/\w+<\/a>/)
- end
- def Get_Http_Info.get_html(url)
- info = nil
- begin
- hInternet = InternetOpen()
- if(hInternet != 0)
- hService = InternetOpenUrl(hInternet, url)
- if(hService != 0)
- status_code = HttpQueryInfo(hService)
- if(status_code == HTTP_CODE_OK)
- info = InternetReadFile(hService)
- end
- InternetCloseHandle(hService)
- end
- InternetCloseHandle(hInternet)
- end
- rescue
- # 例外发生
- return nil
- end
- return info
- end
-
- #------------------------------------------------------
- # 向66RPG网站发送新玩家
- #------------------------------------------------------
- def Get_Http_Info.add_click()
- url = "http://jump.66rpg.com/stat.php?uid=" + $tj_66rpg_uid.to_s + "&gid=" + $tj_game_name.to_s
- info = nil
- begin
- hInternet = InternetOpen()
- if(hInternet != 0)
- hService = InternetOpenUrl(hInternet, url)
- if(hService != 0)
- status_code = HttpQueryInfo(hService)
- if(status_code == HTTP_CODE_OK)
- info = InternetReadFile(hService)
- end
- InternetCloseHandle(hService)
- end
- InternetCloseHandle(hInternet)
- end
- rescue
- # 例外发生
- return nil
- end
- return info
- end
- end
- #==============================================================================
- # 下面这段是开头LOGO + 发送执行
- #==============================================================================
- if !File.exist?("SaveX.rxdata")
- temp_file = File.open("SaveX.rxdata", "wb")
- time_begin = Time.now.sec + Time.now.min
- logo_pic = Sprite.new
- begin
- logo_pic.bitmap = Bitmap.new(tj_logo)
- rescue
- logo_pic.bitmap = Bitmap.new(Graphics.width, Graphics.height)
- logo_pic.bitmap.font.size = 18
- logo_pic.bitmap.font.color = Color.new(0, 0, 0)
- logo_pic.bitmap.font.shadow = false
- logo_pic.bitmap.fill_rect(0, 0, Graphics.width, Graphics.height, Color.new(255, 255, 255))
- logo_pic.bitmap.draw_text(0, 100, Graphics.width, 24, "制作自己的游戏 梦想世界 在你手中", 1)
- logo_pic.bitmap.draw_text(0, 130, Graphics.width, 24, "http://www.66RPG.com", 1)
- end
- logo_pic.opacity = 0
- for i in 0...20
- logo_pic.opacity += 15
- Graphics.update
- Input.update
- end
- infos = Get_Http_Info.add_click()
- infos = infos == nil ? "?" : infos.to_i.to_s
- now_time = Time.now.sec + Time.now.min
- while( now_time < time_begin + 4)
- Graphics.update
- Input.update
- now_time = Time.now.sec + Time.now.min
- break if now_time < time_begin
- end
- help_pic = Sprite.new
- help_pic.bitmap = Bitmap.new(Graphics.width, Graphics.height)
- help_pic.bitmap.font.size = 18
- help_pic.bitmap.font.color = Color.new(0, 0, 0)
- help_pic.bitmap.font.shadow = false
- help_pic.bitmap.fill_rect(0, 0, Graphics.width, Graphics.height, Color.new(255, 255, 255))
- help_pic.bitmap.draw_text(0, 70, Graphics.width, 24, "制作自己的游戏 梦想世界 在你手中", 1)
- help_pic.bitmap.draw_text(0, 100, Graphics.width, 24, "http://www.66RPG.com", 1)
- help_pic.bitmap.draw_text(0, 170, Graphics.width, 24, tj_game_description + ",你是本游戏第 " + infos + " 位玩家", 1)
- help_pic.bitmap.draw_text(0, 200, Graphics.width, 24, "游戏操作方式:纯键盘操作", 1)
- help_pic.bitmap.draw_text(0, 230, Graphics.width, 24, "角色移动:上、下、左、右 | 确定键:回车 | 取消键:ESC", 1)
- help_pic.bitmap.font.color = Color.new(160, 160, 160)
- help_pic.bitmap.draw_text(0, 320, Graphics.width, 24, "按回车键进入游戏", 1)
- help_pic.opacity = 0
- for i in 0...20
- logo_pic.opacity -= 15
- help_pic.opacity += 15
- Graphics.update
- Input.update
- end
- for i in 0...20 do Graphics.update end
- loop do
- Graphics.update
- Input.update
- if Input.trigger?(Input::C)
- begin
- Audio.se_play(tj_decision, 80, 100)
- rescue
- end
- break
- end
- end
- temp_file.write(infos.to_s)
- temp_file.close
- Graphics.freeze
- help_pic.dispose
- logo_pic.dispose
- end
复制代码 |
评分
-
查看全部评分
|