View Single Post
joropito
AlliedModders Donor
Join Date: Mar 2009
Location: pfnAddToFullPack
Old 03-12-2010 , 10:33   Re: catching player using voice
Reply With Quote #9

I guess the only way to do that is to force people to use a custom voicerecord command (+startvoice) and implement at FM_Voice_SetClientListening your own control.

You have to block every voice communication for users not using that command.

PHP Code:
#include <amxmodx>
#include <fakemeta>

#define get_bit(%1,%2)     ( %1 &   1 << ( %2 & 31 ) )
#define set_bit(%1,%2)    %1 |=  ( 1 << ( %2 & 31 ) )
#define clear_bit(%1,%2)    %1 &= ~( 1 << ( %2 & 31 ) )

new g_PlayerVoice

public plugin_init()
{
    
register_clcmd("+startvoice""player_startvoice_on")
    
register_clcmd("-startvoice""player_startvoice_off")

    
register_forward(FM_Voice_SetClientListenting"setclient_listening")
}

public 
player_startvoice_on(id)
{
    
set_bit(g_PlayerVoiceid)
    
client_cmd(id"+voicerecord")
    return 
PLUGIN_HANDLED
}

public 
player_startvoice_off(id)
{
    
clear_bit(g_PlayerVoiceid)
    
client_cmd(id"-voicerecord")
    return 
PLUGIN_HANDLED
}

public 
setclient_listening(receiversenderbool:listen)
{
    if(!
is_user_connected(receiver) || !is_user_connected(sender) || (receiver == sender)
      return 
FMRES_IGNORED

    
if(!get_big(g_PlayerVoicesender))
    {
        
engfunc(EngFunc_SetClientListeningreceiversenderfalse)    // Can't talk because is not using +startvoice
        
return PLUGIN_SUPERCEDE
    
}

/*
      put your code here
      you can modify bool:listen depending on what you want and then call SetClientListening + return SUPERCEDE

      To change behavior (mute, permit, etc)
          engfunc(EngFunc_SetClientListening, receiver, sender, listen)
          return FMRES_SUPERCEDE
*/

    
return FMRES_IGNORED

__________________

Divide et vinces
approved plugins | steam account

I don't accept PM for support. Just ask on forums.
If you're looking for private work, PM me.

Last edited by joropito; 03-12-2010 at 10:36.
joropito is offline
Send a message via MSN to joropito