voting
#1

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 != -1SendClientMessage(playeridCOLOR_BRIGHTRED"*base is already started"); 
    else if(
GameTypeOff == 1SendClientMessage(playeridCOLOR_BRIGHTRED"*Voting goes on arenas"); 
    else if(
Gug == 0SendClientMessage(playeridCOLOR_BRIGHTRED"*Voting is disconnected by the administrator"); 
    else if(
Player[playerid][pVoted]) SendClientMessage(playeridCOLOR_BRIGHTRED"*You have already voted"); 
    else if(
ConnectedPlayers() < 2SendClientMessage(playeridCOLOR_BRIGHTRED"*On the server there are not enough players"); 
    else if(!
strlen(cmdtext[6])) SendClientMessage(playeridAAD_COLOR_GREY" Use: /base <baseid>"); 
    else { 
    new 
baseid strval(cmdtext[6]); 
    if(
baseid >= MAX_BASESSendClientMessage(playeridCOLOR_BRIGHTRED"*Bases it is not revealed"); 
    else if(!
Exists[baseid]) SendClientMessage(playeridCOLOR_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_GREEN2string); 
    if(
Votes[baseid] >= 3
    { 
    
Voting false
    
StartMode(baseid); 
    } 
    if(!
Voting
    { 
    
Voting true
    new 
i
       while((
MAX_BASES) || (MAX_PLAYERS)) 
       { 
    if(
MAX_BASES && != baseidVotes[i] = 0
    if(
MAX_PLAYERS && != playeridPlayer[i][pVoted] = false
    
i++; 
       } 
    
VotingTime 20
       
VoteMove(); 
    } 
    } 
//========================= 
    
if(!strcmp(cmdtext,"/arena",true,6)) 
    { 
    new 
string[STR]; 
    if(
Current != -1SendClientMessage(playeridCOLOR_BRIGHTRED"*arena is already started"); 
    else if(
GameTypeOff == 2SendClientMessage(playeridCOLOR_BRIGHTRED"*Voting goes on bases"); 
    else if(
Gug == 0SendClientMessage(playeridCOLOR_BRIGHTRED"*Voting is disconnected by the administrator"); 
    else if(
Player[playerid][pVoted]) SendClientMessage(playeridCOLOR_BRIGHTRED"*You have already voted"); 
    else if(!
strlen(cmdtext[7])) SendClientMessage(playeridAAD_COLOR_GREY" Use: /arena <arenaid>"); 
    else 
    { 
    new 
arenaid strval(cmdtext[7]); 
    if(
arenaid >= MAX_ARENASSendClientMessage(playeridCOLOR_BRIGHTRED"* arenas it is not revealed"); 
    else if(
ConnectedPlayers() < 2SendClientMessage(playeridCOLOR_BRIGHTRED"*On the server there are not enough players"); 
    else if(!
Exists2[arenaid]) SendClientMessage(playeridCOLOR_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_GREEN2string); 
    if(
Votes[arenaid] >= 6
    { 
    
Voting false
    
StartModeARENA(arenaid); 
    } 
    if(!
Voting
    { 
    
Voting true
    new 
i
       while((
MAX_ARENAS) || (MAX_PLAYERS)) 
       { 
    if(
MAX_ARENAS && != arenaidVotes[i] = 0
    if(
MAX_PLAYERS && != playeridPlayer[i][pVoted] = false
    
i++; 
      } 
    
VotingTime 20
       
VoteMove2(); 
    } 
    } 
    } 
    return 
1
    } 
forward VoteMove(); 
public 
VoteMove() 

    if((
Current != -1) || !Voting) return 0
    new 
string[256]; 
    new 
aalive 0dalive 0
    
VotingTime--; 
    for(new 
0MAX_PLAYERSi++) 
    { 
    if(
IsPlayerConnected(i)) 
    { 
    switch(
Player[i][pTeam]) 
    { 
    case 
T_ATT
    { 
    
aalive++; 
    } 
    case 
T_DEF
    { 
    
dalive++; 
    } 
    } 
    } 
    } 
    for(new 
0;i<21;i++){ 
    
format(string,128,"~w~time voting: ~w~(~r~%d~w~)~w~ - ~r~Att: %d ~y~vs ~b~Def: %d",VotingTimeaalivedalive); 
    
TextDrawSetString(Info_text[i],string); 
    } 
    if(
VotingTime <= 0
    { 
    
Voting false
    new 
maxam 0tmpbases[MAX_BASES]; 
    for(new 
iMAX_BASESi++) 
    { 
    if(
Exists[i] && (Votes[i] > 0)) 
    { 
    
tmpbases[maxam] = i
    
maxam++; 
    } 
    } 
    
StartMode(tmpbases[random(maxam)]); 
    return 
1
    } 
    
SetTimer("VoteMove",1000,0); 
    
format(mapstr20"mapname Voting %d Second",VotingTime); 
    
SendRconCommand(mapstr); 
    for(new 
iMAX_PLAYERSi++) 
    { 
    
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 0dalive 0
    
VotingTime--; 
     for(new 
0MAX_PLAYERSi++) 
    { 
    if(
IsPlayerConnected(i)) 
    { 
    switch(
Player[i][pTeam]) 
    { 
    case 
T_ATT
    { 
    
aalive++; 
    } 
    case 
T_DEF
    { 
    
dalive++; 
    } 
    } 
    } 
    } 
    for(new 
0;i<21;i++){ 
    
format(string,128,"~w~time voting: ~w~(~r~%d~w~)~w~ - ~r~Att: %d ~y~vs ~b~Def: %d",VotingTimeaalivedalive); 
    
TextDrawSetString(Info_text[i],string); 
    } 
    if(
VotingTime <= 0
    { 
    
Voting false
    new 
maxam 0tmparenas[MAX_ARENAS]; 
    for(new 
iMAX_ARENASi++) 
    { 
    if(
Exists2[i] && (Votes[i] > 0)) 
    { 
    
tmparenas[maxam] = i
    
maxam++; 
    } 
    } 
    
StartModeARENA(tmparenas[random(maxam)]); 
    return 
1
    } 
    
SetTimer("VoteMove2",1000,0); 
    
format(mapstr20"mapname Voting %d Second",VotingTime); 
    
SendRconCommand(mapstr); 
    for(new 
iMAX_PLAYERSi++) 
    { 
    
PlayerPlaySound(i,1056,0.0,0.0,0.0); 
    } 
    return 
0

Reply
#2

I didn't understand where is the problem in this code.
And why do you use 'strcmp', instead of some faster and better functions such as 'zcmd'?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)