Skip to content

Commit

Permalink
rg_round_end: Add option trigger to all hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
s1lentq committed May 22, 2018
1 parent c649b89 commit f85b12e
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 6 deletions.
6 changes: 4 additions & 2 deletions reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
18 changes: 18 additions & 0 deletions reapi/msvc/reapi.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@
<Filter Include="common">
<UniqueIdentifier>{8232a3e7-911f-4ee1-8223-03ac077d7bee}</UniqueIdentifier>
</Filter>
<Filter Include="include\cssdk\dlls\API">
<UniqueIdentifier>{7bbc2807-1f04-4c73-a99c-e7955f9bda90}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\include\metamod\dllapi.h">
Expand Down Expand Up @@ -702,6 +705,21 @@
<ClInclude Include="..\src\amx_hook.h">
<Filter>src</Filter>
</ClInclude>
<ClInclude Include="..\include\cssdk\dlls\API\CSEntity.h">
<Filter>include\cssdk\dlls\API</Filter>
</ClInclude>
<ClInclude Include="..\include\cssdk\dlls\API\CSInterfaces.h">
<Filter>include\cssdk\dlls\API</Filter>
</ClInclude>
<ClInclude Include="..\include\cssdk\dlls\API\CSPlayer.h">
<Filter>include\cssdk\dlls\API</Filter>
</ClInclude>
<ClInclude Include="..\include\cssdk\dlls\API\CSPlayerItem.h">
<Filter>include\cssdk\dlls\API</Filter>
</ClInclude>
<ClInclude Include="..\include\cssdk\dlls\API\CSPlayerWeapon.h">
<Filter>include\cssdk\dlls\API</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\include\cssdk\common\parsemsg.cpp">
Expand Down
26 changes: 22 additions & 4 deletions reapi/src/natives/natives_misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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<BOOL>(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;
}

Expand Down

0 comments on commit f85b12e

Please sign in to comment.