FM_PrecacheSound forwards only 4 sound precaches
I tried to make a simple sound replacement plugin, but a method called by reigster_forward looking for FM_PrecacheSound is only called four times. Always for the same four sounds. First, have some code:
Code:
Code:
// blablaIn the end, sr_do is only called for those four pl_wade#.wav-sounds. I added the method sr_do_debug to check whether I lost time by the the code block which parses the sound replacement file, but the whole thing seems to be as linear as it is supposed to be. (Thank god) Any clue what the problem might be? This is the sr.cfg that is used: Code:
// -- AMXX Sound replacement file -- |
Re: FM_PrecacheSound forwards only 4 sound precaches
The good news is that the problem is really not your code. I tested it as it is just changed the config file entry to a sound that I have in my computer and I got lots of debug. (Not only those four sounds)
The bad news is that I don't know what's the problem. __ Apart of your problem, but it won't hurt: Don't use read_file to parse a file. read_file reads, everytime it's called, the file from its beginning. Basically you are reading n + (n - 1) + (n - 2) + 1 lines instead of n. And this PHP Code:
should be PHP Code:
|
Re: FM_PrecacheSound forwards only 4 sound precaches
Thanks for taking the time to test this, and for doing it this fast.
About using equal instead, okay, was not aware of the third parameter. But it seems to now return false all the time. About read_file: What else to use? (And how?) In C++ you'd use a file handle, and close it when you are done reading everything. As far as I know this option exists in sourcemod. Didn't ever see it in AMXX. I now removed the check for if the file exists, since if the file is in a *.gcf, it won't be found even if there. I tried running this plugin on Sven Co-op 4 and 3. My first suspicion was SC 4.0's new sound engine being at fault, but the good ol' 3.0 from 2004 or so output the same. Now testing this on Half-Life straight. [...] Better, but still not perfect. It now parses billions of sounds and it finds the sound to replace, okay. However, the replacement seems to have failed. Still hearing the original sound. And more strangely, every time a sound is heard, the forward is called again and again for the heard sounds. Only thing I can think of why it does this is to check if the sound was precached because Valve was too stupid to make a variable with arrays to act as a list for precached sounds. |
Re: FM_PrecacheSound forwards only 4 sound precaches
About the read, fopen, fclose, fgets etc. exist. See in file.inc
|
Re: FM_PrecacheSound forwards only 4 sound precaches
Quote:
|
Re: FM_PrecacheSound forwards only 4 sound precaches
Thanks. Still, the main problem remains.
Seems it can only replace some sounds. E.g. something happend to crowbar-hits-wall-sound, but the sound of a crossbowbolt being shot cannot be changed. Also, the only change I can manage is that it says SV_StartSound: sound xyz not precached. Whereas xyz would still be the original sound. So I'd have to hook up SV_StartSound. Is this possible? I'm finding nothing comparable anywhere. Also, I have to unregister the forward at an appropriate point. EDIT: I am so completely unsure if I am using forward_return correctly here. Can I just return the parameters one after another like this? Code:
|
Re: FM_PrecacheSound forwards only 4 sound precaches
And what the heck is up with this?
Code:
FM_BuildSoundMsg, // void ) (ent, iChannel, const szSample[], Float:fVolume, Float:fAttenuation, iFlags, iPitch, iMsg_Dest, iMsg_Type, const Float:fOrigin[3], ent) |
| All times are GMT -4. The time now is 13:55. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.