Raised This Month: $ Target: $400
 0% 

Another problem with emit_sound


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Pro Patria Finland
Senior Member
Join Date: Apr 2006
Location: BaronPub.com
Old 06-05-2007 , 14:47   Another problem with emit_sound
Reply With Quote #1

I am using two different "knife" models in Freemanmod. Crowbar for the Gordons and the pipewrench for the Shephards. So obviously I need two different sounds too. So this is how I am doing it:

Code:
public fw_emitsound(id,channel,sample[],Float:volume,Float:attenuation,fFlags,pitch) {     if (cs_get_user_team(id) == CS_TEAM_T) {                 if(equal(sample,"weapons/knife_slash1.wav")) {                 emit_sound(id,channel,"cbar_miss1.wav",volume,attenuation,fFlags,pitch);         return FMRES_SUPERCEDE;         } }     else if (cs_get_user_team(id)== CS_TEAM_CT) {                         if(equal(sample,"weapons/knife_slash1.wav")) {                 emit_sound(id,channel,"pwrench_miss2.wav",volume,attenuation,fFlags,pitch);         return FMRES_SUPERCEDE;         } }             return FMRES_IGNORED;   }

So anyhows the plugin for this part works exactly how I want it to work (I tested it with Potti). When the Gordon hits a wall with his crowbar, I hear the crowbar sound and when the Shephard hits the wall with his pipewrench, I hear the pipewrench sound. Still, my console gets filled with "native error" on the line with "cs_get_user_team" and it also says "player out of range."

Any suggestions how to fix this / do it differently?
__________________
I am not a number. I am Gordon Freeman!
Pro Patria Finland is offline
Old 06-05-2007, 15:15
organizedKaoS
This message has been deleted by organizedKaoS.
Pro Patria Finland
Senior Member
Join Date: Apr 2006
Location: BaronPub.com
Old 06-05-2007 , 15:26   Re: Another problem with emit_sound
Reply With Quote #2

I didn't believe it was gonna, but changing to get_user_team(id) actually worked. (I also tried the first option, but it returned with the same errors).

Thanks alot!
__________________
I am not a number. I am Gordon Freeman!
Pro Patria Finland is offline
Zenith77
Veteran Member
Join Date: Aug 2005
Old 06-06-2007 , 10:07   Re: Another problem with emit_sound
Reply With Quote #3

The reason why you were getting errors is because you never added any check to the forward to make sure it's a player. The forward could have been called when some other entity made a sound. To fix this:

Code:
public fw_emitsound(id,channel,sample[],Float:volume,Float:attenuation,fFlags,pitch) {      if (!is_user_alive(id)) // you can do is_user_connected() to if you wish           return FMRES_IGNORED;      // other code here }

And get_user_team() stopped throwing errors because it doesn't throw any in the first place:

Code:
    if (index < 1 || index > gpGlobals->maxClients)         return -1;
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred

Last edited by Zenith77; 06-06-2007 at 10:12.
Zenith77 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 10:30.


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