Command/Feature - /infectmessage

Conor

Member
Joined
Dec 12, 2012
Messages
34
Reaction score
103
Points
18
Website
cipbot.webs.com
Hello!

My command suggestion:

/infectmessage <add> <param1>:<param2>
/infectmessage <del> <param1>:<param2>
/infectmessage list

What does it do? You can add/remove custom infect messages to the server. e.g. if you wanted to make it say 'Player1 just ate Player2's head for dinner!' when they infect them, then you can. When you get bored of it, you could remove it.

This suggestion would be recommended for admins (obvious reasons), maybe you guys could discuss and have weekly infection message additions and removals, or just add them randomly when you think of a good one. Maybe you could have sections of the forums to suggest infection messages or something too :)

I know the devs can just change the source code to include new messages, but this would save them time in the long run, and make the server a little more unique and interesting, which we would all love :)

I have made the command before, so feel free to look at / modify / use my code below. I hope it can help and I hope you may see the use in this command.


Command:
Code:
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
 
namespace BlocktopiaZombies
{
    public class CmdInfectMessage : Command
    {
        public override string name { get { return "infectmessage"; } }
        public override string shortcut { get { return "infectmsg" } }
        public override string type { get { return "mod"; } }
        public override bool museumUsable { get { return true; } }
        public override LevelPermission defaultRank { get { return LevelPermission.Admin; } }
        public CmdInfectMessage() { }
 
 
        public override void Help(Player p)
        {
            Player.SendMessage(p, "/infectmessage [add/del] [before-name-message]:[after-name-message] - Adds an infect message to the server for usage in free for all rounds.");
            Player.SendMessage(p, "/infectmessage list - list all current customised infection messages.");
            Player.SendMessage(p, "- For an example, type /infectmessage example.");
        }
 
 
        public override void Use(Player p, string message)
        {
            if (message.Trim().ToLower() == "example")
            {
                Player.SendMessage(p, "/infectmessage add just gave : an undead sandwhich!");
                Player.SendMessage(p, "After using the command, it would appear like this in game:");
                Player.SendMessage(p, "When personA infects personB:");
                Player.SendMessage(p, "personA just gave personB an undead sandwhich!");
                Player.SendMessage(p, "If you wanted to delete this infection message in the future, you could type:");
                Player.SendMessage(p, "/infectmessage del just gave : an undead sandwhich!");
            }
           else if (message.Trim().ToLower() == "list")
           {
                foreach (string line in File.ReadAllLines("FolderX/infectmsgs.txt"))
                {
                     bool anyThere = false;
                     if (line.Trim() != "" && line.Trim().IndexOf("#") != 0)
                     { 
                        anyThere = true;
                        try
                        {
                             Player.SendMessage(p, "'" + line.Trim() + "'"); // Could be modified to be prettier
                        }
                        catch { }
                     }
                     if (!anyThere) 
                     {
                          Player.SendMessage(p, "No custom infection messages found."); 
                     } 
                } 
            }
            else
            {
                if (message.Trim() == "" || !message.Trim().Contains(" ")) { Player.SendMessage(p, "3"); Help(p); return; }
                if (message.Split(' ')[0].ToLower() != "add" && message.Split(' ')[0].ToLower() != "del") { Player.SendMessage(p, "1"); Help(p); return; }
                string[] split = message.Split(new char[] { ' ' }, 2);
                string check = split[1];
 
                if (check.IndexOf(":") == -1) { Player.SendMessage(p, "2"); Help(p); return; }
 
                string msg1 = check.Substring(0, check.IndexOf(":"));
                string msg2 = " ";
                try
                {
                    msg2 = check.Substring(check.IndexOf(":") + 1);
                }
                catch { msg2 = " "; }
 
                try
                {
                    if (split[0].ToLower() == "add")
                    {
                        File.AppendAllText("FolderX/infectmsgs.txt", Environment.NewLine + msg1 + ":" + msg2);
                        Player.SendMessage(p, "Infection message succesfully added. It will be active next round.");
                    }
                    else
                    {
                        bool anyFound = false;
                        List<string> toPaste = new List<string>();
                        foreach (string line in File.ReadAllLines("FolderX/infectmsgs.txt"))
                        {
                            if (line.ToLower() != (msg1 + ":" + msg2).ToLower())
                            {
                                toPaste.Add(line);
                            }
                            else { anyFound = true; }
                        }
 
                        if (!anyFound)
                        {
                            Player.SendMessage(p, "Infection message could not be found to be deleted. Are you sure you formatted the command 100% correctly? Remember that whitespaces are included in the infection message.");
                        }
                        else
                        {
                            File.WriteAllLines("FolderX/infectmsgs.txt", toPaste.ToArray());
                            Player.SendMessage(p, "The infection message was succesfully deleted."); 
                        }
                    }
                }
                catch { Player.SendMessage(p, "An error occured when saving the infection message."); }
            }
        }
    }
}

During map interval & Server start-up
Code:
        public static void AddInfectedMessages()
        {
            if (!File.Exists("FolderX/infectmsgs.txt")) { return; }
            foreach (string line in File.ReadAllLines("FolderX/infectmsgs.txt"))
            {
                if (line.Trim() != "" && line.Trim().IndexOf("#") != 0)
                {
                    if (line.Contains(":"))
                    {
                        bool add = true;
                        string s1 = "ate", s2 = "'s brain"; // just incase something derps... but it won't.
                        try
                        {
                            s1 = " " + line.Split(':')[0].TrimStart();
                            s2 = line.Split(':')[1];
                        }
                        catch { add = false; }
 
                        if (add)
                        {
                            if (!infectMessages.Contains(s1))
                            {
                                infectMessages.Add(s1);
                            }
                            if (!infectMessages2.Contains(s2))
                            {
                                infectMessages2.Add(s2);
                            }
                        }
                    }
                }
            }
        }
infectMessages and infectMessages2 are the names of the infection message lists. Providing you have the same mechanism as an old MCForge zombie survival game did, then it should stay as it is. Otherwise you may need to modify it slightly. In case you don't use the traditional way, this is what the code looks like (so you can see what is happening with the messages):
Code:
// player1 just infected player2:
 
Random r = new Random();
int msg = r.Next(0, infectMessages.Count);
 
if (infectMessages2[msg].Trim() == "")
{
    Player.GlobalMessage(c.red + player1.name + c.yellow + infectMessages[msg] + c.red + player2.name);
 }
else if (infectMessages[msg].Trim() == "")
{
    Player.GlobalMessage(c.red + player2.name + c.yellow + infectMessages2[msg]);
}
else
{
     Player.GlobalMessage(c.red + player1.name + c.yellow + infectMessages[msg] + c.red + player2.name + c.yellow + infectMessages2[msg]);
}
Lastly, for anybody confused about how you actually use the command, this is how it works. (Read the text in the code):
Player.SendMessage(p, "/infectmessage add just gave : an undead sandwhich!");
Player.SendMessage(p, "After using the command, it would appear like this in game:");
Player.SendMessage(p, "When personA infects personB:");
Player.SendMessage(p, "personA just gave personB an undead sandwhich!");
Player.SendMessage(p, "If you wanted to delete this infection message in the future, you could type:");
Player.SendMessage(p, "/infectmessage del just gave : an undead sandwhich!");
Thank you.
 

Damer_Flinn

Resident Asha'man
Joined
Aug 6, 2011
Messages
888
Reaction score
975
Points
243
Though this is a nice idea, it's not really needed. The infect messages are stored on a text file, not coded directly into the server. So when we want to change them out it's as simple as logging on to the VPS and changing out the .txt file.

On that note though, please feel free to post some new infection messages here.

$zombie &7turned $human &7to the dark side!
$zombie &7hugged $human
$zombie &7infected $human
$zombie &7zombified $human
$zombie &7chomped $human
$zombie &7zombified $human
$zombie &7caught $human
$zombie &7munched $human
$zombie &7chewed $human
$zombie &7nommed $human
$zombie &7ate $human
$zombie &7feasted upon $human
$zombie &7gnawed $human
$zombie &7undeadified $human
$zombie &7bit $human
$zombie &7changed $human
$zombie &7hunted $human
$zombie &7converted $human
$zombie &7cuddled $human
$zombie &7made sweet undead love to $human
$zombie &7touched $human
$zombie &7took a chunk out of $human
$zombie &7gnawed $human
$zombie &7YABBA MY ICING'd $human
$zombie &7licked $human
$zombie &7did something naughty to $human
$zombie &7headbutted $human
$zombie &7got lucky with $human
$zombie &7slow roasted a nice fresh $human
$zombie &7JUST BIT HIM, OH GOD HE BIT $human
$zombie &7and $human &7played hide the snake
$zombie &7ate $human &7and you're next!
$human &7and $zombie &7sitting in a tree
$zombie &7got red on $human
$zombie &7mutated $human
$human &7was annihilated by $zombie
$human &7was k'splatted by $zombie
$zombie &7showed $human &7why not to poke the zombie
$human &7bit $zombie, &7why would they do that?
$human &7was gobbled by $zombie
$zombie &7oooh la la'd $human
$zombie &7introduced $human &7to the party
$human &7couldn't outrun $zombie
$zombie &7made a $human &7pie
$zombie &7danubed into $human
$zombie &7couldn't danube harder against $human
$zombie &7murdered $human
$zombie &7made sweet, tender love to $human
$zombie &7terminated $human
$human &7was blown away by $zombie
$zombie &7brutally murdered $human
$zombie &7stole $human&7's brain
$zombie &7broke $human
$zombie &7ended $human&f.exe
$zombie &7ruined $human
$zombie &7sucked on $human&f's &7brain
$zombie &7pounced on $human
$zombie &7inhaled $human
$zombie &7fed &abath salts&7 to $human
$zombie &7consumed $human
$zombie &7snacked on $human
$zombie &7scarfed $human
$zombie &7ingested $human
$zombie &7dined on the brains of $human
$zombie &7wolfed down $human
$zombie &7feasted on $human
$zombie &7pigged out on $human
$zombie &7fed upon $human
$zombie &7swallowed $human
$zombie &7ate $human
$zombie &7touched $human &6FANCY KILL!
 

Mccuish

The Canadian Nightmare
Contributor
Joined
Aug 6, 2011
Messages
977
Reaction score
854
Points
93
$zombie has infected $player with the T virus
$zombie turned $player's brain into food
$zombie had a $player buffet

all i could think of at the moment but i'll think of more later