Raised This Month: $ Target: $400
 0% 

FM_PrecacheSound forwards only 4 sound precaches


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Silencer123
Veteran Member
Join Date: Jul 2006
Old 05-30-2009 , 10:25   FM_PrecacheSound forwards only 4 sound precaches
Reply With Quote #1

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:
#include <amxmodx> #include <fakemeta> new const REPLACEMENTFILE[] = "addons/amxmodx/configs/sr.cfg"; const MAXENTRIES = 512; const MAXPATHLENGTH = 127; new const VERSION[]=  "1.0"; new i; new column1[MAXENTRIES][MAXPATHLENGTH+1]; new column2[MAXENTRIES][MAXPATHLENGTH+1]; public plugin_precache() {     register_forward(FM_PrecacheSound, "sr_do_debug", 0);     register_plugin("Sound replacement", VERSION, "Silencer")     if(file_exists(REPLACEMENTFILE)) {         new len = file_size(REPLACEMENTFILE, 1); // Amount of lines in file         if(len > MAXENTRIES)             len = MAXENTRIES;         new txtlen;         const arrays=2*MAXPATHLENGTH+1;         new line[arrays+1];         new skipline;         new hack[MAXPATHLENGTH+6+1]         for(i = 0; i < len-skipline; i++) {             read_file(REPLACEMENTFILE, i+skipline, line, arrays, txtlen);             log_amx("[SR] Debug: Read line %i.", i+skipline+1);             if(contain(line, "//") == 0) { // skip comments                 i--;                 skipline++;                 log_amx("[SR] Debug: Skipping comment in line %i.", i+skipline+1);             } else {                 parse(line, column1[i], MAXPATHLENGTH+1, column2[i], MAXPATHLENGTH+1);                 log_amx("[SR] Debug: Parsed ^"%s^" and ^"%s^".", column1[i], column2[i]);                 if(column1[i][MAXPATHLENGTH] != 0) {                     column1[i][MAXPATHLENGTH] = 0;                     log_amx("[SR] Warning: Origin sound file path in line %i of sound replacement file is longer than %i chars! Not using.", i+skipline+1, MAXPATHLENGTH);                     i--;                     skipline++;                 } else if(column2[i][MAXPATHLENGTH] != 0) {                     column2[i][MAXPATHLENGTH] = 0;                     log_amx("[SR] Warning: Target sound file path in line %i of sound replacement file is longer than %i chars! Not using.", i+skipline+1, MAXPATHLENGTH);                     i--;                     skipline++;                 } else {                     format(hack, 6, "sound/");                     add(hack, MAXPATHLENGTH+6, column1[i], 0);                     if(!file_exists(hack)) { // file_exists starts searching in modfolder                         log_amx("[SR] Warning: Origin sound file path in line %i of sound replacement file not found! Not using.", i+skipline+1, MAXPATHLENGTH);                         i--;                         skipline++;                     } else {                         format(hack, 6, "sound/");                         add(hack, MAXPATHLENGTH+6, column2[i], 0);                         if(!file_exists(hack)) { // file_exists starts searching in modfolder                             log_amx("[SR] Warning: Target sound file path in line %i of sound replacement file not found! Not using.", i+skipline+1, MAXPATHLENGTH);                             i--;                             skipline++;                         }                     }                 }             }         }         if(i > 0) {             log_amx("[SR] Debug: Replacing %i sounds...", i);             register_forward(FM_PrecacheSound, "sr_do", 0);         } else {             log_amx("[SR] Error: Zero sounds replaced.");             set_fail_state("Nothing to replace");         }     } else {         log_amx("[SR] Error: Sound replacement file ^"%s^" not found.", REPLACEMENTFILE);         set_fail_state("File not found");     } } public sr_do(const PATH[]) { // PATH is the original sound file path     log_amx("[SR] Debug: ^"sr_do^" called!");     for(new j = 0; j < i; j++) {         log_amx("[SR] Debug: Checking if ^"%s^" equals ^"%s^"", PATH, column1[j]);         if(equali(PATH, column1[j])) {             log_amx("[SR] Debug: Yes! CALLING FORWARD_RETURN!");             forward_return(FMV_STRING, column2[j]);             return FMRES_SUPERCEDE;         }         log_amx("[SR] Debug: No.");     }     return FMRES_IGNORED; } public sr_do_debug(const PATH[]) {     log_amx("[SR] Debug: ^"sr_do_debug^" called! PATH = ^"%s^"", PATH);     return FMRES_IGNORED; }
Now, see the console output after loading any map:
Code:
// blabla

L 05/30/2009 - 15:54:19: [sr.amxx] [SR] Debug: Read line 1.
L 05/30/2009 - 15:54:19: [sr.amxx] [SR] Debug: Skipping comment in line 1.
L 05/30/2009 - 15:54:19: [sr.amxx] [SR] Debug: Read line 2.
L 05/30/2009 - 15:54:19: [sr.amxx] [SR] Debug: Skipping comment in line 2.
L 05/30/2009 - 15:54:19: [sr.amxx] [SR] Debug: Read line 3.
L 05/30/2009 - 15:54:19: [sr.amxx] [SR] Debug: Skipping comment in line 3.
L 05/30/2009 - 15:54:19: [sr.amxx] [SR] Debug: Read line 4.
L 05/30/2009 - 15:54:19: [sr.amxx] [SR] Debug: Skipping comment in line 4.
L 05/30/2009 - 15:54:19: [sr.amxx] [SR] Debug: Read line 5.
L 05/30/2009 - 15:54:19: [sr.amxx] [SR] Debug: Skipping comment in line 5.
L 05/30/2009 - 15:54:19: [sr.amxx] [SR] Debug: Read line 6.
L 05/30/2009 - 15:54:19: [sr.amxx] [SR] Debug: Skipping comment in line 6.
L 05/30/2009 - 15:54:19: [sr.amxx] [SR] Debug: Read line 7.
L 05/30/2009 - 15:54:19: [sr.amxx] [SR] Debug: Skipping comment in line 7.
L 05/30/2009 - 15:54:19: [sr.amxx] [SR] Debug: Read line 8.
L 05/30/2009 - 15:54:19: [sr.amxx] [SR] Debug: Skipping comment in line 8.
L 05/30/2009 - 15:54:19: [sr.amxx] [SR] Debug: Read line 9.
L 05/30/2009 - 15:54:19: [sr.amxx] [SR] Debug: Skipping comment in line 9.
L 05/30/2009 - 15:54:19: [sr.amxx] [SR] Debug: Read line 10.
L 05/30/2009 - 15:54:19: [sr.amxx] [SR] Debug: Parsed "weapons/sniper_zoom.wav" and "weapons/explode3.wav".
L 05/30/2009 - 15:54:19: [sr.amxx] [SR] Debug: Replacing 1 sounds...

// blabla

L 05/30/2009 - 15:54:21: [sr.amxx] [SR] Debug: "sr_do_debug" called! PATH = "player/pl_wade1.wav"
L 05/30/2009 - 15:54:21: [sr.amxx] [SR] Debug: "sr_do" called!
L 05/30/2009 - 15:54:21: [sr.amxx] [SR] Debug: Checking if "player/pl_wade1.wav" equals "weapons/sniper_zoom.wav"
L 05/30/2009 - 15:54:21: [sr.amxx] [SR] Debug: No.
L 05/30/2009 - 15:54:21: [sr.amxx] [SR] Debug: "sr_do_debug" called! PATH = "player/pl_wade2.wav"
L 05/30/2009 - 15:54:21: [sr.amxx] [SR] Debug: "sr_do" called!
L 05/30/2009 - 15:54:21: [sr.amxx] [SR] Debug: Checking if "player/pl_wade2.wav" equals "weapons/sniper_zoom.wav"
L 05/30/2009 - 15:54:21: [sr.amxx] [SR] Debug: No.
L 05/30/2009 - 15:54:21: [sr.amxx] [SR] Debug: "sr_do_debug" called! PATH = "player/pl_wade3.wav"
L 05/30/2009 - 15:54:21: [sr.amxx] [SR] Debug: "sr_do" called!
L 05/30/2009 - 15:54:21: [sr.amxx] [SR] Debug: Checking if "player/pl_wade3.wav" equals "weapons/sniper_zoom.wav"
L 05/30/2009 - 15:54:21: [sr.amxx] [SR] Debug: No.
L 05/30/2009 - 15:54:21: [sr.amxx] [SR] Debug: "sr_do_debug" called! PATH = "player/pl_wade4.wav"
L 05/30/2009 - 15:54:21: [sr.amxx] [SR] Debug: "sr_do" called!
L 05/30/2009 - 15:54:21: [sr.amxx] [SR] Debug: Checking if "player/pl_wade4.wav" equals "weapons/sniper_zoom.wav"
L 05/30/2009 - 15:54:21: [sr.amxx] [SR] Debug: No.

// blabla
As you can see, I already debugged a lot.
In 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 --
// One line, one sound replacement:
// First comes the path to the sound to replace.
// Then comes a space.
// Then comes the path to the new sound file.
// Don't wrap quotes around the paths. Example:
// ambience/squeeks1.wav my_great_server_with_custom_sounds/my_squeeks1_custom.wav
// Please keep the file paths short. Don't make long file names and deep folder structures.
// The above would be a horrid example of doing that.
weapons/sniper_zoom.wav weapons/explode3.wav
__________________
EAT YOUR VEGGIES

Last edited by Silencer123; 05-30-2009 at 10:30.
Silencer123 is offline
 


Thread Tools
Display Modes

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 13:55.


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