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
50 changes: 50 additions & 0 deletions extensions/tf2/natives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand All @@ -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}
};
7 changes: 7 additions & 0 deletions gamedata/sm-tf2.games.txt
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,13 @@
"linux" "139"
"mac" "139"
}

"RemoveWearable"
{
"windows" "426"
"linux" "427"
"mac" "427"
}
}
}
}
11 changes: 11 additions & 0 deletions plugins/include/tf2.inc
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,17 @@ native bool:TF2_IsHolidayActive(TFHoliday:holiday);
*/
native bool:TF2_IsPlayerInDuel(client);

/**
* Removes an econ wearable (hat, misc, etc) from a player.
* This also deletes the wearable entity.
*
* @param client Client index.
* @param wearable Index of the wearable entity.
* @noreturn
* @error Invalid client index, client not in game, invalid wearable entity, or no mod support.
*/
native TF2_RemoveWearable(client, wearable);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does removing the wearable destroy the entity? I don't know, but I feel that the function doc should clarify.


/**
* Called after a condition is added to a player
*
Expand Down