AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Issue with replacing text in a file (https://forums.alliedmods.net/showthread.php?t=27773)

Geesu 04-28-2006 22:27

Issue with replacing text in a file
 
So I have this function:

Code:
public WC3_EnableModule( module_name[] ) {     new modulesINI[] = "addons/amxmodx/configs/modules.ini";     new tempModulesINI[] ="addons/amxmodx/configs/temp_modules.ini";     new fp = fopen( modulesINI, "r" );     new data[128];     new fptemp = fopen( tempModulesINI, "w" );     while( !feof( fp ) )     {         fgets( fp, data, 63 );         // Module Name Found         if ( contain( data, module_name ) != -1 )         {             // Semicolon before module name found             if ( contain( data, ";" ) != -1 )             {                 new len = strlen( data );                 for ( new i = 1; i < len; i++ )                 {                     fputc( fptemp, data[i] );                 }             }         }         else         {             new len = strlen( data );             for ( new i = 0; i < len; i++ )             {                 fputc( fptemp, data[i] );             }         }     }     fclose( fp );     fclose( fptemp );         delete_file( modulesINI );         //we dont have an rename_file function so we have to copy the temp file again     fp = fopen( modulesINI, "w" );     fptemp = fopen( tempModulesINI, "r" );     while( !feof( fptemp ) )     {         fgets( fptemp, data, 63 );                 new len = strlen( data );         for ( new i = 0; i < len; i++ )         {             fputc( fp, data[i] );         }             }         fclose( fp );     fclose( fptemp );         //delete the tempfile     //delete_file( tempModulesINI ); }

Which is called by:

Code:
public WC3_CheckModules() {     WC3_DetermineGame();     new bool:bReloadMap = false;         server_print( "Checking %d modules with game %d", iTotalNotLoadedModules, g_MOD );     // Loop through all the modules and determine what we need to do     for ( new i = 0; i < iTotalNotLoadedModules; i++ )     {         // Enable cstrike module         if ( equal( szNotLoadedModules[i], "cstrike" ) )         {             if ( g_MOD == GAME_CSTRIKE || g_MOD == GAME_CZERO )             {                 WC3_EnableModule( "cstrike_amxx" );                 bReloadMap = true;             }         }         // Enable DOD Fun module         else if ( equal( szNotLoadedModules[i], "dod" ) )         {             if ( g_MOD == GAME_DOD )             {                 WC3_EnableModule( "dodfun_amxx" );                 bReloadMap = true;             }         }         // Enable DOD X module         else if ( equal( szNotLoadedModules[i], "dodx" )  )         {             if ( g_MOD == GAME_DOD )             {                 WC3_EnableModule( "dodx_amxx" );                 bReloadMap = true;             }         }         // Enable SQL Module         else if ( equal( szNotLoadedModules[i], "dbi" ) )         {             WC3_EnableModule( "sqlite_amxx" );             bReloadMap = true;         }         // Enable Engine module         else if ( equal( szNotLoadedModules[i], "engine" ) )         {             WC3_EnableModule( "engine_amxx" );             bReloadMap = true;         }         // Enable Fakemeta module         else if ( equal( szNotLoadedModules[i], "fakemeta" ) )         {             WC3_EnableModule( "fakemeta_amxx" );             bReloadMap = true;         }         // Enable Fun module         else if ( equal( szNotLoadedModules[i], "fun" ) )         {             WC3_EnableModule( "fun_amxx" );             bReloadMap = true;         }         server_print( "Module Not Loaded: %s", szNotLoadedModules[i] );     }     if ( bReloadMap )     {         server_print( "Going to reload the map soon..." );         set_task( 2.0, "WC3_ReloadMap" );     } }

The function removes the ; before the lines in modules.ini as it should for EVERY function call above except for sqlite_amxx

For sqlite_amxx it just erased the line, i have NO idea why, can anyone shed some light onto this?

Thanks,
Josh

SweatyBanana 04-28-2006 22:42

Code:

else if ( equal( szNotLoadedModules[i], "dbi" ) 0 )

U have a zero in there...

Geesu 04-29-2006 02:25

LOL ignore that.... it was && 0 which was just there for testing and i didn't remove all of it


All times are GMT -4. The time now is 05:07.

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