rehlds / ReAPI

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

Add new native `rg_observer_find_next_player` #325

Open jonathan-up opened 3 months ago

jonathan-up commented 3 months ago

Tested✔

#include <amxmodx>
#include <reapi>

public plugin_init()
{
    register_clcmd("say .fnp", "cmd_fnp");

    RegisterHookChain(RG_CBasePlayer_Observer_FindNextPlayer, "RG_CBasePlayer_Observer_FindNextPlayer_Pre", false);
}

public RG_CBasePlayer_Observer_FindNextPlayer_Pre(const this, bool:bReverse, name[])
{
    client_print(this, print_chat, "FindNextPlayer: bReverse(%d), name(%s)", bReverse, name);
}

public cmd_fnp(const index)
{
    if (!(get_member(index, m_afPhysicsFlags) & PFLAG_OBSERVER))
    {
        client_print(index, print_chat, "YOUR ARE NOT A OBSERVER");
        return PLUGIN_HANDLED;
    }

    client_print(index, print_chat, "YOU DID");
    rg_observer_find_next_player(index, true, "");
    return PLUGIN_HANDLED;
}