12.02.2011, 19:12
It is necessary to correct voting in fashion AAD that it was possible to vote simultaneously for base and arena and that that base/arena for which have given more voices was started.
PHP код:
//========================
if(!strcmp(cmdtext,"/base",true,5))
{
new string[STR];
if(Current != -1) SendClientMessage(playerid, COLOR_BRIGHTRED, "*base is already started");
else if(GameTypeOff == 1) SendClientMessage(playerid, COLOR_BRIGHTRED, "*Voting goes on arenas");
else if(Gug == 0) SendClientMessage(playerid, COLOR_BRIGHTRED, "*Voting is disconnected by the administrator");
else if(Player[playerid][pVoted]) SendClientMessage(playerid, COLOR_BRIGHTRED, "*You have already voted");
else if(ConnectedPlayers() < 2) SendClientMessage(playerid, COLOR_BRIGHTRED, "*On the server there are not enough players");
else if(!strlen(cmdtext[6])) SendClientMessage(playerid, AAD_COLOR_GREY, " Use: /base <baseid>");
else {
new baseid = strval(cmdtext[6]);
if(baseid >= MAX_BASES) SendClientMessage(playerid, COLOR_BRIGHTRED, "*Bases it is not revealed");
else if(!Exists[baseid]) SendClientMessage(playerid, COLOR_BRIGHTRED, "*Bases it is not revealed");
else {
Votes[baseid] = Votes[baseid] +1;
Player[playerid][pVoted] = true;
format(string,STR,"*Player %s has voted for base %d*", Playername(playerid), baseid);
SendClientMessageToAll(AAD_COLOR_GREEN2, string);
if(Votes[baseid] >= 3)
{
Voting = false;
StartMode(baseid);
}
if(!Voting)
{
Voting = true;
new i;
while((i < MAX_BASES) || (i < MAX_PLAYERS))
{
if(i < MAX_BASES && i != baseid) Votes[i] = 0;
if(i < MAX_PLAYERS && i != playerid) Player[i][pVoted] = false;
i++;
}
VotingTime = 20;
VoteMove();
}
}
//=========================
if(!strcmp(cmdtext,"/arena",true,6))
{
new string[STR];
if(Current != -1) SendClientMessage(playerid, COLOR_BRIGHTRED, "*arena is already started");
else if(GameTypeOff == 2) SendClientMessage(playerid, COLOR_BRIGHTRED, "*Voting goes on bases");
else if(Gug == 0) SendClientMessage(playerid, COLOR_BRIGHTRED, "*Voting is disconnected by the administrator");
else if(Player[playerid][pVoted]) SendClientMessage(playerid, COLOR_BRIGHTRED, "*You have already voted");
else if(!strlen(cmdtext[7])) SendClientMessage(playerid, AAD_COLOR_GREY, " Use: /arena <arenaid>");
else
{
new arenaid = strval(cmdtext[7]);
if(arenaid >= MAX_ARENAS) SendClientMessage(playerid, COLOR_BRIGHTRED, "* arenas it is not revealed");
else if(ConnectedPlayers() < 2) SendClientMessage(playerid, COLOR_BRIGHTRED, "*On the server there are not enough players");
else if(!Exists2[arenaid]) SendClientMessage(playerid, COLOR_BRIGHTRED, "*arenas it is not revealed");
else
{
Votes[arenaid] = Votes[arenaid] +1;
Player[playerid][pVoted] = true;
format(string,STR,"*Player %s has voted for arena %d.", Playername(playerid), arenaid);
SendClientMessageToAll(AAD_COLOR_GREEN2, string);
if(Votes[arenaid] >= 6)
{
Voting = false;
StartModeARENA(arenaid);
}
if(!Voting)
{
Voting = true;
new i;
while((i < MAX_ARENAS) || (i < MAX_PLAYERS))
{
if(i < MAX_ARENAS && i != arenaid) Votes[i] = 0;
if(i < MAX_PLAYERS && i != playerid) Player[i][pVoted] = false;
i++;
}
VotingTime = 20;
VoteMove2();
}
}
}
return 1;
}
forward VoteMove();
public VoteMove()
{
if((Current != -1) || !Voting) return 0;
new string[256];
new aalive = 0, dalive = 0;
VotingTime--;
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
switch(Player[i][pTeam])
{
case T_ATT:
{
aalive++;
}
case T_DEF:
{
dalive++;
}
}
}
}
for(new i = 0;i<21;i++){
format(string,128,"~w~time voting: ~w~(~r~%d~w~)~w~ - ~r~Att: %d ~y~vs ~b~Def: %d",VotingTime, aalive, dalive);
TextDrawSetString(Info_text[i],string);
}
if(VotingTime <= 0)
{
Voting = false;
new maxam = 0, tmpbases[MAX_BASES];
for(new i; i < MAX_BASES; i++)
{
if(Exists[i] && (Votes[i] > 0))
{
tmpbases[maxam] = i;
maxam++;
}
}
StartMode(tmpbases[random(maxam)]);
return 1;
}
SetTimer("VoteMove",1000,0);
format(mapstr, 20, "mapname Voting %d Second",VotingTime);
SendRconCommand(mapstr);
for(new i; i < MAX_PLAYERS; i++)
{
PlayerPlaySound(i,1056,0.0,0.0,0.0);
}
return 0;
}
//------------------------------------------------------------------------------
forward VoteMove2();
public VoteMove2()
{
if((Current != -1) || !Voting) return 0;
new string[256];
new aalive = 0, dalive = 0;
VotingTime--;
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
switch(Player[i][pTeam])
{
case T_ATT:
{
aalive++;
}
case T_DEF:
{
dalive++;
}
}
}
}
for(new i = 0;i<21;i++){
format(string,128,"~w~time voting: ~w~(~r~%d~w~)~w~ - ~r~Att: %d ~y~vs ~b~Def: %d",VotingTime, aalive, dalive);
TextDrawSetString(Info_text[i],string);
}
if(VotingTime <= 0)
{
Voting = false;
new maxam = 0, tmparenas[MAX_ARENAS];
for(new i; i < MAX_ARENAS; i++)
{
if(Exists2[i] && (Votes[i] > 0))
{
tmparenas[maxam] = i;
maxam++;
}
}
StartModeARENA(tmparenas[random(maxam)]);
return 1;
}
SetTimer("VoteMove2",1000,0);
format(mapstr, 20, "mapname Voting %d Second",VotingTime);
SendRconCommand(mapstr);
for(new i; i < MAX_PLAYERS; i++)
{
PlayerPlaySound(i,1056,0.0,0.0,0.0);
}
return 0;
}