找回密码
 立即注册
楼主: 强子

[脚本] 在服务器获取到了客户端的ip地址列表代码

[复制链接]
发表于 2013-3-5 08:37 | 显示全部楼层 |阅读模式
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Data;
  4. using Mono.Data.SqliteClient;

  5. public class test : MonoBehaviour {
  6.         
  7.         // Use this for initialization
  8.         void Start () {
  9.         
  10.         }
  11.         void OnGUI()
  12.         {
  13.                 OpenDB();
  14.         }
  15.         public void OpenDB()
  16.         {
  17.         string connection= "URI=file:play.db";
  18.         IDbConnection dbcon = (IDbConnection) new SqliteConnection(connection);
  19.         IDataReader reader;
  20.                 dbcon.Open();
  21.                 IDbCommand dbcmd = dbcon.CreateCommand();
  22.                 string strsql = "select name,ip " + " from players";
  23.                 dbcmd.CommandText = strsql;
  24.                 reader = dbcmd.ExecuteReader();
  25.                 while(reader.Read()){
  26.                         string name = reader.GetString(0);
  27.                         string ip = reader.GetString(1);
  28.                         GUILayout.Label(name);
  29.                         GUILayout.Label(ip);
  30.                 }
  31.                 reader.Close();
  32.                 reader = null;
  33.                 dbcmd.Dispose();
  34.                 dbcmd = null;
  35.                 dbcon.Close();
  36.                 dbcon = null;
  37.         }
  38.         // Update is called once per frame
  39.         void Update () {
  40.         
  41.         }
  42. }
复制代码
发表于 2013-4-6 21:17 | 显示全部楼层
{:5_424:}{:5_424:}{:5_424:}{:5_424:}
发表于 2013-6-3 23:00 | 显示全部楼层
{:soso__3669389859068460655_3:}知道自己发的是什么吗??
发表于 2017-4-16 08:41 | 显示全部楼层
很不错
发表于 2017-4-16 08:49 | 显示全部楼层
楼主是超人
发表于 2017-4-16 08:58 | 显示全部楼层
真心顶
发表于 2017-4-16 08:25 | 显示全部楼层
说的非常好
发表于 2017-4-16 08:22 | 显示全部楼层
很好哦
发表于 2017-5-1 19:15 | 显示全部楼层
很不错
发表于 2017-5-1 19:19 | 显示全部楼层
好帖就是要顶
懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Unity开发者联盟 ( 粤ICP备20003399号 )

GMT+8, 2024-5-3 21:11 , Processed in 0.101538 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表