|
11 | 11 |
|
12 | 12 | #include <stocksoup/memory>
|
13 | 13 |
|
14 |
| -#define PLUGIN_VERSION "0.14.1" |
| 14 | +#define PLUGIN_VERSION "0.15.0" |
15 | 15 | public Plugin myinfo = {
|
16 | 16 | name = "TF2 Utils",
|
17 | 17 | author = "nosoop",
|
@@ -42,6 +42,7 @@ Handle g_SDKCallPlayerEquipWearable;
|
42 | 42 | Handle g_SDKCallPointInRespawnRoom;
|
43 | 43 |
|
44 | 44 | Address offs_ConditionNames;
|
| 45 | +Address offs_CTFPlayer_aHealers; |
45 | 46 |
|
46 | 47 | Address offs_CTFPlayer_hMyWearables;
|
47 | 48 |
|
@@ -73,6 +74,8 @@ public APLRes AskPluginLoad2(Handle self, bool late, char[] error, int maxlen) {
|
73 | 74 | CreateNative("TF2Util_GetPlayerBurnDuration", Native_GetPlayerBurnDuration);
|
74 | 75 | CreateNative("TF2Util_SetPlayerBurnDuration", Native_SetPlayerBurnDuration);
|
75 | 76 |
|
| 77 | + CreateNative("TF2Util_GetPlayerHealer", Native_GetPlayerHealer); |
| 78 | + |
76 | 79 | CreateNative("TF2Util_IsEntityWearable", Native_IsEntityWearable);
|
77 | 80 | CreateNative("TF2Util_GetPlayerWearable", Native_GetPlayerWearable);
|
78 | 81 | CreateNative("TF2Util_GetPlayerWearableCount", Native_GetPlayerWearableCount);
|
@@ -225,6 +228,8 @@ public void OnPluginStart() {
|
225 | 228 | }
|
226 | 229 | offs_ConditionNames = GameConfGetAddress(hGameConf, "g_aConditionNames");
|
227 | 230 |
|
| 231 | + offs_CTFPlayer_aHealers = view_as<Address>(FindSendPropInfo("CTFPlayer", "m_nNumHealers") + 0xC); |
| 232 | + |
228 | 233 | delete hGameConf;
|
229 | 234 | }
|
230 | 235 |
|
@@ -388,6 +393,27 @@ public int Native_GetPlayerShootPosition(Handle plugin, int nParams) {
|
388 | 393 | SetNativeArray(2, vecResult, sizeof(vecResult));
|
389 | 394 | }
|
390 | 395 |
|
| 396 | +// int(int client, int index); |
| 397 | +int Native_GetPlayerHealer(Handle plugin, int nParams) { |
| 398 | + // Pelipoika did this ages ago https://forums.alliedmods.net/showthread.php?t=306854 |
| 399 | + // it's bundled here for consistency's sake, and in case it needs maintenance in the future |
| 400 | + int client = GetNativeCell(1); |
| 401 | + int index = GetNativeCell(2); |
| 402 | + |
| 403 | + if (client < 1 || client > MaxClients || !IsClientInGame(client)) { |
| 404 | + ThrowNativeError(SP_ERROR_NATIVE, "Client index %d is invalid", client); |
| 405 | + } |
| 406 | + |
| 407 | + int count = GetEntProp(client, Prop_Send, "m_nNumHealers"); |
| 408 | + if (index < 0 || index >= count) { |
| 409 | + ThrowNativeError(SP_ERROR_NATIVE, "Invalid index %d (count: %d)", index, count); |
| 410 | + } |
| 411 | + |
| 412 | + Address pData = DereferencePointer(GetEntityAddress(client) |
| 413 | + + view_as<Address>(offs_CTFPlayer_aHealers)); |
| 414 | + return EntRefToEntIndex(LoadEntityHandleFromAddress(pData + view_as<Address>(0x24 * index))); |
| 415 | +} |
| 416 | + |
391 | 417 | // bool(int entity);
|
392 | 418 | public int Native_IsEntityWeapon(Handle plugin, int nParams) {
|
393 | 419 | int entity = GetNativeCell(1);
|
|
0 commit comments