Правила форума Гаранты форума
Размещение рекламы AMX-X компилятор

Здравствуйте, гость Вход | Регистрация

Наши новости:

14-дек
24-апр
10-апр
11-апр

отредактируйте это

Статус пользователя whythis
сообщение 12.6.2021, 23:11
Сообщение #1
Стаж: 4 года 11 месяцев

Сообщений: 8
Благодарностей: 1
Полезность: 0

Привет, у меня есть этот код: Код:
#include <amxmodx>
#include <amxmisc>

new const Version[] = "0.2";

const MAX_LINE_LENGTH = 64;
const MAX_LINES = 100;
const MENU_READY = -1;

new g_MenuID = MENU_READY;
new g_szConfigFile[ 64 ] , g_szFileLine[ MAX_LINE_LENGTH ] , g_FileLines[ MAX_LINES ];
new g_pCvarFile , g_pCvarComment , g_pCvarUseConfigsDir;

public plugin_init()
{
register_plugin( "Config Editor Menu" , Version , "bugsy" );

register_clcmd( "configmenu" , "ShowConfigMenu" , ADMIN_RCON );

g_pCvarFile = register_cvar( "cem_filename" , "maps.ini" );
g_pCvarComment = register_cvar( "cem_commentline" , "1" );
g_pCvarUseConfigsDir = register_cvar( "cem_useconfigsdir" , "1" );
}

public ShowConfigMenu( id , level , cid )
{
if ( !cmd_access( id , level, cid , 0 ) )
return PLUGIN_HANDLED;

if ( g_MenuID != MENU_READY )
{
console_print( id , "* Another user is currently editing this file. Please try again later." );
return PLUGIN_HANDLED;
}

new iFile , szFile[ 32 ] , iLine , iPos;

if ( get_pcvar_num( g_pCvarUseConfigsDir ) )
{
szFile[ 0 ] = '/';
get_pcvar_string( g_pCvarFile , szFile[ 1 ] , charsmax( szFile ) );
copy( g_szConfigFile[ get_configsdir( g_szConfigFile , charsmax( g_szConfigFile ) ) ] , charsmax( g_szConfigFile ) , szFile );
}
else
{
get_pcvar_string( g_pCvarFile , g_szConfigFile , charsmax( g_szConfigFile ) );
}

if ( ( iFile = fopen( g_szConfigFile , "rt" ) ) )
{
g_MenuID = menu_create( "Edit Config" , "MenuItemSelected" );

while ( ( iPos < ( MAX_LINES - 1 ) ) && ( fgets( iFile , g_szFileLine , charsmax( g_szFileLine ) ) ) )
{
trim( g_szFileLine );

if ( g_szFileLine[ 0 ] && ( g_szFileLine[ 0 ] != ';' ) && ( g_szFileLine[ 0 ] != '/' && g_szFileLine[ 1 ] != '/' ) )
{
g_FileLines[ iPos++ ] = iLine;
menu_additem( g_MenuID , g_szFileLine , g_szFileLine , ADMIN_KICK );
}
iLine++;
}

fclose( iFile );

if ( !menu_display( id , g_MenuID ) )
{
console_print( id , "* There are no items in this config file." );
menu_destroy( g_MenuID );
g_MenuID = MENU_READY;
}
}
else
{
console_print( id , "* Error opening file: %s" , g_szConfigFile );
}

return PLUGIN_HANDLED;
}

public MenuItemSelected( id , iMenuID , iItem )
{
new iAccess , iCB

if ( iItem >= 0 )
{
menu_item_getinfo( iMenuID , iItem , iAccess , g_szFileLine[ 1 ] , charsmax( g_szFileLine ) - 1 , _ , _ , iCB );
g_szFileLine[ 0 ] = get_pcvar_num( g_pCvarComment ) ? ';' : EOS;
write_file( g_szConfigFile , g_szFileLine , g_FileLines[ iItem ] );
}

menu_destroy( g_MenuID );
g_MenuID = MENU_READY;
}

и мне нравится такая работа: когда пользователь выбирает строку, прежде чем удалить ее, откройте новое меню и покажите что-то вроде этого:
Код:
Special Vip name is : %s // first line part 
Special Vip Steam : %s // part 2 of line
Special Vip time play : %d // part 3 of line
Special Vip Point : %s // part 4
Special Vip Mancmoney : %s // part 5
Special Vip Lase visit : %d // part 6

1. Remove this VIP
0. Exit


Отредактировал: $@NyA, - 13.6.2021, 0:12
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   Цитировать сообщение
  Ответить в данную темуНачать новую тему
 
0 пользователей и 1 гостей читают эту тему: