-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathForceFullUpdate.cs
85 lines (67 loc) · 2.41 KB
/
ForceFullUpdate.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
using System.Runtime.InteropServices;
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Memory;
namespace HidePlayers;
[StructLayout(LayoutKind.Sequential)]
struct CUtlMemory
{
public unsafe nint* m_pMemory;
public int m_nAllocationCount;
public int m_nGrowSize;
}
[StructLayout(LayoutKind.Sequential)]
struct CUtlVector
{
public unsafe nint this[int index]
{
get => this.m_Memory.m_pMemory[index];
set => this.m_Memory.m_pMemory[index] = value;
}
public int m_iSize;
public CUtlMemory m_Memory;
public nint Element(int index) => this[index];
}
// thx https://discord.com/channels/1160907911501991946/1175947333880524962/1231712355784851497
class INetworkServerService : NativeObject
{
private readonly VirtualFunctionWithReturn<nint, nint> GetIGameServerFunc;
public INetworkServerService() : base(NativeAPI.GetValveInterface(0, "NetworkServerService_001"))
{
this.GetIGameServerFunc = new VirtualFunctionWithReturn<nint, nint>(this.Handle, GameData.GetOffset("INetworkServerService_GetIGameServer"));
}
public INetworkGameServer GetIGameServer()
{
return new INetworkGameServer(this.GetIGameServerFunc.Invoke(this.Handle));
}
}
public class INetworkGameServer : NativeObject
{
private static int SlotsOffset = GameData.GetOffset("INetworkGameServer_Slots");
private CUtlVector Slots;
public INetworkGameServer(nint ptr) : base(ptr)
{
this.Slots = Marshal.PtrToStructure<CUtlVector>(base.Handle + SlotsOffset);
}
public CServerSideClient? GetClientBySlot(int playerSlot)
{
if (playerSlot >= 0 && playerSlot < this.Slots.m_iSize)
return this.Slots[playerSlot] == IntPtr.Zero ? null : new CServerSideClient(this.Slots[playerSlot]);
return null;
}
}
public class CServerSideClient : NativeObject
{
private static int m_nForceWaitForTick = GameData.GetOffset("CServerSideClient_m_nForceWaitForTick");
public unsafe int ForceWaitForTick
{
get { return *(int*)(base.Handle + m_nForceWaitForTick); }
set { *(int*)(base.Handle + m_nForceWaitForTick) = value; }
}
public CServerSideClient(nint ptr) : base(ptr)
{ }
public void ForceFullUpdate()
{
this.ForceWaitForTick = -1;
}
}