diff --git a/extensions/tf2/natives.cpp b/extensions/tf2/natives.cpp index 018a00d3..0f2a7133 100644 --- a/extensions/tf2/natives.cpp +++ b/extensions/tf2/natives.cpp @@ -550,6 +550,37 @@ cell_t TF2_IsPlayerInDuel(IPluginContext *pContext, const cell_t *params) return (retValue) ? 1 : 0; } +// native bool:TF2_IsHolidayActive(TFHoliday:holiday); +cell_t TF2_IsHolidayActive(IPluginContext *pContext, const cell_t *params) +{ + static ICallWrapper *pWrapper = NULL; + + // UTIL_IsHolidayActive(int) + if (!pWrapper) + { + REGISTER_NATIVE_ADDR("IsHolidayActive", + PassInfo pass[1]; \ + pass[0].flags = PASSFLAG_BYVAL; \ + pass[0].size = sizeof(int); \ + pass[0].type = PassType_Basic; \ + PassInfo ret; \ + ret.flags = PASSFLAG_BYVAL; \ + ret.size = sizeof(bool); \ + ret.type = PassType_Basic; \ + pWrapper = g_pBinTools->CreateCall(addr, CallConv_Cdecl, &ret, pass, 1)) + } + + unsigned char vstk[sizeof(int)]; + unsigned char *vptr = vstk; + *(int *)vptr = params[1]; + + bool retValue; + + pWrapper->Execute(vstk, &retValue); + + return (retValue) ? 1 : 0; +} + sp_nativeinfo_t g_TFNatives[] = { {"TF2_IgnitePlayer", TF2_Burn}, @@ -566,5 +597,6 @@ sp_nativeinfo_t g_TFNatives[] = {"TF2_StunPlayer", TF2_StunPlayer}, {"TF2_MakeBleed", TF2_MakeBleed}, {"TF2_IsPlayerInDuel", TF2_IsPlayerInDuel}, + {"TF2_IsHolidayActive", TF2_IsHolidayActive}, {NULL, NULL} }; diff --git a/plugins/include/tf2.inc b/plugins/include/tf2.inc index 4f84f733..ce4ec38d 100644 --- a/plugins/include/tf2.inc +++ b/plugins/include/tf2.inc @@ -343,6 +343,14 @@ forward Action:TF2_OnGetHoliday(&TFHoliday:holiday); */ forward Action:TF2_OnIsHolidayActive(TFHoliday:holiday, &bool:result); +/** + * Returns whether or not a holiday is active + * + * @param holiday Holiday being checked. + * @return Boolean of whether or not the holiday is active. + */ +native bool:TF2_IsHolidayActive(TFHoliday:holiday); + /** * Returns whether or not a client (Player) is in a duel. * @@ -427,5 +435,6 @@ public __ext_tf2_SetNTVOptional() MarkNativeAsOptional("TF2_GetResourceEntity"); MarkNativeAsOptional("TF2_GetClass"); MarkNativeAsOptional("TF2_IsPlayerInDuel"); + MarkNativeAsOptional("TF2_IsHolidayActive"); } #endif