19.03.2012, 13:07
Erm, I tested it now and had to change some stuff because there were errors! But there's a problem:
I start a votekick against myself, and then, I'm voting for "no", that means "/voteno"! But, it shows the following:
Votesystem: Yes: 0 No:
It should usually also count the No's and the current results...Here, I'mma show you my whole code again, the rest seems to be okay!^^
I start a votekick against myself, and then, I'm voting for "no", that means "/voteno"! But, it shows the following:
Votesystem: Yes: 0 No:
It should usually also count the No's and the current results...Here, I'mma show you my whole code again, the rest seems to be okay!^^
PHP код:
CMD:votekick(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >= 1)
{
if(VoteOn) return SendClientMessage(playerid, 0xCC0000AA, "There's already a vote going on!");
new Target, reason[64];
if(sscanf(params, "rS(None)[64]", Target, reason)) return SendClientMessage(playerid, 0xCC0000AA, "USAGE: /votekick <playerid> <optional:reason>");
VoteOn = true;
VoteAgainst = Target;
format(VoteReason, sizeof(VoteReason), "%s", reason);
VoteTimer = SetTimer("VoteEnd", 60000, false);
new string[128];
format(string, sizeof(string), "Vote kick initiated against %s (Reason: %s)", Name(Target), VoteReason);
SendClientMessageToAll(COLOR_LIGHTBLUE, string);
}
else return SendClientMessage(playerid, COLOR_RED,"You have to be level 1 to use that command!");
return 1;
}
CMD:voteyes(playerid)
{
if(!VoteOn) return SendClientMessage(playerid, 0xCC0000AA, "There's no vote going on!");
if(HasVoted[playerid]) return SendClientMessage(playerid, 0xCC0000AA, "You already voted!");
YesVotes++;
HasVoted[playerid] = true;
new string[50];
format(string, sizeof(string), "{00CCCC}| Vote System | {00CC00}Yes: %i {CC0000}No: %i", YesVotes, NoVotes);
SendClientMessageToAll(0x00CCCCAA, string);
return 1;
}
CMD:voteno(playerid)
{
if(!VoteOn) return SendClientMessage(playerid, 0xCC0000AA, "There's no vote going on!");
if(HasVoted[playerid]) return SendClientMessage(playerid, 0xCC0000AA, "You already voted!");
NoVotes++;
HasVoted[playerid] = true;
new string[50];
format(string, sizeof(string), "{00CCCC}| Vote System | {00CC00}Yes: %i {CC0000}No: %i", YesVotes, NoVotes);
SendClientMessageToAll(0x00CCCCAA, string);
return 1;
}
CMD:vkick(playerid, params[]) return cmd_votekick(playerid, params);
CMD:vyes(playerid) return cmd_voteyes(playerid);
CMD:vno(playerid) return cmd_voteno(playerid);
PHP код:
forward VoteEnd(playerid);
public VoteEnd(playerid)
{
new votestring[128];
if(YesVotes == NoVotes) format(votestring, sizeof(votestring), "Vote Failed. Yes: %i No: %i", YesVotes, NoVotes);
else if(YesVotes > NoVotes)
{
format(votestring, sizeof(votestring), "%s got vote kicked. Yes: %i No: %i (Reason: %s)", YesVotes, NoVotes, VoteReason);
SendClientMessage(playerid, VoteAgainst, votestring);
Kick(VoteAgainst);
}
else format(votestring, sizeof(votestring), "Votekick failed. Yes: %i No: %i", YesVotes, NoVotes);
SendClientMessageToAll(0x00CCCCAA, votestring);
VoteAgainst = -1;
VoteReason = "\0";
YesVotes = 0; NoVotes = 0;
for(new i=0; i < MAX_PLAYERS; i++) if(HasVoted[i]) HasVoted[i] = false;
VoteOn = false;
KillTimer(VoteTimer);
}