Release Imposter Plugin
#1
I present to you the awful and possibly badly coded Imposter Plugin as requested by @pollarpart. Hahaha, I'm kidding. :p What it basically does is stops anyone from joining the game if their name is in the database and their XUIDs don't match hence the 'imposter' term used.

Source:
Code:
using System; using System.Collections.Generic; using System.Text; using Addon; namespace ImposterPlugin { public class ImposterPlugin : CPlugin { Dictionary<string, string> _realPlayers = new Dictionary<string, string>(); #region Permission/Setting Functions string CheckSetting(string key, string value) { if (string.IsNullOrEmpty(GetServerCFG("ImposterPlugin", key, ""))) { SetServerCFG("ImposterPlugin", key, value); return value; } return GetServerCFG("ImposterPlugin", key, ""); } List<string> GetCommandsAllowedInGroup(string groupname) { List<string> group = new List<string>(); string group_string = GetServerCFG("Permission", groupname + "_commands", " "); if (group_string != " ") foreach (string cmd in group_string.Split(',')) group.Add(cmd); return group; } List<string> GetUsersInGroup(string groupname) { List<string> group = new List<string>(); string group_string = GetServerCFG("Permission", groupname + "_xuids", " "); if (group_string != " ") foreach (string xuid in group_string.Split(',')) group.Add(xuid); return group; } bool CommandAllowedForPlayer(string XUID, string command) { foreach (string usergroup in GetServerCFG("Permission", "Usergroups", "").Split(',')) if ((GetCommandsAllowedInGroup(usergroup).Contains(command) || GetCommandsAllowedInGroup(usergroup).Contains("*ALL*")) && GetUsersInGroup(usergroup).Contains(XUID)) return true; return false; } #endregion public override void OnServerLoad() { if (!string.IsNullOrEmpty(CheckSetting("RealList", string.Empty))) foreach (var pair in CheckSetting("RealList", string.Empty).Split(',')) _realPlayers.Add(pair.Split(';')[0], pair.Split(';')[1]); ServerPrint("Imposter Plugin v1 has been loaded!"); } public override void OnPlayerConnect(ServerClient Client) { if (_realPlayers.ContainsKey(Client.Name) && _realPlayers[Client.Name] != Client.XUID) ServerCommand(string.Format("kickclient {0} \"Imposter detected!", Client.ClientNum)); } public override ChatType OnSay(string Message, ServerClient Client) { if (Message.StartsWith("!setreal") && CommandAllowedForPlayer(Client.XUID, "!setreal")) { string[] parts = Message.Split(' '); // Accept 1 or 2 parameters (including the !setreal itself) if(parts.Length == 2 || parts.Length == 3) { foreach(ServerClient client in GetClients()) { if(client.Name == parts[1]) { // Take the XUID from the 2nd parameter if possible, otherwise just // grab the XUID from the current player in game with the matching name. string xuid = parts.Length == 3 ? parts[2] : client.XUID; if (_realPlayers.ContainsKey(parts[1])) _realPlayers[parts[1]] = xuid; else _realPlayers.Add(parts[1], xuid); string newSetting = string.Empty; foreach(var kvp in _realPlayers) { if(!string.IsNullOrEmpty(newSetting)) newSetting += ','; newSetting += kvp.Key + ";" + kvp.Value; } // Update settings. SetServerCFG("ImposterPlugin", "RealList", newSetting); return ChatType.ChatNone; } } TellClient(Client.ClientNum, string.Format("Could not find ^3{0} ^7in the game!", parts[1]), true); } } return ChatType.ChatContinue; } } }

Usage:
!setreal <player name> - Set's the player in the current game as the 'real' person.
!setreal <player name> <xuid> - Adds the player and xuid to the list, the player doesn't have to be in the server.

Requirements:
Permissions Plugin by Pozzuh

Make sure to add the !setreal command to the allowed commands.


Attached Files
.zip   ImposterPlugin.zip (Size: 3.1 KB / Downloads: 82)
[Image: 30xhrep.png]

A casual conversation between barata and I about Nukem.
Reply

#2
Nice, thanks!
Reply

#3
i was about to code this , but @master131 did it Tongue
nice work.

*----Off Topic----*
How Fast! Big Grin
Reply

#4
Thank you! Big Grin
Reply

#5
I just realised I screwed up the kick message Dodgy I think it should still work though.

EDIT - Yeah, still works.
[Image: 30xhrep.png]

A casual conversation between barata and I about Nukem.
Reply



Possibly Related Threads…
Thread Author Replies Views Last Post
Rainbow [Release] Plugin ReservedSlot v1.3 frst_ 1 5,018 11-08-2018, 19:17
Last Post: frst_
Tongue [Release] MW3 Shop plugin Dude 56 51,452 03-25-2018, 05:18
Last Post: [email protected]
  [Release] Permission plugin Pozzuh 202 164,556 05-01-2017, 15:41
Last Post: W4R||The Hyper
  [Release] FIXED SPEED PLUGIN hillbilly 2 5,672 06-02-2016, 20:23
Last Post: clacki
  [Release] Bots Plugin For Users Casper 22 39,938 08-22-2015, 17:45
Last Post: SnapBacks
  [Release] God Plugin v5.0 [Ingame Rcon Tool] OzonE 464 337,385 06-27-2015, 15:38
Last Post: bluedot
  [Release] Anti Hardscope Plugin 8q4s8 26 27,712 06-20-2015, 22:44
Last Post: urj88419
  [Release] ProMod Plugin zxz0O0 875 763,945 03-25-2015, 22:02
Last Post: kris
  [Release] [Discontinued] Speed Plugin Pozzuh 164 122,576 10-06-2014, 12:56
Last Post: Nekochan
  [help]how create a ping plugin clacki 3 5,111 09-13-2014, 01:23
Last Post: clacki

Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum Powered By MyBB, Theme by © 2002-2026 Melroy van den Berg.