mirror of
https://github.com/Nereziel/cs2-WeaponPaints.git
synced 2026-03-01 22:02:11 +00:00
1.8c
- Better gloves operations - Changed gloves table
This commit is contained in:
@@ -88,16 +88,16 @@ namespace WeaponPaints
|
||||
await using var connection = await _database.GetConnectionAsync();
|
||||
|
||||
// Construct the SQL query with specific columns for better performance
|
||||
string query = "SELECT `weapon_defindex`, `paint` FROM `wp_player_gloves` WHERE `steamid` = @steamid";
|
||||
string query = "SELECT `weapon_defindex` FROM `wp_player_gloves` WHERE `steamid` = @steamid";
|
||||
|
||||
// Execute the query and retrieve glove data
|
||||
var gloveData = await connection.QueryFirstOrDefaultAsync<(ushort Definition, int Paint)>(query, new { steamid = player.SteamId });
|
||||
ushort? gloveData = await connection.QueryFirstOrDefaultAsync<ushort?>(query, new { steamid = player.SteamId });
|
||||
|
||||
// Check if glove data is retrieved successfully
|
||||
if (gloveData != default)
|
||||
if (gloveData != null)
|
||||
{
|
||||
// Update g_playersGlove dictionary with glove data
|
||||
WeaponPaints.g_playersGlove[(uint)player.Index] = gloveData;
|
||||
WeaponPaints.g_playersGlove[(uint)player.Index] = gloveData.Value;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -212,15 +212,15 @@ namespace WeaponPaints
|
||||
}
|
||||
}
|
||||
|
||||
internal async Task SyncGloveToDatabase(PlayerInfo player, ushort defindex, int paint)
|
||||
internal async Task SyncGloveToDatabase(PlayerInfo player, ushort defindex)
|
||||
{
|
||||
if (!_config.Additional.GloveEnabled) return;
|
||||
|
||||
try
|
||||
{
|
||||
await using var connection = await _database.GetConnectionAsync();
|
||||
string query = "INSERT INTO `wp_player_gloves` (`steamid`, `weapon_defindex`, `paint`) VALUES(@steamid, @weapon_defindex, @paint) ON DUPLICATE KEY UPDATE `weapon_defindex` = @weapon_defindex, `paint` = @paint";
|
||||
await connection.ExecuteAsync(query, new { steamid = player.SteamId, weapon_defindex = defindex, paint });
|
||||
string query = "INSERT INTO `wp_player_gloves` (`steamid`, `weapon_defindex`) VALUES(@steamid, @weapon_defindex, @paint) ON DUPLICATE KEY UPDATE `weapon_defindex` = @weapon_defindex";
|
||||
await connection.ExecuteAsync(query, new { steamid = player.SteamId, weapon_defindex = defindex });
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user