Raised This Month: $ Target: $400
 0% 

How to catch the "MIC" event ?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
kran
Junior Member
Join Date: Apr 2009
Old 04-06-2009 , 01:38   How to catch the "MIC" event ?
Reply With Quote #1

I want to catch the event when player start speaking and end speaking .

How to do that?
kran is offline
minimiller
Veteran Member
Join Date: Aug 2007
Location: United Kingdom
Old 04-06-2009 , 07:51   Re: How to catch the "MIC" event ?
Reply With Quote #2

PHP Code:
register_clcmd("+voicerecord""voice_on", -1);
register_clcmd("-voicerecord""voice_off", -1); 
__________________
minimiller is offline
Send a message via MSN to minimiller
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 04-06-2009 , 16:31   Re: How to catch the "MIC" event ?
Reply With Quote #3

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; }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Owyn
Veteran Member
Join Date: Nov 2007
Old 04-06-2009 , 16:33   Re: How to catch the "MIC" event ?
Reply With Quote #4

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 ?
__________________
☜ Free Mozy ☂backup\҉sync user
Quote:
Американский форум - Задаёшь вопрос, потом тебе отвечают.
Израильский форум - Задаёшь вопрос, потом тебе задают вопрос.
Русский форум - Задаёшь вопрос, потом тебе долго рассказывают, какой ты мудак.
Owyn is offline
Send a message via ICQ to Owyn
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 04-06-2009 , 16:34   Re: How to catch the "MIC" event ?
Reply With Quote #5

Quote:
Originally Posted by .Owyn. View Post
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. View Post
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.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
joropito
AlliedModders Donor
Join Date: Mar 2009
Location: pfnAddToFullPack
Old 03-07-2010 , 17:18   Re: How to catch the "MIC" event ?
Reply With Quote #6

I'm getting always 0 as return value of get_speak.

I'm missing something?
__________________

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.
joropito is offline
Send a message via MSN to joropito
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 03-10-2010 , 09:02   Re: How to catch the "MIC" event ?
Reply With Quote #7

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'

__________________
Bugsy is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 03-10-2010 , 16:55   Re: How to catch the "MIC" event ?
Reply With Quote #8

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.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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