mirror of
https://github.com/Nereziel/cs2-WeaponPaints.git
synced 2026-02-18 10:43:22 +00:00
Update WeaponPaints.cs
Creating tables fix
This commit is contained in:
@@ -127,29 +127,29 @@ public class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig>
|
||||
CheckDatabaseTables();
|
||||
}
|
||||
|
||||
private void CheckDatabaseTables()
|
||||
async private void CheckDatabaseTables()
|
||||
{
|
||||
try
|
||||
{
|
||||
using var connection = new MySqlConnection(DatabaseConnectionString);
|
||||
connection.OpenAsync();
|
||||
using var connection = new MySqlConnection(DatabaseConnectionString);
|
||||
await connection.OpenAsync();
|
||||
|
||||
using var transaction = connection.BeginTransaction();
|
||||
using var transaction = await connection.BeginTransactionAsync();
|
||||
|
||||
try
|
||||
{
|
||||
string createTable1 = "CREATE TABLE IF NOT EXISTS `wp_player_skins` (`steamid` varchar(64) NOT NULL, `weapon_defindex` int(6) NOT NULL, `weapon_paint_id` int(6) NOT NULL, `weapon_wear` float NOT NULL DEFAULT 0.0001, `weapon_seed` int(16) NOT NULL DEFAULT 0) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;";
|
||||
string createTable2 = "CREATE TABLE IF NOT EXISTS `wp_player_knife` (`steamid` varchar(64) NOT NULL, `knife` varchar(64) NOT NULL, UNIQUE (`steamid`)) ENGINE = InnoDB;";
|
||||
string createTable1 = "CREATE TABLE IF NOT EXISTS `wp_player_skins` (`steamid` varchar(64) NOT NULL, `weapon_defindex` int(6) NOT NULL, `weapon_paint_id` int(6) NOT NULL, `weapon_wear` float NOT NULL DEFAULT 0.0001, `weapon_seed` int(16) NOT NULL DEFAULT 0) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci";
|
||||
string createTable2 = "CREATE TABLE IF NOT EXISTS `wp_player_knife` (`steamid` varchar(64) NOT NULL, `knife` varchar(64) NOT NULL, UNIQUE (`steamid`)) ENGINE = InnoDB";
|
||||
|
||||
connection.ExecuteAsync(createTable1);
|
||||
connection.ExecuteAsync(createTable2);
|
||||
await connection.ExecuteAsync(createTable1, transaction: transaction);
|
||||
await connection.ExecuteAsync(createTable2, transaction: transaction);
|
||||
|
||||
transaction.Commit();
|
||||
await transaction.CommitAsync();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
transaction.RollbackAsync();
|
||||
throw new Exception("Unable to create tables!");
|
||||
await transaction.RollbackAsync();
|
||||
throw new Exception("Unable to create tables!");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
Reference in New Issue
Block a user