Raised This Month: $51 Target: $400
 12% 

Playing sounds via player voicecomm (RawAudio)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Peace-Maker
SourceMod Plugin Approver
Join Date: Aug 2008
Location: Germany
Old 11-07-2010 , 12:42   Playing sounds via player voicecomm (RawAudio)
Reply With Quote #1

This stock allows you to play a sound to all clients as if some player is saying it through his microphone. It shows the voice activation on the right side of the screen.

You can only play one sound at a time. If there is currently a sound played or a bot is voicechatting the playing is stopped and your sound is played instead.

Huge thanks to javalia, who helped finding out the struct of the RawAudio user message.

PHP Code:
/**
 * Plays a soundfile as if the player is using voicecomm.
 *
 * The voiceindicator is shown on the right, as if the players is talking.
 *
 * @param emitter        The player who's speaking.
 * @param soundfile        Path to the soundfile relative to the sound/ folder.
 * @param length        Length in seconds how long the hud "voiceindicator" is shown.
 * @param pitch            The pitch of the audiofile.
 * @return                True on success, false on failure.
 */
stock bool:SendVoiceCommAll(const emitter, const String:soundfile[], Float:length 0.0pitch 100)
{
    new 
Handle:hBf StartMessageAll("RawAudio");

    if(
hBf != INVALID_HANDLE)
    {
        
BfWriteByte(hBfpitch);
        
BfWriteByte(hBfemitter);
        
BfWriteFloat(hBflength);
        
BfWriteString(hBfsoundfile);
        
EndMessage();
        return 
true;
    }
    return 
false;

__________________
Peace-Maker is offline
javalia
Senior Member
Join Date: May 2009
Location: korea, republic of
Old 11-07-2010 , 13:07   Re: Playing sounds via player voicecomm (RawAudio)
Reply With Quote #2

this will not print any radio text msg in chat, so u will need to do it in manual
(this is not bad thing, it is good thing)

and, u can hear voice of enemy by this.

and, emitter has no need to be a client, it is enough by a entity. even world entity can make voice, and a prop can, but no voicemark will shown.

this is my version of functions

Code:
stock bool:sendRawAudioMsgTo(client, target, const String:sSound[255], iVoicePitch = 100, Float:fVoiceMarkShowTime = 1.0){
    
    //Peace-Maker has found how to use this usermsg, well, i helped him lol
    
    new Handle:buffer = StartMessageOne("RawAudio", target);
    
    if (buffer != INVALID_HANDLE) { 
        
        BfWriteByte(buffer, iVoicePitch);
        BfWriteByte(buffer, client);
        BfWriteFloat(buffer, fVoiceMarkShowTime);
        BfWriteString(buffer, sSound);
        EndMessage(); 
        
        return true;
        
    }
    
    return false;
    
}
it will only send msg to certain player, not so differnt from original one of first thread
__________________
javalia is offline
honorcode23
BANNED
Join Date: Mar 2010
Location: Chile
Old 11-08-2010 , 22:30   Re: Playing sounds via player voicecomm (RawAudio)
Reply With Quote #3

May i ask something? Will this work if i use a soundfile located on the server and send the sound using this method to all players without forcing them to download? I mean, will the sound be interpretated as voice comunication (Without download) :/?
honorcode23 is offline
javalia
Senior Member
Join Date: May 2009
Location: korea, republic of
Old 11-09-2010 , 02:37   Re: Playing sounds via player voicecomm (RawAudio)
Reply With Quote #4

Quote:
Originally Posted by honorcode23 View Post
May i ask something? Will this work if i use a soundfile located on the server and send the sound using this method to all players without forcing them to download? I mean, will the sound be interpretated as voice comunication (Without download) :/?
no, u cannot, u should make all clients download sound file to hear the sound.
__________________
javalia 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 05:51.


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