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
7 changes: 4 additions & 3 deletions Variables.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,11 @@ public partial class WeaponPaints

private static readonly MemoryFunctionVoid<nint, string, float> CAttributeListSetOrAddAttributeValueByName = new(GameData.GetSignature("CAttributeList_SetOrAddAttributeValueByName"));

private static readonly MemoryFunctionWithReturn<nint, string, int, int> SetBodygroupFunc = new(
GameData.GetSignature("CBaseModelEntity_SetBodygroup"));
//we dont need anymore because we use AcceptInput
//private static readonly MemoryFunctionWithReturn<nint, string, int, int> SetBodygroupFunc = new(
// GameData.GetSignature("CBaseModelEntity_SetBodygroup"));

private static readonly Func<nint, string, int, int> SetBodygroup = SetBodygroupFunc.Invoke;
//private static readonly Func<nint, string, int, int> SetBodygroup = SetBodygroupFunc.Invoke;

private static Dictionary<int, string> WeaponDefindex { get; } = new()
{
Expand Down
32 changes: 8 additions & 24 deletions WeaponAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,6 @@ private void RefreshWeapons(CCSPlayerController? player)
if (!weapon.Value.OwnerEntity.IsValid) continue;
if (gun.Entity == null) continue;
if (!gun.IsValid) continue;
if (!gun.VisibleinPVS) continue;

try
{
Expand Down Expand Up @@ -406,7 +405,7 @@ private void GivePlayerGloves(CCSPlayerController player)

item.Initialized = true;

SetBodygroup(pawn.Handle, "default_gloves", 1);
SetBodygroup(pawn, "default_gloves", 1);
}
catch (Exception) { }
}, TimerFlags.STOP_ON_MAPCHANGE);
Expand All @@ -430,13 +429,15 @@ private static int GetRandomPaint(int defindex)
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<nint, string, int>(
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)
Expand All @@ -454,13 +455,6 @@ private static void UpdateWeaponMeshGroupMask(CBaseEntity weapon, bool isLegacy
private static void UpdatePlayerWeaponMeshGroupMask(CCSPlayerController player, CBasePlayerWeapon weapon, bool isLegacy)
{
UpdateWeaponMeshGroupMask(weapon, isLegacy);

var viewModel = GetPlayerViewModel(player);
if (viewModel == null || viewModel.Weapon.Value == null ||
viewModel.Weapon.Value.Index != weapon.Index) return;

UpdateWeaponMeshGroupMask(viewModel, isLegacy);
Utilities.SetStateChanged(viewModel, "CBaseEntity", "m_CBodyComponent");
}

private static void GivePlayerAgent(CCSPlayerController player)
Expand Down Expand Up @@ -558,16 +552,6 @@ private void UpdatePlayerEconItemId(CEconItemView econItemView)
return !Utility.IsPlayerValid(player) ? null : player;
}

private static unsafe CBaseViewModel? GetPlayerViewModel(CCSPlayerController player)
{
if (player.PlayerPawn.Value == null || player.PlayerPawn.Value.ViewModelServices == null) return null;
CCSPlayer_ViewModelServices viewModelServices = new(player.PlayerPawn.Value.ViewModelServices!.Handle);
var ptr = viewModelServices.Handle + Schema.GetSchemaOffset("CCSPlayer_ViewModelServices", "m_hViewModel");
var references = MemoryMarshal.CreateSpan(ref ptr, 3);
var viewModel = (CHandle<CBaseViewModel>)Activator.CreateInstance(typeof(CHandle<CBaseViewModel>), references[0])!;
return viewModel.Value == null ? null : viewModel.Value;
}

private static bool HasChangedKnife(CCSPlayerController player, out string? knifeValue)
{
knifeValue = null;
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.281" />
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.331" />
<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
18 changes: 2 additions & 16 deletions gamedata/weaponpaints.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,9 @@
{
"ChangeSubclass": {
"signatures": {
"library": "server",
"windows": "48 89 6C 24 ? 56 48 83 EC ? 48 8B EA 48 8B F1 E8 ? ? ? ? 84 C0 0F 84",
"linux": "55 48 89 E5 41 55 41 54 49 89 F4 53 48 89 FB 48 83 EC ? E8 ? ? ? ? 84 C0 74"
}
},
"CAttributeList_SetOrAddAttributeValueByName": {
"signatures": {
"library": "server",
"windows": "40 53 41 56 41 57 48 81 EC 90 00 00 00 0F 29 74 24 70",
"linux": "55 48 89 E5 41 57 41 56 49 89 FE 41 55 41 54 49 89 F4 53 48 83 EC 78"
}
},
"CBaseModelEntity_SetBodygroup": {
"signatures": {
"library": "server",
"windows": "48 89 5C 24 08 48 89 74 24 10 57 48 83 EC 20 41 8B F8 48 8B F2 48 8B D9 E8 ? ? ? ?",
"linux": "55 48 89 E5 41 55 49 89 F5 41 54 41 89 D4 53 48 89 FB 48 83 EC 08 E8 ? ? ? ? 48 85 C0"
"windows": "40 53 55 41 56 48 81 EC 90 00 00 00",
"linux": "55 48 89 E5 41 57 41 56 49 89 FE 41 55 41 54 53 48 89 F3 48 83 EC ? F3 0F 11 85"
}
}
}