一个投票换图的插件
按Y输入/maps 或在控制台输入/maps可请求投票换图当7成的玩家请求投票换图时系统会随即抽取6张地图发起投票
new Float:VoteTemp = maxpaly * 0.7; 这里改比例
#include <amxmodx>
#include <amxmisc>
#define KeysSet_Maps_Menu (1<<9)|(1<<3)|(1<<4)|(1<<5)|(1<<6)|(1<<7)|(1<<8)
new bool:LpVote;
new VoteCoun=0;
new LpMapNums;
new Array:LpMapName;
new Array:VoteMapName;
new LpVoteCount;
public plugin_init(){
register_plugin("请求换图", "1.0", "小坏")
register_clcmd("say /maps","Set_Maps");
register_clcmd("/maps","Set_Maps");
register_menucmd(register_menuid("Set_Maps_Menu"), KeysSet_Maps_Menu, "Pressed_Set_Maps_Menu")
LpMapName = ArrayCreate(32);
VoteMapName = ArrayCreate(32);
VoteCoun = 0;
return PLUGIN_CONTINUE
}
public plugin_cfg()
{
Text(1456);
set_task(120.0,"Text",111223+456,"",0,"b");
new maps_ini_file;
get_configsdir(maps_ini_file, 63);
format(maps_ini_file, 63, "%s/maps.ini", maps_ini_file);
if (!file_exists(maps_ini_file))
get_cvar_string("mapcyclefile", maps_ini_file, sizeof(maps_ini_file) - 1);
if (!file_exists(maps_ini_file))
format(maps_ini_file, 63, "mapcycle.txt")
load_settings(maps_ini_file)
}
public client_connect(id)
{
LpVote = false;
return PLUGIN_HANDLED
}
public client_disconnect (id)
{
if(LpVote){
LpVote = false;
VoteCoun--;
}
return PLUGIN_HANDLED
}
public Text(id)
{
client_print(0, print_chat, "按Y输入/maps 或在控制台输入/maps可请求投票换图");
client_print(0, print_chat, "当7成的玩家请求投票换图时系统会随即抽取6张地图发起投票");
}
public Set_Maps(id)
{
if(LpVote)
{
client_print(id,print_center,"你已经发起投票指令 请等待其他玩家决定!");
} else {
LpVote = true;
VoteCoun++;
new name;
get_user_name(id,name,31);
client_print(0, print_chat, "玩家[ %s ]请求投票换图",name);
client_print(0, print_chat, "当7成的玩家请求投票换图时系统会随即抽取6张地图发起投票");
new maxpaly = get_playersnum();
new Float:VoteTemp = maxpaly * 0.7;
if(VoteCoun >= floatround(VoteTemp)){
client_print(0, print_chat, "超过7成的玩家请求投票换图系统随即抽取6张地图发起投票");
new menustr
ArrayClear(VoteMapName);
new len = format(menustr,512,"\r投票换图:^n^n");
for(new i=4; i<10;i++)
{
new LpItem;
new tempMap;
LpItem = random_num(0,LpMapNums);
ArrayGetString(LpMapName, LpItem, tempMap, charsmax(tempMap));
len += format(menustr,512-len, "\r%i. \w%s^n",i,tempMap);
ArrayPushString(VoteMapName, tempMap);
LpVoteCount = 0;
}
len += format(menustr,512-len, "\r0. \w弃权^n");
for(new i=0;i<maxpaly;i++)
{
show_menu(id, KeysSet_Maps_Menu, menustr, 20, "Set_Maps_Menu");
}
client_print(0, print_chat, "系统将在25秒后按投票结果进行换图");
client_print(0, print_center, "系统将在25秒后按投票结果进行换图");
set_task(25.0, "Maps",78917474)
}
}
}
public Pressed_Set_Maps_Menu(id, key)
{
switch (key)
{
case 3:{
LpVoteCount++;
}
case 4:{
LpVoteCount++;
}
case 5:{
LpVoteCount++;
}
case 6:{
LpVoteCount++;
}
case 7:{
LpVoteCount++;
}
case 8:{
LpVoteCount++;
}
}
new name,tempMap;
get_user_name(id,name,31);
if(key == 9)
{
tempMap= "弃权"
} else {
ArrayGetString(VoteMapName, key-3, tempMap, charsmax(tempMap));
}
client_print(0, print_chat, "[ %s ]选择: %s",name,tempMap);
return PLUGIN_CONTINUE
}
public Maps()
{
new a = 0;
new tempMap;
for (new i = 0; i < 6; ++i)
{
if (LpVoteCount < LpVoteCount)
{
a = i
}
}
ArrayGetString(VoteMapName, a, tempMap, charsmax(tempMap));
set_task(2.0, "delayedChange", 0, tempMap, strlen(tempMap) + 1)
ArrayClear(VoteMapName);
return 1;
}
public delayedChange(mapname[])
server_cmd("changelevel %s", mapname)
load_settings(filename[])
{
new fp = fopen(filename, "r");
if (!fp)
{
return 0;
}
new text;
new tempMap;
while (!feof(fp))
{
fgets(fp, text, charsmax(text));
if (text == ';')
{
continue;
}
if (parse(text, tempMap, charsmax(tempMap)) < 1)
{
continue;
}
if (!ValidMap(tempMap))
{
continue;
}
ArrayPushString(LpMapName, tempMap);
LpMapNums++;
}
return 1;
}
stock bool:ValidMap(mapname[])
{
if ( is_map_valid(mapname) )
{
return true;
}
new len = strlen(mapname) - 4;
if (len < 0)
{
return false;
}
if ( equali(mapname, ".bsp") )
{
mapname = '^0';
if ( is_map_valid(mapname) )
{
return true;
}
}
return false;
} 小坏 2# rsdtt
干嘛??? 2# rsdtt
干嘛???
lovehuai 发表于 2010-8-7 13:19 http://www.dt-club.net/forum/images/common/back.gif
呀啦那一卡 4# 8874323
死开基佬
贫道性取向正常
贫道只对软妹子有爱
萝莉大爱
兽耳萝莉最爱 4# 8874323
死开基佬
贫道性取向正常
贫道只对软妹子有爱
萝莉大爱
兽耳萝莉最爱
lovehuai 发表于 2010-8-7 19:24 http://www.dt-club.net/forum/images/common/back.gif
2楼其实loli,头像是为了隐藏身份:lol votekick.smavotekick.smavotekick.smavotekick.sma votekick.smavotekick.smavotekick.smavotekick.sma 嘿嘿, 直接贴上源码很好
对潜力选手的一种优待 死开基佬
贫道性取向正常
贫道只对软妹子有爱
萝莉大爱
兽耳萝莉最爱
页:
[1]
2