|
楼主 |
发表于 2010-10-10 17:07:59
|
显示全部楼层
来自 中国–上海–上海
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[128], sTempItem[128];
static sTemp[4][STR_LEN];
static iFileP;
iFileP = fopen(gAdminsFile, "rt");
while(!feof(iFileP))
{
fgets(iFileP, sBuffer, sizeof sBuffer - 1);
if((strlen(sBuffer) < 3) || sBuffer[0] == ';')
continue;
parse(sBuffer, sTemp[0], sizeof sTemp[] - 1, sTemp[1], sizeof sTemp[] - 1, sTemp[2], sizeof sTemp[] - 1, sTemp[3], sizeof sTemp[] - 1);
for(new j = 0 ; j < sizeof sTemp ; j++)
{
remove_quotes(sTemp[j]);
}
formatex(sTempItem, sizeof sTempItem - 1, "\w%s\r|\w%s\r|\w%s\r|\w%s\r", sTemp[0], sTemp[1], sTemp[2], sTemp[3]);
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[id][j], sizeof gAdminTargetDetails[][] - 1, "");
return 1;
}
static iAccess, iCallback;
static sBuffer[128];
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[id][j], sizeof gAdminTargetDetails[][] - 1, "\w", "");
replace(gAdminTargetDetails[id][j], sizeof gAdminTargetDetails[][] - 1, "\r", "");
trim(gAdminTargetDetails[id][j]);
}
cmdAdminEditSubMenu(id);
return 1;
}
public cmdAdminEditSubMenu(id)
{
static iMenu, sTemp[STR_LEN];
formatex(sTemp, sizeof sTemp - 1, "\y管理员经理人(\w编辑管理员 \r%s\y):", gAdminTargetDetails[id][0]);
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[6];
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[id] = 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[64];
read_argv(1, sArg, sizeof sArg - 1);
if(!sArg[0])
return 1;
formatex(gAdminTargetAccount[id], sizeof gAdminTargetAccount[] - 1, sArg);
console_print(id, "成功储存帐号 : ^"%s^" 对指定的管理员。", gAdminTargetAccount[id]);
return 1;
}
public cmdAdminAddAccessFlags(id)
{
static iMenu;
iMenu = menu_create("\y管理员经理人 (\w编辑管理员权限等级):", "AddAccessFlagsMenuHandler");
static sTemp[128];
for(new i = 0 ; i < sizeof gAdminAccessFlags ; i++)
{
formatex(sTemp, sizeof sTemp - 1, "%s - \y%s", gAdminAccessFlags[i], gAdminAccessFlagsDetails[i]);
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[32], sBuffer[10];
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[id], sBuffer) != -1)
replace(gAdminTargetAccessFlags[id], sizeof gAdminTargetAccessFlags[] - 1, sBuffer, "");
else
format(gAdminTargetAccessFlags[id], sizeof gAdminTargetAccessFlags[] - 1, "%s%s", gAdminTargetAccessFlags[id], 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[id]);
menu_display(id, menu, 0);
return 1;
}
public cmdSaveAdminModification(id)
{
static iFileP;
iFileP = fopen(gAdminsFile, "rt");
static sBuffer[128], sTempAccount[4][STR_LEN];
new i;
while(!feof(iFileP))
{
fgets(iFileP, sBuffer, sizeof sBuffer - 1);
i++;
if((strlen(sBuffer) < 3) || sBuffer[0] == ';')
continue;
parse(sBuffer, sTempAccount[0], sizeof sTempAccount[] - 1, sTempAccount[1], sizeof sTempAccount[] - 1, sTempAccount[2], sizeof sTempAccount[] - 1, sTempAccount[3], sizeof sTempAccount[] - 1);
for(new j = 0 ; j < sizeof sTempAccount ; j++)
{
remove_quotes(sTempAccount[j]);
}
if(equali(sTempAccount[0], gAdminTargetDetails[id][0]))
{
formatex(sBuffer, sizeof sBuffer - 1, "^"%s^" ^"%s^" ^"%s%^" ^"%s^"", gAdminTargetAccount[id][0] ? gAdminTargetAccount[id] : sTempAccount[0], gAdminTargetPassword[id][0] ? gAdminTargetPassword[id] : sTempAccount[1], gAdminTargetFlags[id][0] ? gAdminTargetFlags[id] : sTempAccount[2], gAdminTargetAccessFlags[id][0] ? gAdminTargetAccessFlags[id] : sTempAccount[3]);
write_file(gAdminsFile, sBuffer, i - 1);
break;
}
}
fclose(iFileP);
client_print(id, print_chat, "成功编辑管理员帐号 ^"%s^"!", gAdminTargetDetails[id][0]);
server_cmd("amx_reloadadmins");
formatex(gAdminTargetFlags[id], sizeof gAdminTargetFlags[] - 1, "");
formatex(gAdminTargetPassword[id], sizeof gAdminTargetPassword[] - 1, "");
formatex(gAdminTargetAccessFlags[id], sizeof gAdminTargetAccessFlags[] - 1, "");
formatex(gAdminTargetAccount[id], sizeof gAdminTargetAccount[] - 1, "");
return 1;
}
stock register_saycmd(saycommand[], function[], flags = -1, info[])
{
static sTemp[64];
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[i] != token)
{
if (++len < piecelen)
output[index][pieces][len] = input[i];
}
else
{
output[index][pieces++][++len] = 0;
len = -1;
if(pieces == outputsize)
return pieces;
}
} |
|