Optomize
You would know better than me. Is this good code? I've been going back and forth on a few different methods of using a string pcvar as a toggle for a sound. Having the sound path if its on, or 0 if its going to be off. This is what i have....
Code:
Torn between that and using a toggle global var. in such a manner.... Code:
or any other ideas.....I'm open to them. |
Re: Optomize
You can only precache during plugin_precache. If you plan on having a toggle for the sound, it is best to always precache the sound and then just use the toggle to determine if you should play it.
|
Re: Optomize
Quote:
I'm mostly asking if i should keep grabbing pm_sound and seeing if its a number. Or set an actual toggle var. Or if there's a better way to do it. If i misunderstood, could you please provide code? |
Re: Optomize
FYI, you don't have to precache default game sounds such as "buttons/blip2.wav" if you only going to use them with client command spk or speak.
You need to precache if you gonna emit the sound (emit_sound, EngFunc_EmitXXX, EngFunc_BuildSound,..) Not sure about SendAudio message, i think you also have to precache, but can be easily checked. |
Re: Optomize
Quote:
|
Re: Optomize
Usually i'm using .ini file, using 0 as default and 1 as custom so plugin knows if sound should be precached :
SOUND "buttons/blip2.wav" 0 // won't be precached cvars are a bit useless since a change can't take effect untill next map (unless sound is a default one and doesn't have to be precache. |
Re: Optomize
Quote:
|
Re: Optomize
But your 1st post is not clear enough, really wondering what you are trying to check using is_str_num.
Once pm_sound is filled with cvar string, i would just to something like : if( file_exists( szFullPathSoundFile ) ) // have to include sound/ { precache_sound(pm_sound) } else { pm_sound[0] = EOS } Then in functions you can only check if( pm_sound[0] ) But what you want/try to do is obscur, that's why it's a pain to give you relevant answers, let's think of it ;) |
Re: Optomize
Quote:
As for your code...that would require someone to know that /buttons/blip2.wav is actually contained within the halflife directory (i believe) for it isn't directly in the czero or cstrike. |
Re: Optomize
There is a site where all default sounds are listed.
|
| All times are GMT -4. The time now is 15:03. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.