K4-Arenas
K4-Arenas copied to clipboard
[FEATURE] Get player weapon preferences using API
If possible it would be very helpful for people who make custom rounds to gather information about player weapon preferences using API instead creating a new database connection and query.
I created something like this and it works fine but maybe there is a other, better way to do so:
public Dictionary<string, CsItem?> GetPlayerWeaponPreferences(CCSPlayerController player)
{
var arenaPlayer = plugin.Arenas?.FindPlayer(player);
if (arenaPlayer == null)
{
return new Dictionary<string, CsItem?>();
}
var playerWeapons = new Dictionary<string, CsItem?>()
{
{ "Rifle", arenaPlayer.WeaponPreferences[WeaponType.Rifle] },
{ "Sniper", arenaPlayer.WeaponPreferences[WeaponType.Sniper] },
{ "SMG", arenaPlayer.WeaponPreferences[WeaponType.SMG] },
{ "LMG", arenaPlayer.WeaponPreferences[WeaponType.LMG] },
{ "Shotgun", arenaPlayer.WeaponPreferences[WeaponType.Shotgun] },
{ "Pistol", arenaPlayer.WeaponPreferences[WeaponType.Pistol] },
};
return playerWeapons;
}