AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How to catch the "MIC" event ? (https://forums.alliedmods.net/showthread.php?t=89409)

kran 04-06-2009 01:38

How to catch the "MIC" event ?
 
I want to catch the event when player start speaking and end speaking .

How to do that?

minimiller 04-06-2009 07:51

Re: How to catch the "MIC" event ?
 
PHP Code:

register_clcmd("+voicerecord""voice_on", -1);
register_clcmd("-voicerecord""voice_off", -1); 


Exolent[jNr] 04-06-2009 16:31

Re: How to catch the "MIC" event ?
 
You cannot hook [+/-] commands from the games unless they aren't standard.

Here is how you catch it:
Code:
#include <engine> #include <fakemeta> new sv_alltalk; public plugin_init() {     register_forward(FM_Voice_SetClientListening, "FwdSetVoice");         sv_alltalk = get_cvar_pointer("sv_alltalk"); } public FwdSetVoice(receiver, sender, listen) {     if( receiver == sender     || !is_user_connected(receiver)     || !is_user_connected(sender) ) return FMRES_IGNORED;         new senSpeak = get_speak(sender);         if( senSpeak == SPEAK_MUTED ) return FMRES_IGNORED;         new recSpeak = get_speak(receiver);         if( recSpeak == SPEAK_LISTENALL     || senSpeak == SPEAK_ALL     || senSpeak == SPEAK_NORMAL && (            get_pcvar_num(sv_alltalk)         || get_user_team(receiver) == get_user_team(sender) && (                is_user_alive(sender)             || !is_user_alive(receiver)             )         )     )     {         // 'sender' is talking to 'receiver'     }         return FMRES_IGNORED; }

Owyn 04-06-2009 16:33

Re: How to catch the "MIC" event ?
 
so if i return supercode will this block the voice?
ps - if i set_speak to muted when player connect, will it stay whole game on server and he won't be able to use mic ?

Exolent[jNr] 04-06-2009 16:34

Re: How to catch the "MIC" event ?
 
Quote:

Originally Posted by .Owyn. (Post 799159)
so if i return supercode will this block the voice?

Where I put the comment, just add this code:
Code:
engfunc(EngFunc_SetClientListening, receiver, sender, 0); return FMRES_SUPERCEDE;

Quote:

Originally Posted by .Owyn. (Post 799159)
ps - if i set_speak to muted when player connect, will it stay whole game on server and he won't be able to use mic ?

Correct. It will not change unless another plugin changes it.

joropito 03-07-2010 17:18

Re: How to catch the "MIC" event ?
 
I'm getting always 0 as return value of get_speak.

I'm missing something?

Bugsy 03-10-2010 09:02

Re: How to catch the "MIC" event ?
 
I put a client_print in there to test and it constantly printed even when I wasn't pressing\holding voice com button. Or is that not what it's supposed to hook?

PHP Code:

{
    
client_printsender print_chat "I am talking [%d:%d]" sender receiver );
   
// 'sender' is talking to 'receiver'



Exolent[jNr] 03-10-2010 16:55

Re: How to catch the "MIC" event ?
 
That forward is called to set if 'sender' can talk to 'receiver'.
You can change the return value or return FMRES_SUPERCEDE and use:
engfunc( EngFunc_SetClientListening, receiver, sender, 0 );
And that will set that sender can't talk to receiver.


All times are GMT -4. The time now is 02:28.

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