mirror of
https://github.com/Nereziel/cs2-WeaponPaints.git
synced 2026-02-25 12:52:17 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3296055841 | ||
|
|
89de192c20 | ||
|
|
a1297b9cbe |
@@ -127,29 +127,29 @@ public class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig>
|
|||||||
CheckDatabaseTables();
|
CheckDatabaseTables();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CheckDatabaseTables()
|
async private void CheckDatabaseTables()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var connection = new MySqlConnection(DatabaseConnectionString);
|
using var connection = new MySqlConnection(DatabaseConnectionString);
|
||||||
connection.OpenAsync();
|
await connection.OpenAsync();
|
||||||
|
|
||||||
using var transaction = connection.BeginTransaction();
|
using var transaction = await connection.BeginTransactionAsync();
|
||||||
|
|
||||||
try
|
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 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 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);
|
await connection.ExecuteAsync(createTable1, transaction: transaction);
|
||||||
connection.ExecuteAsync(createTable2);
|
await connection.ExecuteAsync(createTable2, transaction: transaction);
|
||||||
|
|
||||||
transaction.Commit();
|
await transaction.CommitAsync();
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
transaction.RollbackAsync();
|
await transaction.RollbackAsync();
|
||||||
throw new Exception("Unable to create tables!");
|
throw new Exception("Unable to create tables!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -220,12 +220,12 @@ public override void Unload(bool hotReload)
|
|||||||
private void OnClientDisconnect(int playerSlot)
|
private void OnClientDisconnect(int playerSlot)
|
||||||
{
|
{
|
||||||
CCSPlayerController player = Utilities.GetPlayerFromSlot(playerSlot);
|
CCSPlayerController player = Utilities.GetPlayerFromSlot(playerSlot);
|
||||||
// TODO: Clean up after player
|
if (!player.IsValid || player.IsBot) return;
|
||||||
if (Config.Additional.KnifeEnabled)
|
|
||||||
g_playersKnife.Remove(playerSlot+1);
|
if (Config.Additional.KnifeEnabled)
|
||||||
if (Config.Additional.SkinEnabled)
|
g_playersKnife.Remove(playerSlot+1);
|
||||||
gPlayerWeaponPaints.Remove(new SteamID(player.SteamID).SteamId64);
|
if (Config.Additional.SkinEnabled)
|
||||||
|
gPlayerWeaponPaints.Remove(new SteamID(player.SteamID).SteamId64);
|
||||||
}
|
}
|
||||||
|
|
||||||
private HookResult OnPlayerSpawn(EventPlayerSpawn @event, GameEventInfo info)
|
private HookResult OnPlayerSpawn(EventPlayerSpawn @event, GameEventInfo info)
|
||||||
|
|||||||
Reference in New Issue
Block a user