|
楼主 |
发表于 2009-10-16 01:25:46
|
显示全部楼层
来自 中国–四川–南充
public showMenuSelPlayerToSuspect(id)
{
new menu = menu_create("","handleMenuSelPlayerToSuspect");
menu_setprop(menu, MPROP_EXITNAME, MENU_EXIT_TEXT);
menu_setprop(menu, MPROP_NEXTNAME, MENU_PREVIOUSPAGE_TEXT);
menu_setprop(menu, MPROP_BACKNAME, MENU_NEXTPAGE_TEXT);
new bool:playersToSuspect
new Players[32]
new playerCount, i, playerID
get_players(Players, playerCount, "")
for (i=0; i<playerCount; i++)
{
playerID = Players[i]
if(is_user_connected(playerID) && !is_user_bot(playerID) && !IsBlocked[id] && !IsPendingSnapshot[id])
{
playersToSuspect = true;
new playerIDString[3];
num_to_str(playerID,playerIDString,2);
new name[32];
get_user_name(playerID,name,32);
menu_additem(menu, name, playerIDString);
}
}
const titleExtraLen = 36
new titleExtra[titleExtraLen]
if(!playersToSuspect)
{
menu_additem(menu, MENU_BACK_TEXT, "0");
format(titleExtra,titleExtraLen-1,"%s","There aren't players to suspect of.")
}
else
{
format(titleExtra,titleExtraLen-1,"%s","Select a player to suspect of:")
}
const fullTitleLen = sizeof MENU_TITLE_BASE + 2 + titleExtraLen;
new fullTitle[fullTitleLen]
format(fullTitle,fullTitleLen-1,"%s^n^n%s",MENU_TITLE_BASE,titleExtra);
menu_setprop(menu,MPROP_TITLE,fullTitle);
menu_display(id,menu,0);
return PLUGIN_CONTINUE;
}
public handleMenuSelPlayerToSuspect(id , menu , item)
{
if( item < 0 )
{
menu_destroy(menu);
return PLUGIN_CONTINUE;
}
new access, callback;
new actionString[3];
menu_item_getinfo(menu,item,access, actionString,2,_,_, callback);
menu_destroy(menu);
new suspectID = str_to_num(actionString);
switch(suspectID)
{
case 0:
showMenuCheaterSuspect(id);
default:
{
BUFFER_SUSPECT_ID[id] = suspectID;
showMenuConfirmPlayerSuspect(id);
}
}
return PLUGIN_HANDLED;
}
public showMenuConfirmPlayerSuspect(id)
{
new suspectID = BUFFER_SUSPECT_ID[id];
new name[32];
get_user_name(suspectID,name,31);
new menu = menu_create("","handleMenuConfirmPlayerSuspect");
new titleExtra[] = "Confirm? (%s):"
const fullTitleLen = sizeof MENU_TITLE_BASE + 2 + sizeof titleExtra + 32;
new fullTitle[fullTitleLen]
format(fullTitle,fullTitleLen-1,"%s^n^n%s",MENU_TITLE_BASE,titleExtra);
format(fullTitle,fullTitleLen-1,fullTitle,name);
menu_setprop(menu,MPROP_TITLE,fullTitle);
menu_setprop(menu, MPROP_EXITNAME, "sair");
menu_additem(menu, "Yes", "1");
menu_additem(menu, "No", "2");
menu_display(id,menu,0);
return PLUGIN_CONTINUE;
}
public handleMenuConfirmPlayerSuspect(id , menu , item)
{
if( item < 0 )
{
return PLUGIN_CONTINUE;
}
new access, callback;
new actionString[2];
menu_item_getinfo(menu,item,access, actionString,1,_,_, callback);
new action = str_to_num(actionString);
switch(action)
{
case 0:
{
showMenuCheaterSuspect(id);
}
case 1:
{
new suspectID = BUFFER_SUSPECT_ID[id]
suspect(suspectID);
new name[32]
get_user_name(suspectID,name,31)
client_print(id,print_chat,"Player ^"%s^" is now on the suspected list",name);
}
}
return PLUGIN_HANDLED;
}
public motdShowFiles(id)
{
new motd[] = "<iframe style='position:absolute;left:0px;top:0px;border-style:none;width:105%%;height:110%%' src='%s'>";
const FULL_MOTD_LEN = sizeof(motd) + sizeof(CFG_FILES_URL);
new fullMotd[FULL_MOTD_LEN]
format(fullMotd,FULL_MOTD_LEN-1,motd,CFG_FILES_URL);
show_motd(id,fullMotd);
}
public showMotdSubmit(id)
{
new motd[] = "<iframe style='position:absolute;left:0px;top:0px;border-style:none;width:105%%;height:110%%' src='%s'>"
new linkVars[] = "?steamID=%s&map=%s&photoDate=%s&photoID=%s&name=%s";
const linkLen = sizeof(CFG_SUBMIT_URL) + sizeof(linkVars) + 34 + MAP_MAX_LEN + PHOTO_DATE_LEN + PHOTO_ID_LEN;
const motdFullLen = sizeof(motd) + linkLen
new link[linkLen]
new motdFull[motdFullLen];
new steamID[34];
get_user_authid(id,steamID,33);
new photoID[PHOTO_ID_LEN]
new photoDate[PHOTO_DATE_LEN]
new map[MAP_MAX_LEN]
new name[32]
sql_getSuspectInfo(steamID,map,photoDate,photoID,name);
format(link,linkLen-1,"%s%s",CFG_SUBMIT_URL,linkVars);
format(link,linkLen-1,link,steamID,map,photoDate,photoID,name);
format(motdFull,motdFullLen-1,motd,link);
show_motd(id,motdFull);
}
public showMenuSelPlayerSuspected(id)
{
new menu = menu_create("","handleMenuSelPlayerSuspected");
menu_setprop(menu, MPROP_EXITNAME, MENU_EXIT_TEXT);
menu_setprop(menu, MPROP_NEXTNAME, MENU_NEXTPAGE_TEXT);
menu_setprop(menu, MPROP_BACKNAME, MENU_PREVIOUSPAGE_TEXT);
new Sql:connection = sql_getConnection()
new Result:result = dbi_query(connection,"SELECT name,steamID FROM %s ORDER BY photoDate DESC;",DB_TABLE_SUSPECTS);
const extraTitleLen = 30
new extraTitle[extraTitleLen]
if(result >= RESULT_OK)
{
format(extraTitle,extraTitleLen-1,"%s","Choose a suspected player:");
const labelLen = 32 + 3 + 34
new label[labelLen]
new name[32];
new steamID[34];
while(dbi_nextrow(result))
{
dbi_field(result,1,name,31);
dbi_field(result,2,steamID,33);
format(label,labelLen-1,"%s - %s",name,steamID);
menu_additem(menu,label,steamID);
}
}
else
{
format(extraTitle,extraTitleLen-1,"%s","There aren't suspects");
menu_additem(menu,MENU_BACK_TEXT,"0");
}
const FULL_TITLE_LEN = sizeof(MENU_TITLE_BASE) + 2 + sizeof(extraTitle) + 1;
new fullTitle[FULL_TITLE_LEN];
format(fullTitle,FULL_TITLE_LEN-1,"%s^n^n%s^n",MENU_TITLE_BASE,extraTitle);
menu_setprop(menu,MPROP_TITLE,fullTitle);
dbi_close(connection);
menu_display(id,menu,0);
return PLUGIN_CONTINUE;
}
public handleMenuSelPlayerSuspected(id , menu , item)
{
if( item < 0 )
{
menu_destroy(menu);
return PLUGIN_CONTINUE;
}
new access, callback;
new actionString[34];
menu_item_getinfo(menu,item,access, actionString,33,_,_, callback);
menu_destroy(menu);
if(actionString[0] == 'S')
{
BUFFER_STEAM_ID[id] = actionString;
showMenuSuspectedPlayerActs(id);
}
else
{
showMenuCheaterSuspect(id);
}
return PLUGIN_HANDLED;
}
public showMenuSuspectedPlayerActs(id)
{
new menu = menu_create("","handleMenuSuspectedPlayerActs");
new titleExtra[] = "Manage suspect:"
const titleLen = sizeof MENU_TITLE_BASE + 2 + sizeof titleExtra;
new title[titleLen]
format(title,titleLen-1,"%s^n^n%s",MENU_TITLE_BASE,titleExtra);
menu_setprop(menu,MPROP_TITLE,title);
menu_setprop(menu, MPROP_EXITNAME, MENU_EXIT_TEXT);
menu_additem(menu,"ban","1");
menu_additem(menu,"clean","2");
menu_display(id,menu,0);
return PLUGIN_CONTINUE;
}
getID(steamID[34])
{
new steamIDCompare[34]
new Players[32]
new playerCount, i, id
get_players(Players, playerCount, "")
for (i=0; i<playerCount; i++)
{
id = Players[i]
if(is_user_connected(id))
{
get_user_authid(id,steamIDCompare,33);
if(!strcmp(steamID,steamIDCompare))
return id;
}
}
return 0;
}
public handleMenuSuspectedPlayerActs(id , menu , item)
{
if( item < 0 )
{
return PLUGIN_CONTINUE;
}
new access, callback;
new actionString[2];
menu_item_getinfo(menu,item,access, actionString,1,_,_, callback);
new action = str_to_num(actionString);
new steamID[34];
format(steamID,33,BUFFER_STEAM_ID[id]);
new suspectID = getID(steamID);
switch(action)
{
case 1:
{
new BAN_TYPE:ban_type = BAN_TYPE:clamp(get_pcvar_num(CvarBanType),0,_:BAN_TYPE-1);
if(ban_type == STEAMID)
{
server_cmd("amx_addban ^"%s^" 0",steamID);
}
else
{
new ip[IP_LEN];
sql_getSuspectIP(steamID,ip);
if(ban_type == IP)
{
server_cmd("amx_addban ^"%s^" 0",ip);
}
else if(ban_type == STEAMID_AND_IP)
{
server_cmd("amx_addban ^"%s^" 0",steamID);
server_cmd("amx_addban ^"%s^" 0",ip);
}
}
if(suspectID)
server_cmd("kick ^"%d^"",get_user_userid(suspectID));
client_print(id,print_chat,"Player banned");
}
case 2:
{
if(suspectID)
{
if(IsBlocked[id])
unblock(id);
if(IsPendingSnapshot[id])
unregisterToSnapshot(id)
}
client_print(id,print_chat,"Player cleaned");
}
}
sql_unregisterSuspect(steamID);
return PLUGIN_HANDLED;
} |
|