Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eae091b59a | ||
|
|
a89593f6a2 | ||
|
|
c418de1e17 | ||
|
|
82e73e764e | ||
|
|
ad6c7df357 | ||
|
|
a1fa8f37c7 | ||
|
|
475e91e779 | ||
|
|
a136f5472e | ||
|
|
b5d7f12024 | ||
|
|
9ec64e346f | ||
|
|
b4dc20523c | ||
|
|
8891ce815e | ||
|
|
ea9963b920 | ||
|
|
4a5a08aca9 | ||
|
|
573604a9d9 | ||
|
|
3929a43e46 | ||
|
|
f7f18b7919 | ||
|
|
0d110d83c7 |
27
Commands.cs
@@ -153,18 +153,15 @@ public partial class WeaponPaints
|
|||||||
{
|
{
|
||||||
if (player == null || !player.IsValid) return;
|
if (player == null || !player.IsValid) return;
|
||||||
|
|
||||||
if (!GPlayerWeaponsInfo.TryGetValue(player.Slot, out var teamInfo) ||
|
|
||||||
!teamInfo.TryGetValue(player.Team, out var teamWeapons) )
|
|
||||||
return;
|
|
||||||
|
|
||||||
var weapon = player.PlayerPawn.Value?.WeaponServices?.ActiveWeapon.Value;
|
var weapon = player.PlayerPawn.Value?.WeaponServices?.ActiveWeapon.Value;
|
||||||
|
|
||||||
if (weapon == null || !weapon.IsValid)
|
if (weapon == null || !weapon.IsValid)
|
||||||
return;
|
return;
|
||||||
if (!teamWeapons.TryGetValue(weapon.AttributeManager.Item.ItemDefinitionIndex, out var teamWeapon))
|
|
||||||
return;
|
|
||||||
|
|
||||||
teamWeapon.StatTrak = !teamWeapon.StatTrak;
|
if (!HasChangedPaint(player, weapon.AttributeManager.Item.ItemDefinitionIndex, out var weaponInfo) || weaponInfo == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
weaponInfo.StatTrak = !weaponInfo.StatTrak;
|
||||||
RefreshWeapons(player);
|
RefreshWeapons(player);
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(Localizer["wp_stattrak_action"]))
|
if (!string.IsNullOrEmpty(Localizer["wp_stattrak_action"]))
|
||||||
@@ -181,7 +178,7 @@ public partial class WeaponPaints
|
|||||||
.Where(pair => pair.Key.StartsWith("weapon_knife") || pair.Key.StartsWith("weapon_bayonet"))
|
.Where(pair => pair.Key.StartsWith("weapon_knife") || pair.Key.StartsWith("weapon_bayonet"))
|
||||||
.ToDictionary(pair => pair.Key, pair => pair.Value);
|
.ToDictionary(pair => pair.Key, pair => pair.Value);
|
||||||
|
|
||||||
var giveItemMenu = MenuApi?.NewMenu(Localizer["wp_knife_menu_title"]);
|
var giveItemMenu = Utility.CreateMenu(Localizer["wp_knife_menu_title"]);
|
||||||
|
|
||||||
var handleGive = (CCSPlayerController player, ChatMenuOption option) =>
|
var handleGive = (CCSPlayerController player, ChatMenuOption option) =>
|
||||||
{
|
{
|
||||||
@@ -265,7 +262,7 @@ public partial class WeaponPaints
|
|||||||
.Except([new KeyValuePair<string, string>("weapon_knife", "Default Knife")])
|
.Except([new KeyValuePair<string, string>("weapon_knife", "Default Knife")])
|
||||||
.ToDictionary(kvp => kvp.Value, kvp => kvp.Key);
|
.ToDictionary(kvp => kvp.Value, kvp => kvp.Key);
|
||||||
|
|
||||||
var weaponSelectionMenu = MenuApi?.NewMenu(Localizer["wp_skin_menu_weapon_title"]);
|
var weaponSelectionMenu = Utility.CreateMenu(Localizer["wp_skin_menu_weapon_title"]);
|
||||||
|
|
||||||
// Function to handle skin selection for a specific weapon
|
// Function to handle skin selection for a specific weapon
|
||||||
var handleWeaponSelection = (CCSPlayerController? player, ChatMenuOption option) =>
|
var handleWeaponSelection = (CCSPlayerController? player, ChatMenuOption option) =>
|
||||||
@@ -280,7 +277,7 @@ public partial class WeaponPaints
|
|||||||
weaponName?.ToString() == selectedWeaponClassname
|
weaponName?.ToString() == selectedWeaponClassname
|
||||||
)?.ToList();
|
)?.ToList();
|
||||||
|
|
||||||
var skinSubMenu = MenuApi?.NewMenu(Localizer["wp_skin_menu_skin_title", selectedWeapon]);
|
var skinSubMenu = Utility.CreateMenu(Localizer["wp_skin_menu_skin_title", selectedWeapon]);
|
||||||
|
|
||||||
// Function to handle skin selection for the chosen weapon
|
// Function to handle skin selection for the chosen weapon
|
||||||
var handleSkinSelection = (CCSPlayerController p, ChatMenuOption opt) =>
|
var handleSkinSelection = (CCSPlayerController p, ChatMenuOption opt) =>
|
||||||
@@ -337,7 +334,7 @@ public partial class WeaponPaints
|
|||||||
value.Seed = 0;
|
value.Seed = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerInfo playerInfo = new PlayerInfo
|
var playerInfo = new PlayerInfo
|
||||||
{
|
{
|
||||||
UserId = p.UserId,
|
UserId = p.UserId,
|
||||||
Slot = p.Slot,
|
Slot = p.Slot,
|
||||||
@@ -416,7 +413,7 @@ public partial class WeaponPaints
|
|||||||
|
|
||||||
private void SetupGlovesMenu()
|
private void SetupGlovesMenu()
|
||||||
{
|
{
|
||||||
var glovesSelectionMenu = MenuApi?.NewMenu(Localizer["wp_glove_menu_title"]);
|
var glovesSelectionMenu = Utility.CreateMenu(Localizer["wp_glove_menu_title"]);
|
||||||
if (glovesSelectionMenu == null) return;
|
if (glovesSelectionMenu == null) return;
|
||||||
glovesSelectionMenu.PostSelectAction = PostSelectAction.Close;
|
glovesSelectionMenu.PostSelectAction = PostSelectAction.Close;
|
||||||
|
|
||||||
@@ -625,7 +622,7 @@ public partial class WeaponPaints
|
|||||||
if (!CommandsCooldown.TryGetValue(player.Slot, out DateTime cooldownEndTime) ||
|
if (!CommandsCooldown.TryGetValue(player.Slot, out DateTime cooldownEndTime) ||
|
||||||
DateTime.UtcNow >= (CommandsCooldown.TryGetValue(player.Slot, out cooldownEndTime) ? cooldownEndTime : DateTime.UtcNow))
|
DateTime.UtcNow >= (CommandsCooldown.TryGetValue(player.Slot, out cooldownEndTime) ? cooldownEndTime : DateTime.UtcNow))
|
||||||
{
|
{
|
||||||
var agentsSelectionMenu = MenuApi?.NewMenu(Localizer["wp_agent_menu_title"]);
|
var agentsSelectionMenu = Utility.CreateMenu(Localizer["wp_agent_menu_title"]);
|
||||||
if (agentsSelectionMenu == null) return;
|
if (agentsSelectionMenu == null) return;
|
||||||
agentsSelectionMenu.PostSelectAction = PostSelectAction.Close;
|
agentsSelectionMenu.PostSelectAction = PostSelectAction.Close;
|
||||||
|
|
||||||
@@ -665,7 +662,7 @@ public partial class WeaponPaints
|
|||||||
|
|
||||||
private void SetupMusicMenu()
|
private void SetupMusicMenu()
|
||||||
{
|
{
|
||||||
var musicSelectionMenu = MenuApi?.NewMenu(Localizer["wp_music_menu_title"]);
|
var musicSelectionMenu = Utility.CreateMenu(Localizer["wp_music_menu_title"]);
|
||||||
if (musicSelectionMenu == null) return;
|
if (musicSelectionMenu == null) return;
|
||||||
musicSelectionMenu.PostSelectAction = PostSelectAction.Close;
|
musicSelectionMenu.PostSelectAction = PostSelectAction.Close;
|
||||||
|
|
||||||
@@ -800,7 +797,7 @@ public partial class WeaponPaints
|
|||||||
|
|
||||||
private void SetupPinsMenu()
|
private void SetupPinsMenu()
|
||||||
{
|
{
|
||||||
var pinsSelectionMenu = MenuApi?.NewMenu(Localizer["wp_pins_menu_title"]);
|
var pinsSelectionMenu = Utility.CreateMenu(Localizer["wp_pins_menu_title"]);
|
||||||
if (pinsSelectionMenu == null) return;
|
if (pinsSelectionMenu == null) return;
|
||||||
pinsSelectionMenu.PostSelectAction = PostSelectAction.Close;
|
pinsSelectionMenu.PostSelectAction = PostSelectAction.Close;
|
||||||
|
|
||||||
|
|||||||
@@ -99,5 +99,8 @@ namespace WeaponPaints
|
|||||||
|
|
||||||
[JsonPropertyName("Additional")]
|
[JsonPropertyName("Additional")]
|
||||||
public Additional Additional { get; set; } = new();
|
public Additional Additional { get; set; } = new();
|
||||||
|
|
||||||
|
[JsonPropertyName("MenuType")]
|
||||||
|
public string MenuType { get; set; } = "selectable";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
48
Events.cs
@@ -79,15 +79,17 @@ namespace WeaponPaints
|
|||||||
IpAddress = player.IpAddress?.Split(":")[0]
|
IpAddress = player.IpAddress?.Split(":")[0]
|
||||||
};
|
};
|
||||||
|
|
||||||
if (WeaponSync != null)
|
Task.Run(async () =>
|
||||||
{
|
{
|
||||||
_ = Task.Run(async () => await WeaponSync.SyncStatTrakToDatabase(playerInfo));
|
if (WeaponSync != null)
|
||||||
}
|
await WeaponSync.SyncStatTrakToDatabase(playerInfo);
|
||||||
|
|
||||||
|
if (Config.Additional.SkinEnabled)
|
||||||
|
{
|
||||||
|
GPlayerWeaponsInfo.TryRemove(player.Slot, out _);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
if (Config.Additional.SkinEnabled)
|
|
||||||
{
|
|
||||||
GPlayerWeaponsInfo.TryRemove(player.Slot, out _);
|
|
||||||
}
|
|
||||||
if (Config.Additional.KnifeEnabled)
|
if (Config.Additional.KnifeEnabled)
|
||||||
{
|
{
|
||||||
GPlayersKnife.TryRemove(player.Slot, out _);
|
GPlayersKnife.TryRemove(player.Slot, out _);
|
||||||
@@ -191,7 +193,7 @@ namespace WeaponPaints
|
|||||||
return HookResult.Continue;
|
return HookResult.Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HookResult OnGiveNamedItemPost(DynamicHook hook)
|
private HookResult OnGiveNamedItemPost(DynamicHook hook)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -202,14 +204,16 @@ namespace WeaponPaints
|
|||||||
|
|
||||||
var player = GetPlayerFromItemServices(itemServices);
|
var player = GetPlayerFromItemServices(itemServices);
|
||||||
if (player != null)
|
if (player != null)
|
||||||
|
{
|
||||||
GivePlayerWeaponSkin(player, weapon);
|
GivePlayerWeaponSkin(player, weapon);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
|
|
||||||
return HookResult.Continue;
|
return HookResult.Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnEntityCreated(CEntityInstance entity)
|
private void OnEntityCreated(CEntityInstance entity)
|
||||||
{
|
{
|
||||||
var designerName = entity.DesignerName;
|
var designerName = entity.DesignerName;
|
||||||
|
|
||||||
@@ -274,10 +278,17 @@ namespace WeaponPaints
|
|||||||
[GameEventHandler]
|
[GameEventHandler]
|
||||||
public HookResult OnItemPickup(EventItemPickup @event, GameEventInfo _)
|
public HookResult OnItemPickup(EventItemPickup @event, GameEventInfo _)
|
||||||
{
|
{
|
||||||
if (!IsWindows) return HookResult.Continue;
|
// if (!IsWindows) return HookResult.Continue;
|
||||||
|
|
||||||
var player = @event.Userid;
|
var player = @event.Userid;
|
||||||
if (player != null && player is { IsValid: true, Connected: PlayerConnectedState.PlayerConnected, PawnIsAlive: true, PlayerPawn.IsValid: true })
|
if (player == null || !player.IsValid || player.IsBot) return HookResult.Continue;
|
||||||
|
if (!@event.Item.Contains("knife")) return HookResult.Continue;
|
||||||
|
|
||||||
|
var weaponDefIndex = (int)@event.Defindex;
|
||||||
|
|
||||||
|
if (!HasChangedKnife(player, out var _) || !HasChangedPaint(player, weaponDefIndex, out var _))
|
||||||
|
return HookResult.Continue;
|
||||||
|
|
||||||
|
if (player is { Connected: PlayerConnectedState.PlayerConnected, PawnIsAlive: true, PlayerPawn.IsValid: true })
|
||||||
{
|
{
|
||||||
GiveOnItemPickup(player);
|
GiveOnItemPickup(player);
|
||||||
}
|
}
|
||||||
@@ -295,20 +306,16 @@ namespace WeaponPaints
|
|||||||
|
|
||||||
if (victim == null || !victim.IsValid || victim == player)
|
if (victim == null || !victim.IsValid || victim == player)
|
||||||
return HookResult.Continue;
|
return HookResult.Continue;
|
||||||
|
|
||||||
if (!GPlayerWeaponsInfo.TryGetValue(player.Slot, out var teamInfo) ||
|
|
||||||
!teamInfo.TryGetValue(player.Team, out var teamWeapons) )
|
|
||||||
return HookResult.Continue;
|
|
||||||
|
|
||||||
CBasePlayerWeapon? weapon = player.PlayerPawn.Value?.WeaponServices?.ActiveWeapon.Value;
|
CBasePlayerWeapon? weapon = player.PlayerPawn.Value?.WeaponServices?.ActiveWeapon.Value;
|
||||||
|
|
||||||
if (weapon == null) return HookResult.Continue;
|
if (weapon == null) return HookResult.Continue;
|
||||||
|
|
||||||
int weaponDefIndex = weapon.AttributeManager.Item.ItemDefinitionIndex;
|
int weaponDefIndex = weapon.AttributeManager.Item.ItemDefinitionIndex;
|
||||||
|
|
||||||
if (!teamWeapons.TryGetValue(weaponDefIndex, out var weaponInfo) || weaponInfo.Paint == 0)
|
if (!HasChangedPaint(player, weaponDefIndex, out var weaponInfo) || weaponInfo == null)
|
||||||
return HookResult.Continue;
|
return HookResult.Continue;
|
||||||
|
|
||||||
if (!weaponInfo.StatTrak) return HookResult.Continue;
|
if (!weaponInfo.StatTrak) return HookResult.Continue;
|
||||||
|
|
||||||
weaponInfo.StatTrakCount += 1;
|
weaponInfo.StatTrakCount += 1;
|
||||||
@@ -336,8 +343,7 @@ namespace WeaponPaints
|
|||||||
if (Config.Additional.ShowSkinImage)
|
if (Config.Additional.ShowSkinImage)
|
||||||
RegisterListener<Listeners.OnTick>(OnTick);
|
RegisterListener<Listeners.OnTick>(OnTick);
|
||||||
|
|
||||||
if (!IsWindows)
|
VirtualFunctions.GiveNamedItemFunc.Hook(OnGiveNamedItemPost, HookMode.Post);
|
||||||
VirtualFunctions.GiveNamedItemFunc.Hook(OnGiveNamedItemPost, HookMode.Post);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
30
Utility.cs
@@ -1,6 +1,8 @@
|
|||||||
using CounterStrikeSharp.API.Core;
|
using CounterStrikeSharp.API.Core;
|
||||||
using CounterStrikeSharp.API.Core.Translations;
|
using CounterStrikeSharp.API.Core.Translations;
|
||||||
|
using CounterStrikeSharp.API.Modules.Menu;
|
||||||
using Dapper;
|
using Dapper;
|
||||||
|
using MenuManager;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
@@ -188,10 +190,32 @@ namespace WeaponPaints
|
|||||||
Console.WriteLine("[WeaponPaints] " + message);
|
Console.WriteLine("[WeaponPaints] " + message);
|
||||||
Console.ResetColor();
|
Console.ResetColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static string ReplaceTags(string message)
|
internal static IMenu? CreateMenu(string title)
|
||||||
{
|
{
|
||||||
return message.ReplaceColorTags();
|
var menuType = WeaponPaints.Instance.Config.MenuType.ToLower();
|
||||||
|
|
||||||
|
var menu = menuType switch
|
||||||
|
{
|
||||||
|
_ when menuType.Equals("selectable", StringComparison.CurrentCultureIgnoreCase) =>
|
||||||
|
WeaponPaints.MenuApi?.NewMenu(title),
|
||||||
|
|
||||||
|
_ when menuType.Equals("dynamic", StringComparison.CurrentCultureIgnoreCase) =>
|
||||||
|
WeaponPaints.MenuApi?.NewMenuForcetype(title, MenuType.ButtonMenu),
|
||||||
|
|
||||||
|
_ when menuType.Equals("center", StringComparison.CurrentCultureIgnoreCase) =>
|
||||||
|
WeaponPaints.MenuApi?.NewMenuForcetype(title, MenuType.CenterMenu),
|
||||||
|
|
||||||
|
_ when menuType.Equals("chat", StringComparison.CurrentCultureIgnoreCase) =>
|
||||||
|
WeaponPaints.MenuApi?.NewMenuForcetype(title, MenuType.ChatMenu),
|
||||||
|
|
||||||
|
_ when menuType.Equals("console", StringComparison.CurrentCultureIgnoreCase) =>
|
||||||
|
WeaponPaints.MenuApi?.NewMenuForcetype(title, MenuType.ConsoleMenu),
|
||||||
|
|
||||||
|
_ => WeaponPaints.MenuApi?.NewMenu(title)
|
||||||
|
};
|
||||||
|
|
||||||
|
return menu;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static async Task CheckVersion(string version, ILogger logger)
|
internal static async Task CheckVersion(string version, ILogger logger)
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ public partial class WeaponPaints
|
|||||||
internal static readonly ConcurrentDictionary<int, ConcurrentDictionary<CsTeam, ushort>> GPlayersGlove = new();
|
internal static readonly ConcurrentDictionary<int, ConcurrentDictionary<CsTeam, ushort>> GPlayersGlove = new();
|
||||||
internal static readonly ConcurrentDictionary<int, ConcurrentDictionary<CsTeam, ushort>> GPlayersMusic = new();
|
internal static readonly ConcurrentDictionary<int, ConcurrentDictionary<CsTeam, ushort>> GPlayersMusic = new();
|
||||||
internal static readonly ConcurrentDictionary<int, ConcurrentDictionary<CsTeam, ushort>> GPlayersPin = new();
|
internal static readonly ConcurrentDictionary<int, ConcurrentDictionary<CsTeam, ushort>> GPlayersPin = new();
|
||||||
public static readonly ConcurrentDictionary<int, (string? CT, string? T)> GPlayersAgent = new();
|
internal static readonly ConcurrentDictionary<int, (string? CT, string? T)> GPlayersAgent = new();
|
||||||
internal static readonly ConcurrentDictionary<int, ConcurrentDictionary<CsTeam, 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 = [];
|
||||||
@@ -92,7 +92,7 @@ public partial class WeaponPaints
|
|||||||
internal static Database? Database;
|
internal static Database? Database;
|
||||||
|
|
||||||
private static readonly MemoryFunctionVoid<nint, string, float> CAttributeListSetOrAddAttributeValueByName = new(GameData.GetSignature("CAttributeList_SetOrAddAttributeValueByName"));
|
private static readonly MemoryFunctionVoid<nint, string, float> CAttributeListSetOrAddAttributeValueByName = new(GameData.GetSignature("CAttributeList_SetOrAddAttributeValueByName"));
|
||||||
|
|
||||||
private static readonly MemoryFunctionWithReturn<nint, string, int, int> SetBodygroupFunc = new(
|
private static readonly MemoryFunctionWithReturn<nint, string, int, int> SetBodygroupFunc = new(
|
||||||
GameData.GetSignature("CBaseModelEntity_SetBodygroup"));
|
GameData.GetSignature("CBaseModelEntity_SetBodygroup"));
|
||||||
|
|
||||||
|
|||||||
152
WeaponAction.cs
@@ -20,27 +20,30 @@ 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) ||
|
switch (isKnife)
|
||||||
isKnife && GPlayersKnife[player.Slot][player.Team] == "weapon_knife") return;
|
|
||||||
|
|
||||||
if (isKnife)
|
|
||||||
{
|
{
|
||||||
var newDefIndex = WeaponDefindex.FirstOrDefault(x => x.Value == GPlayersKnife[player.Slot][player.Team]);
|
case true when !HasChangedKnife(player, out var _):
|
||||||
if (newDefIndex.Key == 0) return;
|
return;
|
||||||
|
|
||||||
if (weapon.AttributeManager.Item.ItemDefinitionIndex != newDefIndex.Key)
|
case true:
|
||||||
{
|
{
|
||||||
SubclassChange(weapon, (ushort)newDefIndex.Key);
|
var newDefIndex = WeaponDefindex.FirstOrDefault(x => x.Value == GPlayersKnife[player.Slot][player.Team]);
|
||||||
}
|
if (newDefIndex.Key == 0) return;
|
||||||
|
|
||||||
weapon.AttributeManager.Item.ItemDefinitionIndex = (ushort)newDefIndex.Key;
|
if (weapon.AttributeManager.Item.ItemDefinitionIndex != newDefIndex.Key)
|
||||||
weapon.AttributeManager.Item.EntityQuality = 3;
|
{
|
||||||
|
SubclassChange(weapon, (ushort)newDefIndex.Key);
|
||||||
|
}
|
||||||
|
|
||||||
|
weapon.AttributeManager.Item.ItemDefinitionIndex = (ushort)newDefIndex.Key;
|
||||||
|
weapon.AttributeManager.Item.EntityQuality = 3;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
weapon.AttributeManager.Item.EntityQuality = 0;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
weapon.AttributeManager.Item.EntityQuality = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
UpdatePlayerEconItemId(weapon.AttributeManager.Item);
|
UpdatePlayerEconItemId(weapon.AttributeManager.Item);
|
||||||
|
|
||||||
int weaponDefIndex = weapon.AttributeManager.Item.ItemDefinitionIndex;
|
int weaponDefIndex = weapon.AttributeManager.Item.ItemDefinitionIndex;
|
||||||
@@ -52,7 +55,7 @@ namespace WeaponPaints
|
|||||||
bool isLegacyModel;
|
bool isLegacyModel;
|
||||||
|
|
||||||
if (_config.Additional.GiveRandomSkin &&
|
if (_config.Additional.GiveRandomSkin &&
|
||||||
!GPlayerWeaponsInfo[player.Slot][player.Team].ContainsKey(weaponDefIndex))
|
!HasChangedPaint(player, weaponDefIndex, out _))
|
||||||
{
|
{
|
||||||
// Random skins
|
// Random skins
|
||||||
weapon.FallbackPaintKit = GetRandomPaint(weaponDefIndex);
|
weapon.FallbackPaintKit = GetRandomPaint(weaponDefIndex);
|
||||||
@@ -85,13 +88,9 @@ namespace WeaponPaints
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!GPlayerWeaponsInfo.TryGetValue(player.Slot, out var teamInfo) ||
|
if (!HasChangedPaint(player, weaponDefIndex, out var weaponInfo) || weaponInfo == null)
|
||||||
!teamInfo.TryGetValue(player.Team, out var teamWeapons) )
|
|
||||||
return;
|
|
||||||
if (!teamWeapons.TryGetValue(weaponDefIndex, out var value))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
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]}");
|
||||||
|
|
||||||
weapon.AttributeManager.Item.AttributeList.Attributes.RemoveAll();
|
weapon.AttributeManager.Item.AttributeList.Attributes.RemoveAll();
|
||||||
@@ -103,21 +102,14 @@ namespace WeaponPaints
|
|||||||
weapon.AttributeManager.Item.CustomName = weaponInfo.Nametag;
|
weapon.AttributeManager.Item.CustomName = weaponInfo.Nametag;
|
||||||
weapon.FallbackPaintKit = weaponInfo.Paint;
|
weapon.FallbackPaintKit = weaponInfo.Paint;
|
||||||
|
|
||||||
if (weaponInfo is { Paint: 38, Seed: 0 })
|
weapon.FallbackSeed = weaponInfo is { Paint: 38, Seed: 0 } ? _fadeSeed++ : weaponInfo.Seed;
|
||||||
{
|
|
||||||
weapon.FallbackSeed = _fadeSeed++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
weapon.FallbackSeed = weaponInfo.Seed;
|
|
||||||
}
|
|
||||||
|
|
||||||
weapon.FallbackWear = weaponInfo.Wear;
|
weapon.FallbackWear = weaponInfo.Wear;
|
||||||
CAttributeListSetOrAddAttributeValueByName.Invoke(weapon.AttributeManager.Item.NetworkedDynamicAttributes.Handle, "set item texture prefab", weapon.FallbackPaintKit);
|
CAttributeListSetOrAddAttributeValueByName.Invoke(weapon.AttributeManager.Item.NetworkedDynamicAttributes.Handle, "set item texture prefab", weapon.FallbackPaintKit);
|
||||||
|
|
||||||
if (weaponInfo.StatTrak)
|
if (weaponInfo.StatTrak)
|
||||||
{
|
{
|
||||||
weapon.AttributeManager.Item.EntityQuality = 7;
|
weapon.AttributeManager.Item.EntityQuality = 9;
|
||||||
|
|
||||||
CAttributeListSetOrAddAttributeValueByName.Invoke(weapon.AttributeManager.Item.NetworkedDynamicAttributes.Handle, "kill eater", ViewAsFloat((uint)weaponInfo.StatTrakCount));
|
CAttributeListSetOrAddAttributeValueByName.Invoke(weapon.AttributeManager.Item.NetworkedDynamicAttributes.Handle, "kill eater", ViewAsFloat((uint)weaponInfo.StatTrakCount));
|
||||||
CAttributeListSetOrAddAttributeValueByName.Invoke(weapon.AttributeManager.Item.NetworkedDynamicAttributes.Handle, "kill eater score type", 0);
|
CAttributeListSetOrAddAttributeValueByName.Invoke(weapon.AttributeManager.Item.NetworkedDynamicAttributes.Handle, "kill eater score type", 0);
|
||||||
@@ -131,8 +123,6 @@ namespace WeaponPaints
|
|||||||
if (fallbackPaintKit == 0)
|
if (fallbackPaintKit == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (isKnife) return;
|
|
||||||
|
|
||||||
if (weaponInfo.KeyChain != null) SetKeychain(player, weapon);
|
if (weaponInfo.KeyChain != null) SetKeychain(player, weapon);
|
||||||
if (weaponInfo.Stickers.Count > 0) SetStickers(player, weapon);
|
if (weaponInfo.Stickers.Count > 0) SetStickers(player, weapon);
|
||||||
|
|
||||||
@@ -143,6 +133,7 @@ namespace WeaponPaints
|
|||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
isLegacyModel = skinInfo.Count <= 0 || skinInfo[0].Value<bool>("legacy_model");
|
isLegacyModel = skinInfo.Count <= 0 || skinInfo[0].Value<bool>("legacy_model");
|
||||||
|
|
||||||
UpdatePlayerWeaponMeshGroupMask(player, weapon, isLegacyModel);
|
UpdatePlayerWeaponMeshGroupMask(player, weapon, isLegacyModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -150,9 +141,7 @@ namespace WeaponPaints
|
|||||||
private void IncrementWearForWeaponWithStickers(CCSPlayerController player, CBasePlayerWeapon weapon)
|
private void IncrementWearForWeaponWithStickers(CCSPlayerController player, CBasePlayerWeapon weapon)
|
||||||
{
|
{
|
||||||
int weaponDefIndex = weapon.AttributeManager.Item.ItemDefinitionIndex;
|
int weaponDefIndex = weapon.AttributeManager.Item.ItemDefinitionIndex;
|
||||||
if (!GPlayerWeaponsInfo.TryGetValue(player.Slot, out var playerWeapons) ||
|
if (!HasChangedPaint(player, weaponDefIndex, out var weaponInfo) || weaponInfo == null ||
|
||||||
!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;
|
||||||
@@ -175,11 +164,8 @@ namespace WeaponPaints
|
|||||||
|
|
||||||
int weaponDefIndex = weapon.AttributeManager.Item.ItemDefinitionIndex;
|
int weaponDefIndex = weapon.AttributeManager.Item.ItemDefinitionIndex;
|
||||||
|
|
||||||
if (!GPlayerWeaponsInfo.TryGetValue(player.Slot, out var playerWeapons) ||
|
if (!HasChangedPaint(player ,weaponDefIndex, out var weaponInfo) || weaponInfo == null)
|
||||||
!playerWeapons[player.Team].TryGetValue(weaponDefIndex, out var weaponInfo))
|
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var sticker in weaponInfo.Stickers)
|
foreach (var sticker in weaponInfo.Stickers)
|
||||||
{
|
{
|
||||||
@@ -187,15 +173,13 @@ namespace WeaponPaints
|
|||||||
|
|
||||||
CAttributeListSetOrAddAttributeValueByName.Invoke(weapon.AttributeManager.Item.NetworkedDynamicAttributes.Handle,
|
CAttributeListSetOrAddAttributeValueByName.Invoke(weapon.AttributeManager.Item.NetworkedDynamicAttributes.Handle,
|
||||||
$"sticker slot {stickerSlot} id", ViewAsFloat(sticker.Id));
|
$"sticker slot {stickerSlot} id", ViewAsFloat(sticker.Id));
|
||||||
// CAttributeListSetOrAddAttributeValueByName.Invoke(weapon.AttributeManager.Item.NetworkedDynamicAttributes.Handle,
|
if (sticker.OffsetX != 0 || sticker.OffsetY != 0)
|
||||||
// $"sticker slot {stickerSlot} schema", stickerSlot);
|
CAttributeListSetOrAddAttributeValueByName.Invoke(weapon.AttributeManager.Item.NetworkedDynamicAttributes.Handle,
|
||||||
// if (stickerSlot == 5)
|
$"sticker slot {stickerSlot} schema", 0);
|
||||||
// {
|
|
||||||
CAttributeListSetOrAddAttributeValueByName.Invoke(weapon.AttributeManager.Item.NetworkedDynamicAttributes.Handle,
|
CAttributeListSetOrAddAttributeValueByName.Invoke(weapon.AttributeManager.Item.NetworkedDynamicAttributes.Handle,
|
||||||
$"sticker slot {stickerSlot} offset x", sticker.OffsetX);
|
$"sticker slot {stickerSlot} offset x", sticker.OffsetX);
|
||||||
CAttributeListSetOrAddAttributeValueByName.Invoke(weapon.AttributeManager.Item.NetworkedDynamicAttributes.Handle,
|
CAttributeListSetOrAddAttributeValueByName.Invoke(weapon.AttributeManager.Item.NetworkedDynamicAttributes.Handle,
|
||||||
$"sticker slot {stickerSlot} offset y", sticker.OffsetY);
|
$"sticker slot {stickerSlot} offset y", sticker.OffsetY);
|
||||||
// }
|
|
||||||
CAttributeListSetOrAddAttributeValueByName.Invoke(weapon.AttributeManager.Item.NetworkedDynamicAttributes.Handle,
|
CAttributeListSetOrAddAttributeValueByName.Invoke(weapon.AttributeManager.Item.NetworkedDynamicAttributes.Handle,
|
||||||
$"sticker slot {stickerSlot} wear", sticker.Wear);
|
$"sticker slot {stickerSlot} wear", sticker.Wear);
|
||||||
CAttributeListSetOrAddAttributeValueByName.Invoke(weapon.AttributeManager.Item.NetworkedDynamicAttributes.Handle,
|
CAttributeListSetOrAddAttributeValueByName.Invoke(weapon.AttributeManager.Item.NetworkedDynamicAttributes.Handle,
|
||||||
@@ -217,9 +201,9 @@ namespace WeaponPaints
|
|||||||
|
|
||||||
int weaponDefIndex = weapon.AttributeManager.Item.ItemDefinitionIndex;
|
int weaponDefIndex = weapon.AttributeManager.Item.ItemDefinitionIndex;
|
||||||
|
|
||||||
if (!GPlayerWeaponsInfo.TryGetValue(player.Slot, out var playerWeaponsInfo) ||
|
if (!HasChangedPaint(player, weaponDefIndex, out var value) || value?.KeyChain == null)
|
||||||
!playerWeaponsInfo[player.Team].TryGetValue(weaponDefIndex, out var value) ||
|
return;
|
||||||
value.KeyChain == null) return;
|
|
||||||
var keyChain = value.KeyChain;
|
var keyChain = value.KeyChain;
|
||||||
|
|
||||||
CAttributeListSetOrAddAttributeValueByName.Invoke(weapon.AttributeManager.Item.NetworkedDynamicAttributes.Handle,
|
CAttributeListSetOrAddAttributeValueByName.Invoke(weapon.AttributeManager.Item.NetworkedDynamicAttributes.Handle,
|
||||||
@@ -242,6 +226,7 @@ namespace WeaponPaints
|
|||||||
|
|
||||||
//string knifeToGive = (CsTeam)player.TeamNum == CsTeam.Terrorist ? "weapon_knife_t" : "weapon_knife";
|
//string knifeToGive = (CsTeam)player.TeamNum == CsTeam.Terrorist ? "weapon_knife_t" : "weapon_knife";
|
||||||
player.GiveNamedItem(CsItem.Knife);
|
player.GiveNamedItem(CsItem.Knife);
|
||||||
|
Utilities.SetStateChanged(player, "CCSPlayerController", "m_pInventoryServices");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool PlayerHasKnife(CCSPlayerController? player)
|
private static bool PlayerHasKnife(CCSPlayerController? player)
|
||||||
@@ -284,6 +269,8 @@ namespace WeaponPaints
|
|||||||
if (player.Team is CsTeam.None or CsTeam.Spectator)
|
if (player.Team is CsTeam.None or CsTeam.Spectator)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
var hasKnife = false;
|
||||||
|
|
||||||
Dictionary<string, List<(int, int)>> weaponsWithAmmo = [];
|
Dictionary<string, List<(int, int)>> weaponsWithAmmo = [];
|
||||||
|
|
||||||
foreach (var weapon in weapons)
|
foreach (var weapon in weapons)
|
||||||
@@ -291,7 +278,7 @@ namespace WeaponPaints
|
|||||||
if (!weapon.IsValid || weapon.Value == null ||
|
if (!weapon.IsValid || weapon.Value == null ||
|
||||||
!weapon.Value.IsValid || !weapon.Value.DesignerName.Contains("weapon_"))
|
!weapon.Value.IsValid || !weapon.Value.DesignerName.Contains("weapon_"))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
CCSWeaponBaseGun gun = weapon.Value.As<CCSWeaponBaseGun>();
|
CCSWeaponBaseGun gun = weapon.Value.As<CCSWeaponBaseGun>();
|
||||||
|
|
||||||
if (weapon.Value.Entity == null) continue;
|
if (weapon.Value.Entity == null) continue;
|
||||||
@@ -330,6 +317,7 @@ namespace WeaponPaints
|
|||||||
if (weaponData.GearSlot == gear_slot_t.GEAR_SLOT_KNIFE)
|
if (weaponData.GearSlot == gear_slot_t.GEAR_SLOT_KNIFE)
|
||||||
{
|
{
|
||||||
weapon.Value?.AddEntityIOEvent("Kill", weapon.Value, null, "", 0.1f);
|
weapon.Value?.AddEntityIOEvent("Kill", weapon.Value, null, "", 0.1f);
|
||||||
|
hasKnife = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -341,9 +329,16 @@ namespace WeaponPaints
|
|||||||
AddTimer(0.23f, () =>
|
AddTimer(0.23f, () =>
|
||||||
{
|
{
|
||||||
if (!_gBCommandsAllowed) return;
|
if (!_gBCommandsAllowed) return;
|
||||||
|
|
||||||
if (!PlayerHasKnife(player))
|
if (!PlayerHasKnife(player) && hasKnife)
|
||||||
GiveKnifeToPlayer(player);
|
{
|
||||||
|
var newKnife = new CBasePlayerWeapon(player.GiveNamedItem(CsItem.Knife));
|
||||||
|
newKnife.AddEntityIOEvent("Kill", newKnife, null, "", 0.01f);
|
||||||
|
var newWeapon = new CBasePlayerWeapon(player.GiveNamedItem(CsItem.USP));
|
||||||
|
player.GiveNamedItem(CsItem.Knife);
|
||||||
|
player.ExecuteClientCommand("slot3");
|
||||||
|
newWeapon.AddEntityIOEvent("Kill", newWeapon, null, "", 0.01f);
|
||||||
|
}
|
||||||
|
|
||||||
foreach (var entry in weaponsWithAmmo)
|
foreach (var entry in weaponsWithAmmo)
|
||||||
{
|
{
|
||||||
@@ -396,9 +391,10 @@ namespace WeaponPaints
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (!GPlayersGlove.TryGetValue(player.Slot, out var gloveInfo) ||
|
if (!GPlayersGlove.TryGetValue(player.Slot, out var gloveInfo) ||
|
||||||
!gloveInfo.TryGetValue(player.Team, out var gloveId) || gloveId == 0) return;
|
!gloveInfo.TryGetValue(player.Team, out var gloveId) ||
|
||||||
|
gloveId == 0 ||
|
||||||
WeaponInfo weaponInfo = GPlayerWeaponsInfo[player.Slot][player.Team][gloveId];
|
!HasChangedPaint(player, gloveId, out var weaponInfo) || weaponInfo == null)
|
||||||
|
return;
|
||||||
|
|
||||||
item.ItemDefinitionIndex = gloveId;
|
item.ItemDefinitionIndex = gloveId;
|
||||||
item.ItemIDLow = 16384 & 0xFFFFFFFF;
|
item.ItemIDLow = 16384 & 0xFFFFFFFF;
|
||||||
@@ -462,6 +458,7 @@ namespace WeaponPaints
|
|||||||
var viewModel = GetPlayerViewModel(player);
|
var viewModel = GetPlayerViewModel(player);
|
||||||
if (viewModel == null || viewModel.Weapon.Value == null ||
|
if (viewModel == null || viewModel.Weapon.Value == null ||
|
||||||
viewModel.Weapon.Value.Index != weapon.Index) return;
|
viewModel.Weapon.Value.Index != weapon.Index) return;
|
||||||
|
|
||||||
UpdateWeaponMeshGroupMask(viewModel, isLegacy);
|
UpdateWeaponMeshGroupMask(viewModel, isLegacy);
|
||||||
Utilities.SetStateChanged(viewModel, "CBaseEntity", "m_CBodyComponent");
|
Utilities.SetStateChanged(viewModel, "CBaseEntity", "m_CBodyComponent");
|
||||||
}
|
}
|
||||||
@@ -525,13 +522,22 @@ namespace WeaponPaints
|
|||||||
|
|
||||||
var myWeapons = pawn.WeaponServices?.MyWeapons;
|
var myWeapons = pawn.WeaponServices?.MyWeapons;
|
||||||
if (myWeapons == null) return;
|
if (myWeapons == null) return;
|
||||||
|
|
||||||
foreach (var handle in myWeapons)
|
foreach (var handle in myWeapons)
|
||||||
{
|
{
|
||||||
var weapon = handle.Value;
|
var weapon = handle.Value;
|
||||||
if (weapon != null && weapon.DesignerName.Contains("knife"))
|
|
||||||
|
if (weapon == null || !weapon.IsValid) continue;
|
||||||
|
if (myWeapons.Count == 1)
|
||||||
{
|
{
|
||||||
GivePlayerWeaponSkin(player, weapon);
|
var newWeapon = new CBasePlayerWeapon(player.GiveNamedItem(CsItem.USP));
|
||||||
|
weapon.AddEntityIOEvent("Kill", weapon, null, "", 0.01f);
|
||||||
|
player.GiveNamedItem(CsItem.Knife);
|
||||||
|
player.ExecuteClientCommand("slot3");
|
||||||
|
newWeapon.AddEntityIOEvent("Kill", newWeapon, null, "", 0.01f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GivePlayerWeaponSkin(player, weapon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -562,6 +568,36 @@ namespace WeaponPaints
|
|||||||
return viewModel.Value == null ? null : viewModel.Value;
|
return viewModel.Value == null ? null : viewModel.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static bool HasChangedKnife(CCSPlayerController player, out string? knifeValue)
|
||||||
|
{
|
||||||
|
knifeValue = null;
|
||||||
|
|
||||||
|
// Check if player has knife info for their slot and team
|
||||||
|
if (!GPlayersKnife.TryGetValue(player.Slot, out var knife) ||
|
||||||
|
!knife.TryGetValue(player.Team, out var value) ||
|
||||||
|
value == "weapon_knife") return false;
|
||||||
|
knifeValue = value; // Assign the knife value to the out parameter
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool HasChangedPaint(CCSPlayerController player, int weaponDefIndex, out WeaponInfo? weaponInfo)
|
||||||
|
{
|
||||||
|
weaponInfo = null;
|
||||||
|
|
||||||
|
// Check if player has weapons info for their slot and team
|
||||||
|
if (!GPlayerWeaponsInfo.TryGetValue(player.Slot, out var teamInfo) ||
|
||||||
|
!teamInfo.TryGetValue(player.Team, out var teamWeapons))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if the specified weapon has a paint/skin change
|
||||||
|
if (!teamWeapons.TryGetValue(weaponDefIndex, out var value) || value.Paint <= 0) return false;
|
||||||
|
|
||||||
|
weaponInfo = value; // Assign the out variable when it exists
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
private static float ViewAsFloat(uint value)
|
private static float ViewAsFloat(uint value)
|
||||||
{
|
{
|
||||||
return BitConverter.Int32BitsToSingle((int)value);
|
return BitConverter.Int32BitsToSingle((int)value);
|
||||||
|
|||||||
@@ -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 => "3.0b";
|
public override string ModuleVersion => "3.1c";
|
||||||
|
|
||||||
public override void Load(bool hotReload)
|
public override void Load(bool hotReload)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
using MySqlConnector;
|
using MySqlConnector;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using CounterStrikeSharp.API.Modules.Utils;
|
using CounterStrikeSharp.API.Modules.Utils;
|
||||||
|
using System.Globalization;
|
||||||
|
|
||||||
namespace WeaponPaints;
|
namespace WeaponPaints;
|
||||||
|
|
||||||
@@ -50,7 +50,7 @@ internal class WeaponSynchronization
|
|||||||
if (!_config.Additional.KnifeEnabled || string.IsNullOrEmpty(player?.SteamId))
|
if (!_config.Additional.KnifeEnabled || string.IsNullOrEmpty(player?.SteamId))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const string query = "SELECT `knife`, `weapon_team` FROM `wp_player_knife` WHERE `steamid` = @steamid";
|
const string query = "SELECT `knife`, `weapon_team` FROM `wp_player_knife` WHERE `steamid` = @steamid ORDER BY `weapon_team` ASC";
|
||||||
var rows = connection.Query<dynamic>(query, new { steamid = player.SteamId }); // Retrieve all records for the player
|
var rows = connection.Query<dynamic>(query, new { steamid = player.SteamId }); // Retrieve all records for the player
|
||||||
|
|
||||||
foreach (var row in rows)
|
foreach (var row in rows)
|
||||||
@@ -61,9 +61,9 @@ internal class WeaponSynchronization
|
|||||||
// Determine the weapon team based on the query result
|
// Determine the weapon team based on the query result
|
||||||
CsTeam weaponTeam = (int)row.weapon_team switch
|
CsTeam weaponTeam = (int)row.weapon_team switch
|
||||||
{
|
{
|
||||||
0 => CsTeam.None,
|
|
||||||
2 => CsTeam.Terrorist,
|
2 => CsTeam.Terrorist,
|
||||||
_ => CsTeam.CounterTerrorist
|
3 => CsTeam.CounterTerrorist,
|
||||||
|
_ => CsTeam.None,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Get or create entries for the player’s slot
|
// Get or create entries for the player’s slot
|
||||||
@@ -95,7 +95,7 @@ internal class WeaponSynchronization
|
|||||||
if (!_config.Additional.GloveEnabled || string.IsNullOrEmpty(player?.SteamId))
|
if (!_config.Additional.GloveEnabled || string.IsNullOrEmpty(player?.SteamId))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const string query = "SELECT `weapon_defindex`, `weapon_team` FROM `wp_player_gloves` WHERE `steamid` = @steamid";
|
const string query = "SELECT `weapon_defindex`, `weapon_team` FROM `wp_player_gloves` WHERE `steamid` = @steamid ORDER BY `weapon_team` ASC";
|
||||||
var rows = connection.Query<dynamic>(query, new { steamid = player.SteamId }); // Retrieve all records for the player
|
var rows = connection.Query<dynamic>(query, new { steamid = player.SteamId }); // Retrieve all records for the player
|
||||||
|
|
||||||
foreach (var row in rows)
|
foreach (var row in rows)
|
||||||
@@ -106,9 +106,9 @@ internal class WeaponSynchronization
|
|||||||
var playerGloves = WeaponPaints.GPlayersGlove.GetOrAdd(player.Slot, _ => new ConcurrentDictionary<CsTeam, ushort>());
|
var playerGloves = WeaponPaints.GPlayersGlove.GetOrAdd(player.Slot, _ => new ConcurrentDictionary<CsTeam, ushort>());
|
||||||
CsTeam weaponTeam = (int)row.weapon_team switch
|
CsTeam weaponTeam = (int)row.weapon_team switch
|
||||||
{
|
{
|
||||||
0 => CsTeam.None,
|
|
||||||
2 => CsTeam.Terrorist,
|
2 => CsTeam.Terrorist,
|
||||||
_ => CsTeam.CounterTerrorist
|
3 => CsTeam.CounterTerrorist,
|
||||||
|
_ => CsTeam.None,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Get or create entries for the player’s slot
|
// Get or create entries for the player’s slot
|
||||||
@@ -172,36 +172,35 @@ internal class WeaponSynchronization
|
|||||||
|
|
||||||
// var weaponInfos = new ConcurrentDictionary<int, WeaponInfo>();
|
// var weaponInfos = new ConcurrentDictionary<int, WeaponInfo>();
|
||||||
|
|
||||||
const string query = "SELECT * FROM `wp_player_skins` WHERE `steamid` = @steamid";
|
const string query = "SELECT * FROM `wp_player_skins` WHERE `steamid` = @steamid ORDER BY `weapon_team` ASC";
|
||||||
var playerSkins = connection.Query<dynamic>(query, new { steamid = player.SteamId });
|
var playerSkins = connection.Query<dynamic>(query, new { steamid = player.SteamId });
|
||||||
|
|
||||||
foreach (var row in playerSkins)
|
foreach (var row in playerSkins)
|
||||||
{
|
{
|
||||||
int weaponDefIndex = row?.weapon_defindex ?? 0;
|
int weaponDefIndex = row.weapon_defindex ?? 0;
|
||||||
int weaponPaintId = row?.weapon_paint_id ?? 0;
|
int weaponPaintId = row.weapon_paint_id ?? 0;
|
||||||
float weaponWear = row?.weapon_wear ?? 0f;
|
float weaponWear = row.weapon_wear ?? 0f;
|
||||||
int weaponSeed = row?.weapon_seed ?? 0;
|
int weaponSeed = row.weapon_seed ?? 0;
|
||||||
string weaponNameTag = row?.weapon_nametag ?? "";
|
string weaponNameTag = row.weapon_nametag ?? "";
|
||||||
bool weaponStatTrak = row?.weapon_stattrak ?? false;
|
bool weaponStatTrak = row.weapon_stattrak ?? false;
|
||||||
int weaponStatTrakCount = row?.weapon_stattrak_count ?? 0;
|
int weaponStatTrakCount = row.weapon_stattrak_count ?? 0;
|
||||||
|
|
||||||
CsTeam weaponTeam = row?.weapon_team switch
|
CsTeam weaponTeam = row.weapon_team switch
|
||||||
{
|
{
|
||||||
null => CsTeam.None,
|
|
||||||
0 => CsTeam.None,
|
|
||||||
2 => CsTeam.Terrorist,
|
2 => CsTeam.Terrorist,
|
||||||
_ => CsTeam.CounterTerrorist
|
3 => CsTeam.CounterTerrorist,
|
||||||
|
_ => CsTeam.None,
|
||||||
};
|
};
|
||||||
|
|
||||||
string[]? keyChainParts = row?.weapon_keychain?.ToString().Split(';');
|
string[]? keyChainParts = row.weapon_keychain?.ToString().Split(';');
|
||||||
|
|
||||||
KeyChainInfo keyChainInfo = new KeyChainInfo();
|
KeyChainInfo keyChainInfo = new KeyChainInfo();
|
||||||
|
|
||||||
if (keyChainParts!.Length == 5 &&
|
if (keyChainParts!.Length == 5 &&
|
||||||
uint.TryParse(keyChainParts[0], out uint keyChainId) &&
|
uint.TryParse(keyChainParts[0], out uint keyChainId) &&
|
||||||
float.TryParse(keyChainParts[1], out float keyChainOffsetX) &&
|
float.TryParse(keyChainParts[1], NumberStyles.Float, CultureInfo.InvariantCulture, out float keyChainOffsetX) &&
|
||||||
float.TryParse(keyChainParts[2], out float keyChainOffsetY) &&
|
float.TryParse(keyChainParts[2], NumberStyles.Float, CultureInfo.InvariantCulture, out float keyChainOffsetY) &&
|
||||||
float.TryParse(keyChainParts[3], out float keyChainOffsetZ) &&
|
float.TryParse(keyChainParts[3], NumberStyles.Float, CultureInfo.InvariantCulture, out float keyChainOffsetZ) &&
|
||||||
uint.TryParse(keyChainParts[4], out uint keyChainSeed))
|
uint.TryParse(keyChainParts[4], out uint keyChainSeed))
|
||||||
{
|
{
|
||||||
// Successfully parsed the values
|
// Successfully parsed the values
|
||||||
@@ -248,11 +247,11 @@ internal class WeaponSynchronization
|
|||||||
if (parts.Length != 7 ||
|
if (parts.Length != 7 ||
|
||||||
!uint.TryParse(parts[0], out uint stickerId) ||
|
!uint.TryParse(parts[0], out uint stickerId) ||
|
||||||
!uint.TryParse(parts[1], out uint stickerSchema) ||
|
!uint.TryParse(parts[1], out uint stickerSchema) ||
|
||||||
!float.TryParse(parts[2], out float stickerOffsetX) ||
|
!float.TryParse(parts[2], NumberStyles.Float, CultureInfo.InvariantCulture, out float stickerOffsetX) ||
|
||||||
!float.TryParse(parts[3], out float stickerOffsetY) ||
|
!float.TryParse(parts[3], NumberStyles.Float, CultureInfo.InvariantCulture, out float stickerOffsetY) ||
|
||||||
!float.TryParse(parts[4], out float stickerWear) ||
|
!float.TryParse(parts[4], NumberStyles.Float, CultureInfo.InvariantCulture, out float stickerWear) ||
|
||||||
!float.TryParse(parts[5], out float stickerScale) ||
|
!float.TryParse(parts[5], NumberStyles.Float, CultureInfo.InvariantCulture, out float stickerScale) ||
|
||||||
!float.TryParse(parts[6], out float stickerRotation)) continue;
|
!float.TryParse(parts[6], NumberStyles.Float, CultureInfo.InvariantCulture, out float stickerRotation)) continue;
|
||||||
|
|
||||||
StickerInfo stickerInfo = new StickerInfo
|
StickerInfo stickerInfo = new StickerInfo
|
||||||
{
|
{
|
||||||
@@ -303,7 +302,7 @@ internal class WeaponSynchronization
|
|||||||
if (!_config.Additional.MusicEnabled || string.IsNullOrEmpty(player?.SteamId))
|
if (!_config.Additional.MusicEnabled || string.IsNullOrEmpty(player?.SteamId))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const string query = "SELECT `music_id`, `weapon_team` FROM `wp_player_music` WHERE `steamid` = @steamid";
|
const string query = "SELECT `music_id`, `weapon_team` FROM `wp_player_music` WHERE `steamid` = @steamid ORDER BY `weapon_team` ASC";
|
||||||
var rows = connection.Query<dynamic>(query, new { steamid = player.SteamId }); // Retrieve all records for the player
|
var rows = connection.Query<dynamic>(query, new { steamid = player.SteamId }); // Retrieve all records for the player
|
||||||
|
|
||||||
foreach (var row in rows)
|
foreach (var row in rows)
|
||||||
@@ -314,9 +313,9 @@ internal class WeaponSynchronization
|
|||||||
// Determine the weapon team based on the query result
|
// Determine the weapon team based on the query result
|
||||||
CsTeam weaponTeam = (int)row.weapon_team switch
|
CsTeam weaponTeam = (int)row.weapon_team switch
|
||||||
{
|
{
|
||||||
0 => CsTeam.None,
|
|
||||||
2 => CsTeam.Terrorist,
|
2 => CsTeam.Terrorist,
|
||||||
_ => CsTeam.CounterTerrorist
|
3 => CsTeam.CounterTerrorist,
|
||||||
|
_ => CsTeam.None,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Get or create entries for the player’s slot
|
// Get or create entries for the player’s slot
|
||||||
@@ -348,7 +347,7 @@ internal class WeaponSynchronization
|
|||||||
if (string.IsNullOrEmpty(player?.SteamId))
|
if (string.IsNullOrEmpty(player?.SteamId))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const string query = "SELECT `id`, `weapon_team` FROM `wp_player_pins` WHERE `steamid` = @steamid";
|
const string query = "SELECT `id`, `weapon_team` FROM `wp_player_pins` WHERE `steamid` = @steamid ORDER BY `weapon_team` ASC";
|
||||||
var rows = connection.Query<dynamic>(query, new { steamid = player.SteamId }); // Retrieve all records for the player
|
var rows = connection.Query<dynamic>(query, new { steamid = player.SteamId }); // Retrieve all records for the player
|
||||||
|
|
||||||
foreach (var row in rows)
|
foreach (var row in rows)
|
||||||
@@ -359,9 +358,9 @@ internal class WeaponSynchronization
|
|||||||
// Determine the weapon team based on the query result
|
// Determine the weapon team based on the query result
|
||||||
CsTeam weaponTeam = (int)row.weapon_team switch
|
CsTeam weaponTeam = (int)row.weapon_team switch
|
||||||
{
|
{
|
||||||
0 => CsTeam.None,
|
|
||||||
2 => CsTeam.Terrorist,
|
2 => CsTeam.Terrorist,
|
||||||
_ => CsTeam.CounterTerrorist
|
3 => CsTeam.CounterTerrorist,
|
||||||
|
_ => CsTeam.None,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Get or create entries for the player’s slot
|
// Get or create entries for the player’s slot
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 88 KiB After Width: | Height: | Size: 88 KiB |
|
Before Width: | Height: | Size: 93 KiB After Width: | Height: | Size: 93 KiB |
|
Before Width: | Height: | Size: 71 KiB After Width: | Height: | Size: 73 KiB |
|
Before Width: | Height: | Size: 83 KiB After Width: | Height: | Size: 84 KiB |
|
Before Width: | Height: | Size: 85 KiB After Width: | Height: | Size: 85 KiB |
BIN
website/img/skins/weapon_ak47-113.png
Normal file
|
After Width: | Height: | Size: 94 KiB |
|
Before Width: | Height: | Size: 102 KiB After Width: | Height: | Size: 102 KiB |
|
Before Width: | Height: | Size: 86 KiB After Width: | Height: | Size: 87 KiB |
|
Before Width: | Height: | Size: 90 KiB After Width: | Height: | Size: 90 KiB |
BIN
website/img/skins/weapon_ak47-1179.png
Normal file
|
After Width: | Height: | Size: 79 KiB |
|
Before Width: | Height: | Size: 76 KiB After Width: | Height: | Size: 76 KiB |
|
Before Width: | Height: | Size: 95 KiB After Width: | Height: | Size: 95 KiB |
|
Before Width: | Height: | Size: 82 KiB After Width: | Height: | Size: 82 KiB |
|
Before Width: | Height: | Size: 81 KiB After Width: | Height: | Size: 81 KiB |
BIN
website/img/skins/weapon_ak47-142.png
Normal file
|
After Width: | Height: | Size: 92 KiB |
|
Before Width: | Height: | Size: 76 KiB After Width: | Height: | Size: 77 KiB |
|
Before Width: | Height: | Size: 84 KiB After Width: | Height: | Size: 85 KiB |
|
Before Width: | Height: | Size: 85 KiB After Width: | Height: | Size: 86 KiB |
|
Before Width: | Height: | Size: 83 KiB After Width: | Height: | Size: 84 KiB |
|
Before Width: | Height: | Size: 70 KiB After Width: | Height: | Size: 72 KiB |
|
Before Width: | Height: | Size: 78 KiB After Width: | Height: | Size: 79 KiB |
|
Before Width: | Height: | Size: 85 KiB After Width: | Height: | Size: 85 KiB |
|
Before Width: | Height: | Size: 91 KiB After Width: | Height: | Size: 92 KiB |
|
Before Width: | Height: | Size: 85 KiB After Width: | Height: | Size: 85 KiB |
|
Before Width: | Height: | Size: 75 KiB After Width: | Height: | Size: 76 KiB |
|
Before Width: | Height: | Size: 90 KiB After Width: | Height: | Size: 90 KiB |
|
Before Width: | Height: | Size: 82 KiB After Width: | Height: | Size: 83 KiB |
|
Before Width: | Height: | Size: 70 KiB After Width: | Height: | Size: 72 KiB |
|
Before Width: | Height: | Size: 84 KiB After Width: | Height: | Size: 84 KiB |
|
Before Width: | Height: | Size: 79 KiB After Width: | Height: | Size: 79 KiB |
|
Before Width: | Height: | Size: 84 KiB After Width: | Height: | Size: 85 KiB |
|
Before Width: | Height: | Size: 96 KiB After Width: | Height: | Size: 96 KiB |
|
Before Width: | Height: | Size: 91 KiB After Width: | Height: | Size: 91 KiB |
|
Before Width: | Height: | Size: 86 KiB After Width: | Height: | Size: 87 KiB |
|
Before Width: | Height: | Size: 90 KiB After Width: | Height: | Size: 90 KiB |
|
Before Width: | Height: | Size: 87 KiB After Width: | Height: | Size: 87 KiB |
|
Before Width: | Height: | Size: 75 KiB After Width: | Height: | Size: 76 KiB |
|
Before Width: | Height: | Size: 89 KiB After Width: | Height: | Size: 90 KiB |
|
Before Width: | Height: | Size: 98 KiB After Width: | Height: | Size: 98 KiB |
|
Before Width: | Height: | Size: 77 KiB After Width: | Height: | Size: 78 KiB |
|
Before Width: | Height: | Size: 90 KiB After Width: | Height: | Size: 90 KiB |
|
Before Width: | Height: | Size: 79 KiB After Width: | Height: | Size: 80 KiB |
|
Before Width: | Height: | Size: 84 KiB After Width: | Height: | Size: 85 KiB |
|
Before Width: | Height: | Size: 78 KiB After Width: | Height: | Size: 79 KiB |
|
Before Width: | Height: | Size: 80 KiB After Width: | Height: | Size: 80 KiB |
|
Before Width: | Height: | Size: 89 KiB After Width: | Height: | Size: 90 KiB |
BIN
website/img/skins/weapon_ak47-912.png
Normal file
|
After Width: | Height: | Size: 80 KiB |
|
Before Width: | Height: | Size: 85 KiB After Width: | Height: | Size: 86 KiB |
|
Before Width: | Height: | Size: 89 KiB After Width: | Height: | Size: 89 KiB |
|
Before Width: | Height: | Size: 81 KiB After Width: | Height: | Size: 81 KiB |
|
Before Width: | Height: | Size: 116 KiB After Width: | Height: | Size: 117 KiB |
|
Before Width: | Height: | Size: 107 KiB After Width: | Height: | Size: 108 KiB |
|
Before Width: | Height: | Size: 105 KiB After Width: | Height: | Size: 107 KiB |
|
Before Width: | Height: | Size: 116 KiB After Width: | Height: | Size: 117 KiB |
|
Before Width: | Height: | Size: 110 KiB After Width: | Height: | Size: 112 KiB |
BIN
website/img/skins/weapon_aug-121.png
Normal file
|
After Width: | Height: | Size: 104 KiB |
|
Before Width: | Height: | Size: 122 KiB After Width: | Height: | Size: 123 KiB |
BIN
website/img/skins/weapon_aug-134.png
Normal file
|
After Width: | Height: | Size: 127 KiB |
BIN
website/img/skins/weapon_aug-173.png
Normal file
|
After Width: | Height: | Size: 116 KiB |
|
Before Width: | Height: | Size: 102 KiB After Width: | Height: | Size: 104 KiB |
|
Before Width: | Height: | Size: 103 KiB After Width: | Height: | Size: 105 KiB |
|
Before Width: | Height: | Size: 107 KiB After Width: | Height: | Size: 109 KiB |
|
Before Width: | Height: | Size: 101 KiB After Width: | Height: | Size: 103 KiB |
|
Before Width: | Height: | Size: 101 KiB After Width: | Height: | Size: 103 KiB |
|
Before Width: | Height: | Size: 112 KiB After Width: | Height: | Size: 113 KiB |
|
Before Width: | Height: | Size: 121 KiB After Width: | Height: | Size: 121 KiB |
|
Before Width: | Height: | Size: 114 KiB After Width: | Height: | Size: 116 KiB |
|
Before Width: | Height: | Size: 105 KiB After Width: | Height: | Size: 107 KiB |
|
Before Width: | Height: | Size: 109 KiB After Width: | Height: | Size: 111 KiB |
|
Before Width: | Height: | Size: 118 KiB After Width: | Height: | Size: 119 KiB |
|
Before Width: | Height: | Size: 123 KiB After Width: | Height: | Size: 124 KiB |
|
Before Width: | Height: | Size: 115 KiB After Width: | Height: | Size: 116 KiB |
|
Before Width: | Height: | Size: 114 KiB After Width: | Height: | Size: 115 KiB |
|
Before Width: | Height: | Size: 114 KiB After Width: | Height: | Size: 115 KiB |
|
Before Width: | Height: | Size: 121 KiB After Width: | Height: | Size: 122 KiB |
|
Before Width: | Height: | Size: 113 KiB After Width: | Height: | Size: 115 KiB |
|
Before Width: | Height: | Size: 117 KiB After Width: | Height: | Size: 119 KiB |
|
Before Width: | Height: | Size: 107 KiB After Width: | Height: | Size: 109 KiB |
|
Before Width: | Height: | Size: 105 KiB After Width: | Height: | Size: 106 KiB |
|
Before Width: | Height: | Size: 117 KiB After Width: | Height: | Size: 118 KiB |
|
Before Width: | Height: | Size: 111 KiB After Width: | Height: | Size: 112 KiB |
|
Before Width: | Height: | Size: 116 KiB After Width: | Height: | Size: 116 KiB |
|
Before Width: | Height: | Size: 110 KiB After Width: | Height: | Size: 111 KiB |
|
Before Width: | Height: | Size: 116 KiB After Width: | Height: | Size: 117 KiB |
|
Before Width: | Height: | Size: 107 KiB After Width: | Height: | Size: 108 KiB |
|
Before Width: | Height: | Size: 115 KiB After Width: | Height: | Size: 116 KiB |
|
Before Width: | Height: | Size: 119 KiB After Width: | Height: | Size: 120 KiB |
|
Before Width: | Height: | Size: 116 KiB After Width: | Height: | Size: 118 KiB |
|
Before Width: | Height: | Size: 113 KiB After Width: | Height: | Size: 114 KiB |
|
Before Width: | Height: | Size: 110 KiB After Width: | Height: | Size: 111 KiB |
|
Before Width: | Height: | Size: 66 KiB After Width: | Height: | Size: 67 KiB |