rehlds / ReAPI

AMXModX module providing APIs for ReHLDS, ReGameDLL, and Metamod plugins (e.g., ReUnion, ReVoice).
GNU General Public License v3.0
160 stars 105 forks source link

RoundEnd hook is not getting called on rg_round_end #108

Closed ish12321 closed 6 years ago

ish12321 commented 6 years ago

Hey,

/* Sublime AMXX Editor v2.2 */

#include <amxmodx>
// #include <amxmisc>
// #include <cstrike>
// #include <engine>
// #include <fakemeta>
// #include <hamsandwich>
// #include <fun>
// #include <xs>
// #include <sqlx>
#include <reapi>

#define PLUGIN  "[ReAPI] Round End Hook Bug"
#define VERSION "1.0"
#define AUTHOR  "Ish Chhabra"

public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR)

    RegisterHookChain(RG_RoundEnd, "RG_Hook_RoundEnd", false);

    register_clcmd("say testit", "testit");
    // Add your code here...
}

public testit()
{
    rg_round_end(5.0, WINSTATUS_DRAW, ROUND_END_DRAW);
}

public RG_Hook_RoundEnd(WinStatus:status, ScenarioEventEndRound:event, Float:tmDelay)
{
    client_print(0, print_chat, "HOOK CALLED");
}

when I say "testit" the RoundEnd hookchain should be called and I should get message HOOK CALLED. The RoundEnd hookchain is but not getting called on rg_round_end. Please check this and fix this.

ish12321 commented 6 years ago

Bump

Sugisakii commented 6 years ago

rg_round_end is to force the end of round, but can not be hooked by RG_RoundEnd

RG_RoundEnd, hooked the end of rounds called by CheckWinCondition or CheckMapCondition

u can do this, call function manually

public testit()
{
    rg_round_end(5.0, WINSTATUS_DRAW, ROUND_END_DRAW);
    RG_Hook_RoundEnd(WINSTATUS_DRAW, ROUND_END_DRAW);
}

public RG_Hook_RoundEnd(WinStatus:status, ScenarioEventEndRound:event, Float:tmDelay)
{
    client_print(0, print_chat, "HOOK CALLED");
}
ish12321 commented 6 years ago

But isnt it wrong to not being called or is it the way it was intended to be?

IgnacioFDM commented 6 years ago

I agree it would be better if RoundEnd hook were called on rg_round_end

Sugisakii commented 6 years ago

it's better to stay as it is, if you want to hook the end of round, but just want to know the end use this

register_logevent("OnRoundEnd", 2, "1=Round_End")
public OnRoundEnd()
{
      // my code here
}
    /*
    * Description:      1 == CTs won last round, 2 == Terrorists did, 3 == Draw, no winner
    * Member type:      int
    * Get params:       get_member_game(member);
    * Set params:       set_member_game(member, value);
    */
    m_iRoundWinStatus,

use RG_RoundEnd only to make the round infinite or to make the delay longer