Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
bin/
obj/
website/getskins.php
.idea/
.idea/
WeaponPaints.sln.DotSettings.user
11 changes: 6 additions & 5 deletions Events.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using CounterStrikeSharp.API.Modules.Entities;
using CounterStrikeSharp.API.Modules.Memory;
using CounterStrikeSharp.API.Modules.Memory.DynamicFunctions;
using Microsoft.Extensions.Logging;

namespace WeaponPaints
{
Expand Down Expand Up @@ -222,7 +223,7 @@ private void OnEntityCreated(CEntityInstance entity)

if (designerName.Contains("weapon"))
{
Server.NextFrame(() =>
Server.NextWorldUpdate(() =>
{
var weapon = new CBasePlayerWeapon(entity.Handle);
if (!weapon.IsValid) return;
Expand Down Expand Up @@ -251,7 +252,7 @@ private void OnEntityCreated(CEntityInstance entity)

if (string.IsNullOrEmpty(player?.PlayerName)) return;
if (!Utility.IsPlayerValid(player)) return;

GivePlayerWeaponSkin(player, weapon);
}
catch (Exception)
Expand Down Expand Up @@ -285,7 +286,7 @@ public HookResult OnItemPickup(EventItemPickup @event, GameEventInfo _)
var player = @event.Userid;
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 _))
Expand All @@ -295,7 +296,7 @@ public HookResult OnItemPickup(EventItemPickup @event, GameEventInfo _)
{
GiveOnItemPickup(player);
}

return HookResult.Continue;
}

Expand Down Expand Up @@ -340,7 +341,7 @@ private void RegisterListeners()
RegisterEventHandler<EventRoundStart>(OnRoundStart);
RegisterEventHandler<EventRoundEnd>(OnRoundEnd);
RegisterEventHandler<EventRoundMvp>(OnRoundMvp);
RegisterListener<Listeners.OnEntityCreated>(OnEntityCreated);
RegisterListener<Listeners.OnEntitySpawned>(OnEntityCreated);
RegisterEventHandler<EventPlayerDeath>(OnPlayerDeath);

if (Config.Additional.ShowSkinImage)
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.1d
3.2a
33 changes: 14 additions & 19 deletions WeaponAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using CounterStrikeSharp.API.Modules.Utils;
using Microsoft.Extensions.Logging;
using System.Collections.Concurrent;
using System.Runtime.InteropServices;
using Newtonsoft.Json.Linq;

namespace WeaponPaints
Expand All @@ -17,9 +16,9 @@ private void GivePlayerWeaponSkin(CCSPlayerController player, CBasePlayerWeapon
{
if (!Config.Additional.SkinEnabled) return;
if (!GPlayerWeaponsInfo.TryGetValue(player.Slot, out _)) return;

bool isKnife = weapon.DesignerName.Contains("knife") || weapon.DesignerName.Contains("bayonet");

switch (isKnife)
{
case true when !HasChangedKnife(player, out var _):
Expand Down Expand Up @@ -64,22 +63,22 @@ private void GivePlayerWeaponSkin(CCSPlayerController player, CBasePlayerWeapon
weapon.FallbackPaintKit = GetRandomPaint(weaponDefIndex);
weapon.FallbackSeed = 0;
weapon.FallbackWear = 0.01f;

weapon.AttributeManager.Item.NetworkedDynamicAttributes.Attributes.RemoveAll();
CAttributeListSetOrAddAttributeValueByName.Invoke(weapon.AttributeManager.Item.NetworkedDynamicAttributes.Handle, "set item texture prefab", GetRandomPaint(weaponDefIndex));
CAttributeListSetOrAddAttributeValueByName.Invoke(weapon.AttributeManager.Item.NetworkedDynamicAttributes.Handle, "set item texture seed", 0);
CAttributeListSetOrAddAttributeValueByName.Invoke(weapon.AttributeManager.Item.NetworkedDynamicAttributes.Handle, "set item texture wear", 0.01f);

weapon.AttributeManager.Item.AttributeList.Attributes.RemoveAll();
CAttributeListSetOrAddAttributeValueByName.Invoke(weapon.AttributeManager.Item.AttributeList.Handle, "set item texture prefab", GetRandomPaint(weaponDefIndex));
CAttributeListSetOrAddAttributeValueByName.Invoke(weapon.AttributeManager.Item.AttributeList.Handle, "set item texture seed", 0);
CAttributeListSetOrAddAttributeValueByName.Invoke(weapon.AttributeManager.Item.AttributeList.Handle, "set item texture wear", 0.01f);

fallbackPaintKit = weapon.FallbackPaintKit;

if (fallbackPaintKit == 0)
return;

skinInfo = SkinsList
.Where(w =>
w["weapon_defindex"]?.ToObject<int>() == weaponDefIndex &&
Expand Down Expand Up @@ -135,7 +134,6 @@ private void GivePlayerWeaponSkin(CCSPlayerController player, CBasePlayerWeapon
.ToList();

isLegacyModel = skinInfo.Count <= 0 || skinInfo[0].Value<bool>("legacy_model");

UpdatePlayerWeaponMeshGroupMask(player, weapon, isLegacyModel);
}

Expand Down Expand Up @@ -385,7 +383,6 @@ private void GivePlayerGloves(CCSPlayerController player)
item.NetworkedDynamicAttributes.Attributes.RemoveAll();
item.AttributeList.Attributes.RemoveAll();


Instance.AddTimer(0.08f, () =>
{
try
Expand Down Expand Up @@ -453,19 +450,17 @@ public static void SetBodygroup(CCSPlayerPawn pawn, string group, int value)
pawn.AcceptInput("SetBodygroup", value:$"{group},{value}");
}

private static void UpdateWeaponMeshGroupMask(CBaseEntity weapon, bool isLegacy = false)
private void UpdateWeaponMeshGroupMask(CBaseEntity weapon, bool isLegacy = false)
{
if (weapon.CBodyComponent?.SceneNode == null) return;
var skeleton = weapon.CBodyComponent.SceneNode.GetSkeletonInstance();
var value = (ulong)(isLegacy ? 2 : 1);
if (!weapon.DesignerName.Contains("ak47")) return;
if (weapon.CBodyComponent?.SceneNode == null) return;
var skeleton = weapon.CBodyComponent.SceneNode.GetSkeletonInstance();

if (skeleton.ModelState.MeshGroupMask != value)
{
skeleton.ModelState.MeshGroupMask = value;
}
weapon.AcceptInput("SetBodygroup", value: $"body,{(isLegacy ? 1 : 0)}");
// skeleton.ModelState.MeshGroupMask = isLegacy ? 2UL : 1UL;
}

private static void UpdatePlayerWeaponMeshGroupMask(CCSPlayerController player, CBasePlayerWeapon weapon, bool isLegacy)
private void UpdatePlayerWeaponMeshGroupMask(CCSPlayerController player, CBasePlayerWeapon weapon, bool isLegacy)
{
UpdateWeaponMeshGroupMask(weapon, isLegacy);
}
Expand Down
7 changes: 5 additions & 2 deletions WeaponPaints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Core.Attributes;
using CounterStrikeSharp.API.Core.Attributes.Registration;
using CounterStrikeSharp.API.Modules.Commands;
using CounterStrikeSharp.API.Modules.Entities.Constants;
using Microsoft.Extensions.Logging;
using MySqlConnector;

namespace WeaponPaints;

[MinimumApiVersion(276)]
[MinimumApiVersion(380)]
public partial class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig>
{
internal static WeaponPaints Instance { get; private set; } = new();
Expand All @@ -17,7 +20,7 @@ public partial class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig
public override string ModuleAuthor => "Nereziel & daffyy";
public override string ModuleDescription => "Skin, gloves, agents and knife selector, standalone and web-based";
public override string ModuleName => "WeaponPaints";
public override string ModuleVersion => "3.1d";
public override string ModuleVersion => "3.2a";

public override void Load(bool hotReload)
{
Expand Down
2 changes: 1 addition & 1 deletion WeaponPaints.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.331" />
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.339" />
<PackageReference Include="Dapper" Version="2.1.35" />
<PackageReference Include="MySqlConnector" Version="2.4.0-beta.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
Expand Down
6 changes: 5 additions & 1 deletion WeaponPaints.sln.DotSettings.user
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/AddReferences/RecentPaths/=C_003A_005CUsers_005Cxdaff_005CDocuments_005CGitHub_005Ccs2_002DWeaponPaints_005C3rd_005Fparty_005CMenuManagerApi_002Edll/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
<s:Boolean x:Key="/Default/AddReferences/RecentPaths/=C_003A_005CUsers_005Cxdaff_005CDocuments_005CGitHub_005Ccs2_002DWeaponPaints_005C3rd_005Fparty_005CMenuManagerApi_002Edll/@EntryIndexedValue">True</s:Boolean>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ACBaseAnimGraph_002Eg_002Ecs_002Fl_003AC_0021_003FUsers_003Fxdaff_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FSourcesCache_003Fedce4cda20b83aa28fbed15b81eb0eda1753e497144879a4bd754947d37639_003FCBaseAnimGraph_002Eg_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ACBodyComponent_002Eg_002Ecs_002Fl_003AC_0021_003FUsers_003Fxdaff_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FSourcesCache_003Fdb7e149cad83cf211ee55349a3442256ec62acce5ba41474ad124572f767e271_003FCBodyComponent_002Eg_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ACModelState_002Eg_002Ecs_002Fl_003AC_0021_003FUsers_003Fxdaff_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FSourcesCache_003Fb03ffa24c03867c84b5d095397bd1578b8ea563ab2c72b30242ffad815d49e_003FCModelState_002Eg_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ANetworkedVector_002Ecs_002Fl_003AC_0021_003FUsers_003Fxdaff_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FSourcesCache_003Fd68dbf9c04bc6046e155f1866c3615a47e34017f330c9e351d68979b9281c_003FNetworkedVector_002Ecs/@EntryIndexedValue">ForceIncluded</s:String></wpf:ResourceDictionary>
20 changes: 10 additions & 10 deletions website/data/collectibles_sv.json
Original file line number Diff line number Diff line change
Expand Up @@ -551,12 +551,12 @@
},
{
"id": "988",
"name": "Champion at IEM Rio 2022",
"name": "Mästare i IEM Rio 2022",
"image": "https://raw.githubusercontent.com/Nereziel/cs2-WeaponPaints/main/website/img/skins/collectible-988.png"
},
{
"id": "989",
"name": "Finalist at IEM Rio 2022",
"name": "Finalist i IEM Rio 2022",
"image": "https://raw.githubusercontent.com/Nereziel/cs2-WeaponPaints/main/website/img/skins/collectible-989.png"
},
{
Expand All @@ -566,27 +566,27 @@
},
{
"id": "991",
"name": "Quarterfinalist at IEM Rio 2022",
"name": "Kvartsfinalist i IEM Rio 2022",
"image": "https://raw.githubusercontent.com/Nereziel/cs2-WeaponPaints/main/website/img/skins/collectible-991.png"
},
{
"id": "992",
"name": "Champion at BLAST.tv Paris 2023",
"name": "Mästare vid BLAST.tv Paris 2023",
"image": "https://raw.githubusercontent.com/Nereziel/cs2-WeaponPaints/main/website/img/skins/collectible-992.png"
},
{
"id": "993",
"name": "Finalist at BLAST.tv Paris 2023",
"name": "Finalist vid BLAST.tv Paris 2023",
"image": "https://raw.githubusercontent.com/Nereziel/cs2-WeaponPaints/main/website/img/skins/collectible-993.png"
},
{
"id": "994",
"name": "Semifinalist at BLAST.tv Paris 2023",
"name": "Semifinalist vid BLAST.tv Paris 2023",
"image": "https://raw.githubusercontent.com/Nereziel/cs2-WeaponPaints/main/website/img/skins/collectible-994.png"
},
{
"id": "995",
"name": "Quarterfinalist at BLAST.tv Paris 2023",
"name": "Kvartsfinalist vid BLAST.tv Paris 2023",
"image": "https://raw.githubusercontent.com/Nereziel/cs2-WeaponPaints/main/website/img/skins/collectible-995.png"
},
{
Expand Down Expand Up @@ -1551,7 +1551,7 @@
},
{
"id": "4884",
"name": "Paris 2023 Coin",
"name": "Paris 2023-mynt",
"image": "https://raw.githubusercontent.com/Nereziel/cs2-WeaponPaints/main/website/img/skins/collectible-4884.png"
},
{
Expand All @@ -1561,12 +1561,12 @@
},
{
"id": "4886",
"name": "Paris 2023 Gold Coin",
"name": "Paris 2023 – guldmynt",
"image": "https://raw.githubusercontent.com/Nereziel/cs2-WeaponPaints/main/website/img/skins/collectible-4886.png"
},
{
"id": "4887",
"name": "Paris 2023 Diamond Coin",
"name": "Paris 2023 – diamantmynt",
"image": "https://raw.githubusercontent.com/Nereziel/cs2-WeaponPaints/main/website/img/skins/collectible-4887.png"
},
{
Expand Down
10 changes: 5 additions & 5 deletions website/data/keychains_bg.json
Original file line number Diff line number Diff line change
Expand Up @@ -291,12 +291,12 @@
},
{
"id": "2025910",
"name": "Souvenir Charm | Отличен най-добър момент BLAST.tv Austin 2025 | Deagle Supremacy",
"name": "Souvenir Charm | Отличен най-добър момент BLAST.tv Austin 2025 | Превъзходство с Deagle",
"image": "https://raw.githubusercontent.com/Nereziel/cs2-WeaponPaints/main/website/img/skins/highlight-aus2025_910doubledeaglevsfazeonmirage.png"
},
{
"id": "20259102",
"name": "Souvenir Charm | Отличен най-добър момент BLAST.tv Austin 2025 | 2 Pistol Headshots",
"name": "Souvenir Charm | Отличен най-добър момент BLAST.tv Austin 2025 | 2 изстрела в главата с пистолет",
"image": "https://raw.githubusercontent.com/Nereziel/cs2-WeaponPaints/main/website/img/skins/highlight-aus2025_9102kpistolvsfazeonmirage.png"
},
{
Expand All @@ -306,17 +306,17 @@
},
{
"id": "2025210",
"name": "Souvenir Charm | Отличен най-добър момент BLAST.tv Austin 2025 | The Running MAC-10",
"name": "Souvenir Charm | Отличен най-добър момент BLAST.tv Austin 2025 | Бягащият MAC-10",
"image": "https://raw.githubusercontent.com/Nereziel/cs2-WeaponPaints/main/website/img/skins/highlight-aus2025_karrigan2kmac10vsmongolzonanubis.png"
},
{
"id": "20259101",
"name": "Souvenir Charm | Отличен най-добър момент BLAST.tv Austin 2025 | One Kill Is Enough",
"name": "Souvenir Charm | Отличен най-добър момент BLAST.tv Austin 2025 | Едно убийство е достатъчно",
"image": "https://raw.githubusercontent.com/Nereziel/cs2-WeaponPaints/main/website/img/skins/highlight-aus2025_9101kvspainonmirage.png"
},
{
"id": "2025132",
"name": "Souvenir Charm | Отличен най-добър момент BLAST.tv Austin 2025 | Fear Him",
"name": "Souvenir Charm | Отличен най-добър момент BLAST.tv Austin 2025 | Страхувайте се от него",
"image": "https://raw.githubusercontent.com/Nereziel/cs2-WeaponPaints/main/website/img/skins/highlight-aus2025_mzinhoclose1v3vsvitalityondust2.png"
},
{
Expand Down
Loading