diff --git a/extensions/tf2/natives.cpp b/extensions/tf2/natives.cpp index 75835f8d..4a1fabee 100644 --- a/extensions/tf2/natives.cpp +++ b/extensions/tf2/natives.cpp @@ -599,6 +599,55 @@ cell_t TF2_IsHolidayActive(IPluginContext *pContext, const cell_t *params) return (retValue) ? 1 : 0; } +cell_t TF2_RemoveWearable(IPluginContext *pContext, const cell_t *params) +{ + static ICallWrapper *pWrapper = NULL; + + //CBasePlayer::RemoveWearable(CEconWearable *) + + if (!pWrapper) + { + int offset; + + if (!g_pGameConf->GetOffset("RemoveWearable", &offset)) + { + return pContext->ThrowNativeError("Failed to locate function"); + } + + PassInfo pass[1]; + pass[0].flags = PASSFLAG_BYVAL; + pass[0].size = sizeof(CBaseEntity *); + pass[0].type = PassType_Basic; + + pWrapper = g_pBinTools->CreateVCall(offset, 0, 0, NULL, pass, 1); + + g_RegNatives.Register(pWrapper); + } + + CBaseEntity *pEntity; + if (!(pEntity = UTIL_GetCBaseEntity(params[1], true))) + { + return pContext->ThrowNativeError("Client index %d is not valid", params[1]); + } + + CBaseEntity *pWearable; + if (!(pWearable = UTIL_GetCBaseEntity(params[2], false))) + { + return pContext->ThrowNativeError("Wearable index %d is not valid", params[2]); + } + + unsigned char vstk[sizeof(void *) + sizeof(CBaseEntity *)]; + unsigned char *vptr = vstk; + + *(void **)vptr = (void *)pEntity; + vptr += sizeof(void *); + *(CBaseEntity **)vptr = pWearable; + + pWrapper->Execute(vstk, NULL); + + return 1; +} + sp_nativeinfo_t g_TFNatives[] = { {"TF2_IgnitePlayer", TF2_Burn}, @@ -616,5 +665,6 @@ sp_nativeinfo_t g_TFNatives[] = {"TF2_MakeBleed", TF2_MakeBleed}, {"TF2_IsPlayerInDuel", TF2_IsPlayerInDuel}, {"TF2_IsHolidayActive", TF2_IsHolidayActive}, + {"TF2_RemoveWearable", TF2_RemoveWearable}, {NULL, NULL} }; diff --git a/gamedata/sm-tf2.games.txt b/gamedata/sm-tf2.games.txt index bb853292..d944d639 100644 --- a/gamedata/sm-tf2.games.txt +++ b/gamedata/sm-tf2.games.txt @@ -137,6 +137,13 @@ "linux" "139" "mac" "139" } + + "RemoveWearable" + { + "windows" "426" + "linux" "427" + "mac" "427" + } } } } diff --git a/plugins/include/tf2.inc b/plugins/include/tf2.inc index 8eb2e517..95c5f5dd 100644 --- a/plugins/include/tf2.inc +++ b/plugins/include/tf2.inc @@ -359,6 +359,15 @@ native bool:TF2_IsHolidayActive(TFHoliday:holiday); */ native bool:TF2_IsPlayerInDuel(client); +/** + * Removes an econ wearable (hat, misc, etc) from a player. + * + * @param client Client index. + * @param wearable Index of the wearable entity. + * @noreturn +*/ +native TF2_RemoveWearable(client, wearable); + /** * Called after a condition is added to a player *