求助 谁说明一下这个插件怎么用
这是一个添加VIP和OP的插件 #include <amxmodx>#include <amxmisc>
#define PLUGIN "Admins Manager"
#define VERSION "1.3"
#define AUTHOR "Alka"
#define STR_LEN 64
#define MENU_ACCESS_FLAG ADMIN_RCON
new gConfigsDir;
new gAdminsFile;
new const gAdminFlags[][] = {
"a", "b", "c", "d",
"e", "f", "g", "h",
"i", "j", "k", "l",
"m", "n", "o", "p",
"q", "r", "s", "t",
"u"
};
new const gAdminAccessFlags[][] = {
"a", "b", "c", "d", "e"
};
new const gAdminFlagsDetails[][] = {
"Immunity",
"Reservation",
"Kick",
"Ban / Unban",
"Slay / Slap",
"Change Map",
"Cvar change",
"Cfg exec",
"Chat messages",
"Vote",
"Server Password",
"Rcon",
"Custom A",
"Custom B",
"Custom C",
"Custom D",
"Custom E",
"Custom F",
"Custom G",
"Custom H",
"Amxx Menu"
};
new const gAdminAccessFlagsDetails[][] = {
"Disconnect on invalid password",
"Clan tag",
"For SteamId / WonId",
"For Ip",
"Password is not checked"
};
new gAdminTargetId;
new gAdminTargetFlags;
new gAdminTargetPassword;
new gAdminTargetAccessFlags;
new gAdminTargetAccount;
new gAdminTargetDetails;
new gAdminSaveMode;
new bool:gAccessFromEditMenu;
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR);
register_saycmd("adminsmanager", "cmdAdminsManage", -1, "");
register_concmd("amx_adminpassword", "cmdAdminPassword", MENU_ACCESS_FLAG, "<password> - Save / change this password for specified admin.");
register_concmd("amx_adminaccount", "cmdAdminAccount", MENU_ACCESS_FLAG, "<name / ip / steam id> - Save / change this account info for specified admin.");
get_configsdir(gConfigsDir, sizeof gConfigsDir - 1);
formatex(gAdminsFile, sizeof gAdminsFile - 1, "%s/users.ini", gConfigsDir);
if(!file_exists(gAdminsFile))
set_fail_state("Non-existent file.");
}
public cmdAdminsManage(id)
{
static iMenu, iCallBack;
iMenu = menu_create("\y管理员经理人 (\w主菜单\y):", "MainMenuHandler");
iCallBack = menu_makecallback("MainMenuCallBack");
menu_additem(iMenu, "\w增加管理员", "1", 0, iCallBack);
menu_additem(iMenu, "\w移除管理员", "2", 0, iCallBack);
menu_additem(iMenu, "\w编辑管理员", "3", 0, iCallBack);
menu_addblank(iMenu, 0);
menu_display(id, iMenu, 0);
}
public MainMenuCallBack(id, menu, item)
return access(id, MENU_ACCESS_FLAG) ? ITEM_ENABLED : ITEM_DISABLED;
public MainMenuHandler(id, menu, item)
{
if(item == MENU_EXIT)
return 1;
static iAccess, iCallback;
static sData;
menu_item_getinfo(menu, item, iAccess, sData, sizeof sData - 1, _, _, iCallback);
static iKey;
iKey = str_to_num(sData);
switch(iKey)
{
case 1: { cmdAdminAdd(id); }
case 2: { cmdAdminRemove(id); }
case 3: { cmdAdminEdit(id); }
}
return 1;
}
public cmdAdminAdd(id)
{
static iMenu;
iMenu = menu_create("\y管理员经理人 (\w增加管理员\y):", "AddMenuHandler");
static sPlayers, iNum;
get_players(sPlayers, iNum, "ch");
for(new i = 0 ; i < iNum ; i++)
{
static sName;
get_user_name(sPlayers, sName, sizeof sName - 1);
menu_additem(iMenu, sName, "", 0, -1);
}
menu_addblank(iMenu, 0);
menu_display(id, iMenu, 0);
}
public AddMenuHandler(id, menu, item)
{
if(item == MENU_EXIT)
{
cmdAdminsManage(id);
return 1;
}
static iAccess, iCallback;
static sBuffer;
menu_item_getinfo(menu, item, iAccess, "", 0, sBuffer, sizeof sBuffer - 1, iCallback);
static iTarget;
iTarget = get_user_index(sBuffer);
gAdminTargetId = iTarget;
cmdAdminAddSubMenu(id);
return 1;
}
public cmdAdminAddSubMenu(id)
{
static sTemp, sName;
get_user_name(gAdminTargetId, sName, sizeof sName - 1);
formatex(sTemp, sizeof sTemp - 1, "\y管理员经理人 (\w增加管理员 \r%s\y):", sName);
static iMenu;
iMenu = menu_create(sTemp, "AddSubMenuHandler");
menu_additem(iMenu, "\w增加 / 移除类型", "1", 0, -1);
menu_additem(iMenu, "\w重新设定类型", "2", 0, -1);
menu_addblank(iMenu, 0);
static sBuffer;
switch(gAdminSaveMode)
{
case 0: { formatex(sBuffer, sizeof sBuffer - 1, "\w储存管理员方法: \rIp"); }
case 1: { formatex(sBuffer, sizeof sBuffer - 1, "\w储存管理员方法: \rSteam Id"); }
case 2: { formatex(sBuffer, sizeof sBuffer - 1, "\w储存管理员方法: \rName + Password"); }
}
menu_additem(iMenu, sBuffer, "3", 0, -1);
menu_additem(iMenu, "\w储存管理员", "4", 0, -1);
menu_addblank(iMenu, 0);
menu_display(id, iMenu, 0);
}
public AddSubMenuHandler(id, menu, item)
{
if(item == MENU_EXIT)
{
cmdAdminAdd(id);
return 1;
}
static iAccess, iCallback;
static sData;
menu_item_getinfo(menu, item, iAccess, sData, sizeof sData - 1, _, _, iCallback);
static iKey;
iKey = str_to_num(sData);
switch(iKey)
{
case 1: { cmdAdminAddFlags(id); }
case 2: { cmdAdminAddResetFlags(id); }
case 3: { cmdAdminSaveMode(id); }
case 4: { cmdAdminAddSave(id); }
}
return 1;
}
public cmdAdminAddFlags(id)
{
static iMenu;
iMenu = menu_create("\y管理员经理人 (\w增加管理员类型):", "AddFlagsMenuHandler"); static sTemp;
for(new i = 0 ; i < sizeof gAdminFlags ; i++)
{
formatex(sTemp, sizeof sTemp - 1, "%s - \y%s", gAdminFlags, gAdminFlagsDetails);
menu_additem(iMenu, sTemp, "", 0, -1);
}
menu_addblank(iMenu, 0);
menu_display(id, iMenu, 0);
}
public AddFlagsMenuHandler(id, menu, item)
{
if(item == MENU_EXIT)
{
if(gAccessFromEditMenu)
{
cmdAdminEditSubMenu(id);
gAccessFromEditMenu = false;
return 1;
}
else
{
cmdAdminAddSubMenu(id);
return 1;
}
}
static iAccess, iCallback;
static sTemp, sBuffer;
menu_item_getinfo(menu, item, iAccess, "", 0, sTemp, sizeof sTemp - 1, iCallback);
strtok(sTemp, sBuffer, sizeof sBuffer - 1, sTemp, sizeof sTemp - 1, '-', 1);
if(containi(gAdminTargetFlags, sBuffer) != -1)
replace(gAdminTargetFlags, sizeof gAdminTargetFlags[] - 1, sBuffer, "");
else
format(gAdminTargetFlags, sizeof gAdminTargetFlags[] - 1, "%s%s", gAdminTargetFlags, sBuffer);
set_hudmessage(255, 255, 255, -1.0, 0.8, 0, 1.0, 2.0, 0.2, 0.1, 1);
show_hudmessage(id, "增加管理员类型 : ^"%s^"", gAdminTargetFlags);
menu_display(id, menu, 0);
return 1;
}
public cmdAdminAddResetFlags(id)
{
formatex(gAdminTargetFlags, sizeof gAdminTargetFlags[] - 1, "");
set_hudmessage(255, 255, 255, -1.0, 0.8, 0, 1.0, 2.0, 0.2, 0.1, 1);
show_hudmessage(id, "增加管理员类型 : 类型重新设定");
cmdAdminAddSubMenu(id);
return 1;
}
public cmdAdminSaveMode(id)
{
static iNum;
iNum++;
if(iNum > 2)
iNum = 0;
gAdminSaveMode = iNum;
if(iNum == 2)
{
set_hudmessage(255, 255, 255, -1.0, 0.8, 0, 1.0, 2.0, 0.2, 0.1, 1);
show_hudmessage(id, "增加管理员密码: 在控制台上打上新的管理密码^n指令: amx_adminpassword");
}
cmdAdminAddSubMenu(id);
return 1;
}
public cmdAdminAddSave(id)
{
static iFile;
iFile = fopen(gAdminsFile, "at+");
if(!gAdminTargetFlags)
{
set_hudmessage(255, 255, 255, -1.0, 0.8, 0, 1.0, 2.0, 0.2, 0.1, 1);
show_hudmessage(id, "你必须选择一些类型在储存^n管理员之前。");
cmdAdminAddSubMenu(id);
return 1;
}
static UserInfo;
switch(gAdminSaveMode)
{
case 0: { get_user_ip(gAdminTargetId, UserInfo, sizeof UserInfo - 1, 1); }
case 1: { get_user_authid(gAdminTargetId, UserInfo, sizeof UserInfo - 1); }
case 2:
{
if(!gAdminTargetPassword)
{
set_hudmessage(255, 255, 255, -1.0, 0.8, 0, 1.0, 2.0, 0.2, 0.1, 1);
show_hudmessage(id, "在控制台上打上新的管理密码^n指令: amx_adminpassword <password>");
cmdAdminAddSubMenu(id);
return 1;
}
get_user_name(gAdminTargetId, UserInfo, sizeof UserInfo - 1);
}
}
static sTemp;
new iLine;
while(!feof(iFile))
{
fgets(iFile, sTemp, sizeof sTemp - 1);
iLine++;
if((containi(sTemp, UserInfo) != -1) && sTemp != ';')
{
client_print(id, print_chat, "对不起,管理员帐号的帐号资讯已经存在!");
return 1;
}
}
static sBuffer;
switch(gAdminSaveMode)
{
case 0: { formatex(sBuffer, sizeof sBuffer - 1, "^n^"%s^" ^"^" ^"%s^" ^"de^"", UserInfo, gAdminTargetFlags); }
case 1: { formatex(sBuffer, sizeof sBuffer - 1, "^n^"%s^" ^"^" ^"%s^" ^"ce^"", UserInfo, gAdminTargetFlags); }
case 2: { formatex(sBuffer, sizeof sBuffer - 1, "^n^"%s^" ^"%s^" ^"%s^" ^"a^"", UserInfo, gAdminTargetPassword, gAdminTargetFlags); }
}
fprintf(iFile, sBuffer);
fclose(iFile);
client_print(id, print_chat, "成功在线上增加 ^"%s^" 到管理员列表 %d!", UserInfo, iLine + 1);
server_cmd("amx_reloadadmins");
formatex(gAdminTargetFlags, sizeof gAdminTargetFlags[] - 1, "");
formatex(gAdminTargetPassword, sizeof gAdminTargetPassword[] - 1, "");
gAdminTargetId = 0;
return 1;
}
public cmdAdminPassword(id, level, cid)
{
if(!cmd_access(id, level, cid, 2))
return 1;
static sArg;
read_argv(1, sArg, sizeof sArg - 1);
if(!sArg)
return 1;
formatex(gAdminTargetPassword, sizeof gAdminTargetPassword[] - 1, sArg);
console_print(id, "成功储存密码 : ^"%s^" 对指定的管理员!", gAdminTargetPassword);
return 1;
}
public cmdAdminRemove(id)
{
static iMenu;
iMenu = menu_create("\y管理员经理人 (\w移除管理员\y):", "RemoveMenuHandler");
static sBuffer, sTempItem;
static sTemp;
static iFileP;
iFileP = fopen(gAdminsFile, "rt");
while(!feof(iFileP))
{
fgets(iFileP, sBuffer, sizeof sBuffer - 1);
if((strlen(sBuffer) < 3) || sBuffer == ';')
continue;
parse(sBuffer, sTemp, sizeof sTemp[] - 1, sTemp, sizeof sTemp[] - 1, sTemp, sizeof sTemp[] - 1, sTemp, sizeof sTemp[] - 1);
for(new j = 0 ; j < sizeof sTemp ; j++)
{
remove_quotes(sTemp);
}
formatex(sTempItem, sizeof sTempItem - 1, "\w%s\r|\w%s\r|\w%s\r|\w%s\r", sTemp, sTemp, sTemp, sTemp);
menu_additem(iMenu, sTempItem, "", 0, -1);
}
fclose(iFileP);
menu_addblank(iMenu, 0);
menu_display(id, iMenu, 0);
}
public RemoveMenuHandler(id, menu, item)
{
if(item == MENU_EXIT)
{
cmdAdminsManage(id);
return 1;
}
static iAccess, iCallback;
static sBuffer, sTemp;
menu_item_getinfo(menu, item, iAccess, "", 0, sBuffer, sizeof sBuffer - 1, iCallback);
strtok(sBuffer, sTemp, sizeof sTemp - 1, sBuffer, sizeof sBuffer - 1, '|');
replace(sTemp, sizeof sTemp - 1, "\w", "");
replace(sTemp, sizeof sTemp - 1, "\r", "");
trim(sTemp);
static iFileP;
iFileP = fopen(gAdminsFile, "rt");
static sTempAccount;
new i;
while(!feof(iFileP))
{
fgets(iFileP, sBuffer, sizeof sBuffer - 1);
i++;
if((strlen(sBuffer) < 3) || sBuffer == ';')
continue;
parse(sBuffer, sTempAccount, sizeof sTempAccount - 1);
remove_quotes(sTempAccount);
if(equali(sTempAccount, sTemp))
{
format(sBuffer, sizeof sBuffer - 1, ";%s", sBuffer);
write_file(gAdminsFile, sBuffer, i - 1);
break;
}
}
fclose(iFileP); client_print(id, print_chat, "成功移除 ^"%s^" 在管理员列表!", sTemp);
server_cmd("amx_reloadadmins");
return 1;
}
public cmdAdminEdit(id)
{
static iMenu;
iMenu = menu_create("\y管理员经理人 (\w编辑管理员\y):", "EditMenuHandler");
static sBuffer, sTempItem;
static sTemp;
static iFileP;
iFileP = fopen(gAdminsFile, "rt");
while(!feof(iFileP))
{
fgets(iFileP, sBuffer, sizeof sBuffer - 1);
if((strlen(sBuffer) < 3) || sBuffer == ';')
continue;
parse(sBuffer, sTemp, sizeof sTemp[] - 1, sTemp, sizeof sTemp[] - 1, sTemp, sizeof sTemp[] - 1, sTemp, sizeof sTemp[] - 1);
for(new j = 0 ; j < sizeof sTemp ; j++)
{
remove_quotes(sTemp);
}
formatex(sTempItem, sizeof sTempItem - 1, "\w%s\r|\w%s\r|\w%s\r|\w%s\r", sTemp, sTemp, sTemp, sTemp);
menu_additem(iMenu, sTempItem, "", 0, -1);
}
fclose(iFileP);
menu_addblank(iMenu, 0);
menu_display(id, iMenu, 0);
}
public EditMenuHandler(id, menu, item)
{
if(item == MENU_EXIT)
{
cmdAdminsManage(id);
for(new j = 0 ; j < sizeof gAdminTargetDetails[] ; j++)
formatex(gAdminTargetDetails, sizeof gAdminTargetDetails[][] - 1, "");
return 1;
}
static iAccess, iCallback;
static sBuffer;
menu_item_getinfo(menu, item, iAccess, "", 0, sBuffer, sizeof sBuffer - 1, iCallback);
str_piece(id, sBuffer, gAdminTargetDetails, sizeof gAdminTargetDetails[], sizeof gAdminTargetDetails[][] - 1, '|');
for(new j = 0 ; j < sizeof gAdminTargetDetails[] ; j++)
{
replace(gAdminTargetDetails, sizeof gAdminTargetDetails[][] - 1, "\w", "");
replace(gAdminTargetDetails, sizeof gAdminTargetDetails[][] - 1, "\r", "");
trim(gAdminTargetDetails);
}
cmdAdminEditSubMenu(id);
return 1;
}
public cmdAdminEditSubMenu(id)
{
static iMenu, sTemp;
formatex(sTemp, sizeof sTemp - 1, "\y管理员经理人(\w编辑管理员 \r%s\y):", gAdminTargetDetails);
iMenu = menu_create(sTemp, "EditSubMenuHandler");
menu_additem(iMenu, "\w编辑帐号名字", "1", 0, -1);
menu_additem(iMenu, "\w编辑密码", "2", 0, -1);
menu_additem(iMenu, "\w编辑类型", "3", 0 , -1);
menu_additem(iMenu, "\w编辑权限等级", "4", 0, -1);
menu_addblank(iMenu, 0);
menu_additem(iMenu, "\w储存修改", "5", 0, -1);
menu_addblank(iMenu, 0);
menu_display(id, iMenu, 0);
}
public EditSubMenuHandler(id, menu, item)
{
if(item == MENU_EXIT)
{
cmdAdminEdit(id);
return 1;
}
static iAccess, iCallback;
static sData;
menu_item_getinfo(menu, item, iAccess, sData, sizeof sData - 1, _, _, iCallback);
static iKey;
iKey = str_to_num(sData);
switch(iKey)
{
case 1:
{
set_hudmessage(255, 255, 255, -1.0, 0.8, 0, 1.0, 2.0, 0.2, 0.1, 1);
show_hudmessage(id, "在控制台打上指令: amx_adminaccount 获取详情。");
}
case 2:
{
set_hudmessage(255, 255, 255, -1.0, 0.8, 0, 1.0, 2.0, 0.2, 0.1, 1);
show_hudmessage(id, "在控制台打上指令: amx_adminpassword 获取详情。");
}
case 3:
{
gAccessFromEditMenu = true;
cmdAdminAddFlags(id);
return 1;
}
case 4: { cmdAdminAddAccessFlags(id); return 1; }
case 5: { cmdSaveAdminModification(id); return 1; }
}
menu_display(id, menu, 0);
return 1;
}
public cmdAdminAccount(id, level, cid)
{
if(!cmd_access(id, level, cid, 2))
return 1;
static sArg;
read_argv(1, sArg, sizeof sArg - 1);
if(!sArg)
return 1;
formatex(gAdminTargetAccount, sizeof gAdminTargetAccount[] - 1, sArg);
console_print(id, "成功储存帐号 : ^"%s^" 对指定的管理员。", gAdminTargetAccount);
return 1;
}
public cmdAdminAddAccessFlags(id)
{
static iMenu;
iMenu = menu_create("\y管理员经理人 (\w编辑管理员权限等级):", "AddAccessFlagsMenuHandler");
static sTemp;
for(new i = 0 ; i < sizeof gAdminAccessFlags ; i++)
{
formatex(sTemp, sizeof sTemp - 1, "%s - \y%s", gAdminAccessFlags, gAdminAccessFlagsDetails);
menu_additem(iMenu, sTemp, "", 0, -1);
}
menu_addblank(iMenu, 0);
menu_display(id, iMenu, 0);
}
public AddAccessFlagsMenuHandler(id, menu, item)
{
if(item == MENU_EXIT)
{
cmdAdminEditSubMenu(id);
return 1;
}
static iAccess, iCallback;
static sTemp, sBuffer;
menu_item_getinfo(menu, item, iAccess, "", 0, sTemp, sizeof sTemp - 1, iCallback);
strtok(sTemp, sBuffer, sizeof sBuffer - 1, sTemp, sizeof sTemp - 1, '-', 1);
if(containi(gAdminTargetAccessFlags, sBuffer) != -1)
replace(gAdminTargetAccessFlags, sizeof gAdminTargetAccessFlags[] - 1, sBuffer, "");
else
format(gAdminTargetAccessFlags, sizeof gAdminTargetAccessFlags[] - 1, "%s%s", gAdminTargetAccessFlags, sBuffer);
set_hudmessage(255, 255, 255, -1.0, 0.8, 0, 1.0, 2.0, 0.2, 0.1, 1);
show_hudmessage(id, "增加管理员权限等级 : ^"%s^"", gAdminTargetAccessFlags);
menu_display(id, menu, 0);
return 1;
}
public cmdSaveAdminModification(id)
{
static iFileP;
iFileP = fopen(gAdminsFile, "rt");
static sBuffer, sTempAccount;
new i;
while(!feof(iFileP))
{
fgets(iFileP, sBuffer, sizeof sBuffer - 1);
i++;
if((strlen(sBuffer) < 3) || sBuffer == ';')
continue;
parse(sBuffer, sTempAccount, sizeof sTempAccount[] - 1, sTempAccount, sizeof sTempAccount[] - 1, sTempAccount, sizeof sTempAccount[] - 1, sTempAccount, sizeof sTempAccount[] - 1);
for(new j = 0 ; j < sizeof sTempAccount ; j++)
{
remove_quotes(sTempAccount);
}
if(equali(sTempAccount, gAdminTargetDetails))
{
formatex(sBuffer, sizeof sBuffer - 1, "^"%s^" ^"%s^" ^"%s%^" ^"%s^"", gAdminTargetAccount ? gAdminTargetAccount : sTempAccount, gAdminTargetPassword ? gAdminTargetPassword : sTempAccount, gAdminTargetFlags ? gAdminTargetFlags : sTempAccount, gAdminTargetAccessFlags ? gAdminTargetAccessFlags : sTempAccount);
write_file(gAdminsFile, sBuffer, i - 1);
break;
}
}
fclose(iFileP);
client_print(id, print_chat, "成功编辑管理员帐号 ^"%s^"!", gAdminTargetDetails);
server_cmd("amx_reloadadmins");
formatex(gAdminTargetFlags, sizeof gAdminTargetFlags[] - 1, "");
formatex(gAdminTargetPassword, sizeof gAdminTargetPassword[] - 1, "");
formatex(gAdminTargetAccessFlags, sizeof gAdminTargetAccessFlags[] - 1, "");
formatex(gAdminTargetAccount, sizeof gAdminTargetAccount[] - 1, "");
return 1;
}
stock register_saycmd(saycommand[], function[], flags = -1, info[])
{
static sTemp;
formatex(sTemp, sizeof sTemp - 1, "say /%s", saycommand);
register_clcmd(sTemp, function, flags, info);
formatex(sTemp, sizeof sTemp - 1, "say .%s", saycommand);
register_clcmd(sTemp, function, flags, info);
formatex(sTemp, sizeof sTemp - 1, "say_team /%s", saycommand);
register_clcmd(sTemp, function, flags, info);
formatex(sTemp, sizeof sTemp - 1, "say_team .%s", saycommand);
register_clcmd(sTemp, function, flags, info);
}
stock str_piece(index, const input[], output[][][], outputsize, piecelen, token = '|') //Stock by purple_pixie, edited by me. :D
{
new i = -1, pieces, len = -1;
while(input[++i] != 0)
{
if (input != token)
{
if (++len < piecelen)
output = input;
}
else
{
output[++len] = 0;
len = -1;
if(pieces == outputsize)
return pieces;
}
} 以上是源码 请说明一下该怎么用 本人菜鸟 看不懂 为什么没人说明一下呢 再顶一下 据续顶....... 你发帖就舒服,看帖的就蛋疼 ....... 晕 那怎么发....我试试先 怎么上传源码啊
页:
[1]
2