Compare commits

...

4 Commits

Author SHA1 Message Date
Nereziel
0f6bb26ac9 Merge pull request #76 from daffyyyy/some-changes
Improved player index
2023-11-30 10:34:07 +01:00
daffyyyy
be51e4d1e9 Improved player index
The latest version of cssharp adds player.Index instead of entityIndex and does not allow to compile
2023-11-30 02:20:16 +01:00
Nereziel
0d521e0cd3 Merge pull request #75 from daffyyyy/some-changes
Some fixes
2023-11-29 20:45:16 +01:00
daffyyyy
00f920713d Some fixes 2023-11-29 19:39:56 +01:00
7 changed files with 118 additions and 104 deletions

View File

@@ -16,14 +16,14 @@ namespace WeaponPaints
});
AddCommand($"css_{Config.Additional.CommandRefresh}", "Skins refresh", (player, info) =>
{
if (!Utility.IsPlayerValid(player)) return;
if (!Utility.IsPlayerValid(player) || !g_bCommandsAllowed) return;
OnCommandRefresh(player, info);
});
if (Config.Additional.CommandKillEnabled)
{
AddCommand($"css_{Config.Additional.CommandKill}", "kill yourself", (player, info) =>
{
if (!Utility.IsPlayerValid(player) || !player!.PlayerPawn.IsValid) return;
if (player == null || !Utility.IsPlayerValid(player) || player.PlayerPawn.Value == null || !player!.PlayerPawn.IsValid) return;
player.PlayerPawn.Value.CommitSuicide(true, false);
});
@@ -31,7 +31,7 @@ namespace WeaponPaints
}
private void SetupKnifeMenu()
{
if (!Config.Additional.KnifeEnabled) return;
if (!Config.Additional.KnifeEnabled || !g_bCommandsAllowed) return;
var knivesOnly = weaponList
.Where(pair => pair.Key.StartsWith("weapon_knife") || pair.Key.StartsWith("weapon_bayonet"))
@@ -60,22 +60,20 @@ namespace WeaponPaints
player!.PrintToChat(Utility.ReplaceTags(temp));
}
g_playersKnife[(int)player!.EntityIndex!.Value.Value] = knifeKey;
g_playersKnife[(int)player!.Index] = knifeKey;
if (player!.PawnIsAlive)
if (player!.PawnIsAlive && g_bCommandsAllowed)
{
g_changedKnife.Add((int)player.EntityIndex!.Value.Value);
if (PlayerHasKnife(player))
{
RefreshPlayerKnife(player);
}
//g_changedKnife.Add((int)player.Index);
RefreshWeapons(player);
//RefreshPlayerKnife(player);
/*
AddTimer(1.0f, () => GiveKnifeToPlayer(player));
*/
}
if (weaponSync != null)
Task.Run(() => weaponSync.SyncKnifeToDatabase((int)player.EntityIndex!.Value.Value, knifeKey));
Task.Run(() => weaponSync.SyncKnifeToDatabase((int)player.Index, knifeKey));
}
}
};
@@ -85,8 +83,8 @@ namespace WeaponPaints
}
AddCommand($"css_{Config.Additional.CommandKnife}", "Knife Menu", (player, info) =>
{
if (!Utility.IsPlayerValid(player)) return;
int playerIndex = (int)player!.EntityIndex!.Value.Value;
if (!Utility.IsPlayerValid(player) || !g_bCommandsAllowed) return;
int playerIndex = (int)player!.Index;
if (commandCooldown != null && DateTime.UtcNow >= commandCooldown[playerIndex].AddSeconds(Config.CmdRefreshCooldownSeconds) && playerIndex > 0 && playerIndex < commandCooldown.Length)
{
@@ -112,7 +110,7 @@ namespace WeaponPaints
{
if (!Utility.IsPlayerValid(player)) return;
int playerIndex = (int)player!.EntityIndex!.Value.Value;
int playerIndex = (int)player!.Index;
string selectedWeapon = option.Text;
if (classNamesByWeapon.TryGetValue(selectedWeapon, out string? selectedWeaponClassname))
{
@@ -128,9 +126,11 @@ namespace WeaponPaints
// Function to handle skin selection for the chosen weapon
var handleSkinSelection = (CCSPlayerController? p, ChatMenuOption opt) =>
{
if (p == null || !p.IsValid) return;
if (p == null || !p.IsValid || p.Index <= 0) return;
var steamId = new SteamID(player.SteamID);
playerIndex = (int)p.Index;
var steamId = new SteamID(p.SteamID);
var firstSkin = skinsList?.FirstOrDefault(skin =>
{
if (skin != null && skin.TryGetValue("weapon_name", out var weaponName))
@@ -151,23 +151,24 @@ namespace WeaponPaints
string temp = $" {Config.Prefix} {Config.Messages.ChosenSkinMenu}".Replace("{SKIN}", selectedSkin);
p.PrintToChat(Utility.ReplaceTags(temp));
/*
if (!gPlayerWeaponsInfo[playerIndex].ContainsKey(weaponDefIndex))
{
gPlayerWeaponsInfo[playerIndex][weaponDefIndex] = new WeaponInfo();
}
*/
gPlayerWeaponsInfo[playerIndex][weaponDefIndex].Paint = paintID;
gPlayerWeaponsInfo[playerIndex][weaponDefIndex].Wear = 0.0f;
gPlayerWeaponsInfo[playerIndex][weaponDefIndex].Seed = 0;
if (!Config.GlobalShare)
{
if (weaponSync == null) return;
Task.Run(async () =>
{
await weaponSync.SyncWeaponPaintsToDatabase(player);
await weaponSync.SyncWeaponPaintsToDatabase(p);
});
}
}
};
// Add skin options to the submenu for the selected weapon
@@ -203,7 +204,7 @@ namespace WeaponPaints
AddCommand($"css_{Config.Additional.CommandSkinSelection}", "Skins selection menu", (player, info) =>
{
if (!Utility.IsPlayerValid(player)) return;
int playerIndex = (int)player!.EntityIndex!.Value.Value;
int playerIndex = (int)player!.Index;
if (commandCooldown != null && DateTime.UtcNow >= commandCooldown[playerIndex].AddSeconds(Config.CmdRefreshCooldownSeconds) && playerIndex > 0 && playerIndex < commandCooldown.Length)
{
@@ -222,11 +223,11 @@ namespace WeaponPaints
private void OnCommandRefresh(CCSPlayerController? player, CommandInfo command)
{
if (!Config.Additional.CommandWpEnabled || !Config.Additional.SkinEnabled) return;
if (!Config.Additional.CommandWpEnabled || !Config.Additional.SkinEnabled || !g_bCommandsAllowed) return;
if (!Utility.IsPlayerValid(player)) return;
string temp = "";
if (!player!.EntityIndex.HasValue) return;
int playerIndex = (int)player!.EntityIndex!.Value.Value;
if (player == null || player.Index <= 0) return;
int playerIndex = (int)player!.Index;
if (playerIndex != 0 && DateTime.UtcNow >= commandCooldown[playerIndex].AddSeconds(Config.CmdRefreshCooldownSeconds))
{
commandCooldown[playerIndex] = DateTime.UtcNow;

View File

@@ -15,6 +15,7 @@ namespace WeaponPaints
//RegisterEventHandler<EventPlayerConnectFull>(OnPlayerConnectFull);
RegisterEventHandler<EventPlayerSpawn>(OnPlayerSpawn);
RegisterEventHandler<EventRoundStart>(OnRoundStart, HookMode.Pre);
RegisterEventHandler<EventRoundEnd>(OnRoundEnd);
RegisterEventHandler<EventItemPurchase>(OnEventItemPurchasePost);
RegisterEventHandler<EventItemPickup>(OnItemPickup);
}
@@ -66,7 +67,6 @@ namespace WeaponPaints
if (Config.Additional.KnifeEnabled && weaponSync != null)
_ = weaponSync.GetKnifeFromDatabase(playerIndex);
/*
Task.Run(async () =>
{
@@ -85,9 +85,9 @@ namespace WeaponPaints
if (player == null || !player.IsValid || player.IsHLTV) return;
if (Config.Additional.KnifeEnabled)
g_playersKnife.Remove((int)player.EntityIndex!.Value.Value);
g_playersKnife.Remove((int)player.Index);
if (Config.Additional.SkinEnabled)
gPlayerWeaponsInfo.Remove((int)player.EntityIndex!.Value.Value);
gPlayerWeaponsInfo.Remove((int)player.Index);
}
private HookResult OnPlayerSpawn(EventPlayerSpawn @event, GameEventInfo info)
@@ -100,7 +100,7 @@ namespace WeaponPaints
if (Config.Additional.KnifeEnabled)
{
g_knifePickupCount[(int)player.EntityIndex!.Value.Value] = 0;
g_knifePickupCount[(int)player.Index] = 0;
if (!PlayerHasKnife(player))
GiveKnifeToPlayer(player);
}
@@ -118,20 +118,29 @@ namespace WeaponPaints
NativeAPI.IssueServerCommand("mp_ct_default_melee \"\"");
NativeAPI.IssueServerCommand("mp_equipment_reset_rounds 0");
g_bCommandsAllowed = true;
return HookResult.Continue;
}
private HookResult OnRoundEnd(EventRoundEnd @event, GameEventInfo info)
{
g_bCommandsAllowed = false;
return HookResult.Continue;
}
private HookResult OnItemPickup(EventItemPickup @event, GameEventInfo info)
{
if (@event.Defindex == 42 || @event.Defindex == 59)
{
CCSPlayerController? player = @event.Userid;
if (!Utility.IsPlayerValid(player) || !player.PawnIsAlive || g_knifePickupCount[(int)player.EntityIndex!.Value.Value] >= 2) return HookResult.Continue;
if (!Utility.IsPlayerValid(player) || !player.PawnIsAlive || g_knifePickupCount[(int)player.Index] >= 2) return HookResult.Continue;
if (g_playersKnife.ContainsKey((int)player.EntityIndex!.Value.Value)
if (g_playersKnife.ContainsKey((int)player.Index)
&&
g_playersKnife[(int)player.EntityIndex!.Value.Value] != "weapon_knife")
g_playersKnife[(int)player.Index] != "weapon_knife")
{
g_knifePickupCount[(int)player.EntityIndex!.Value.Value]++;
g_knifePickupCount[(int)player.Index]++;
RemovePlayerKnife(player, true);
AddTimer(0.3f, ()=> GiveKnifeToPlayer(player));
@@ -167,29 +176,32 @@ namespace WeaponPaints
{
try
{
if (!weapon.IsValid) return;
if (weapon.OwnerEntity.Value == null) return;
if (!weapon.OwnerEntity.Value.EntityIndex.HasValue)
/*
if (weapon.OwnerEntity.Index > 0)
{
for (int i = 1; i <= Server.MaxPlayers; i++)
{
CCSPlayerController? ghostPlayer = Utilities.GetPlayerFromIndex(i);
if (!Utility.IsPlayerValid(ghostPlayer)) continue;
if (g_changedKnife.Contains((int)ghostPlayer.EntityIndex!.Value.Value))
if (g_changedKnife.Contains((int)ghostPlayer.Index))
{
ChangeWeaponAttributes(weapon, ghostPlayer, isKnife);
g_changedKnife.Remove((int)ghostPlayer.EntityIndex!.Value.Value);
g_changedKnife.Remove((int)ghostPlayer.Index);
break;
}
}
return;
}
if (!weapon.OwnerEntity.Value.EntityIndex.HasValue) return;
int weaponOwner = (int)weapon.OwnerEntity.Value.EntityIndex.Value.Value;
}
*/
if (weapon.OwnerEntity.Index <= 0) return;
int weaponOwner = (int)weapon.OwnerEntity.Index;
var pawn = new CBasePlayerPawn(NativeAPI.GetEntityFromIndex(weaponOwner));
if (!pawn.IsValid) return;
var playerIndex = (int)pawn.Controller.Value.EntityIndex!.Value.Value;
var playerIndex = (int)pawn.Controller.Index;
var player = Utilities.GetPlayerFromIndex(playerIndex);
if (!Utility.IsPlayerValid(player)) return;

View File

@@ -19,7 +19,7 @@ namespace WeaponPaints
internal static string BuildDatabaseConnectionString()
{
if (Config == null) return String.Empty;
if (Config == null) return string.Empty;
var builder = new MySqlConnectionStringBuilder
{
Server = Config.DatabaseHost,

View File

@@ -9,9 +9,9 @@ namespace WeaponPaints
{
internal static void ChangeWeaponAttributes(CBasePlayerWeapon? weapon, CCSPlayerController? player, bool isKnife = false)
{
if (weapon == null || !weapon.IsValid || !Utility.IsPlayerValid(player)) return;
if (player == null || weapon == null || !weapon.IsValid || !Utility.IsPlayerValid(player)) return;
int playerIndex = (int)player!.EntityIndex!.Value.Value;
int playerIndex = (int)player.Index;
if (!gPlayerWeaponsInfo.ContainsKey(playerIndex)) return;
@@ -55,7 +55,7 @@ namespace WeaponPaints
internal static void GiveKnifeToPlayer(CCSPlayerController? player)
{
if (!_config.Additional.KnifeEnabled || player == null || !player.IsValid) return;
if (g_playersKnife.TryGetValue((int)player.EntityIndex!.Value.Value, out var knife))
if (g_playersKnife.TryGetValue((int)player.Index, out var knife))
{
player.GiveNamedItem(knife);
}
@@ -77,7 +77,7 @@ namespace WeaponPaints
}
internal void RemovePlayerKnife(CCSPlayerController? player, bool force = false)
{
if (player == null || !player.IsValid || !player.PawnIsAlive) return;
if (player == null || !player.IsValid || player.PlayerPawn.Value == null || !player.PawnIsAlive) return;
if (player.PlayerPawn.Value.WeaponServices == null || player.PlayerPawn.Value.ItemServices == null) return;
var weapons = player.PlayerPawn.Value.WeaponServices.MyWeapons;
@@ -88,16 +88,16 @@ namespace WeaponPaints
foreach (var weapon in weapons)
{
if (weapon != null && weapon.IsValid && weapon.Value.IsValid)
if (weapon != null && weapon.IsValid && weapon.Value != null && weapon.Value.IsValid)
{
//if (weapon.Value.AttributeManager.Item.ItemDefinitionIndex == 42 || weapon.Value.AttributeManager.Item.ItemDefinitionIndex == 59)
if (weapon.Value.DesignerName.Contains("knife") || weapon.Value.DesignerName.Contains("bayonet"))
{
if (!force)
{
if (!weapon.Value.EntityIndex.HasValue) return;
int weaponEntityIndex = (int)weapon.Value.EntityIndex!.Value.Value;
NativeAPI.IssueClientCommand((int)player.EntityIndex!.Value.Value - 1, "slot3");
if ((int)weapon.Index <= 0) return;
int weaponEntityIndex = (int)weapon.Index;
NativeAPI.IssueClientCommand((int)player.Index - 1, "slot3");
AddTimer(0.35f, () => service.DropActivePlayerWeapon(weapon.Value));
AddTimer(1.0f, () =>
@@ -123,35 +123,35 @@ namespace WeaponPaints
internal void RefreshPlayerKnife(CCSPlayerController? player)
{
if (player == null || !player.IsValid || !player.PawnIsAlive) return;
if (player == null || !player.IsValid || player.PlayerPawn.Value == null || !player.PawnIsAlive) return;
if (player.PlayerPawn.Value.WeaponServices == null || player.PlayerPawn.Value.ItemServices == null) return;
var weapons = player.PlayerPawn.Value.WeaponServices.MyWeapons;
if (weapons != null && weapons.Count > 0)
{
CCSPlayer_ItemServices service = new CCSPlayer_ItemServices(player.PlayerPawn.Value.ItemServices.Handle);
CCSPlayer_ItemServices service = new(player.PlayerPawn.Value.ItemServices.Handle);
//var dropWeapon = VirtualFunction.CreateVoid<nint, nint>(service.Handle, GameData.GetOffset("CCSPlayer_ItemServices_DropActivePlayerWeapon"));
foreach (var weapon in weapons)
{
if (weapon != null && weapon.IsValid && weapon.Value.IsValid)
if (weapon != null && weapon.IsValid && weapon.Value != null && weapon.Value.IsValid)
{
//if (weapon.Value.AttributeManager.Item.ItemDefinitionIndex == 42 || weapon.Value.AttributeManager.Item.ItemDefinitionIndex == 59)
if (weapon.Value.DesignerName.Contains("knife") || weapon.Value.DesignerName.Contains("bayonet"))
{
if (!weapon.Value.EntityIndex.HasValue) return;
int weaponEntityIndex = (int)weapon.Value.EntityIndex!.Value.Value;
NativeAPI.IssueClientCommand((int)player.EntityIndex!.Value.Value - 1, "slot3");
if (weapon.Index <= 0) return;
int weaponEntityIndex = (int)weapon.Index;
NativeAPI.IssueClientCommand((int)player.Index - 1, "slot3");
AddTimer(0.22f, () =>
{
if (player.PlayerPawn.Value.WeaponServices.ActiveWeapon.Value.DesignerName.Contains("knife")
if (player.PlayerPawn.Value.WeaponServices.ActiveWeapon.Value!.DesignerName.Contains("knife")
||
player.PlayerPawn.Value.WeaponServices.ActiveWeapon.Value.DesignerName.Contains("bayonet")
player.PlayerPawn.Value.WeaponServices.ActiveWeapon.Value!.DesignerName.Contains("bayonet")
)
{
if (player.PawnIsAlive)
{
NativeAPI.IssueClientCommand((int)player.EntityIndex!.Value.Value - 1, "slot3");
NativeAPI.IssueClientCommand((int)player.Index - 1, "slot3");
service.DropActivePlayerWeapon(weapon.Value);
GiveKnifeToPlayer(player);
}
@@ -164,7 +164,7 @@ namespace WeaponPaints
{
CEntityInstance? knife = Utilities.GetEntityFromIndex<CEntityInstance>(weaponEntityIndex);
if (knife != null && knife.IsValid && knife.Handle != -1 && knife.EntityIndex.HasValue)
if (knife != null && knife.IsValid && knife.Handle != -1 && knife.Index > 0)
{
knife.Remove();
}
@@ -183,28 +183,30 @@ namespace WeaponPaints
{
if (!Utility.IsPlayerValid(player) || !player!.PawnIsAlive) return;
AddTimer(0.18f, () => NativeAPI.IssueClientCommand((int)player.EntityIndex!.Value.Value - 1, "slot3"));
AddTimer(0.25f, () => NativeAPI.IssueClientCommand((int)player.EntityIndex!.Value.Value - 1, "slot2"));
AddTimer(0.38f, () => NativeAPI.IssueClientCommand((int)player.EntityIndex!.Value.Value - 1, "slot1"));
AddTimer(0.18f, () => NativeAPI.IssueClientCommand((int)player.Index - 1, "slot3"));
AddTimer(0.25f, () => NativeAPI.IssueClientCommand((int)player.Index - 1, "slot2"));
AddTimer(0.38f, () => NativeAPI.IssueClientCommand((int)player.Index - 1, "slot1"));
}
internal void RefreshWeapons(CCSPlayerController? player)
{
if (player == null || !player.IsValid || !player.PawnIsAlive) return;
if (player == null || !player.IsValid || player.PlayerPawn.Value == null || !player.PawnIsAlive) return;
if (player.PlayerPawn.Value.WeaponServices == null || player.PlayerPawn.Value.ItemServices == null) return;
var weapons = player.PlayerPawn.Value.WeaponServices.MyWeapons;
if (weapons != null && weapons.Count > 0)
{
CCSPlayer_ItemServices service = new CCSPlayer_ItemServices(player.PlayerPawn.Value.ItemServices.Handle);
CCSPlayer_ItemServices service = new(player.PlayerPawn.Value.ItemServices.Handle);
//var dropWeapon = VirtualFunction.CreateVoid<nint, nint>(service.Handle, GameData.GetOffset("CCSPlayer_ItemServices_DropActivePlayerWeapon"));
foreach (var weapon in weapons)
{
if (weapon != null && weapon.IsValid && weapon.Value.IsValid)
if (weapon != null && weapon.IsValid && weapon.Value != null && weapon.Value.IsValid)
{
if (!weapon.Value.EntityIndex.HasValue || !weapon.Value.DesignerName.Contains("weapon_")) continue;
if (weapon.Index <= 0 || !weapon.Value.DesignerName.Contains("weapon_")) continue;
//if (weapon.Value.AttributeManager.Item.ItemDefinitionIndex == 42 || weapon.Value.AttributeManager.Item.ItemDefinitionIndex == 59)
try
{
if (weapon.Value.DesignerName.Contains("knife") || weapon.Value.DesignerName.Contains("bayonet"))
{
weapon.Value.Remove();
@@ -218,17 +220,22 @@ namespace WeaponPaints
reservedAmmo = weapon.Value.ReserveAmmo[0];
weapon.Value.Remove();
CBasePlayerWeapon newWeapon = new CBasePlayerWeapon(player.GiveNamedItem(weapon.Value.DesignerName));
CBasePlayerWeapon newWeapon = new(player.GiveNamedItem(weapon.Value.DesignerName));
Server.NextFrame(() =>
{
newWeapon.Clip1 = clip1;
newWeapon.ReserveAmmo[0] = reservedAmmo;
});
}
} catch(Exception ex)
{
Console.WriteLine("[WeaponPaints] Refreshing weapons exception");
Console.WriteLine(ex.Message);
}
}
}
if (Config.Additional.SkinVisibilityFix)
RefreshSkins(player);
}
}
@@ -242,14 +249,14 @@ namespace WeaponPaints
return false;
}
if (player.PlayerPawn.Value.WeaponServices == null || player.PlayerPawn.Value.ItemServices == null)
if (player.PlayerPawn.Value == null || player.PlayerPawn.Value.WeaponServices == null || player.PlayerPawn.Value.ItemServices == null)
return false;
var weapons = player.PlayerPawn.Value.WeaponServices.MyWeapons;
if (weapons == null || weapons.Count <= 0) return false;
foreach (var weapon in weapons)
{
if (weapon != null && weapon.IsValid && weapon.Value.IsValid)
if (weapon != null && weapon.IsValid && weapon.Value != null && weapon.Value.IsValid)
{
if (weapon.Value.DesignerName.Contains("knife") || weapon.Value.DesignerName.Contains("bayonet"))
{
@@ -273,7 +280,7 @@ namespace WeaponPaints
if (WeaponPaints.skinsList != null)
{
// Filter weapons by the provided defindex
var filteredWeapons = WeaponPaints.skinsList.FindAll(w => w["weapon_defindex"]?.ToString() == defindex.ToString());
var filteredWeapons = skinsList.FindAll(w => w["weapon_defindex"]?.ToString() == defindex.ToString());
if (filteredWeapons.Count > 0)
{

View File

@@ -5,7 +5,7 @@ using CounterStrikeSharp.API.Modules.Cvars;
using Newtonsoft.Json.Linq;
namespace WeaponPaints;
[MinimumApiVersion(71)]
[MinimumApiVersion(82)]
public partial class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig>
{
public override string ModuleName => "WeaponPaints";
@@ -31,7 +31,8 @@ public partial class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig
internal static Dictionary<int, Dictionary<int, WeaponInfo>> gPlayerWeaponsInfo = new Dictionary<int, Dictionary<int, WeaponInfo>>();
internal static Dictionary<int, int> g_knifePickupCount = new Dictionary<int, int>();
internal static Dictionary<int, string> g_playersKnife = new();
internal static List<int> g_changedKnife = new();
//internal static List<int> g_changedKnife = new();
internal bool g_bCommandsAllowed = true;
internal static List<JObject> skinsList = new List<JObject>();
internal static readonly Dictionary<string, string> weaponList = new()

View File

@@ -8,16 +8,9 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.80" />
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.84" />
<PackageReference Include="Dapper" Version="2.1.24" />
<PackageReference Include="MySqlConnector" Version="2.3.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
<ItemGroup>
<Reference Include="CounterStrikeSharp.API">
<HintPath>deps\CounterStrikeSharp.API.dll</HintPath>
</Reference>
</ItemGroup>
</Project>

View File

@@ -229,9 +229,9 @@ namespace WeaponPaints
internal async Task SyncWeaponPaintsToDatabase(CCSPlayerController? player)
{
if (!Utility.IsPlayerValid(player)) return;
if (player == null || !Utility.IsPlayerValid(player)) return;
int playerIndex = (int)player!.EntityIndex!.Value.Value;
int playerIndex = (int)player.Index;
string steamId = new SteamID(player.SteamID).SteamId64.ToString();
using var connection = new MySqlConnection(_databaseConnectionString);