object GetPlayerData(string userid, string key) { if (key == "name") { return(GetName(userid)); } if (useSQLITE) { string query = string.Format("SELECT {2} FROM {0} WHERE steamid = {1} LIMIT 1", "playerdatabase", userid, key); sqlite.Append(query); IEnumerable <Dictionary <string, object> > res = Interface.Oxide.GetLibrary <Ext.SQLite.Libraries.SQLite>("SQLite").Query(sqlite, sqconnection); foreach (Dictionary <string, object> obj in res) { foreach (object value in obj.Values) { return(value.ToString()); } } } else if (useMysql) { string query = string.Format("SELECT {2} FROM `{0}` WHERE `steamid` = '{1}' LIMIT 1", mysqlTable, userid, key); sql = Interface.Oxide.GetLibrary <Ext.MySql.Libraries.MySql>("MySql").NewSql(); sql.Append(query); IEnumerable <Dictionary <string, object> > res = Interface.Oxide.GetLibrary <Ext.MySql.Libraries.MySql>("MySql").Query(sql, connection); foreach (Dictionary <string, object> obj in res) { foreach (object value in obj.Values) { return(value.ToString()); } } } else { if (Data[userid] == null) { return(null); } if (!((Dictionary <string, object>)Data[userid]).ContainsKey(key)) { return(null); } return(((Dictionary <string, object>)Data[userid])[key]); } return(null); }
public Sql On(string onClause, params object[] args) { return(_sql.Append("ON " + onClause, args)); }
void Loaded() { if (!permission.PermissionExists("admin")) { permission.RegisterPermission("admin", this); } LoadData(); if (useSQLITE) { sqconnection = Interface.Oxide.GetLibrary <Ext.SQLite.Libraries.SQLite>("SQLite").OpenDb("PlayerDatabaseSQL"); sqlite = Interface.Oxide.GetLibrary <Ext.SQLite.Libraries.SQLite>("SQLite").NewSql(); sqlite.Append("create table if not exists playerdatabase (name text, steamid text)"); Interface.Oxide.GetLibrary <Ext.SQLite.Libraries.SQLite>("SQLite").Query(sqlite, sqconnection); sqlite.Append("PRAGMA encoding = 'UTF - 8'"); Interface.Oxide.GetLibrary <Ext.SQLite.Libraries.SQLite>("SQLite").Query(sqlite, sqconnection); sqlite.Append("SELECT steamid FROM playerdatabase"); IEnumerable <Dictionary <string, object> > res = Interface.Oxide.GetLibrary <Ext.SQLite.Libraries.SQLite>("SQLite").Query(sqlite, sqconnection); foreach (Dictionary <string, object> obj in res) { foreach (object key in obj.Values) { AvaibleUserID.Add(key.ToString()); } } sqlite.Append("SELECT * FROM playerdatabase"); res = Interface.Oxide.GetLibrary <Ext.SQLite.Libraries.SQLite>("SQLite").Query(sqlite, sqconnection); foreach (Dictionary <string, object> obj in res) { Debug.Log(obj.ToString()); foreach (string key in obj.Keys) { AvaibleKeys.Add(key.ToString()); } break; } if (AvaibleKeys.Count == 0) { AvaibleKeys.Add("name"); AvaibleKeys.Add("steamid"); } } else if (useMysql) { connection = Interface.Oxide.GetLibrary <Ext.MySql.Libraries.MySql>("MySql").OpenDb(mysqlHost, mysqlPort, mysqlDatabase, mysqlUsername, mysqlPass); sql = Interface.Oxide.GetLibrary <Ext.MySql.Libraries.MySql>("MySql").NewSql(); sql.Append("SELECT steamid FROM `" + mysqlTable + "`"); IEnumerable <Dictionary <string, object> > res = Interface.Oxide.GetLibrary <Ext.MySql.Libraries.MySql>("MySql").Query(sql, connection); foreach (Dictionary <string, object> obj in res) { foreach (object key in obj.Values) { AvaibleUserID.Add(key.ToString()); } } sql = Interface.Oxide.GetLibrary <Ext.MySql.Libraries.MySql>("MySql").NewSql(); sql.Append("SELECT * FROM `" + mysqlTable + "`"); res = Interface.Oxide.GetLibrary <Ext.MySql.Libraries.MySql>("MySql").Query(sql, connection); foreach (Dictionary <string, object> obj in res) { foreach (string key in obj.Keys) { AvaibleKeys.Add(key.ToString()); } break; } if (AvaibleKeys.Count == 0) { AvaibleKeys.Add("name"); AvaibleKeys.Add("steamid"); } } }