I found this but the configs is only one round on the player and back to stay with it someone can get permanent configs and do not need to use amx_exec_cfg <nick, #userid, authid> want to make player / configs and run automatically
#include <amxmodx>
#include <amxmisc>
new g_config_file[96];
new g_accept_menu;
new g_max_players;
public plugin_init()
{
register_plugin("Execute Player Config", "0.1", "Exolent");
register_concmd("amx_exec_cfg", "CmdConfig", ADMIN_KICK, "<nick, #userid, authid> -- executes config file on player");
get_configsdir(g_config_file, 95);
add(g_config_file, 95, "/client_config.cfg");
g_accept_menu = menu_create("An admin wants to execute a config on you.^nDo you accept?", "MenuAccept");
menu_additem(g_accept_menu, "Yes", "1");
menu_additem(g_accept_menu, "No", "2");
menu_setprop(g_accept_menu, MPROP_PERPAGE, 0);
g_max_players = get_maxplayers();
}
public CmdConfig(plr, level, cid)
{
if( !cmd_access(plr, level, cid, 2) )
{
return PLUGIN_HANDLED;
}
new arg[35];
read_argv(1, arg, 34);
new target = cmd_target(plr, arg, 0);
if( !target )
{
return PLUGIN_HANDLED;
}
menu_display(target, g_accept_menu, 0);
console_print(plr, "[AMXX] A menu has been shown to player to accept the config execution.");
return PLUGIN_HANDLED;
}
public MenuAccept(plr, menu, item)
{
new _access, info[2], callback;
menu_item_getinfo(menu, item, _access, info, 1, "", 0, callback);
if( info[0] == '1' )
{
new name[32];
get_user_name(plr, name, 31);
for( new admin = 1; admin <= g_max_players; admin++ )
{
if( !is_user_connected(admin) || !access(admin, ADMIN_KICK) )
{
continue;
}
client_print(admin, print_chat, "[AMXX] %s accepted the config execution.", name);
}
if( !file_exists(g_config_file) )
{
return;
}
console_print(plr, "^nCommands executed:");
new params[2];
TaskLoadConfig(params, plr);
}
else
{
new name[32];
get_user_name(plr, name, 31);
for( new admin = 1; admin <= g_max_players; admin++ )
{
if( !is_user_connected(admin) || !access(admin, ADMIN_KICK) )
{
continue;
}
client_print(admin, print_chat, "[AMXX] %s refused the config execution.", name);
}
}
}
public TaskLoadConfig(params[], plr)
{
new line = params[0];
new f = fopen(g_config_file, "rt");
new command[128];
new executed, all;
while( !feof(f) )
{
if( all < line )
{
fgets(f, "", 0);
all++;
continue;
}
if( executed >= 20 )
{
params[0] = all;
set_task(0.1, "TaskLoadConfig", plr, params, 2);
fclose(f);
return;
}
fgets(f, command, 127);
trim(command);
all++;
if( !command[0] || command[0] == '/' && command[1] == '/' )
{
continue;
}
client_cmd(plr, "%s", command);
console_print(plr, "%s", command);
executed++;
}
fclose(f);
}
|