mirror of
https://github.com/Nereziel/cs2-WeaponPaints.git
synced 2026-02-18 10:43:22 +00:00
2.9a
- Team based items
This commit is contained in:
187
Commands.cs
187
Commands.cs
@@ -1,7 +1,9 @@
|
|||||||
using CounterStrikeSharp.API.Core;
|
using System.Collections.Concurrent;
|
||||||
|
using CounterStrikeSharp.API.Core;
|
||||||
using CounterStrikeSharp.API.Modules.Commands;
|
using CounterStrikeSharp.API.Modules.Commands;
|
||||||
using CounterStrikeSharp.API.Modules.Menu;
|
using CounterStrikeSharp.API.Modules.Menu;
|
||||||
using CounterStrikeSharp.API.Modules.Timers;
|
using CounterStrikeSharp.API.Modules.Timers;
|
||||||
|
using CounterStrikeSharp.API.Modules.Utils;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
namespace WeaponPaints;
|
namespace WeaponPaints;
|
||||||
@@ -150,6 +152,11 @@ public partial class WeaponPaints
|
|||||||
{
|
{
|
||||||
if (!Utility.IsPlayerValid(player)) return;
|
if (!Utility.IsPlayerValid(player)) return;
|
||||||
|
|
||||||
|
var playerKnives = GPlayersKnife.GetOrAdd(player.Slot, new ConcurrentDictionary<CsTeam, string>());
|
||||||
|
var teamsToCheck = player.TeamNum < 2
|
||||||
|
? new[] { CsTeam.Terrorist, CsTeam.CounterTerrorist }
|
||||||
|
: [player.Team];
|
||||||
|
|
||||||
var knifeName = option.Text;
|
var knifeName = option.Text;
|
||||||
var knifeKey = knivesOnly.FirstOrDefault(x => x.Value == knifeName).Key;
|
var knifeKey = knivesOnly.FirstOrDefault(x => x.Value == knifeName).Key;
|
||||||
if (string.IsNullOrEmpty(knifeKey)) return;
|
if (string.IsNullOrEmpty(knifeKey)) return;
|
||||||
@@ -172,14 +179,18 @@ public partial class WeaponPaints
|
|||||||
Name = player.PlayerName,
|
Name = player.PlayerName,
|
||||||
IpAddress = player.IpAddress?.Split(":")[0]
|
IpAddress = player.IpAddress?.Split(":")[0]
|
||||||
};
|
};
|
||||||
|
|
||||||
GPlayersKnife[player.Slot] = knifeKey;
|
foreach (var team in teamsToCheck)
|
||||||
|
{
|
||||||
|
// Attempt to get the existing knives
|
||||||
|
playerKnives[team] = knifeKey;
|
||||||
|
}
|
||||||
|
|
||||||
if (_gBCommandsAllowed && (LifeState_t)player.LifeState == LifeState_t.LIFE_ALIVE)
|
if (_gBCommandsAllowed && (LifeState_t)player.LifeState == LifeState_t.LIFE_ALIVE)
|
||||||
RefreshWeapons(player);
|
RefreshWeapons(player);
|
||||||
|
|
||||||
if (WeaponSync != null)
|
if (WeaponSync != null)
|
||||||
_ = Task.Run(async () => await WeaponSync.SyncKnifeToDatabase(playerInfo, knifeKey));
|
_ = Task.Run(async () => await WeaponSync.SyncKnifeToDatabase(playerInfo, knifeKey, teamsToCheck));
|
||||||
};
|
};
|
||||||
foreach (var knifePair in knivesOnly)
|
foreach (var knifePair in knivesOnly)
|
||||||
{
|
{
|
||||||
@@ -229,7 +240,7 @@ public partial class WeaponPaints
|
|||||||
var selectedWeapon = option.Text;
|
var selectedWeapon = option.Text;
|
||||||
|
|
||||||
if (!classNamesByWeapon.TryGetValue(selectedWeapon, out var selectedWeaponClassname)) return;
|
if (!classNamesByWeapon.TryGetValue(selectedWeapon, out var selectedWeaponClassname)) return;
|
||||||
var skinsForSelectedWeapon = SkinsList?.Where(skin =>
|
var skinsForSelectedWeapon = SkinsList.Where(skin =>
|
||||||
skin.TryGetValue("weapon_name", out var weaponName) &&
|
skin.TryGetValue("weapon_name", out var weaponName) &&
|
||||||
weaponName?.ToString() == selectedWeaponClassname
|
weaponName?.ToString() == selectedWeaponClassname
|
||||||
)?.ToList();
|
)?.ToList();
|
||||||
@@ -241,8 +252,7 @@ public partial class WeaponPaints
|
|||||||
{
|
{
|
||||||
if (!Utility.IsPlayerValid(p)) return;
|
if (!Utility.IsPlayerValid(p)) return;
|
||||||
|
|
||||||
var steamId = p.SteamID.ToString();
|
var firstSkin = SkinsList.FirstOrDefault(skin =>
|
||||||
var firstSkin = SkinsList?.FirstOrDefault(skin =>
|
|
||||||
{
|
{
|
||||||
if (skin.TryGetValue("weapon_name", out var weaponName))
|
if (skin.TryGetValue("weapon_name", out var weaponName))
|
||||||
{
|
{
|
||||||
@@ -259,29 +269,38 @@ public partial class WeaponPaints
|
|||||||
!int.TryParse(weaponDefIndexObj.ToString(), out var weaponDefIndex) ||
|
!int.TryParse(weaponDefIndexObj.ToString(), out var weaponDefIndex) ||
|
||||||
!int.TryParse(selectedPaintId, out var paintId)) return;
|
!int.TryParse(selectedPaintId, out var paintId)) return;
|
||||||
{
|
{
|
||||||
if (Config.Additional.ShowSkinImage && SkinsList != null)
|
if (Config.Additional.ShowSkinImage)
|
||||||
{
|
{
|
||||||
var foundSkin = SkinsList.FirstOrDefault(skin =>
|
var foundSkin = SkinsList.FirstOrDefault(skin =>
|
||||||
((int?)skin?["weapon_defindex"] ?? 0) == weaponDefIndex &&
|
((int?)skin["weapon_defindex"] ?? 0) == weaponDefIndex &&
|
||||||
((int?)skin?["paint"] ?? 0) == paintId &&
|
((int?)skin["paint"] ?? 0) == paintId &&
|
||||||
skin?["image"] != null
|
skin["image"] != null
|
||||||
);
|
);
|
||||||
var image = foundSkin?["image"]?.ToString() ?? "";
|
var image = foundSkin?["image"]?.ToString() ?? "";
|
||||||
_playerWeaponImage[p.Slot] = image;
|
_playerWeaponImage[p.Slot] = image;
|
||||||
AddTimer(2.0f, () => _playerWeaponImage.Remove(p.Slot), CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE);
|
AddTimer(2.0f, () => _playerWeaponImage.Remove(p.Slot), TimerFlags.STOP_ON_MAPCHANGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
p.Print(Localizer["wp_skin_menu_select", selectedSkin]);
|
p.Print(Localizer["wp_skin_menu_select", selectedSkin]);
|
||||||
|
var playerSkins = GPlayerWeaponsInfo.GetOrAdd(p.Slot, new ConcurrentDictionary<CsTeam, ConcurrentDictionary<int, WeaponInfo>>());
|
||||||
|
|
||||||
if (!GPlayerWeaponsInfo[p.Slot].TryGetValue(weaponDefIndex, out var value))
|
var teamsToCheck = p.TeamNum < 2
|
||||||
|
? new[] { CsTeam.Terrorist, CsTeam.CounterTerrorist }
|
||||||
|
: [p.Team];
|
||||||
|
|
||||||
|
foreach (var team in teamsToCheck)
|
||||||
{
|
{
|
||||||
value = new WeaponInfo();
|
// Ensure there's an entry for the team in playerSkins
|
||||||
GPlayerWeaponsInfo[p.Slot][weaponDefIndex] = value;
|
var teamWeapons = playerSkins.GetOrAdd(team, _ => new ConcurrentDictionary<int, WeaponInfo>());
|
||||||
}
|
|
||||||
|
|
||||||
value.Paint = paintId;
|
// Attempt to get or add the existing WeaponInfo
|
||||||
value.Wear = 0.01f;
|
var value = teamWeapons.GetOrAdd(weaponDefIndex, _ => new WeaponInfo());
|
||||||
value.Seed = 0;
|
|
||||||
|
// Update the properties of WeaponInfo
|
||||||
|
value.Paint = paintId;
|
||||||
|
value.Wear = 0.01f;
|
||||||
|
value.Seed = 0;
|
||||||
|
}
|
||||||
|
|
||||||
PlayerInfo playerInfo = new PlayerInfo
|
PlayerInfo playerInfo = new PlayerInfo
|
||||||
{
|
{
|
||||||
@@ -371,6 +390,11 @@ public partial class WeaponPaints
|
|||||||
if (!Utility.IsPlayerValid(player) || player is null) return;
|
if (!Utility.IsPlayerValid(player) || player is null) return;
|
||||||
|
|
||||||
var selectedPaintName = option.Text;
|
var selectedPaintName = option.Text;
|
||||||
|
|
||||||
|
var playerGloves = GPlayersGlove.GetOrAdd(player.Slot, new ConcurrentDictionary<CsTeam, ushort>());
|
||||||
|
var teamsToCheck = player.TeamNum < 2
|
||||||
|
? new[] { CsTeam.Terrorist, CsTeam.CounterTerrorist }
|
||||||
|
: [player.Team];
|
||||||
|
|
||||||
var selectedGlove = GlovesList.FirstOrDefault(g => g.ContainsKey("paint_name") && g["paint_name"]?.ToString() == selectedPaintName);
|
var selectedGlove = GlovesList.FirstOrDefault(g => g.ContainsKey("paint_name") && g["paint_name"]?.ToString() == selectedPaintName);
|
||||||
var image = selectedGlove?["image"]?.ToString() ?? "";
|
var image = selectedGlove?["image"]?.ToString() ?? "";
|
||||||
@@ -397,15 +421,32 @@ public partial class WeaponPaints
|
|||||||
|
|
||||||
if (paint != 0)
|
if (paint != 0)
|
||||||
{
|
{
|
||||||
GPlayersGlove[player.Slot] = (ushort)weaponDefindex;
|
// Ensure that player weapons info exists for the player
|
||||||
|
if (!GPlayerWeaponsInfo.ContainsKey(player.Slot))
|
||||||
if (!GPlayerWeaponsInfo[player.Slot].ContainsKey(weaponDefindex))
|
|
||||||
{
|
{
|
||||||
WeaponInfo weaponInfo = new()
|
GPlayerWeaponsInfo[player.Slot] = new ConcurrentDictionary<CsTeam, ConcurrentDictionary<int, WeaponInfo>>();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure teams are initialized
|
||||||
|
foreach (var team in teamsToCheck)
|
||||||
|
{
|
||||||
|
if (!GPlayerWeaponsInfo[player.Slot].ContainsKey(team))
|
||||||
{
|
{
|
||||||
Paint = paint
|
GPlayerWeaponsInfo[player.Slot][team] = new ConcurrentDictionary<int, WeaponInfo>();
|
||||||
};
|
}
|
||||||
GPlayerWeaponsInfo[player.Slot][weaponDefindex] = weaponInfo;
|
|
||||||
|
// Update the glove for the player in the specified team
|
||||||
|
playerGloves[team] = (ushort)weaponDefindex;
|
||||||
|
|
||||||
|
// Check if the glove information already exists for the player
|
||||||
|
if (!GPlayerWeaponsInfo[player.Slot][team].ContainsKey(weaponDefindex))
|
||||||
|
{
|
||||||
|
WeaponInfo weaponInfo = new()
|
||||||
|
{
|
||||||
|
Paint = paint
|
||||||
|
};
|
||||||
|
GPlayerWeaponsInfo[player.Slot][team][weaponDefindex] = weaponInfo;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -413,28 +454,30 @@ public partial class WeaponPaints
|
|||||||
GPlayersGlove.TryRemove(player.Slot, out _);
|
GPlayersGlove.TryRemove(player.Slot, out _);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(Localizer["wp_glove_menu_select"]))
|
|
||||||
{
|
|
||||||
player.Print(Localizer["wp_glove_menu_select", selectedPaintName]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (WeaponSync == null) return;
|
if (WeaponSync == null) return;
|
||||||
|
|
||||||
_ = Task.Run(async () =>
|
_ = Task.Run(async () =>
|
||||||
{
|
{
|
||||||
await WeaponSync.SyncGloveToDatabase(playerInfo, weaponDefindex);
|
// Sync glove to database for all teams
|
||||||
|
foreach (var team in teamsToCheck)
|
||||||
if (!GPlayerWeaponsInfo[playerInfo.Slot].TryGetValue(weaponDefindex, out var value))
|
|
||||||
{
|
{
|
||||||
value = new WeaponInfo();
|
await WeaponSync.SyncGloveToDatabase(playerInfo, (ushort)weaponDefindex, teamsToCheck);
|
||||||
GPlayerWeaponsInfo[playerInfo.Slot][weaponDefindex] = value;
|
|
||||||
|
// Check if the weapon info exists for the glove
|
||||||
|
if (!GPlayerWeaponsInfo[playerInfo.Slot][team].TryGetValue(weaponDefindex, out var value))
|
||||||
|
{
|
||||||
|
value = new WeaponInfo();
|
||||||
|
GPlayerWeaponsInfo[playerInfo.Slot][team][weaponDefindex] = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update weapon info
|
||||||
|
value.Paint = paint;
|
||||||
|
value.Wear = 0.00f;
|
||||||
|
value.Seed = 0;
|
||||||
|
|
||||||
|
// Sync weapon paints to database
|
||||||
|
await WeaponSync.SyncWeaponPaintsToDatabase(playerInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
value.Paint = paint;
|
|
||||||
value.Wear = 0.00f;
|
|
||||||
value.Seed = 0;
|
|
||||||
|
|
||||||
await WeaponSync.SyncWeaponPaintsToDatabase(playerInfo);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
AddTimer(0.1f, () => GivePlayerGloves(player));
|
AddTimer(0.1f, () => GivePlayerGloves(player));
|
||||||
@@ -596,6 +639,11 @@ public partial class WeaponPaints
|
|||||||
if (!Utility.IsPlayerValid(player) || player is null) return;
|
if (!Utility.IsPlayerValid(player) || player is null) return;
|
||||||
|
|
||||||
var selectedPaintName = option.Text;
|
var selectedPaintName = option.Text;
|
||||||
|
|
||||||
|
var playerMusic = GPlayersMusic.GetOrAdd(player.Slot, new ConcurrentDictionary<CsTeam, ushort>());
|
||||||
|
var teamsToCheck = player.TeamNum < 2
|
||||||
|
? new[] { CsTeam.Terrorist, CsTeam.CounterTerrorist }
|
||||||
|
: [player.Team]; // Corrected array initializer
|
||||||
|
|
||||||
var selectedMusic = MusicList.FirstOrDefault(g => g.ContainsKey("name") && g["name"]?.ToString() == selectedPaintName);
|
var selectedMusic = MusicList.FirstOrDefault(g => g.ContainsKey("name") && g["name"]?.ToString() == selectedPaintName);
|
||||||
if (selectedMusic != null)
|
if (selectedMusic != null)
|
||||||
@@ -607,7 +655,7 @@ public partial class WeaponPaints
|
|||||||
if (Config.Additional.ShowSkinImage)
|
if (Config.Additional.ShowSkinImage)
|
||||||
{
|
{
|
||||||
_playerWeaponImage[player.Slot] = image;
|
_playerWeaponImage[player.Slot] = image;
|
||||||
AddTimer(2.0f, () => _playerWeaponImage.Remove(player.Slot), CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE);
|
AddTimer(2.0f, () => _playerWeaponImage.Remove(player.Slot), TimerFlags.STOP_ON_MAPCHANGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerInfo playerInfo = new PlayerInfo
|
PlayerInfo playerInfo = new PlayerInfo
|
||||||
@@ -619,14 +667,20 @@ public partial class WeaponPaints
|
|||||||
Name = player.PlayerName,
|
Name = player.PlayerName,
|
||||||
IpAddress = player.IpAddress?.Split(":")[0]
|
IpAddress = player.IpAddress?.Split(":")[0]
|
||||||
};
|
};
|
||||||
|
|
||||||
if (paint != 0)
|
if (paint != 0)
|
||||||
{
|
{
|
||||||
GPlayersMusic[player.Slot] = (ushort)paint;
|
foreach (var team in teamsToCheck)
|
||||||
|
{
|
||||||
|
playerMusic[team] = (ushort)paint;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GPlayersMusic[player.Slot] = 0;
|
foreach (var team in teamsToCheck)
|
||||||
|
{
|
||||||
|
playerMusic[team] = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(Localizer["wp_music_menu_select"]))
|
if (!string.IsNullOrEmpty(Localizer["wp_music_menu_select"]))
|
||||||
@@ -638,11 +692,9 @@ public partial class WeaponPaints
|
|||||||
{
|
{
|
||||||
_ = Task.Run(async () =>
|
_ = Task.Run(async () =>
|
||||||
{
|
{
|
||||||
await WeaponSync.SyncMusicToDatabase(playerInfo, (ushort)paint);
|
await WeaponSync.SyncMusicToDatabase(playerInfo, (ushort)paint, teamsToCheck);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
//RefreshGloves(player);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -656,7 +708,10 @@ public partial class WeaponPaints
|
|||||||
IpAddress = player.IpAddress?.Split(":")[0]
|
IpAddress = player.IpAddress?.Split(":")[0]
|
||||||
};
|
};
|
||||||
|
|
||||||
GPlayersMusic[player.Slot] = 0;
|
foreach (var team in teamsToCheck)
|
||||||
|
{
|
||||||
|
playerMusic[team] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(Localizer["wp_music_menu_select"]))
|
if (!string.IsNullOrEmpty(Localizer["wp_music_menu_select"]))
|
||||||
{
|
{
|
||||||
@@ -667,7 +722,7 @@ public partial class WeaponPaints
|
|||||||
{
|
{
|
||||||
_ = Task.Run(async () =>
|
_ = Task.Run(async () =>
|
||||||
{
|
{
|
||||||
await WeaponSync.SyncMusicToDatabase(playerInfo, 0);
|
await WeaponSync.SyncMusicToDatabase(playerInfo, 0, teamsToCheck);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -716,6 +771,11 @@ public partial class WeaponPaints
|
|||||||
|
|
||||||
var selectedPaintName = option.Text;
|
var selectedPaintName = option.Text;
|
||||||
|
|
||||||
|
var playerPins = GPlayersPin.GetOrAdd(player.Slot, new ConcurrentDictionary<CsTeam, ushort>());
|
||||||
|
var teamsToCheck = player.TeamNum < 2
|
||||||
|
? new[] { CsTeam.Terrorist, CsTeam.CounterTerrorist }
|
||||||
|
: [player.Team];
|
||||||
|
|
||||||
var selectedPin = PinsList.FirstOrDefault(g => g.ContainsKey("name") && g["name"]?.ToString() == selectedPaintName);
|
var selectedPin = PinsList.FirstOrDefault(g => g.ContainsKey("name") && g["name"]?.ToString() == selectedPaintName);
|
||||||
if (selectedPin != null)
|
if (selectedPin != null)
|
||||||
{
|
{
|
||||||
@@ -738,14 +798,20 @@ public partial class WeaponPaints
|
|||||||
Name = player.PlayerName,
|
Name = player.PlayerName,
|
||||||
IpAddress = player.IpAddress?.Split(":")[0]
|
IpAddress = player.IpAddress?.Split(":")[0]
|
||||||
};
|
};
|
||||||
|
|
||||||
if (paint != 0)
|
if (paint != 0)
|
||||||
{
|
{
|
||||||
GPlayersPin[player.Slot] = (ushort)paint;
|
foreach (var team in teamsToCheck)
|
||||||
|
{
|
||||||
|
playerPins[team] = (ushort)paint; // Set pin for each team
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GPlayersPin[player.Slot] = 0;
|
foreach (var team in teamsToCheck)
|
||||||
|
{
|
||||||
|
playerPins[team] = 0; // Set pin for each team
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(Localizer["wp_pins_menu_select"]))
|
if (!string.IsNullOrEmpty(Localizer["wp_pins_menu_select"]))
|
||||||
@@ -759,7 +825,7 @@ public partial class WeaponPaints
|
|||||||
{
|
{
|
||||||
_ = Task.Run(async () =>
|
_ = Task.Run(async () =>
|
||||||
{
|
{
|
||||||
await WeaponSync.SyncPinToDatabase(playerInfo, (ushort)paint);
|
await WeaponSync.SyncPinToDatabase(playerInfo, (ushort)paint, teamsToCheck);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -775,7 +841,10 @@ public partial class WeaponPaints
|
|||||||
IpAddress = player.IpAddress?.Split(":")[0]
|
IpAddress = player.IpAddress?.Split(":")[0]
|
||||||
};
|
};
|
||||||
|
|
||||||
GPlayersPin[player.Slot] = 0;
|
foreach (var team in teamsToCheck)
|
||||||
|
{
|
||||||
|
playerPins[team] = 0; // Set music for each team
|
||||||
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(Localizer["wp_pins_menu_select"]))
|
if (!string.IsNullOrEmpty(Localizer["wp_pins_menu_select"]))
|
||||||
{
|
{
|
||||||
@@ -788,7 +857,7 @@ public partial class WeaponPaints
|
|||||||
{
|
{
|
||||||
_ = Task.Run(async () =>
|
_ = Task.Run(async () =>
|
||||||
{
|
{
|
||||||
await WeaponSync.SyncPinToDatabase(playerInfo, 0);
|
await WeaponSync.SyncPinToDatabase(playerInfo, 0, teamsToCheck);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ namespace WeaponPaints
|
|||||||
return HookResult.Continue;
|
return HookResult.Continue;
|
||||||
|
|
||||||
if (WeaponSync != null)
|
if (WeaponSync != null)
|
||||||
_ = Task.Run(async () => await WeaponSync.SyncStatTrakToDatabase(playerInfo, weaponInfos));
|
_ = Task.Run(async () => await WeaponSync.SyncStatTrakToDatabase(playerInfo));
|
||||||
|
|
||||||
if (Config.Additional.SkinEnabled)
|
if (Config.Additional.SkinEnabled)
|
||||||
{
|
{
|
||||||
@@ -253,9 +253,13 @@ namespace WeaponPaints
|
|||||||
private HookResult OnPlayerDeath(EventPlayerDeath @event, GameEventInfo info)
|
private HookResult OnPlayerDeath(EventPlayerDeath @event, GameEventInfo info)
|
||||||
{
|
{
|
||||||
CCSPlayerController? player = @event.Attacker;
|
CCSPlayerController? player = @event.Attacker;
|
||||||
|
CCSPlayerController? victim = @event.Userid;
|
||||||
|
|
||||||
if (player is null || !player.IsValid)
|
if (player is null || !player.IsValid)
|
||||||
return HookResult.Continue;
|
return HookResult.Continue;
|
||||||
|
|
||||||
|
if (victim == null || victim == player)
|
||||||
|
return HookResult.Continue;
|
||||||
|
|
||||||
if (!GPlayerWeaponsInfo.TryGetValue(player.Slot, out _)) return HookResult.Continue;
|
if (!GPlayerWeaponsInfo.TryGetValue(player.Slot, out _)) return HookResult.Continue;
|
||||||
|
|
||||||
@@ -265,7 +269,7 @@ namespace WeaponPaints
|
|||||||
|
|
||||||
int weaponDefIndex = weapon.AttributeManager.Item.ItemDefinitionIndex;
|
int weaponDefIndex = weapon.AttributeManager.Item.ItemDefinitionIndex;
|
||||||
|
|
||||||
if (!GPlayerWeaponsInfo[player.Slot].TryGetValue(weaponDefIndex, out var weaponInfo) || weaponInfo.Paint == 0)
|
if (!GPlayerWeaponsInfo[player.Slot][player.Team].TryGetValue(weaponDefIndex, out var weaponInfo) || weaponInfo.Paint == 0)
|
||||||
return HookResult.Continue;
|
return HookResult.Continue;
|
||||||
|
|
||||||
if (!weaponInfo.StatTrak) return HookResult.Continue;
|
if (!weaponInfo.StatTrak) return HookResult.Continue;
|
||||||
|
|||||||
111
Utility.cs
111
Utility.cs
@@ -24,58 +24,65 @@ namespace WeaponPaints
|
|||||||
{
|
{
|
||||||
string[] createTableQueries =
|
string[] createTableQueries =
|
||||||
[
|
[
|
||||||
"""
|
@"
|
||||||
CREATE TABLE IF NOT EXISTS `wp_player_skins` (
|
CREATE TABLE IF NOT EXISTS `wp_player_skins` (
|
||||||
`steamid` varchar(18) NOT NULL,
|
`steamid` varchar(18) NOT NULL,
|
||||||
`weapon_defindex` int(6) NOT NULL,
|
`weapon_team` int(1) NOT NULL,
|
||||||
`weapon_paint_id` int(6) NOT NULL,
|
`weapon_defindex` int(6) NOT NULL,
|
||||||
`weapon_wear` float NOT NULL DEFAULT 0.000001,
|
`weapon_paint_id` int(6) NOT NULL,
|
||||||
`weapon_seed` int(16) NOT NULL DEFAULT 0,
|
`weapon_wear` float NOT NULL DEFAULT 0.000001,
|
||||||
`weapon_nametag` VARCHAR(128) DEFAULT NULL,
|
`weapon_seed` int(16) NOT NULL DEFAULT 0,
|
||||||
`weapon_stattrak` tinyint(1) NOT NULL,
|
`weapon_nametag` VARCHAR(128) DEFAULT NULL,
|
||||||
`weapon_stattrak_count` int(10) NOT NULL,
|
`weapon_stattrak` tinyint(1) NOT NULL DEFAULT 0,
|
||||||
`weapon_sticker_0` VARCHAR(128) NOT NULL DEFAULT '0;0;0;0;0;0;0' COMMENT 'id;schema;x;y;wear;scale;rotation',
|
`weapon_stattrak_count` int(10) NOT NULL DEFAULT 0,
|
||||||
`weapon_sticker_1` VARCHAR(128) NOT NULL DEFAULT '0;0;0;0;0;0;0' COMMENT 'id;schema;x;y;wear;scale;rotation',
|
`weapon_sticker_0` VARCHAR(128) NOT NULL DEFAULT '0;0;0;0;0;0;0' COMMENT 'id;schema;x;y;wear;scale;rotation',
|
||||||
`weapon_sticker_2` VARCHAR(128) NOT NULL DEFAULT '0;0;0;0;0;0;0' COMMENT 'id;schema;x;y;wear;scale;rotation',
|
`weapon_sticker_1` VARCHAR(128) NOT NULL DEFAULT '0;0;0;0;0;0;0' COMMENT 'id;schema;x;y;wear;scale;rotation',
|
||||||
`weapon_sticker_3` VARCHAR(128) NOT NULL DEFAULT '0;0;0;0;0;0;0' COMMENT 'id;schema;x;y;wear;scale;rotation',
|
`weapon_sticker_2` VARCHAR(128) NOT NULL DEFAULT '0;0;0;0;0;0;0' COMMENT 'id;schema;x;y;wear;scale;rotation',
|
||||||
`weapon_sticker_4` VARCHAR(128) NOT NULL DEFAULT '0;0;0;0;0;0;0' COMMENT 'id;schema;x;y;wear;scale;rotation',
|
`weapon_sticker_3` VARCHAR(128) NOT NULL DEFAULT '0;0;0;0;0;0;0' COMMENT 'id;schema;x;y;wear;scale;rotation',
|
||||||
`weapon_keychain`VARCHAR(128) NOT NULL DEFAULT '0;0;0;0;0' COMMENT 'id;x;y;z;seed'
|
`weapon_sticker_4` VARCHAR(128) NOT NULL DEFAULT '0;0;0;0;0;0;0' COMMENT 'id;schema;x;y;wear;scale;rotation',
|
||||||
) ENGINE=InnoDB
|
`weapon_keychain` VARCHAR(128) NOT NULL DEFAULT '0;0;0;0;0' COMMENT 'id;x;y;z;seed',
|
||||||
""",
|
UNIQUE (`steamid`, `weapon_team`, `weapon_defindex`) -- Add unique constraint here
|
||||||
@"CREATE TABLE IF NOT EXISTS `wp_player_knife` (
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;",
|
||||||
`steamid` varchar(18) NOT NULL,
|
|
||||||
`knife` varchar(64) NOT NULL,
|
@"
|
||||||
UNIQUE (`steamid`)
|
CREATE TABLE IF NOT EXISTS `wp_player_knife` (
|
||||||
) ENGINE = InnoDB",
|
`steamid` varchar(18) NOT NULL,
|
||||||
"""
|
`weapon_team` int(1) NOT NULL,
|
||||||
CREATE TABLE IF NOT EXISTS `wp_player_gloves` (
|
`knife` varchar(64) NOT NULL,
|
||||||
`steamid` varchar(18) NOT NULL,
|
UNIQUE (`steamid`, `weapon_team`) -- Unique constraint
|
||||||
`weapon_defindex` int(11) NOT NULL,
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;",
|
||||||
UNIQUE (`steamid`)
|
|
||||||
) ENGINE=InnoDB
|
@"
|
||||||
""",
|
CREATE TABLE IF NOT EXISTS `wp_player_gloves` (
|
||||||
"""
|
`steamid` varchar(18) NOT NULL,
|
||||||
CREATE TABLE IF NOT EXISTS `wp_player_agents` (
|
`weapon_team` int(1) NOT NULL,
|
||||||
`steamid` varchar(18) NOT NULL,
|
`weapon_defindex` int(11) NOT NULL,
|
||||||
`agent_ct` varchar(64) DEFAULT NULL,
|
UNIQUE (`steamid`, `weapon_team`) -- Unique constraint
|
||||||
`agent_t` varchar(64) DEFAULT NULL,
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;",
|
||||||
UNIQUE (`steamid`)
|
|
||||||
) ENGINE=InnoDB
|
@"
|
||||||
""",
|
CREATE TABLE IF NOT EXISTS `wp_player_agents` (
|
||||||
"""
|
`steamid` varchar(18) NOT NULL,
|
||||||
CREATE TABLE IF NOT EXISTS `wp_player_music` (
|
`agent_ct` varchar(64) DEFAULT NULL,
|
||||||
`steamid` varchar(64) NOT NULL,
|
`agent_t` varchar(64) DEFAULT NULL,
|
||||||
`music_id` int(11) NOT NULL,
|
UNIQUE (`steamid`) -- Unique constraint
|
||||||
UNIQUE (`steamid`)
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;",
|
||||||
) ENGINE=InnoDB
|
|
||||||
""",
|
@"
|
||||||
"""
|
CREATE TABLE IF NOT EXISTS `wp_player_music` (
|
||||||
CREATE TABLE IF NOT EXISTS `wp_player_pins` (
|
`steamid` varchar(64) NOT NULL,
|
||||||
`steamid` varchar(64) NOT NULL,
|
`weapon_team` int(1) NOT NULL,
|
||||||
`id` int(11) NOT NULL,
|
`music_id` int(11) NOT NULL,
|
||||||
UNIQUE (`steamid`)
|
UNIQUE (`steamid`, `weapon_team`) -- Unique constraint
|
||||||
) ENGINE=InnoDB
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;",
|
||||||
""",
|
|
||||||
|
@"
|
||||||
|
CREATE TABLE IF NOT EXISTS `wp_player_pins` (
|
||||||
|
`steamid` varchar(64) NOT NULL,
|
||||||
|
`weapon_team` int(1) NOT NULL,
|
||||||
|
`id` int(11) NOT NULL,
|
||||||
|
UNIQUE (`steamid`, `weapon_team`) -- Unique constraint
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;"
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach (var query in createTableQueries)
|
foreach (var query in createTableQueries)
|
||||||
|
|||||||
11
Variables.cs
11
Variables.cs
@@ -3,6 +3,7 @@ using System.Runtime.InteropServices;
|
|||||||
using CounterStrikeSharp.API.Core;
|
using CounterStrikeSharp.API.Core;
|
||||||
using CounterStrikeSharp.API.Core.Capabilities;
|
using CounterStrikeSharp.API.Core.Capabilities;
|
||||||
using CounterStrikeSharp.API.Modules.Memory.DynamicFunctions;
|
using CounterStrikeSharp.API.Modules.Memory.DynamicFunctions;
|
||||||
|
using CounterStrikeSharp.API.Modules.Utils;
|
||||||
using MenuManager;
|
using MenuManager;
|
||||||
using Microsoft.Extensions.Localization;
|
using Microsoft.Extensions.Localization;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
@@ -72,12 +73,12 @@ public partial class WeaponPaints
|
|||||||
};
|
};
|
||||||
|
|
||||||
public static IStringLocalizer? _localizer;
|
public static IStringLocalizer? _localizer;
|
||||||
internal static readonly ConcurrentDictionary<int, string> GPlayersKnife = new();
|
internal static readonly ConcurrentDictionary<int, ConcurrentDictionary<CsTeam, string>> GPlayersKnife = new();
|
||||||
internal static readonly ConcurrentDictionary<int, ushort> GPlayersGlove = new();
|
internal static readonly ConcurrentDictionary<int, ConcurrentDictionary<CsTeam, ushort>> GPlayersGlove = new();
|
||||||
internal static readonly ConcurrentDictionary<int, ushort> GPlayersMusic = new();
|
internal static readonly ConcurrentDictionary<int, ConcurrentDictionary<CsTeam, ushort>> GPlayersMusic = new();
|
||||||
internal static readonly ConcurrentDictionary<int, ushort> GPlayersPin = new();
|
internal static readonly ConcurrentDictionary<int, ConcurrentDictionary<CsTeam, ushort>> GPlayersPin = new();
|
||||||
public static readonly ConcurrentDictionary<int, (string? CT, string? T)> GPlayersAgent = new();
|
public static readonly ConcurrentDictionary<int, (string? CT, string? T)> GPlayersAgent = new();
|
||||||
internal static readonly ConcurrentDictionary<int, ConcurrentDictionary<int, WeaponInfo>> GPlayerWeaponsInfo = new();
|
internal static readonly ConcurrentDictionary<int, ConcurrentDictionary<CsTeam, ConcurrentDictionary<int, WeaponInfo>>> GPlayerWeaponsInfo = new();
|
||||||
internal static List<JObject> SkinsList = [];
|
internal static List<JObject> SkinsList = [];
|
||||||
internal static List<JObject> PinsList = [];
|
internal static List<JObject> PinsList = [];
|
||||||
internal static List<JObject> GlovesList = [];
|
internal static List<JObject> GlovesList = [];
|
||||||
|
|||||||
@@ -20,11 +20,12 @@ namespace WeaponPaints
|
|||||||
|
|
||||||
bool isKnife = weapon.DesignerName.Contains("knife") || weapon.DesignerName.Contains("bayonet");
|
bool isKnife = weapon.DesignerName.Contains("knife") || weapon.DesignerName.Contains("bayonet");
|
||||||
|
|
||||||
if (isKnife && !GPlayersKnife.ContainsKey(player.Slot) || isKnife && GPlayersKnife[player.Slot] == "weapon_knife") return;
|
if (isKnife && !GPlayersKnife.ContainsKey(player.Slot) ||
|
||||||
|
isKnife && GPlayersKnife[player.Slot][player.Team] == "weapon_knife") return;
|
||||||
|
|
||||||
if (isKnife)
|
if (isKnife)
|
||||||
{
|
{
|
||||||
var newDefIndex = WeaponDefindex.FirstOrDefault(x => x.Value == GPlayersKnife[player.Slot]);
|
var newDefIndex = WeaponDefindex.FirstOrDefault(x => x.Value == GPlayersKnife[player.Slot][player.Team]);
|
||||||
if (newDefIndex.Key == 0) return;
|
if (newDefIndex.Key == 0) return;
|
||||||
|
|
||||||
if (weapon.AttributeManager.Item.ItemDefinitionIndex != newDefIndex.Key)
|
if (weapon.AttributeManager.Item.ItemDefinitionIndex != newDefIndex.Key)
|
||||||
@@ -47,7 +48,7 @@ namespace WeaponPaints
|
|||||||
bool isLegacyModel;
|
bool isLegacyModel;
|
||||||
|
|
||||||
if (_config.Additional.GiveRandomSkin &&
|
if (_config.Additional.GiveRandomSkin &&
|
||||||
!GPlayerWeaponsInfo[player.Slot].ContainsKey(weaponDefIndex))
|
!GPlayerWeaponsInfo[player.Slot][player.Team].ContainsKey(weaponDefIndex))
|
||||||
{
|
{
|
||||||
// Random skins
|
// Random skins
|
||||||
weapon.FallbackPaintKit = GetRandomPaint(weaponDefIndex);
|
weapon.FallbackPaintKit = GetRandomPaint(weaponDefIndex);
|
||||||
@@ -80,7 +81,7 @@ namespace WeaponPaints
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!GPlayerWeaponsInfo[player.Slot].TryGetValue(weaponDefIndex, out var value) || value.Paint == 0) return;
|
if (!GPlayerWeaponsInfo[player.Slot][player.Team].TryGetValue(weaponDefIndex, out var value) || value.Paint == 0) return;
|
||||||
|
|
||||||
var weaponInfo = value;
|
var weaponInfo = value;
|
||||||
//Log($"Apply on {weapon.DesignerName}({weapon.AttributeManager.Item.ItemDefinitionIndex}) paint {gPlayerWeaponPaints[steamId.SteamId64][weapon.AttributeManager.Item.ItemDefinitionIndex]} seed {gPlayerWeaponSeed[steamId.SteamId64][weapon.AttributeManager.Item.ItemDefinitionIndex]} wear {gPlayerWeaponWear[steamId.SteamId64][weapon.AttributeManager.Item.ItemDefinitionIndex]}");
|
//Log($"Apply on {weapon.DesignerName}({weapon.AttributeManager.Item.ItemDefinitionIndex}) paint {gPlayerWeaponPaints[steamId.SteamId64][weapon.AttributeManager.Item.ItemDefinitionIndex]} seed {gPlayerWeaponSeed[steamId.SteamId64][weapon.AttributeManager.Item.ItemDefinitionIndex]} wear {gPlayerWeaponWear[steamId.SteamId64][weapon.AttributeManager.Item.ItemDefinitionIndex]}");
|
||||||
@@ -131,7 +132,8 @@ namespace WeaponPaints
|
|||||||
{
|
{
|
||||||
int weaponDefIndex = weapon.AttributeManager.Item.ItemDefinitionIndex;
|
int weaponDefIndex = weapon.AttributeManager.Item.ItemDefinitionIndex;
|
||||||
if (!GPlayerWeaponsInfo.TryGetValue(player.Slot, out var playerWeapons) ||
|
if (!GPlayerWeaponsInfo.TryGetValue(player.Slot, out var playerWeapons) ||
|
||||||
!playerWeapons.TryGetValue(weaponDefIndex, out var weaponInfo) ||
|
!playerWeapons.TryGetValue(player.Team, out var weaponInfoDict) ||
|
||||||
|
!weaponInfoDict.TryGetValue(weaponDefIndex, out var weaponInfo) ||
|
||||||
weaponInfo.Stickers.Count <= 0) return;
|
weaponInfo.Stickers.Count <= 0) return;
|
||||||
|
|
||||||
float wearIncrement = 0.001f;
|
float wearIncrement = 0.001f;
|
||||||
@@ -155,7 +157,7 @@ namespace WeaponPaints
|
|||||||
int weaponDefIndex = weapon.AttributeManager.Item.ItemDefinitionIndex;
|
int weaponDefIndex = weapon.AttributeManager.Item.ItemDefinitionIndex;
|
||||||
|
|
||||||
if (!GPlayerWeaponsInfo.TryGetValue(player.Slot, out var playerWeapons) ||
|
if (!GPlayerWeaponsInfo.TryGetValue(player.Slot, out var playerWeapons) ||
|
||||||
!playerWeapons.TryGetValue(weaponDefIndex, out var weaponInfo))
|
!playerWeapons[player.Team].TryGetValue(weaponDefIndex, out var weaponInfo))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -197,7 +199,7 @@ namespace WeaponPaints
|
|||||||
int weaponDefIndex = weapon.AttributeManager.Item.ItemDefinitionIndex;
|
int weaponDefIndex = weapon.AttributeManager.Item.ItemDefinitionIndex;
|
||||||
|
|
||||||
if (!GPlayerWeaponsInfo.TryGetValue(player.Slot, out var playerWeaponsInfo) ||
|
if (!GPlayerWeaponsInfo.TryGetValue(player.Slot, out var playerWeaponsInfo) ||
|
||||||
!playerWeaponsInfo.TryGetValue(weaponDefIndex, out var value) ||
|
!playerWeaponsInfo[player.Team].TryGetValue(weaponDefIndex, out var value) ||
|
||||||
value.KeyChain == null) return;
|
value.KeyChain == null) return;
|
||||||
var keyChain = value.KeyChain;
|
var keyChain = value.KeyChain;
|
||||||
|
|
||||||
@@ -263,8 +265,6 @@ namespace WeaponPaints
|
|||||||
if (player.Team is CsTeam.None or CsTeam.Spectator)
|
if (player.Team is CsTeam.None or CsTeam.Spectator)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int playerTeam = player.TeamNum;
|
|
||||||
|
|
||||||
Dictionary<string, List<(int, int)>> weaponsWithAmmo = [];
|
Dictionary<string, List<(int, int)>> weaponsWithAmmo = [];
|
||||||
|
|
||||||
foreach (var weapon in weapons)
|
foreach (var weapon in weapons)
|
||||||
@@ -376,11 +376,12 @@ namespace WeaponPaints
|
|||||||
if (!player.PawnIsAlive)
|
if (!player.PawnIsAlive)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!GPlayersGlove.TryGetValue(player.Slot, out var gloveInfo) || gloveInfo == 0) return;
|
if (!GPlayersGlove.TryGetValue(player.Slot, out var gloveInfo) ||
|
||||||
|
!gloveInfo.TryGetValue(player.Team, out var gloveId) || gloveId == 0) return;
|
||||||
|
|
||||||
WeaponInfo weaponInfo = GPlayerWeaponsInfo[player.Slot][gloveInfo];
|
WeaponInfo weaponInfo = GPlayerWeaponsInfo[player.Slot][player.Team][gloveId];
|
||||||
|
|
||||||
item.ItemDefinitionIndex = gloveInfo;
|
item.ItemDefinitionIndex = gloveId;
|
||||||
item.ItemIDLow = 16384 & 0xFFFFFFFF;
|
item.ItemIDLow = 16384 & 0xFFFFFFFF;
|
||||||
item.ItemIDHigh = 16384;
|
item.ItemIDHigh = 16384;
|
||||||
|
|
||||||
@@ -472,21 +473,24 @@ namespace WeaponPaints
|
|||||||
|
|
||||||
private static void GivePlayerMusicKit(CCSPlayerController player)
|
private static void GivePlayerMusicKit(CCSPlayerController player)
|
||||||
{
|
{
|
||||||
if (!GPlayersMusic.TryGetValue(player.Slot, out var value)) return;
|
if (GPlayersMusic.TryGetValue(player.Slot, out var musicInfo) || musicInfo == null ||
|
||||||
|
!musicInfo.TryGetValue(player.Team, out var musicId) || musicId == 0) return;
|
||||||
|
|
||||||
if (player.InventoryServices == null) return;
|
if (player.InventoryServices == null) return;
|
||||||
|
|
||||||
player.InventoryServices.MusicID = value;
|
player.InventoryServices.MusicID = musicId;
|
||||||
Utilities.SetStateChanged(player, "CCSPlayerController", "m_pInventoryServices");
|
Utilities.SetStateChanged(player, "CCSPlayerController", "m_pInventoryServices");
|
||||||
player.MusicKitID = value;
|
player.MusicKitID = musicId;
|
||||||
Utilities.SetStateChanged(player, "CCSPlayerController", "m_iMusicKitID");
|
Utilities.SetStateChanged(player, "CCSPlayerController", "m_iMusicKitID");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void GivePlayerPin(CCSPlayerController player)
|
private static void GivePlayerPin(CCSPlayerController player)
|
||||||
{
|
{
|
||||||
if (!GPlayersPin.TryGetValue(player.Slot, out var pin)) return;
|
if (!GPlayersPin.TryGetValue(player.Slot, out var pinInfo) ||
|
||||||
|
!pinInfo.TryGetValue(player.Team, out var pinId)) return;
|
||||||
if (player.InventoryServices == null) return;
|
if (player.InventoryServices == null) return;
|
||||||
|
|
||||||
player.InventoryServices.Rank[5] = pin > 0 ? (MedalRank_t)pin : MedalRank_t.MEDAL_RANK_NONE;
|
player.InventoryServices.Rank[5] = pinId > 0 ? (MedalRank_t)pinId : MedalRank_t.MEDAL_RANK_NONE;
|
||||||
Utilities.SetStateChanged(player, "CCSPlayerController", "m_pInventoryServices");
|
Utilities.SetStateChanged(player, "CCSPlayerController", "m_pInventoryServices");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ public partial class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig
|
|||||||
public override string ModuleAuthor => "Nereziel & daffyy";
|
public override string ModuleAuthor => "Nereziel & daffyy";
|
||||||
public override string ModuleDescription => "Skin, gloves, agents and knife selector, standalone and web-based";
|
public override string ModuleDescription => "Skin, gloves, agents and knife selector, standalone and web-based";
|
||||||
public override string ModuleName => "WeaponPaints";
|
public override string ModuleName => "WeaponPaints";
|
||||||
public override string ModuleVersion => "2.8c";
|
public override string ModuleVersion => "2.9a";
|
||||||
|
|
||||||
public override void Load(bool hotReload)
|
public override void Load(bool hotReload)
|
||||||
{
|
{
|
||||||
@@ -25,19 +25,20 @@ public partial class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig
|
|||||||
if (hotReload)
|
if (hotReload)
|
||||||
{
|
{
|
||||||
OnMapStart(string.Empty);
|
OnMapStart(string.Empty);
|
||||||
|
|
||||||
|
GPlayerWeaponsInfo.Clear();
|
||||||
|
GPlayersKnife.Clear();
|
||||||
|
GPlayersGlove.Clear();
|
||||||
|
GPlayersAgent.Clear();
|
||||||
|
GPlayersPin.Clear();
|
||||||
|
GPlayersMusic.Clear();
|
||||||
|
|
||||||
foreach (var player in Enumerable
|
foreach (var player in Enumerable
|
||||||
.OfType<CCSPlayerController>(Utilities.GetPlayers().TakeWhile(player => WeaponSync != null))
|
.OfType<CCSPlayerController>(Utilities.GetPlayers().TakeWhile(_ => WeaponSync != null))
|
||||||
.Where(player => player.IsValid &&
|
.Where(player => player.IsValid &&
|
||||||
!string.IsNullOrEmpty(player.IpAddress) && player is
|
!string.IsNullOrEmpty(player.IpAddress) && player is
|
||||||
{ IsBot: false, Connected: PlayerConnectedState.PlayerConnected }))
|
{ IsBot: false, Connected: PlayerConnectedState.PlayerConnected }))
|
||||||
{
|
{
|
||||||
GPlayerWeaponsInfo.TryRemove(player.Slot, out _);
|
|
||||||
GPlayersKnife.TryRemove(player.Slot, out _);
|
|
||||||
GPlayersGlove.TryRemove(player.Slot, out _);
|
|
||||||
GPlayersAgent.TryRemove(player.Slot, out _);
|
|
||||||
GPlayersPin.TryRemove(player.Slot, out _);
|
|
||||||
|
|
||||||
var playerInfo = new PlayerInfo
|
var playerInfo = new PlayerInfo
|
||||||
{
|
{
|
||||||
UserId = player.UserId,
|
UserId = player.UserId,
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user