private void Unload() { if (_mySqlConnection != null) { _mySqlConnection = null; } }
private void OnServerInitialized() { // Open a connection with the database _mySqlConnection = _mySql.OpenDb(Config["DatabaseHostName"].ToString(), int.Parse(Config["DatabasePort"].ToString()), "onrust1_economy", Config["DatabaseUsername"].ToString(), Config["DatabasePassword"].ToString(), this); // Queries the database every X seconds and updates the local data file accordingly timer.Repeat(float.Parse(Config["UpdateDataTimer"].ToString()), 0, () => { UpdateDataFile(); }); }
private void StartConnection() { if (usingMySQL() && _mySqlConnection == null) { _mySqlConnection = _mySql.OpenDb( Address, Port, dbName, User, Password, this); Puts("Connection opened.(MySQL)"); } }
public static void setupDatabase(RustPlugin plugin) { sqlConnection = sqlite.OpenDb($"Plagued.db", plugin); var sql = new Oxide.Core.Database.Sql(); sql.Append(@"CREATE TABLE IF NOT EXISTS players ( id INTEGER PRIMARY KEY AUTOINCREMENT, user_id TEXT UNIQUE NOT NULL, name TEXT, plague_level INTEGER, kin_changes_count INTEGER, pristine INTEGER );"); sql.Append(@"CREATE TABLE IF NOT EXISTS associations ( id INTEGER PRIMARY KEY AUTOINCREMENT, player_id integer NOT NULL, associate_id integer NOT NULL, level INTEGER, FOREIGN KEY (player_id) REFERENCES players(id), FOREIGN KEY (associate_id) REFERENCES players(id) );"); sql.Append(@"CREATE TABLE IF NOT EXISTS kin ( self_id integer NOT NULL, kin_id integer NOT NULL, timestamp DATETIME DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY (self_id) REFERENCES players(id), FOREIGN KEY (kin_id) REFERENCES players(id), PRIMARY KEY (self_id,kin_id) );"); sql.Append(@"CREATE TABLE IF NOT EXISTS kin_request ( requester_id integer NOT NULL, target_id integer NOT NULL, timestamp DATETIME DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY (requester_id) REFERENCES players(id), FOREIGN KEY (target_id) REFERENCES players(id), PRIMARY KEY (requester_id,target_id) );"); sqlite.Insert(sql, sqlConnection); }
private void OnServerInitialized() { _mySqlConnection = _mySql.OpenDb(Config["host"].ToString(), Convert.ToInt32(Config["port"]), Config["database"].ToString(), Config["username"].ToString(), Config["password"].ToString(), this); var sql = Core.Database.Sql.Builder.Append(CreateQuery); _mySql.Insert(sql, _mySqlConnection); sql = Core.Database.Sql.Builder.Append(SelectData); _mySql.Query(sql, _mySqlConnection, list => { if (list.Count > 0) { foreach (var entry in list) { whitelistedPlayers.Add(entry["steamid"].ToString()); } } PrintWarning("Updated whitelisted users list, checking if players are whitelisted"); }); }