AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Host_Error: PF_precache_generic_I: Bad string (https://forums.alliedmods.net/showthread.php?t=226290)

OnePL 09-16-2013 00:55

Host_Error: PF_precache_generic_I: Bad string
 
Hello,

Turn off my server with the reason:
Code:

FATAL ERROR (shutting down): Host_Error: PF_precache_generic_I: Bad string 'name'
FATAL ERROR (shutting down): Host_Error: PF_precache_generic_I: Bad string

The code looks like this:
Code:

new szFile[127], szStringFile[100][256];
public plugin_precache() {
        format(szFile, 126, "addons/amxmodx/configs/roundsound.ini");
        new fHandle = fopen(szFile, "rt");

        if(!fHandle) return 0;

        new szBuffer[256], pos[256], iLines;
        while(!feof(fHandle)) {
                fgets(fHandle, szBuffer, 255);
                if(szBuffer[0] == ';') continue;

                szStringFile[iLines++] = szBuffer;
        }
        fclose(fHandle);

        for(new i; i < iLines; i++) {
                parse(szStringFile[i], pos, 255);
                precache_generic(pos);
        }
        return 0;
}

roundsound.ini file looks like this:
Code:

"sound/topmasters_fun/3.mp3" "Mega Dance - A ja wole Coca-Cole" "15"
"sound/topmasters_fun/4.mp3" "Benny G. And BBX - Feel It Way Down (TAITO Remix)" "16"
"sound/topmasters_fun/5.mp3" "DJ Trademark - Hard To Stop (Vicetone x Ne-Yo x Daft Punk)" "16"


ConnorMcLeod 09-16-2013 13:22

Re: Host_Error: PF_precache_generic_I: Bad string
 
Try to :

use trim to remove spaces and end of line
use parse so you only keep the sound path instead of path + description

Code:
new szFile[127], szStringFile[100][256]; public plugin_precache() {     format(szFile, 126, "addons/amxmodx/configs/roundsound.ini");     new fHandle = fopen(szFile, "rt");     if(!fHandle) return 0;     new szBuffer[256], szSound[256], iLines;     while(!feof(fHandle)) {         fgets(fHandle, szBuffer, 255);         trim(szBuffer);         if(szBuffer[0] == ';') continue;         // szStringFile[iLines++] = szBuffer;         parse(szBuffer, szStringFile[iLines++], charsmax(szStringFile[]));     }     fclose(fHandle);     for(new i; i < iLines; i++) {         // parse(szStringFile[i], pos, 255);         // precache_generic(pos);         precache_generic(szStringFile[i]);     }     return 0; }

OnePL 09-16-2013 14:17

Re: Host_Error: PF_precache_generic_I: Bad string
 
It did not help

Code:

Host_Error: PF_precache_sound_I: Bad string 'ďťżtopmasters_fun/rs/3.mp3'
FATAL ERROR (shutting down): Host_Error: PF_precache_sound_I: Bad string 'ďťżtopmasters_fun/rs/3.mp3'

I replaced precache_generic to precache_sound

Black Rose 09-16-2013 16:06

Re: Host_Error: PF_precache_generic_I: Bad string
 
Is the file formatted as ANSI or UTF-8?
I only get the error when trying to precache nothing (an empty line). Otherwise it works like it should...

OnePL 09-16-2013 16:31

Re: Host_Error: PF_precache_generic_I: Bad string
 
Thanks! I changed the file encoding from UTF-8 to ANSI and working properly.


All times are GMT -4. The time now is 19:10.

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