/* ========================================== -VoteServ- GamerX VoteKick Service v1.0 Coded by Phantom, Matite ========================================== */ #include #define COLOR_YELLOW 0xFFFF00AA #define COLOR_WHITE 0xFFFFFFAA #define COLOR_RED 0xFF0033AA new Votes; // Vote Count new Voted[MAX_PLAYERS]; // Has Player Voted? new vTimer, vPlayer, players, rVotes; new pPerc, pTime, pState, settimer; // Settings new gString[255]; new KickTimer[MAX_PLAYERS]; new reason[128]; //------------------------------------------------- public OnFilterScriptInit() { print("\n VoteServ for GamerX\n"); print(" Loading Configuration...\n"); rConfig(); print(" Configuration: "); printf(" |RequiredPercentage [%d]", pPerc); printf(" |Voting Period [%d Seconds]", pTime); return 1; } public PlayerName(playerid) { new pName[32]; GetPlayerName(playerid, pName, sizeof(pName)); return pName; } public OnPlayerConnect(playerid) { players++; if(settimer!=1) { SetTimer("constTimer", 1000,1); settimer=1; } return 1; } public OnPlayerDisconnect(playerid) { players--; Voted[playerid] = 0; KickTimer[playerid] = 0; return 1; } //-------------------------------------------------- public OnPlayerCommandText(playerid, cmdtext[]) { new cmd[255], tmp[255]; new string[255]; new idx, idplayer; cmd = strtok(cmdtext, idx); if(strcmp(cmd, "/votekick", true) == 0) { if(vTimer > 0){ SendClientMessage(playerid, COLOR_YELLOW, "Cannot Run Concurrent Vote-Kicks!"); return 1;} tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_WHITE, "USAGE: /votekick [PlayerID] [Reason]"); strdel(reason, 0,128); return 1; } idplayer = strval(tmp); tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_WHITE, "USAGE: /votekick [PlayerID] [Reason]"); strdel(reason, 0,128); return 1; } strins(reason, tmp,0,128); if(IsPlayerConnected(idplayer)) { vPlayer = idplayer; vTimer = (pTime + 1); rVotes = ((players * pPerc) / 100); format(string, sizeof(string), "-VoteServ- %s has started a votekick for %s (%s)", PlayerName(playerid), PlayerName(vPlayer), reason); SendClientMessageToAll(COLOR_YELLOW, string); format(string, sizeof(string), "*** %d Votes Required for kicking [Type /vote to vote]", rVotes); SendClientMessageToAll(COLOR_YELLOW, string); return 1; } } else if(strcmp(cmdtext, "/vote", true) == 0) { if(vTimer < 1){ SendClientMessage(playerid, COLOR_WHITE, "There are no votekicks in action"); return 1;} if(Voted[playerid] == 1){ SendClientMessage(playerid, COLOR_WHITE, "You have already voted!"); return 1;} Votes++; Voted[playerid] = 1; format(string, sizeof(string), "-VoteServ- %s has voted to kick %s (total votes: %d/%d)", PlayerName(playerid), Votes, rVotes); SendClientMessageToAll(COLOR_YELLOW, string); if(Votes == rVotes){ VoteKickSuccessful(); } return 1; } else if(strcmp(cmdtext, "/vs end", true) == 0) { if(vTimer < 1){ SendClientMessage(playerid, COLOR_WHITE, "There are no vote kicks in action"); return 1;} AdminEndVoteKick(playerid); return 1; } else if(strcmp(cmdtext, "/vs help", true) == 0) { SendClientMessage(playerid, COLOR_YELLOW,"GamerX VoteKick Service [VoteServ]"); SendClientMessage(playerid, COLOR_YELLOW,"Availible Commands:"); SendClientMessage(playerid, COLOR_YELLOW,"/votekick [PlayerID] [Reason]"); SendClientMessage(playerid, COLOR_YELLOW,"/vote - Votes for Current VoteKick"); SendClientMessage(playerid, COLOR_YELLOW,"/view - Displays Current VoteKick"); return 1; } else if(strcmp(cmdtext, "/view", true) == 0) { if(vTimer < 1){SendClientMessage(playerid, COLOR_WHITE, "There are no vote kicks in action");return 1;} format(string, sizeof(string), "-VoteServ- Current VoteKick for %s (%s)", PlayerName(vPlayer), reason); SendClientMessageToAll(COLOR_YELLOW, string); format(string, sizeof(string), "*** [%d/%d] Votes Required for kicking [Type /vote to vote]", rVotes, Votes); SendClientMessageToAll(COLOR_YELLOW, string); return 1; } return 0; } public constTimer() { if(vTimer > 1) { vTimer--; } if(vTimer == 1) { EndVoteKick(); vTimer--; } } //------------------------------------------------------------- EndVoteKick() { ClearVoted(); Votes = 0; format(gString, sizeof(gString), "-VoteServ- Attempt to vote kick %s failed", PlayerName(vPlayer)); SendClientMessageToAll(COLOR_YELLOW, gString); vPlayer = -1; strdel(reason, 0,128); return 1; } AdminEndVoteKick(playerid) { ClearVoted(); Votes = 0; vTimer = 0; format(gString, sizeof(gString), "-VoteServ- VoteKick for %s was canceled by an Admin", PlayerName(vPlayer), PlayerName(playerid)); SendClientMessageToAll(COLOR_YELLOW, gString); vPlayer = -1; strdel(reason, 0,128); return 1; } VoteKickSuccessful() { ClearVoted(); Votes = 0; format(gString, sizeof(gString), "-OperServ- %s has been kicked by VoteServ (%s)", PlayerName(vPlayer), reason); SendClientMessageToAll(COLOR_RED, gString); KickTimer[vPlayer] = 1; SetTimer("vKick", 500, 0); vPlayer = -1; strdel(reason, 0,128); return 1; } ClearVoted() { for(new i=0;i ' ') && ((index - offset) < (sizeof(result) - 1))) { result[index - offset] = string[index]; index++; } result[index - offset] = EOS; return result; } strtok(const string[], &index) { new length = strlen(string); while ((index < length) && (string[index] <= ' ')) { index++; } new offset = index; new result[20]; while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1))) { result[index - offset] = string[index]; index++; } result[index - offset] = EOS; return result; }