15.10.2013, 08:27
(
Последний раз редактировалось Nikid; 17.10.2013 в 09:42.
)
PHP код:
#define MAX_MAP 300
if(!strcmp(cmdtext,"/base",true,5))
{
new string[255];
if(Player[playerid][pTeam] != T_DEF) SendClientMessage(playerid, COLOR_GREY, "* Äàííîå ãîëîñîâàíèå òîëüêî äëÿ çàùèòíèêîâ");
else if(Current != -1) SendClientMessage(playerid, COLOR_GREY, "* Èãðà íà áàçå óæå íà÷àëàñü, âû íå ìîæåòå ãîëîñîâàòü â äàííûé ìîìåíò.");
else if(!strlen(cmdtext[6])) SendClientMessage(playerid, COLOR_GREY, " Èñïîëüçóéòå: /base [baseid]");
else {
new baseid = strval(cmdtext[6]);
if(baseid >= MAX_MAP) SendClientMessage(playerid, COLOR_GREY, " Äàííàÿ áàçà íå ñóùåñòâóåò, ââåäèòå /bases äëÿ ïðîñìîòðà ñïèñêà áàç.");
else if(BaseFile[baseid]) SendClientMessage(playerid, COLOR_GREY, " Äàííàÿ áàçà íå ñóùåñòâóåò, ââåäèòå /bases äëÿ ïðîñìîòðà ñïèñêà áàç.");
else {
Votes2[baseid] = Votes2[baseid] +1;
Player[playerid][pVoted] = true;
format(string,255,"%s ãîëîñîâàë çà áàçó #%d", Playername(playerid), baseid);
SendClientMessageToAll(COLOR_YELLOW, string);
if(!Voting)
{
Voting = true;
new i;
while((i < MAX_MAP) || (i < MAX_PLAYERS))
{
if(i < MAX_MAP) Votes2[i] = 0;
if(i < MAX_PLAYERS) Player[i][pVoted] = false;
i++;
}
VotingTime = 20;
VoteMove();
}
}
}
return 1;
}
if(!strcmp(cmdtext,"/arena",true,6))
{
new string[255];
if(Current != -1) SendClientMessage(playerid, COLOR_GREY, "* Èãðà íà àðåíå óæå íà÷àëàñü, âû íå ìîæåòå ãîëîñîâàòü â äàííûé ìîìåíò.");
else if(!strlen(cmdtext[7])) SendClientMessage(playerid, COLOR_GREY, " Èñïîëüçóéòå: /arena [arenaid]");
else {
new arenaid = strval(cmdtext[7]);
if(arenaid >= MAX_MAP) SendClientMessage(playerid, COLOR_GREY, " Äàííîé àðåíû íå ñóùåñòâóåò, ââåäèòå /arenas äëÿ ïðîñìîòðà ñïèñêà àðåí");
else if(!ArenFile[arenaid]) SendClientMessage(playerid, COLOR_GREY, " Äàííîé àðåíû íå ñóùåñòâóåò, ââåäèòå /arenas äëÿ ïðîñìîòðà ñïèñêà àðåí");
else {
Votes[arenaid] = Votes[arenaid] +1;
Player[playerid][pVoted] = true;
format(string,255,"%s ïðîãîëîñîâàë çà àðåíó #%d", Playername(playerid), arenaid);
SendClientMessageToAll(COLOR_YELLOW, string);
if(!Voting)
{
Voting = true;
new i;
while((i < MAX_MAP) || (i < MAX_PLAYERS))
{
if(i < MAX_MAP) Votes[i] = 0;
if(i < MAX_PLAYERS) Player[i][pVoted] = false;
i++;
}
VotingTime = 20;
VoteMove();
}
}
}
return 1;
}
forward VoteMove();
public VoteMove()
{
if((Current != -1) || !Voting) return 0;
VotingTime--;
if(VotingTime <= 0)
{
Voting = false;
new BaseID, ArenaID;
new maxam = 0, tmparenas[300];
for (new i = 0; i <= MAX_MAP; i++)
{
if (i != BaseID)
{
if (Votes2[i] > Votes2[BaseID]){
BaseID = i;
}
}
}
for (new i = 0; i <= MAX_MAP; i++)
{
if (i != ArenaID)
{
if (Votes[i] > Votes[ArenaID]){
ArenaID = i;
}
}
}
if(BaseID > ArenaID){
for (new i = 0; i <= MAX_MAP; i++)
{
if (Votes2[i] == Votes2[BaseID]){
tmparenas[maxam] = i;
maxam++;
}
}
StartMode(tmparenas[random(maxam)], BASE);
} else {
for (new i = 0; i <= MAX_MAP; i++)
{
if (Votes[i] == Votes[ArenaID]){
tmparenas[maxam] = i;
maxam++;
}
}
StartMode(tmparenas[random(maxam)], ARENA);
}
return 1;
}
SetTimer("VoteMove",1000,0);
return 0;
}