AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   catching player using voice (https://forums.alliedmods.net/showthread.php?t=120571)

aaarnas 03-06-2010 07:12

catching player using voice
 
Hello. Is it possible, to catch, when player is speaking with his microphone?
I need to set time to pcvar, when he doing it.

Kryzu 03-06-2010 10:02

Re: catching player using voice
 
Use search:
http://forums.alliedmods.net/showthr...&highlight=mic

aaarnas 03-10-2010 08:14

Re: catching player using voice
 
I knew about this, bus couldn't realise how to use it.

I need to get when player push speak button or speaking at the moment. That only checks players speak flags.

worldspawn 03-10-2010 13:18

Re: catching player using voice
 
http://forums.alliedmods.net/showthread.php?t=89409
if_it_can_help

ConnorMcLeod 03-10-2010 13:29

Re: catching player using voice
 
Same thread as #2, and doesn't help.

aaarnas 03-10-2010 13:50

Re: catching player using voice
 
I was found a better tutorial about that, but this isn't what I need. I think it isn't possible to do.

Or maybe is possible to catch that icon, witch appear when player is talking ?

Sylwester 03-10-2010 16:27

Re: catching player using voice
 
You can't just catch it, because it's handled client-side. I needed this before and I searched a lot, but I found nothing that could easily solve this problem.

Since server is transmitting data to clients, then it must be possible to detect it, but it probably requires messing with memory.

I found a way to detect when player press +voicerecord button (though it's not very good and clients can mess up results if they know how):
client cvar "voice_modenable" is always set to 1 when client press +voicerecord, so you can constantly query it and set it to 0 whenever query returns 1 (client just pressed +voicerecord), but I have no idea how to detect when client stops using it.

aaarnas 03-12-2010 08:11

Re: catching player using voice
 
Thats strange. get_user_info always returns me "voice_modenable" 0, what ever i set it.

joropito 03-12-2010 10:33

Re: catching player using voice
 
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



Sylwester 03-13-2010 02:44

Re: catching player using voice
 
Quote:

Originally Posted by aaarnas (Post 1115209)
Thats strange. get_user_info always returns me "voice_modenable" 0, what ever i set it.

You must use query_client_cvar to get correct value.


All times are GMT -4. The time now is 19:50.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.