Skip to content

Commit b026ce1

Browse files
authored
Merge pull request #425 from stefanx111/fix-patch
Fix update
2 parents c1cd229 + 634d0e4 commit b026ce1

File tree

4 files changed

+15
-44
lines changed

4 files changed

+15
-44
lines changed

Variables.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,11 @@ public partial class WeaponPaints
9393

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

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

99-
private static readonly Func<nint, string, int, int> SetBodygroup = SetBodygroupFunc.Invoke;
100+
//private static readonly Func<nint, string, int, int> SetBodygroup = SetBodygroupFunc.Invoke;
100101

101102
private static Dictionary<int, string> WeaponDefindex { get; } = new()
102103
{

WeaponAction.cs

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,6 @@ private void RefreshWeapons(CCSPlayerController? player)
285285
if (!weapon.Value.OwnerEntity.IsValid) continue;
286286
if (gun.Entity == null) continue;
287287
if (!gun.IsValid) continue;
288-
if (!gun.VisibleinPVS) continue;
289288

290289
try
291290
{
@@ -406,7 +405,7 @@ private void GivePlayerGloves(CCSPlayerController player)
406405

407406
item.Initialized = true;
408407

409-
SetBodygroup(pawn.Handle, "default_gloves", 1);
408+
SetBodygroup(pawn, "default_gloves", 1);
410409
}
411410
catch (Exception) { }
412411
}, TimerFlags.STOP_ON_MAPCHANGE);
@@ -430,13 +429,15 @@ private static int GetRandomPaint(int defindex)
430429
return int.TryParse(randomWeapon["paint"]?.ToString(), out var paintValue) ? paintValue : 0;
431430
}
432431

433-
private static void SubclassChange(CBasePlayerWeapon weapon, ushort itemD)
432+
//xstage idea on css discord
433+
public static void SubclassChange(CBasePlayerWeapon weapon, ushort itemD)
434434
{
435-
var subclassChangeFunc = VirtualFunction.Create<nint, string, int>(
436-
GameData.GetSignature("ChangeSubclass")
437-
);
435+
weapon.AcceptInput("ChangeSubclass", value: itemD.ToString());
436+
}
438437

439-
subclassChangeFunc(weapon.Handle, itemD.ToString());
438+
public static void SetBodygroup(CCSPlayerPawn pawn, string group, int value)
439+
{
440+
pawn.AcceptInput("SetBodygroup", value:$"{group},{value}");
440441
}
441442

442443
private static void UpdateWeaponMeshGroupMask(CBaseEntity weapon, bool isLegacy = false)
@@ -454,13 +455,6 @@ private static void UpdateWeaponMeshGroupMask(CBaseEntity weapon, bool isLegacy
454455
private static void UpdatePlayerWeaponMeshGroupMask(CCSPlayerController player, CBasePlayerWeapon weapon, bool isLegacy)
455456
{
456457
UpdateWeaponMeshGroupMask(weapon, isLegacy);
457-
458-
var viewModel = GetPlayerViewModel(player);
459-
if (viewModel == null || viewModel.Weapon.Value == null ||
460-
viewModel.Weapon.Value.Index != weapon.Index) return;
461-
462-
UpdateWeaponMeshGroupMask(viewModel, isLegacy);
463-
Utilities.SetStateChanged(viewModel, "CBaseEntity", "m_CBodyComponent");
464458
}
465459

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

561-
private static unsafe CBaseViewModel? GetPlayerViewModel(CCSPlayerController player)
562-
{
563-
if (player.PlayerPawn.Value == null || player.PlayerPawn.Value.ViewModelServices == null) return null;
564-
CCSPlayer_ViewModelServices viewModelServices = new(player.PlayerPawn.Value.ViewModelServices!.Handle);
565-
var ptr = viewModelServices.Handle + Schema.GetSchemaOffset("CCSPlayer_ViewModelServices", "m_hViewModel");
566-
var references = MemoryMarshal.CreateSpan(ref ptr, 3);
567-
var viewModel = (CHandle<CBaseViewModel>)Activator.CreateInstance(typeof(CHandle<CBaseViewModel>), references[0])!;
568-
return viewModel.Value == null ? null : viewModel.Value;
569-
}
570-
571555
private static bool HasChangedKnife(CCSPlayerController player, out string? knifeValue)
572556
{
573557
knifeValue = null;

WeaponPaints.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
</PropertyGroup>
1010

1111
<ItemGroup>
12-
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.281" />
12+
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.331" />
1313
<PackageReference Include="Dapper" Version="2.1.35" />
1414
<PackageReference Include="MySqlConnector" Version="2.4.0-beta.1" />
1515
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />

gamedata/weaponpaints.json

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,9 @@
11
{
2-
"ChangeSubclass": {
3-
"signatures": {
4-
"library": "server",
5-
"windows": "48 89 6C 24 ? 56 48 83 EC ? 48 8B EA 48 8B F1 E8 ? ? ? ? 84 C0 0F 84",
6-
"linux": "55 48 89 E5 41 55 41 54 49 89 F4 53 48 89 FB 48 83 EC ? E8 ? ? ? ? 84 C0 74"
7-
}
8-
},
92
"CAttributeList_SetOrAddAttributeValueByName": {
103
"signatures": {
114
"library": "server",
12-
"windows": "40 53 41 56 41 57 48 81 EC 90 00 00 00 0F 29 74 24 70",
13-
"linux": "55 48 89 E5 41 57 41 56 49 89 FE 41 55 41 54 49 89 F4 53 48 83 EC 78"
14-
}
15-
},
16-
"CBaseModelEntity_SetBodygroup": {
17-
"signatures": {
18-
"library": "server",
19-
"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 ? ? ? ?",
20-
"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"
5+
"windows": "40 53 55 41 56 48 81 EC 90 00 00 00",
6+
"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"
217
}
228
}
239
}

0 commit comments

Comments
 (0)