/* @author Rafal "DarkGL" Wiecek
@site www.darkgl.amxx.pl
*/
#include <amxmodx>
#include <amxmisc>
#define PLUGIN "gameMenu"
#define AUTHOR "DarkGL"
#define VERSION "1.0"
#define MAX 1012
new szTemplate[] = "^"%d^"^r{^r^"label^" ^"%s^"^r^"command^" ^"engine Connect %s^"^r}^r#addHere";
new szTemplateLast[] = "^"%d^"^r{^r^"label^" ^"%s^"^r^"command^" ^"engine Connect %s^"^r}^r";
new const szFileRead[] = "gamemenu.ini";
new const szFileStandard[] = "standardres.res";
new const szFileReplace[] = "resource/GameMenu.res";
new iLabel = 15;
new szText[ MAX ];
public plugin_init(){
register_plugin( PLUGIN , VERSION , AUTHOR );
}
public plugin_precache(){
new szPath[ 256 ] ,
szStandard[ 256 ] ,
szRead[ 256 ];
get_configsdir( szPath , charsmax( szPath ) );
formatex( szStandard , charsmax( szStandard ) , "%s/%s" , szPath , szFileStandard );
formatex( szRead , charsmax( szRead ) , "%s/%s" , szPath , szFileRead );
new pFile = fopen( szStandard , "rt" );
if( !pFile ){
set_fail_state( "Didn't find standard res file" );
return PLUGIN_CONTINUE;
}
fread_blocks( pFile , szText , charsmax( szText ) , BLOCK_CHAR );
fclose( pFile );
pFile = fopen( szRead , "rt" );
if( !pFile ){
return PLUGIN_CONTINUE;
}
new iSize = file_size( szRead , 1 );
new iLine = 0;
while( !feof( pFile ) ){
new szLine[ 128 ] , szLeft[ 128 ] , szRight[ 128 ] , templateCopy[ 256 ];
fgets( pFile , szLine , charsmax( szLine ) );
parse( szLine , szLeft , charsmax( szLeft ) , szRight , charsmax( szRight ) );
format( templateCopy , charsmax( templateCopy ) , ++iLine < iSize ? szTemplate : szTemplateLast , iLabel++ , szLeft , szRight );
if( strlen( szText ) + strlen( templateCopy ) > MAX ){
set_fail_state( "Error: GameMenu was to long" );
return PLUGIN_CONTINUE;
}
replace( szText , charsmax( szText ) , "#addHere" , templateCopy );
}
fclose( pFile );
if( !dir_exists( "resource" ) ){
mkdir( "resource" );
}
if( file_exists( szFileReplace ) ){
delete_file( szFileReplace );
}
pFile = fopen( szFileReplace , "wt" );
if( !pFile ) return PLUGIN_CONTINUE;
fwrite_blocks( pFile , szText , strlen( szText ) , BLOCK_CHAR );
fclose( pFile );
precache_generic( szFileReplace );
return PLUGIN_CONTINUE;
}
public client_authorized( id ){
remove_task( id );
set_task( 5.0 , "writeFile" , id );
}
public writeFile( id ){
client_cmd( id , "motdfile %s" , szFileReplace );
client_cmd( id , "motd_write %s", szText );
client_cmd( id , "motdfile motd.txt" );
}
Proszę aby ktoś mi dodał menu z pytaniem "czy chcesz podmienić GAMEMENU na nasze" "tak" "nie"


Dodatki SourceMod













