From bde066631331be99c22c2777be123f7297d94287 Mon Sep 17 00:00:00 2001 From: stefanx111 Date: Tue, 5 Aug 2025 01:08:43 +0300 Subject: [PATCH] bodygroup and subclass change method to use AcceptInput --- Variables.cs | 7 ++++--- WeaponAction.cs | 14 ++++++++------ 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Variables.cs b/Variables.cs index 3ee7bd06..9648ba27 100644 --- a/Variables.cs +++ b/Variables.cs @@ -93,10 +93,11 @@ public partial class WeaponPaints private static readonly MemoryFunctionVoid CAttributeListSetOrAddAttributeValueByName = new(GameData.GetSignature("CAttributeList_SetOrAddAttributeValueByName")); - private static readonly MemoryFunctionWithReturn SetBodygroupFunc = new( - GameData.GetSignature("CBaseModelEntity_SetBodygroup")); + //we dont need anymore because we use AcceptInput + //private static readonly MemoryFunctionWithReturn SetBodygroupFunc = new( + // GameData.GetSignature("CBaseModelEntity_SetBodygroup")); - private static readonly Func SetBodygroup = SetBodygroupFunc.Invoke; + //private static readonly Func SetBodygroup = SetBodygroupFunc.Invoke; private static Dictionary WeaponDefindex { get; } = new() { diff --git a/WeaponAction.cs b/WeaponAction.cs index 48a7b89d..6b52ed27 100644 --- a/WeaponAction.cs +++ b/WeaponAction.cs @@ -405,7 +405,7 @@ namespace WeaponPaints item.Initialized = true; - SetBodygroup(pawn.Handle, "default_gloves", 1); + SetBodygroup(pawn, "default_gloves", 1); } catch (Exception) { } }, TimerFlags.STOP_ON_MAPCHANGE); @@ -429,13 +429,15 @@ namespace WeaponPaints return int.TryParse(randomWeapon["paint"]?.ToString(), out var paintValue) ? paintValue : 0; } - private static void SubclassChange(CBasePlayerWeapon weapon, ushort itemD) + //xstage idea on css discord + public static void SubclassChange(CBasePlayerWeapon weapon, ushort itemD) { - var subclassChangeFunc = VirtualFunction.Create( - GameData.GetSignature("ChangeSubclass") - ); + weapon.AcceptInput("ChangeSubclass", value: itemD.ToString()); + } - subclassChangeFunc(weapon.Handle, itemD.ToString()); + 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)