Pastebin
API
tools
faq
paste
Login
Sign up
Please fix the following errors:
New Paste
Syntax Highlighting
using System; using System.IO; using System.Text; using System.Text.RegularExpressions; using System.Collections.Generic; using System.Collections; using System.Net; using System.Web; using System.Data; using System.Threading; using System.Security; using System.Timers; using System.Diagnostics; using System.Reflection; using System.Runtime.InteropServices; using System.Windows.Forms; using PRoCon.Core; using PRoCon.Core.Plugin; using PRoCon.Core.Plugin.Commands; using PRoCon.Core.Players; using PRoCon.Core.Players.Items; using PRoCon.Core.Battlemap; using PRoCon.Core.Maps; namespace PRoConEvents { using EventType = PRoCon.Core.Events.EventType; using CapturableEvent = PRoCon.Core.Events.CapturableEvents; public class VoteChange : PRoConPluginAPI, IPRoConPluginInterface { double votePercentage = 0.66; int playerCount = 0; string cmdthing = ""; List<string[]> Votes = new List<string[]>(); List<string[]> teamVotes = new List<string[]>(); List<string[]> modeVotes = new List<string[]>(); string currentMap = "MP_Desert05"; string currentMode = "TurfwarLarge0"; string[,] Maps = new string[,] { {"Downtown", "MP_Downtown"}, {"The Block", "MP_Bloodout"}, {"Derailed", "MP_Eastside"}, {"Dust Bowl", "MP_Desert05"}, {"Bank Job", "MP_Bank"}, {"Riptide", "MP_Offshore"}, {"Hollywood Heights", "MP_Hills"}, {"Everglades", "MP_Glades"}, {"Growhouse", "MP_Growhouse"} }; string[,] Modes = new string[,] { {"Blood Money", "BloodMoney0"}, {"Hotwire", "Hotwire0"}, {"Heist", "Heist0"}, {"Crosshair", "Hit0"}, {"Rescue", "Hostage0"}, {"Team Deathmatch", "TeamDeathMatch0"}, {"Conquest Large", "TurfwarLarge0"}, {"Conquest Small", "TurfwarSmall0"}, }; string[,] MapModes = new string[,] { {"BloodMoney0", "all"}, {"Hotwire0", "MP_Downtown MP_Eastside MP_Desert05 MP_Offshore MP_Glades"}, {"Heist0", "all"}, {"Hit0", "all"}, {"Hostage0", "all"}, {"TeamDeathMatch0", "all"}, {"TurfwarLarge0", "MP_Downtown MP_Eastside MP_Desert05 MP_Offshore MP_Glades MP_Bloodout MP_Bank MP_Hills"}, {"TurfwarSmall0", "all"}, }; public VoteChange() { } public void ServerCommand(params String[] args) { List<String> list = new List<String>(); list.Add("procon.protected.send"); list.AddRange(args); this.ExecuteCommand(list.ToArray()); } bool checkMapMode(string map, string mode) { for(int i = 0; i < 7; ++i) { bool contains = MapModes[i,0].ToLower().Contains(mode.ToLower()); if(contains) { if(MapModes[i,1] == "all") return true; if (MapModes[i,1].ToLower().Contains(map.ToLower())) return true; else return false; } } return false; } bool isModeCorrect(string vote, string speaker) { bool alreadyFound = false; string mode = ""; for(int i = 0; i < 7; ++i) { bool contains = Modes[i,0].ToLower().Contains(vote); if(contains) { if(!alreadyFound) { mode = Modes[i,1]; alreadyFound = true; } else { ServerCommand("admin.say", "Found more than one mode. Please be more specific!", "player", speaker); return false; } } } if(alreadyFound) { if (checkMapMode(currentMap, mode)) { return true; } else { ServerCommand("admin.say", "Mode is not available for current map", "player", speaker); return false; } } ServerCommand("admin.say", "No modes corresponding to your vote were found", "player", speaker); return false; } bool isVoteCorrect(string vote, string speaker) { bool alreadyFound = false; for(int i = 0; i < 9; i++) { bool contains = Maps[i,0].ToLower().Contains(vote); if(contains) { if(!alreadyFound) { alreadyFound = true; } else { ServerCommand("admin.say", "Found more than one map. Please be more specific!", "player", speaker); return false; } } } if(alreadyFound) { return true; } return false; } string[] getMap(string vote) { string[] mapInfo = new string[2]; for(int i = 0; i < 9; i++) { bool contains = Maps[i,0].ToLower().Contains(vote); if(contains) { mapInfo[0] = Maps[i,0]; mapInfo[1] = Maps[i,1]; return mapInfo; } } return mapInfo; } string[] getMode(string vote) { string[] mapInfo = new string[2]; for(int i = 0; i < 7; i++) { bool contains = Modes[i,0].ToLower().Contains(vote); if(contains) { mapInfo[0] = Modes[i,0]; mapInfo[1] = Modes[i,1]; return mapInfo; } } return mapInfo; } float countVotes(string map) { float votes = 0; foreach(string[] vote in Votes) { if(vote[1] == map) { //ServerCommand("admin.say", "Vote found", "all"); votes += 1; } } return votes; } int hasVoted(string speaker) { int index = 0; foreach(string[] vote in Votes) { if(vote[0] == speaker) return index; index++; } return -1; } bool teamVoteIsCorrect(string arg1, string arg2) { if(!arg1.Equals("US", StringComparison.InvariantCultureIgnoreCase) && !arg1.Equals("CH", StringComparison.InvariantCultureIgnoreCase) && !arg1.Equals("RU", StringComparison.InvariantCultureIgnoreCase)) return false; if(!arg2.Equals("US", StringComparison.InvariantCultureIgnoreCase) && !arg2.Equals("CH", StringComparison.InvariantCultureIgnoreCase) && !arg2.Equals("RU", StringComparison.InvariantCultureIgnoreCase)) return false; return true; } int teamVoteStringToID(string team) { if(team.Equals("us", StringComparison.InvariantCultureIgnoreCase)) return 0; if(team.Equals("ru", StringComparison.InvariantCultureIgnoreCase)) return 1; if(team.Equals("ch", StringComparison.InvariantCultureIgnoreCase)) return 2; else return -1; } int countTeamVotes(string team1, string team2) { int votes = 0; foreach(string[] vote in teamVotes) { if(vote[1] == team1 && vote[2] == team2) votes++; } return votes; } int countModeVotes(string mode) { int votes = 0; foreach(string[] vote in modeVotes) { if(vote[1] == mode) votes++; } return votes; } int hasVoted_mode(string speaker) { int index = 0; foreach(string[] vote in modeVotes) { if(vote[0] == speaker) return index; index++; } return -1; } void parseMessage(string speaker, string message) { string[] arguments = message.Split(' '); if (arguments[0].Equals("!votechange", StringComparison.InvariantCultureIgnoreCase)) { string vote = ""; for(int i=1; i<arguments.Length; i++) { if(i == arguments.Length-1) vote += arguments[i].ToLower(); else vote += arguments[i].ToLower() + " "; } if (isVoteCorrect(vote, speaker)) { string[] Map = getMap(vote); int voteIndex = hasVoted(speaker); if(voteIndex == -1) { ServerCommand("admin.say", speaker + " voted for " + Map[0], "all"); string[] voteToAdd = new string[] { speaker, Map[0] }; Votes.Add(voteToAdd); } else { ServerCommand("admin.say", speaker + " changed vote to " + Map[0], "all"); Votes[voteIndex][1] = Map[0]; } float voteCount = countVotes(Map[0]); float players = (float)playerCount; double ratio = voteCount/players; if (ratio >= votePercentage) { Votes.Clear(); ServerCommand("mapList.clear"); currentMap = Map[1]; ServerCommand("admin.say", (Math.Round(votePercentage,2)*100).ToString() + "% exceeded. Changing map to " + Map[0] + " in 10 seconds", "all"); if(checkMapMode(currentMap, currentMode)) ServerCommand("mapList.add", Map[1], currentMode, "1"); else { ServerCommand("mapList.add", Map[1], "TurfwarSmall0", "1"); ServerCommand("admin.say", "Changing mode to Conquest Small"); } ServerCommand("mapList.save"); this.ExecuteCommand("procon.protected.tasks.add", "10", "1", "1", "procon.protected.send", "mapList.runNextRound"); } else ServerCommand("admin.say", Math.Round((float)(ratio*100), 2).ToString() + "% of the players have voted for " + Map[0], "all"); } else ServerCommand("admin.say", "No maps corresponding to your vote were found", "player", speaker); } else if(arguments[0].Equals("!help", StringComparison.InvariantCultureIgnoreCase)) { ServerCommand("admin.say", "!voteChange <map>", "player", speaker); ServerCommand("admin.say", "!voteMode <mode>", "player", speaker); //ServerCommand("admin.say", "!killProtection to punish your killers", "player", speaker); ServerCommand("admin.say", "Votes need " + (Math.Round(votePercentage,2)*100).ToString() + "% to pass.", "player", speaker); } else if (arguments[0].Equals("!votemode", StringComparison.InvariantCultureIgnoreCase)) { string vote = ""; for(int i=1; i<arguments.Length; i++) { if(i == arguments.Length-1) vote += arguments[i].ToLower(); else vote += arguments[i].ToLower() + " "; } if (isModeCorrect(vote, speaker)) { string[] Mode = getMode(vote); int voteIndex = hasVoted_mode(speaker); if(voteIndex == -1) { ServerCommand("admin.say", speaker + " voted for " + Mode[0], "all"); string[] voteToAdd = new string[] { speaker, Mode[0] }; modeVotes.Add(voteToAdd); } else { ServerCommand("admin.say", speaker + " changed mode vote to " + Mode[0], "all"); modeVotes[voteIndex][1] = Mode[0]; } float voteCount = countModeVotes(Mode[0]); float players = (float)playerCount; double ratio = voteCount/players; if (ratio >= votePercentage) { modeVotes.Clear(); ServerCommand("mapList.clear"); currentMode = Mode[1]; ServerCommand("admin.say", (Math.Round(votePercentage,2)*100).ToString() + "% exceeded. Changing mode to " + Mode[0] + " in 10 seconds", "all"); ServerCommand("mapList.add", currentMap, currentMode, "1"); ServerCommand("mapList.save"); this.ExecuteCommand("procon.protected.tasks.add", "10", "1", "1", "procon.protected.send", "mapList.runNextRound"); } else ServerCommand("admin.say", Math.Round((float)(ratio*100), 2).ToString() + "% of the players have voted for " + Mode[0], "all"); } } } public void LogWrite(String msg) { this.ExecuteCommand("procon.protected.pluginconsole.write", msg); } public String GetPluginName() { return "Vote Change!"; } public String GetPluginVersion() { return "1.2.0.0"; } public String GetPluginAuthor() { return "Hattiwatti"; } public String GetPluginWebsite() { return "www.BFCinematicTools.com"; } public String GetPluginDescription() { return "This plugin lets players to vote a map change. Ideal for filming servers."; } public List<CPluginVariable> GetDisplayPluginVariables() { List<CPluginVariable> lstReturn = new List<CPluginVariable>(); lstReturn.Add(new CPluginVariable("Settings|Vote percentage to win", votePercentage.GetType(), votePercentage)); lstReturn.Add(new CPluginVariable("Settings|rnd", cmdthing.GetType(), cmdthing)); return lstReturn; } public List<CPluginVariable> GetPluginVariables() { return GetDisplayPluginVariables(); } public void SetPluginVariable(String strVariable, String strValue) { if (Regex.Match(strVariable, @"Vote percentage to win").Success) { float tmp = 0.66f; float.TryParse(strValue, out tmp); votePercentage = tmp; } } public void OnPluginEnable() { ServerCommand("admin.listPlayers", "all"); this.ExecuteCommand("procon.protected.tasks.add", "1", "300", "-1", "procon.protected.send", "admin.say", "Type !help to list available commands", "all"); } public void OnPluginDisable() { } public override void OnVersion(String serverType, String version) { } public override void OnServerInfo(CServerInfo serverInfo) { } public override void OnResponseError(List<String> requestWords, String error) { } public override void OnListPlayers(List<CPlayerInfo> players, CPlayerSubset subset) { playerCount = players.Count; } public override void OnPlayerJoin(string SoldierName) { ServerCommand("admin.say", "Welcome! Type !help for available commands", "player", SoldierName); } public override void OnPlayerLeft(CPlayerInfo playerInfo) { foreach (string[] vote in Votes) { if (vote[0] == playerInfo.SoldierName) { Votes.Remove(vote); return; } } foreach (string[] vote in teamVotes) { if (vote[0] == playerInfo.SoldierName) { teamVotes.Remove(vote); return; } } } public override void OnGlobalChat(String speaker, String message) { parseMessage(speaker, message); } public override void OnTeamChat(String speaker, String message, int teamId) { parseMessage(speaker, message); } public override void OnSquadChat(String speaker, String message, int teamId, int squadId) { parseMessage(speaker, message); } public override void OnLoadingLevel(String mapFileName, int roundsPlayed, int roundsTotal) { Votes.Clear(); teamVotes.Clear(); } public override void OnLevelStarted() { } public void OnPluginLoaded(String strHostName, String strPort, String strPRoConVersion) { this.RegisterEvents(this.GetType().Name, "OnVersion", "OnServerInfo", "OnResponseError", "OnListPlayers", "OnPlayerJoin", "OnPlayerLeft", "OnPlayerKilled", "OnPlayerSpawned", "OnPlayerTeamChange", "OnGlobalChat", "OnTeamChat", "OnSquadChat", "OnRoundOverPlayers", "OnRoundOver", "OnRoundOverTeamScores", "OnLoadingLevel", "OnLevelStarted", "OnLevelLoaded"); } } } // end namespace PRoConEvents
Optional Paste Settings
Category:
None
Cryptocurrency
Cybersecurity
Fixit
Food
Gaming
Haiku
Help
History
Housing
Jokes
Legal
Money
Movies
Music
Pets
Photo
Science
Software
Source Code
Spirit
Sports
Travel
TV
Writing
Tags:
Syntax Highlighting:
None
Bash
C
C#
C++
CSS
HTML
JSON
Java
JavaScript
Lua
Markdown (PRO members only)
Objective C
PHP
Perl
Python
Ruby
Swift
4CS
6502 ACME Cross Assembler
6502 Kick Assembler
6502 TASM/64TASS
ABAP
AIMMS
ALGOL 68
APT Sources
ARM
ASM (NASM)
ASP
ActionScript
ActionScript 3
Ada
Apache Log
AppleScript
Arduino
Asymptote
AutoIt
Autohotkey
Avisynth
Awk
BASCOM AVR
BNF
BOO
Bash
Basic4GL
Batch
BibTeX
Blitz Basic
Blitz3D
BlitzMax
BrainFuck
C
C (WinAPI)
C Intermediate Language
C for Macs
C#
C++
C++ (WinAPI)
C++ (with Qt extensions)
C: Loadrunner
CAD DCL
CAD Lisp
CFDG
CMake
COBOL
CSS
Ceylon
ChaiScript
Chapel
Clojure
Clone C
Clone C++
CoffeeScript
ColdFusion
Cuesheet
D
DCL
DCPU-16
DCS
DIV
DOT
Dart
Delphi
Delphi Prism (Oxygene)
Diff
E
ECMAScript
EPC
Easytrieve
Eiffel
Email
Erlang
Euphoria
F#
FO Language
Falcon
Filemaker
Formula One
Fortran
FreeBasic
FreeSWITCH
GAMBAS
GDB
GDScript
Game Maker
Genero
Genie
GetText
Go
Godot GLSL
Groovy
GwBasic
HQ9 Plus
HTML
HTML 5
Haskell
Haxe
HicEst
IDL
INI file
INTERCAL
IO
ISPF Panel Definition
Icon
Inno Script
J
JCL
JSON
Java
Java 5
JavaScript
Julia
KSP (Kontakt Script)
KiXtart
Kotlin
LDIF
LLVM
LOL Code
LScript
Latex
Liberty BASIC
Linden Scripting
Lisp
Loco Basic
Logtalk
Lotus Formulas
Lotus Script
Lua
M68000 Assembler
MIX Assembler
MK-61/52
MPASM
MXML
MagikSF
Make
MapBasic
Markdown (PRO members only)
MatLab
Mercury
MetaPost
Modula 2
Modula 3
Motorola 68000 HiSoft Dev
MySQL
Nagios
NetRexx
Nginx
Nim
NullSoft Installer
OCaml
OCaml Brief
Oberon 2
Objeck Programming Langua
Objective C
Octave
Open Object Rexx
OpenBSD PACKET FILTER
OpenGL Shading
Openoffice BASIC
Oracle 11
Oracle 8
Oz
PARI/GP
PCRE
PHP
PHP Brief
PL/I
PL/SQL
POV-Ray
ParaSail
Pascal
Pawn
Per
Perl
Perl 6
Phix
Pic 16
Pike
Pixel Bender
PostScript
PostgreSQL
PowerBuilder
PowerShell
ProFTPd
Progress
Prolog
Properties
ProvideX
Puppet
PureBasic
PyCon
Python
Python for S60
QBasic
QML
R
RBScript
REBOL
REG
RPM Spec
Racket
Rails
Rexx
Robots
Roff Manpage
Ruby
Ruby Gnuplot
Rust
SAS
SCL
SPARK
SPARQL
SQF
SQL
SSH Config
Scala
Scheme
Scilab
SdlBasic
Smalltalk
Smarty
StandardML
StoneScript
SuperCollider
Swift
SystemVerilog
T-SQL
TCL
TeXgraph
Tera Term
TypeScript
TypoScript
UPC
Unicon
UnrealScript
Urbi
VB.NET
VBScript
VHDL
VIM
Vala
Vedit
VeriLog
Visual Pro Log
VisualBasic
VisualFoxPro
WHOIS
WhiteSpace
Winbatch
XBasic
XML
XPP
Xojo
Xorg Config
YAML
YARA
Z80 Assembler
ZXBasic
autoconf
jQuery
mIRC
newLISP
q/kdb+
thinBasic
Paste Expiration:
Never
Burn after read
10 Minutes
1 Hour
1 Day
1 Week
2 Weeks
1 Month
6 Months
1 Year
Paste Exposure:
Public
Unlisted
Private
Folder:
(members only)
Password
NEW
Enabled
Disabled
Burn after read
NEW
Paste Name / Title:
Create New Paste
Hello
Guest
Sign Up
or
Login
Sign in with Facebook
Sign in with Twitter
Sign in with Google
You are currently not logged in, this means you can not edit or delete anything you paste.
Sign Up
or
Login
Public Pastes
API Flaw Money Method ✅
CSS | 55 min ago | 1.03 KB
This month smells like moneys
CSS | 58 min ago | 1.03 KB
PRCE internal cursor
8 hours ago | 0.73 KB
AI Interaction Method
8 hours ago | 1.60 KB
awkwrapper.c
C | 9 hours ago | 2.35 KB
z66is_archive.zip.txt
15 hours ago | 39.19 KB
Clients: Setting up 2FA
1 day ago | 1.44 KB
Prevent duplicate recerrence when using [even...
1 day ago | 0.93 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the
Cookies Policy
.
OK, I Understand
Not a member of Pastebin yet?
Sign Up
, it unlocks many cool features!