From f85b12ea75bfca0f747c7ad784b44a00c0d8202f Mon Sep 17 00:00:00 2001 From: s1lent Date: Tue, 22 May 2018 16:26:14 +0700 Subject: [PATCH] rg_round_end: Add option trigger to all hooks --- .../scripting/include/reapi_gamedll.inc | 6 +++-- reapi/msvc/reapi.vcxproj.filters | 18 +++++++++++++ reapi/src/natives/natives_misc.cpp | 26 ++++++++++++++++--- 3 files changed, 44 insertions(+), 6 deletions(-) diff --git a/reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc b/reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc index 92089bef..a531781f 100644 --- a/reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc +++ b/reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc @@ -348,10 +348,12 @@ native Float:[3] rg_fire_bullets3(const inflictor, const attacker, Float:vecSrc[ * @param event The event is the end of the round * @param message The message on round end * @param sentence The sound at the end of the round +* @param trigger This will trigger to all hooks on that function +* Be very careful about recursion! * -* @noreturn +* @return 1 on success, 0 otherwise */ -native rg_round_end(const Float:tmDelay, const WinStatus:st, const ScenarioEventEndRound:event = ROUND_NONE, const message[] = "default", const sentence[] = "default"); +native rg_round_end(const Float:tmDelay, const WinStatus:st, const ScenarioEventEndRound:event = ROUND_NONE, const message[] = "default", const sentence[] = "default", const bool:trigger = false); /* * Updates current scores. diff --git a/reapi/msvc/reapi.vcxproj.filters b/reapi/msvc/reapi.vcxproj.filters index e0785786..1025ad20 100644 --- a/reapi/msvc/reapi.vcxproj.filters +++ b/reapi/msvc/reapi.vcxproj.filters @@ -61,6 +61,9 @@ {8232a3e7-911f-4ee1-8223-03ac077d7bee} + + {7bbc2807-1f04-4c73-a99c-e7955f9bda90} + @@ -702,6 +705,21 @@ src + + include\cssdk\dlls\API + + + include\cssdk\dlls\API + + + include\cssdk\dlls\API + + + include\cssdk\dlls\API + + + include\cssdk\dlls\API + diff --git a/reapi/src/natives/natives_misc.cpp b/reapi/src/natives/natives_misc.cpp index e0969b6b..b98ddca1 100644 --- a/reapi/src/natives/natives_misc.cpp +++ b/reapi/src/natives/natives_misc.cpp @@ -408,13 +408,15 @@ struct { * @param event The event is the end of the round * @param message The message on round end * @param sentence The sound at the end of the round +* @param trigger This will trigger to all hooks on that function +* Be very careful about recursion! * * @noreturn -* native rg_round_end(const Float:tmDelay, const WinStatus:st, const ScenarioEventEndRound:event = ROUND_NONE, const message[] = "default", const sentence[] = "default"); +* native rg_round_end(const Float:tmDelay, const WinStatus:st, const ScenarioEventEndRound:event = ROUND_NONE, const message[] = "default", const sentence[] = "default", const bool:trigger = false); */ cell AMX_NATIVE_CALL rg_round_end(AMX *amx, cell *params) { - enum args_e { arg_count, arg_delay, arg_win, arg_event, arg_message, arg_sentence, arg_silent }; + enum args_e { arg_count, arg_delay, arg_win, arg_event, arg_message, arg_sentence, arg_trigger }; CHECK_GAMERULES(); @@ -448,8 +450,24 @@ cell AMX_NATIVE_CALL rg_round_end(AMX *amx, cell *params) Broadcast(sentence); } - CSGameRules()->EndRoundMessage(message, event); - CSGameRules()->TerminateRound(CAmxArg(amx, params[arg_delay]), winstatus); + float tmDelay = CAmxArg(amx, params[arg_delay]); + if (params[arg_trigger] != 0) + { + return callForward(RG_RoundEnd, + [&message](int _winStatus, ScenarioEventEndRound _event, float _tmDelay) + { + CSGameRules()->EndRoundMessage(message, _event); + CSGameRules()->TerminateRound(_tmDelay, _winStatus); + return TRUE; + }, + winstatus, event, tmDelay); + } + else + { + CSGameRules()->EndRoundMessage(message, event); + CSGameRules()->TerminateRound(tmDelay, winstatus); + } + return TRUE; }