Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- !vsm
- !vr
- !lista
- !vm
- !cmds
- using System;
- using System.Collections.Generic;
- using System.Threading;
- using Addon;
- namespace mw3_votemap
- {
- public class Votemap : CPlugin
- {
- string map_name;
- string mapname;
- Vote vote;
- int Interval;
- int VoteTime;
- int votemsginterval;
- List<int> validPN;
- int Vtime;
- int successpercent;
- public override void OnServerFrame()
- {
- if (Interval > 0)
- Interval--;
- if (VoteTime > 0 && vote.InProgress)
- {
- if (VoteTime % votemsginterval == 0)
- {
- validPN = new List<int>();
- foreach (ServerClient player in GetClients())
- {
- if (player.Ping < 999 && player.Ping > 0)
- {
- validPN.Add(player.ClientNum);
- }
- }
- if (validPN.Count == 0)
- {
- vote.votenext = false;
- vote.votemaprestart = false;
- vote.votemap = false;
- vote.InProgress = false;
- }
- foreach (ServerClient player in GetClients())
- {
- if (vote.votemaprestart)
- {
- //TellClient(player.ClientNum, "^1(" + VoteTime / 50 + "s) ^2" + player.Name + " ^5llamado a votar pora ^3Reiniciar Mapa. ^5Escribe en el chat: ^6!s ^5O ^6!n ^5Para Votar [^3Necesarios " + Math.Ceiling(validPN.Count * 1.6) + " ^2Si " + vote.Agree.Count + " ^1No " + (vote.Against.Count) + "]", true);
- iPrintLnBold("^1(" + VoteTime / 50 + "s)^5Reiniciar Mapa^5? ^3Escribe en el chat: ^6!s ^5O ^6!n ^5Para Votar [^3Nesesarios " + Math.Ceiling(validPN.Count * successpercent * 1.06) + " ^2S " + vote.Agree.Count + " ^1N " + (vote.Against.Count) + "]", player);
- }
- if (vote.votenext)
- {
- //TellClient(player.ClientNum, "^1(" + VoteTime / 50 + "s) ^2" + player.Name + " ^5llamado a votar por Siguiente Mapa. ^5Escribe en el chat: ^6!s ^5O ^6!n ^5Para votar [^3Necesarios " + Math.Ceiling(validPN.Count * 1.6) + " ^2Si " + vote.Agree.Count + " ^1No " + (vote.Against.Count) + "]", true);
- iPrintLnBold("^1(" + VoteTime / 50 + "s)^5Ir a ^3Siguiente Mapa^5? ^3Escribe en el chat: ^6!s ^5O ^6!n ^5Para Votar [^3Nesesarios " + Math.Ceiling(validPN.Count * successpercent * 1.06) + " ^2S " + vote.Agree.Count + " ^1N " + (vote.Against.Count) + "]", player);
- }
- if (vote.votemap)
- {
- //TellClient(player.ClientNum, "^1(" + VoteTime / 50 + "s) ^2" + player.Name + " ^5Votar Por ^3<" + mapname + ">. ^5Escribe en el chat ^3!y ^5or ^3!n ^5Para Votar [^3Nesesarios " + Math.Ceiling(validPN.Count * 1.6) + " ^2Si " + vote.Agree.Count + " ^1No " + (vote.Against.Count) + "]", true);
- iPrintLnBold("^1(" + VoteTime / 50 + "s)^5Ir a ^3" + mapname + "^5? ^3Escribe en el chat: ^6!s ^5O ^6!n ^5Para Votar[^3Nesesarios " + Math.Ceiling(validPN.Count * successpercent * 1.06) + " ^2S " + vote.Agree.Count + " ^1N " + (vote.Against.Count) + "]", player);
- }
- }
- }
- VoteTime--;
- if (VoteTime == 0 && vote.InProgress)
- {
- if (vote.votemaprestart)
- {
- if ((Convert.ToDouble(vote.Agree.Count) / Convert.ToDouble(validPN.Count) * 100) >= successpercent)
- {
- ServerSay("^2SERVER:^3VOTO PASADO:^6Reinicio de Mapa", true);
- ServerCommand("fast_restart");
- }
- else
- ServerSay("^2SERVER:^3VOTO FALLIDO: ^1No hay suficientes jugadores de acuerdo para ^6REINICIAR MAPA.", true);
- }
- if (vote.votenext)
- {
- if ((Convert.ToDouble(vote.Agree.Count) / Convert.ToDouble(validPN.Count) * 100) >= successpercent)
- {
- ServerSay("^2SERVER:^3VOTO PASADO:^6Mapa Cambiado", true);
- ServerCommand("map_rotate");
- }
- else
- ServerSay("^2SERVER:^3VOTO FALLIDO: ^1No hay suficientes jugadores de acuerdo para ^6CAMBIAR MAPA.", true);
- }
- if (vote.votemap)
- {
- if ((Convert.ToDouble(vote.Agree.Count) / Convert.ToDouble(validPN.Count) * 100) >= successpercent)
- {
- ServerSay("^2SERVER:^3VOTO PASADO:^6Mapa Cambiado", true);
- ServerCommand("map " + map_name);
- }
- else
- ServerSay("^2SERVER:^3VOTO FALLIDO: ^1No hay suficientes jugadores de acuerdo para ^6CAMBIAR MAPA.", true);
- }
- ResetVars();
- }
- }
- }
- public override void OnServerLoad()
- {
- ServerPrint("VotarMapa plugin Cargado...By:Brian9985");
- votemsginterval = Convert.ToInt32(GetServerCFG("VOTEMAP", "votemsginterval", "")) * 50;
- Vtime = Convert.ToInt32(GetServerCFG("VOTEMAP", "votetime", "")) * 50;
- successpercent = Convert.ToInt32(GetServerCFG("VOTEMAP", "successpercent", ""));
- }
- public override ChatType OnSay(string Message, ServerClient Client)
- {
- string lowMsg = Message.ToLower();
- if (lowMsg.Equals("!vsm"))
- {
- if (Interval > 0)
- {
- TellClient(Client.ClientNum, "2SERVER:^3No puedes empezar un voto ahora! Espera... " + Interval / 50 + " seconds.", true);
- return ChatType.ChatNone;
- }
- if (vote.InProgress)
- {
- TellClient(Client.ClientNum, "2SERVER:^3Ya hay una votación en curso...!", true);
- }
- else
- {
- vote.Agree = new List<string>();
- vote.Against = new List<string>();
- vote.InProgress = true;
- vote.votenext = true;
- VoteTime = Vtime;
- }
- return ChatType.ChatNone;
- }
- else if (lowMsg.Equals("!s"))
- {
- if (!vote.InProgress)
- {
- TellClient(Client.ClientNum, "2SERVER:^3Actualmente no hay ningún voto en curso! Para iniciar un voto,Escribe en el chat ^6!vn ^3O ^6!vm(nombre corto).", true);
- }
- if (vote.InProgress)
- {
- if (!vote.Agree.Contains(Client.XUID) && !vote.Against.Contains(Client.XUID))
- {
- vote.Agree.Add(Client.XUID);
- ServerSay("^3" + Client.Name + " ^2Voto=^1<SI>", true);
- }
- else if (vote.Agree.Contains(Client.XUID) || vote.Against.Contains(Client.XUID))
- {
- TellClient(Client.ClientNum, "2SERVER:^3Usted ya votó!", true);
- }
- }
- return ChatType.ChatNone;
- }
- else if (lowMsg.Equals("!n"))
- {
- if (!vote.InProgress)
- {
- TellClient(Client.ClientNum, "2SERVER:^3Actualmente no hay ningún voto en curso! Para iniciar un voto,Escribe en el chat ^6!vn ^3or ^6!vm(shortname).", true);
- }
- if (vote.InProgress)
- {
- if (!vote.Agree.Contains(Client.XUID) && !vote.Against.Contains(Client.XUID))
- {
- vote.Against.Add(Client.XUID);
- ServerSay("^3" + Client.Name + " ^2Voto=^1<NO>", true);
- }
- else if (vote.Agree.Contains(Client.XUID) || vote.Against.Contains(Client.XUID))
- {
- TellClient(Client.ClientNum, "2SERVER:^3Usted ya votó!", true);
- }
- }
- return ChatType.ChatNone;
- }
- else if (lowMsg.Equals("!lista"))
- {
- Thread shru = new Thread(showmaplist);
- shru.Start(Client);
- return ChatType.ChatNone;
- }
- else if (lowMsg.Equals("!vmun"))
- {
- if (Interval > 0)
- {
- TellClient(Client.ClientNum, "2SERVER:^3No puedes empezar un voto ahora! espera... " + Interval / 50 + " seconds.", true);
- return ChatType.ChatNone;
- }
- if (vote.InProgress)
- {
- TellClient(Client.ClientNum, "2SERVER:^3Ya hay una votación en curso!", true);
- }
- else
- {
- vote.Agree = new List<string>();
- vote.Against = new List<string>();
- vote.InProgress = true;
- vote.votemap = true;
- VoteTime = Vtime;
- mapname = "Underground";
- map_name = "mp_underground";
- }
- return ChatType.ChatNone;
- }
- else if (lowMsg.Equals("!vmou"))
- {
- if (Interval > 0)
- {
- TellClient(Client.ClientNum, "2SERVER:^3No puedes empezar un voto ahora! espera... " + Interval / 50 + " seconds.", true);
- return ChatType.ChatNone;
- }
- if (vote.InProgress)
- {
- TellClient(Client.ClientNum, "2SERVER:^3Ya hay una votación en curso!", true);
- }
- else
- {
- vote.Agree = new List<string>();
- vote.Against = new List<string>();
- vote.InProgress = true;
- vote.votemap = true;
- VoteTime = Vtime;
- mapname = "Outpost";
- map_name = "mp_radar";
- }
- return ChatType.ChatNone;
- }
- else if (lowMsg.Equals("!vmdo"))
- {
- if (Interval > 0)
- {
- TellClient(Client.ClientNum, "2SERVER:^3No puedes empezar un voto ahora! espera... " + Interval / 50 + " seconds.", true);
- return ChatType.ChatNone;
- }
- if (vote.InProgress)
- {
- TellClient(Client.ClientNum, "2SERVER:^3Ya hay una votación en curso!", true);
- }
- else
- {
- vote.Agree = new List<string>();
- vote.Against = new List<string>();
- vote.InProgress = true;
- vote.votemap = true;
- VoteTime = Vtime;
- mapname = "Dome";
- map_name = "mp_dome";
- }
- return ChatType.ChatNone;
- }
- else if (lowMsg.Equals("!vmre"))
- {
- if (Interval > 0)
- {
- TellClient(Client.ClientNum, "2SERVER:^3No puedes empezar un voto ahora! espera... " + Interval / 50 + " seconds.", true);
- return ChatType.ChatNone;
- }
- if (vote.InProgress)
- {
- TellClient(Client.ClientNum, "2SERVER:^3Ya hay una votación en curso!", true);
- }
- else
- {
- vote.Agree = new List<string>();
- vote.Against = new List<string>();
- vote.InProgress = true;
- vote.votemap = true;
- VoteTime = Vtime;
- mapname = "Resistance";
- map_name = "mp_paris";
- }
- return ChatType.ChatNone;
- }
- else if (lowMsg.Equals("!vmca"))
- {
- if (Interval > 0)
- {
- TellClient(Client.ClientNum, "2SERVER:^3No puedes empezar un voto ahora! espera... " + Interval / 50 + " seconds.", true);
- return ChatType.ChatNone;
- }
- if (vote.InProgress)
- {
- TellClient(Client.ClientNum, "2SERVER:^3Ya hay una votación en curso!", true);
- }
- else
- {
- vote.Agree = new List<string>();
- vote.Against = new List<string>();
- vote.InProgress = true;
- vote.votemap = true;
- VoteTime = Vtime;
- mapname = "Carbon";
- map_name = "mp_carbon";
- }
- return ChatType.ChatNone;
- }
- else if (lowMsg.Equals("!vmin"))
- {
- if (Interval > 0)
- {
- TellClient(Client.ClientNum, "2SERVER:^3No puedes empezar un voto ahora! espera... " + Interval / 50 + " seconds.", true);
- return ChatType.ChatNone;
- }
- if (vote.InProgress)
- {
- TellClient(Client.ClientNum, "2SERVER:^3Ya hay una votación en curso!", true);
- }
- else
- {
- vote.Agree = new List<string>();
- vote.Against = new List<string>();
- vote.InProgress = true;
- vote.votemap = true;
- VoteTime = Vtime;
- mapname = "Interchange";
- map_name = "mp_interchange";
- }
- return ChatType.ChatNone;
- }
- else if (lowMsg.Equals("!vmdt"))
- {
- if (Interval > 0)
- {
- TellClient(Client.ClientNum, "2SERVER:^3No puedes empezar un voto ahora! espera... " + Interval / 50 + " seconds.", true);
- return ChatType.ChatNone;
- }
- if (vote.InProgress)
- {
- TellClient(Client.ClientNum, "2SERVER:^3Ya hay una votación en curso!", true);
- }
- else
- {
- vote.Agree = new List<string>();
- vote.Against = new List<string>();
- vote.InProgress = true;
- vote.votemap = true;
- VoteTime = Vtime;
- mapname = "Downturn";
- map_name = "mp_exchange";
- }
- return ChatType.ChatNone;
- }
- else if (lowMsg.Equals("!vmar"))
- {
- if (Interval > 0)
- {
- TellClient(Client.ClientNum, "2SERVER:^3No puedes empezar un voto ahora! espera... " + Interval / 50 + " seconds.", true);
- return ChatType.ChatNone;
- }
- if (vote.InProgress)
- {
- TellClient(Client.ClientNum, "2SERVER:^3Ya hay una votación en curso!", true);
- }
- else
- {
- vote.Agree = new List<string>();
- vote.Against = new List<string>();
- vote.InProgress = true;
- vote.votemap = true;
- VoteTime = Vtime;
- mapname = "Arkaden";
- map_name = "mp_plaza2";
- }
- return ChatType.ChatNone;
- }
- else if (lowMsg.Equals("!vmlo"))
- {
- if (Interval > 0)
- {
- TellClient(Client.ClientNum, "2SERVER:^3No puedes empezar un voto ahora! espera... " + Interval / 50 + " seconds.", true);
- return ChatType.ChatNone;
- }
- if (vote.InProgress)
- {
- TellClient(Client.ClientNum, "2SERVER:^3Ya hay una votación en curso!", true);
- }
- else
- {
- vote.Agree = new List<string>();
- vote.Against = new List<string>();
- vote.InProgress = true;
- vote.votemap = true;
- VoteTime = Vtime;
- mapname = "Lockdown";
- map_name = "mp_alpha";
- }
- return ChatType.ChatNone;
- }
- else if (lowMsg.Equals("!vmmi"))
- {
- if (Interval > 0)
- {
- TellClient(Client.ClientNum, "2SERVER:^3No puedes empezar un voto ahora! espera... " + Interval / 50 + " seconds.", true);
- return ChatType.ChatNone;
- }
- if (vote.InProgress)
- {
- TellClient(Client.ClientNum, "2SERVER:^3Ya hay una votación en curso!", true);
- }
- else
- {
- vote.Agree = new List<string>();
- vote.Against = new List<string>();
- vote.InProgress = true;
- vote.votemap = true;
- VoteTime = Vtime;
- mapname = "Mission";
- map_name = "mp_bravo";
- }
- return ChatType.ChatNone;
- }
- else if (lowMsg.Equals("!vmse"))
- {
- if (Interval > 0)
- {
- TellClient(Client.ClientNum, "2SERVER:^3No puedes empezar un voto ahora! espera... " + Interval / 50 + " seconds.", true);
- return ChatType.ChatNone;
- }
- if (vote.InProgress)
- {
- TellClient(Client.ClientNum, "2SERVER:^3Ya hay una votación en curso!", true);
- }
- else
- {
- vote.Agree = new List<string>();
- vote.Against = new List<string>();
- vote.InProgress = true;
- vote.votemap = true;
- VoteTime = Vtime;
- mapname = "Seatown";
- map_name = "mp_seatown";
- }
- return ChatType.ChatNone;
- }
- else if (lowMsg.Equals("!vmbo"))
- {
- if (Interval > 0)
- {
- TellClient(Client.ClientNum, "2SERVER:^3No puedes empezar un voto ahora! espera... " + Interval / 50 + " seconds.", true);
- return ChatType.ChatNone;
- }
- if (vote.InProgress)
- {
- TellClient(Client.ClientNum, "2SERVER:^3Ya hay una votación en curso!", true);
- }
- else
- {
- vote.Agree = new List<string>();
- vote.Against = new List<string>();
- vote.InProgress = true;
- vote.votemap = true;
- VoteTime = Vtime;
- mapname = "Bootleg";
- map_name = "mp_bootleg";
- }
- return ChatType.ChatNone;
- }
- else if (lowMsg.Equals("!vmha"))
- {
- if (Interval > 0)
- {
- TellClient(Client.ClientNum, "2SERVER:^3No puedes empezar un voto ahora! espera... " + Interval / 50 + " seconds.", true);
- return ChatType.ChatNone;
- }
- if (vote.InProgress)
- {
- TellClient(Client.ClientNum, "2SERVER:^3Ya hay una votación en curso!", true);
- }
- else
- {
- vote.Agree = new List<string>();
- vote.Against = new List<string>();
- vote.InProgress = true;
- vote.votemap = true;
- VoteTime = Vtime;
- mapname = "Hardhat";
- map_name = "mp_hardhat";
- }
- return ChatType.ChatNone;
- }
- else if (lowMsg.Equals("!vmba"))
- {
- if (Interval > 0)
- {
- TellClient(Client.ClientNum, "2SERVER:^3No puedes empezar un voto ahora! espera... " + Interval / 50 + " seconds.", true);
- return ChatType.ChatNone;
- }
- if (vote.InProgress)
- {
- TellClient(Client.ClientNum, "2SERVER:^3Ya hay una votación en curso!", true);
- }
- else
- {
- vote.Agree = new List<string>();
- vote.Against = new List<string>();
- vote.InProgress = true;
- vote.votemap = true;
- VoteTime = Vtime;
- mapname = "Bakaara";
- map_name = "mp_mogadishu";
- }
- return ChatType.ChatNone;
- }
- else if (lowMsg.Equals("!vmvi"))
- {
- if (Interval > 0)
- {
- TellClient(Client.ClientNum, "2SERVER:^3No puedes empezar un voto ahora! espera... " + Interval / 50 + " seconds.", true);
- return ChatType.ChatNone;
- }
- if (vote.InProgress)
- {
- TellClient(Client.ClientNum, "2SERVER:^3Ya hay una votación en curso!", true);
- }
- else
- {
- vote.Agree = new List<string>();
- vote.Against = new List<string>();
- vote.InProgress = true;
- vote.votemap = true;
- VoteTime = Vtime;
- mapname = "Village";
- map_name = "mp_village";
- }
- return ChatType.ChatNone;
- }
- else if (lowMsg.Equals("!vmfa"))
- {
- if (Interval > 0)
- {
- TellClient(Client.ClientNum, "2SERVER:^3No puedes empezar un voto ahora! espera... " + Interval / 50 + " seconds.", true);
- return ChatType.ChatNone;
- }
- if (vote.InProgress)
- {
- TellClient(Client.ClientNum, "2SERVER:^3Ya hay una votación en curso!", true);
- }
- else
- {
- vote.Agree = new List<string>();
- vote.Against = new List<string>();
- vote.InProgress = true;
- vote.votemap = true;
- VoteTime = Vtime;
- mapname = "Fallen";
- map_name = "mp_lambeth";
- }
- return ChatType.ChatNone;
- }
- else if (lowMsg.Equals("!vfr"))
- {
- if (Interval > 0)
- {
- TellClient(Client.ClientNum, "2SERVER:^3No puedes empezar un voto ahora! espera... " + Interval / 50 + " seconds.", true);
- return ChatType.ChatNone;
- }
- if (vote.InProgress)
- {
- TellClient(Client.ClientNum, "2SERVER:^3Ya hay una votación en curso!", true);
- }
- else
- {
- vote.Agree = new List<string>();
- vote.Against = new List<string>();
- vote.InProgress = true;
- vote.votemaprestart = true;
- VoteTime = Vtime;
- }
- return ChatType.ChatNone;
- }
- else if (lowMsg.Equals("!cvm"))
- {
- Thread shru = new Thread(showcmds);
- shru.Start(Client);
- return ChatType.ChatNone;
- }
- return ChatType.ChatContinue;
- }
- public struct Vote
- {
- public bool InProgress;
- public ServerClient Client;
- public List<string> Agree;
- public List<string> Against;
- public bool votenext;
- public bool votemap;
- public bool votemaprestart;
- }
- private void ResetVars()
- {
- //reset vars
- validPN.Clear();
- VoteTime = 0;
- vote.Agree.Clear();
- vote.Against.Clear();
- vote.InProgress = false;
- vote.votenext = false;
- vote.votemap = false;
- vote.votemaprestart = false;
- //set cooldown timer
- Interval = Convert.ToInt32(GetServerCFG("VOTEMAP", "cooldown", "")) * 50;
- }
- private void showcmds(object cli)
- {
- ServerClient Client = (ServerClient)cli;
- TellClient(Client.ClientNum, "^2SERVER:^3!vfr ^5=^2Votar para ^6Reinciar Mapa ", true);
- Thread.Sleep(5000);
- TellClient(Client.ClientNum, "^2SERVER:3!vsm ^5=^2Votar para ^6Siguiente Mapa ", true);
- Thread.Sleep(5000);
- TellClient(Client.ClientNum, "2SERVER:^3!mlist ^5=^2Para ver lista de ^6Nombres Cortos ^3de mapas ", true);
- Thread.Sleep(5000);
- TellClient(Client.ClientNum, "2SERVER:^3!vm(shortname) ^5=^2votar por mapa especificado. ^1Ejem:^3!vmdo", true);
- Thread.Sleep(5000);
- TellClient(Client.ClientNum, "2SERVER:^6!s ^5= ^2Voto SI, ^6!n ^5= ^2Voto NO", true);
- }
- private void showmaplist(object cli)
- {
- ServerClient Client = (ServerClient)cli;
- TellClient(Client.ClientNum, "^2[Nombre de Mapa] ^6[Nombre Corto]", true);
- Thread.Sleep(2500);
- TellClient(Client.ClientNum, "^2Underground = ^6un", true);
- Thread.Sleep(2500);
- TellClient(Client.ClientNum, "^2Mission = ^6mi", true);
- Thread.Sleep(2500);
- TellClient(Client.ClientNum, "^2Interchange = ^6in", true);
- Thread.Sleep(2500);
- TellClient(Client.ClientNum, "^2Fallen = ^6fa", true);
- Thread.Sleep(2500);
- TellClient(Client.ClientNum, "^2Seatown = ^6se", true);
- Thread.Sleep(2500);
- TellClient(Client.ClientNum, "^2Village = ^6vi", true);
- Thread.Sleep(2500);
- TellClient(Client.ClientNum, "^2Bakaara = ^6ba", true);
- Thread.Sleep(2500);
- TellClient(Client.ClientNum, "^2Dome = ^6do", true);
- Thread.Sleep(2500);
- TellClient(Client.ClientNum, "^2Downturn = ^6dt", true);
- Thread.Sleep(2500);
- TellClient(Client.ClientNum, "^2Lockdown = ^6lo", true);
- Thread.Sleep(2500);
- TellClient(Client.ClientNum, "^2Outpost = ^6ou", true);
- Thread.Sleep(2500);
- TellClient(Client.ClientNum, "^2Arkaden = ^6ar", true);
- Thread.Sleep(2500);
- TellClient(Client.ClientNum, "^2Carbon = ^6ca", true);
- Thread.Sleep(2500);
- TellClient(Client.ClientNum, "^2Bootleg ^6bo", true);
- Thread.Sleep(2500);
- TellClient(Client.ClientNum, "^2Hardhat = ^6ha", true);
- Thread.Sleep(2500);
- TellClient(Client.ClientNum, "^2Resistance = ^6re", true);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement