/votekick + /vote
#4

pawn Код:
new bool:VoteOn = false,
    bool:HasVoted[MAX_PLAYERS] = false,
    VoteAgainst = -1,
    VoteReason[64],
    VoteTimer,
    YesVotes,
    NoVotes;

forward VoteEnd();

public VoteEnd()
{
    new string[128];
    if(YesVotes == NoVotes) format(string, sizeof(string), "Vote Failed. Yes: %i No: %i", YesVotes, NoVotes);
    else if(YesVotes > NoVotes)
    {
        format(string, sizeof(string), "%s vote kicked. Yes: %i No: %i (Reason: %s)", YesVotes, NoVotes, VoteReason);
        SendClientMessage(VoteAgainst, string);
        Kick(VoteAgainst);
    }
    else format(string, sizeof(string), "Vote Failed. Yes: %i No: %i", YesVotes, NoVotes);
    SendClientMessageToAll(0x00CCCCAA, string);
    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);
}

CMD:votekick(playerid, params[])
{
    if(INSERT_ADMIN_LEVEL_HERE)
    {
        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 <player> <optional:reason>");
       
        VoteAgainst = Target;
        format(VoteReason, sizeof(VoteReason), "%s", reason);
        VoteTimer = SetTimer("VoteEnd", 300_000, false);
        new string[128];
        format(string, sizeof(string), "Vote kick initiated against %s (Reason: %s)", Name(Target), VoteReason);
        SendClientMessageToAll(0x00CCCC, string);
    }
    else return SendClientMessage(playerid, 0xCC0000AA, "You aren't the required level.");
    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);
}

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);
}

CMD:vkick(playerid, params[]) return cmd_votekick(playerid, params);
CMD:vyes(playerid) return cmd_voteyes(playerid);
CMD:vno(playerid) return cmd_voteno(playerid);
So something like that?
Reply


Messages In This Thread
/votekick + /vote - by Twisted_Insane - 12.03.2012, 22:36
Re: /votekick + /vote - by [ABK]Antonio - 12.03.2012, 22:39
Re: /votekick + /vote - by Twisted_Insane - 12.03.2012, 23:12
Re: /votekick + /vote - by [ABK]Antonio - 12.03.2012, 23:43
Re: /votekick + /vote - by Twisted_Insane - 13.03.2012, 08:47
Re: /votekick + /vote - by Twisted_Insane - 19.03.2012, 13:07

Forum Jump:


Users browsing this thread: 4 Guest(s)