/clan

/clan

Postby dryfly21 » 06 Jun 2013, 19:42

i would like a cmd /clan i cant seem to make it myself sense its a little more complicated then i can handle
i can grasp the idea and understand what it should do and how it should work but nonetheless i cant get it XD
this is mostly for zombie games so that you can have people join a clan and those that are living can work together and chat without the zombie hearings. if one of them turns to a zombie then they can no longer be in the /clan chat and cant see their msg's. i would also like to put a cap on the amount of clans say five. i dont know if the whole thing can be done i just know parts can but if you do get this done that would be great! thanks! :D

Code: Select all
      Player.SendMessage(p, "/clan new <name> - makes a clan <name>");
      Player.SendMessage(p, "/clans - shows clans");
      Player.SendMessage(p, "/clan who <name> - displays members of a clan");
      Player.SendMessage(p, "/clan chat - chat in your clan");
      Player.SendMessage(p, "/clan join <name> - joins a clan");
      Player.SendMessage(p, "/clan remove <name> - Op+ can remove player from clan");
      Player.SendMessage(p, "/clan del <name> - Op+ can remove a clan");
      Player.SendMessage(p, "/clan leave - leaves a clan");
dryfly21
 
Posts: 135
Joined: 07 Apr 2012, 03:27

Re: /clan

Postby Conor » 06 Jun 2013, 19:54

dryfly21 wrote:i would like a cmd /clan i cant seem to make it myself sense its a little more complicated then i can handle
i can grasp the idea and understand what it should do and how it should work but nonetheless i cant get it XD
this is mostly for zombie games so that you can have people join a clan and those that are living can work together and chat without the zombie hearings. if one of them turns to a zombie then they can no longer be in the /clan chat and cant see their msg's. i would also like to put a cap on the amount of clans say five. i dont know if the whole thing can be done i just know parts can but if you do get this done that would be great! thanks! :D

Code: Select all
      Player.SendMessage(p, "/clan new <name> - makes a clan <name>");
      Player.SendMessage(p, "/clans - shows clans");
      Player.SendMessage(p, "/clan who <name> - displays members of a clan");
      Player.SendMessage(p, "/clan chat - chat in your clan");
      Player.SendMessage(p, "/clan join <name> - joins a clan");
      Player.SendMessage(p, "/clan remove <name> - Op+ can remove player from clan");
      Player.SendMessage(p, "/clan del <name> - Op+ can remove a clan");
      Player.SendMessage(p, "/clan leave - leaves a clan");


If Ismellike doesn't code it for you then I might code it for you at a future point in time as I'm busy with exams at the moment, and this command would take a bit of time. Although Ismellike may help you out in the meantime, or any other coders who want to give it a go.
Conor (Conanza121)
User avatar
Conor
Coder
 
Posts: 390
Joined: 10 Oct 2012, 21:36
Location: @21Conor

Re: /clan

Postby ismellike » 06 Jun 2013, 19:55

I have a pretty lengthy command that has all of these suggestions, do you want it to deduct money on creation/join?
except for like /clan del and /clan who
What a beast...
User avatar
ismellike
Coder
 
Posts: 731
Joined: 31 Oct 2012, 04:04
Location: Kansas

Re: /clan

Postby dryfly21 » 06 Jun 2013, 20:00

ismellike wrote:I have a pretty lengthy command that has all of these suggestions, do you want it to deduct money on creation/join?
except for like /clan del and /clan who

hmm that is interesting do it :D and thanks! :D
dryfly21
 
Posts: 135
Joined: 07 Apr 2012, 03:27

Re: /clan

Postby ismellike » 06 Jun 2013, 20:17

I haven't use this too much so please tell me what you want me to change

Code: Select all
using System.IO;
using System;
using System.Data;
using System.Collections.Generic;

namespace MCDzienny
{
    public class CmdClan : Command
    {
        public bool kick = false;
        List<Player> sure = new List<Player>();
        public override string name { get { return "clan"; } }
        public override string shortcut { get { return ""; } }
        public override string type { get { return "other"; } }
        public override bool museumUsable { get { return false; } }
        public override LevelPermission defaultRank { get { return LevelPermission.Guest; } }
        public CmdClan() { }
        public override void Init()
        {
            if (!Directory.Exists("clans"))
            {
                Directory.CreateDirectory("clans");
            }
            if (!File.Exists("clans/clanlist.txt"))
            {
                File.Create("clans/clanlist.txt");
            }
            if (!File.Exists("clans/playerinfo.txt"))
            {
                File.WriteAllText("clans/playerinfo.txt", "This is the info for the clans of each player; The format is player : clan name");
            }
            Player.Joined += new EventHandler<PlayerEventArgs>(Player_Joined);
        }
        public void Player_Joined(object sender, PlayerEventArgs e)
        {
            e.Player.ExtraData.Add("clan", "");
            try
            {
                if (e.Player.ExtraData["clan"] == "")
                {
                    string line;
                    using (var sr = new StreamReader("clans/playerinfo.txt"))
                    {
                        while (!(line = sr.ReadLine()).Contains(e.Player.name))
                        {
                            sr.ReadLine();
                        }
                    }
                    e.Player.ExtraData["clan"] = line.Split(':')[1];
                }
            }
            catch
            {
            }
        }
        public override void Use(Player p, string message)
        {
            string[] split = message.Trim().Split(' ');
            try
            {
                if (p.ExtraData["clan"] == "")
                {
                    string line;
                    using (var sr = new StreamReader("clans/playerinfo.txt"))
                    {
                        while (!(line = sr.ReadLine()).Contains(p.PublicName))
                        {
                            sr.ReadLine();
                        }
                    }
                    p.ExtraData["clan"] = line.Split(':')[1];
                }
            }
            catch
            {
            }
            switch (split[0])
            {
                case "info":
                    if (p.ExtraData["clan"] != "")
                    {
                        Player.SendMessage(p, "Your clan is " + p.ExtraData["clan"]);
                    }
                    else
                    {
                        Player.SendMessage(p, "You are not in a clan.");
                    }
                    return;
                case "join":
                    string which;
                    try
                    {
                        which = split[1];
                    }
                    catch
                    {
                        Player.SendMessage(p, "Please specify which clan you want to join.");
                        return;
                    }
                    if ((string)p.ExtraData["clan"] != "")
                    {
                        Player.SendMessage(p, "You are already in a clan!");
                    }
                    else if (!Directory.Exists("clans/" + split[1]))
                    {
                        Player.SendMessage(p, "The clan " + split[1] + " does not exist");
                    }
                    else if (p.money < 25)
                    {
                        Player.SendMessage(p, "You dont have enough money to join a clan.");
                    }
                    else
                    {
                        p.money -= 25;
                        Player.SendMessage(p, "-25");
                        File.AppendAllText("clans/playerinfo.txt", Environment.NewLine + p.PublicName + ":" + which);
                        Command.all.Find("settitle").Use(null, p.PublicName + " " + which);
                        Player.GlobalMessage(p.PublicName + " has joined the clan " + which + "!");
                    }
                    return;
                case "members":
                    string person;
                    try
                    {
                        string text;
                        using (var sr = new StreamReader("clans/clanlist.txt"))
                        {
                            text = sr.ReadToEnd();
                        }
                        if (text.Contains(message.Split(' ')[1]))
                        {
                            Player.SendMessage(p, "Members of " + p.ExtraData["clan"] + " %c---");
                            using (var sr = new StreamReader("clans/playerinfo.txt"))
                            {
                                while ((person = sr.ReadLine()) != null)
                                {
                                    if (person.Split(':')[1] == (string)p.ExtraData["clan"])
                                    {
                                        Player.SendMessage(p, person.Split(':')[0]);
                                    }
                                }
                            }
                        }
                        else
                        {
                            Player.SendMessage(p, message.Split(' ')[1] + " is not a valid clan.");
                        }
                    }
                    catch
                    {
                        Player.SendMessage(p, "Members of " + p.ExtraData["clan"] + " %c---");
                        using (var sr = new StreamReader("clans/playerinfo.txt"))
                        {
                            while ((person = sr.ReadLine()) != null)
                            {
                                if (person.Split(':')[1] == (string)p.ExtraData["clan"])
                                {
                                    Player.SendMessage(p, person.Split(':')[0]);
                                }
                            }
                        }
                    }
                    Player.SendMessage(p, "%c-------");
                    return;
                case "list":
                    Player.SendMessage(p, "%a-------");
                    foreach (string line in File.ReadAllLines("clans/clanlist.txt"))
                    {
                        Player.SendMessage(p, line);
                    }
                    Player.SendMessage(p, "%a-------");
                    return;
                case "leave":
                    if ((string)p.ExtraData["clan"] == "")
                    {
                        Player.SendMessage(p, "You are not in a clan.");
                    }
                    else
                    {
                        if (kick == false)
                        {
                            Player.GlobalMessage(p.PublicName + " has just left the clan " + p.ExtraData["clan"] + "!");
                        }
                        else
                        {
                            Player.GlobalMessage(p.PublicName + " was kicked out of his clan.");
                            kick = false;
                        }
                        using (var sw = new StreamWriter("clans/temp.txt"))
                        {
                            foreach (string line in File.ReadAllLines("clans/playerinfo.txt"))
                            {
                                if (!line.Contains(p.PublicName))
                                {
                                    sw.WriteLine(line);
                                }
                            }
                        }
                        File.Delete("clans/playerinfo.txt");
                        File.Move("clans/temp.txt", "clans/playerinfo.txt");
                        Command.all.Find("settitle").Use(null, p.PublicName);
                        p.ExtraData["clan"] = "";
                    }
                    return;
                case "create":
                    string clan;
                    try
                    {
                        clan = split[1];
                    }
                    catch
                    {
                        Player.SendMessage(p, "Please specify the name of your clan.");
                        return;
                    }
                    if (Directory.Exists("clans/" + clan))
                    {
                        Player.SendMessage(p, clan + " is already a clan.");
                    }
                    else if ((string)p.ExtraData["clan"] != "")
                    {
                        Player.SendMessage(p, "You are currently in a clan, please leave it first.");
                    }
                    else if (p.money < 200)
                    {
                        Player.SendMessage(p, "You do not have enough money to make a clan.");
                    }
                    else
                    {
                        p.money -= 200;
                        Player.SendMessage(p, "-200");
                        Player.GlobalMessage("The clan " + clan + " has just been created!");
                        p.ExtraData["clan"] = clan;
                        Command.all.Find("settitle").Use(null, p.PublicName + " " + clan);
                        Directory.CreateDirectory("clans/" + clan);
                        File.WriteAllText("clans/" + clan + "/spawn.txt", "63 63 63");
                        File.AppendAllText("clans/playerinfo.txt", Environment.NewLine + p.PublicName + ":" + clan + ":owner");
                        File.AppendAllText("clans/clanlist.txt", Environment.NewLine + clan);
                    }
                    return;
                case "home":
                    if ((string)p.ExtraData["clan"] == "")
                    {
                        Player.SendMessage(p, "You are not even in a clan!");
                    }
                    else
                    {
                        string level = (string)p.ExtraData["clan"];
                        if (!File.Exists("levels/" + level + ".lvl"))
                        {

                            Command.all.Find("newlvl").Use(null, level + " 128 64 128 flat");
                            Level.Load(level, true);
                            Command.all.Find("goto").Use(p, level);
                            while (p.mapLoading) { }
                            for (int z = -1; z <= 1; ++z)
                                for (int y = -1; y <= 1; ++y)
                                    for (int x = -1; x <= 1; ++x)
                                    {
                                        p.level.Blockchange((ushort)(1 + x), (ushort)(2 + y), (ushort)(1 + z), Block.op_air, true, "");
                                    }
                            p.level.spawnx = 0; p.level.spawny = 1; p.level.spawnz = 0;
                            Group oldgroup = p.group;
                            p.group = Group.findPerm(LevelPermission.Admin);
                            Command.all.Find("replace").Use(p, "dirt adminium");
                            Command.all.Find("click").Use(p, "0 4 3");
                            Command.all.Find("click").Use(p, "3 0 0");
                            p.group = oldgroup;
                        }
                        else
                        {
                            if (Level.IsLevelLoaded(level) == false)
                            {
                                Level.Load(level, true);
                            }
                            if (p.level.name != level)
                            {
                                Command.all.Find("goto").Use(p, level);
                            }
                            while (p.mapLoading == true) { }
                            foreach (string line in File.ReadAllLines("clans/" + level + "/spawn.txt"))
                            {
                                Group pgroup = p.group;
                                p.group = Group.findPerm(LevelPermission.Admin);
                                Command.all.Find("move").Use(p, p.PublicName + " " + line);
                                p.group = pgroup;
                            }
                        }
                    }

                    return;
                case "spawn":
                    if (p.level.name == (string)p.ExtraData["clan"])
                    {
                        using (var sw = new StreamWriter("clans/" + p.level.name + "/spawn.txt"))
                        {
                            sw.WriteLine((p.pos[0] / 32) + " " + (p.pos[1] / 32 - 1) + " " + (p.pos[2] / 32));
                        }
                        Player.SendMessage(p, "Spawn changed.");
                    }
                    return;
                case "kick":
                    Player who = null;
                    try
                    {
                        who = Player.Find(split[1]);
                    }
                    catch
                    {
                        Player.SendMessage(p, "Please specify who to remove.");
                    }
                    if (who == null)
                    {
                        Player.SendMessage(p, split[1] + " is not online right now.");
                        return;
                    }
                    string realowner = "notch";
                    foreach (string line in File.ReadAllLines("clans/playerinfo.txt"))
                    {
                        if (line == p.PublicName + ":" + who.ExtraData["clan"] + ":owner")
                        {
                            realowner = p.PublicName;
                            break;
                        }
                    }
                    if (p.PublicName != realowner)
                    {
                        Player.SendMessage(p, "You are not the owner of the clan, " + (string)who.ExtraData["clan"]);
                    }
                    else
                    {
                        kick = true;
                        Command.all.Find("clan").Use(who, "leave");
                    }
                    return;
                case "chat":
                    Player.players.ForEach(pl =>
                    {
                        if (pl.ExtraData.ContainsKey("clan"))
                        {
                            if ((string)pl.ExtraData["clan"] == (string)p.ExtraData["clan"])
                            {
                                Player.SendMessage(pl, message.Replace("chat", "%0[%aClan%0] " + p.color + p.PublicName + ":%e"));
                            }
                        }
                    });
                    return;
                case "del":
                    string clanowner = "notch";
                    foreach (string line in File.ReadAllLines("clans/playerinfo.txt"))
                    {
                        if (line == p.PublicName + ":" + p.ExtraData["clan"] + ":owner")
                        {
                            clanowner = p.PublicName;
                            break;
                        }
                    }
                    if (clanowner == p.PublicName && !sure.Contains(p))
                    {
                        Player.SendMessage(p, "Are you absolutely sure you want to delete your clan?");
                        Player.SendMessage(p, "Do /m to proceed.");
                        sure.Add(p);
                    }
                    else if (clanowner == p.PublicName && sure.Contains(p))
                    {
                        Player.GlobalMessage(p.ExtraData["clan"] + " has been removed.");
                        using (var sr = new StreamReader("clans/clanlist.txt"))
                        using (var sw = new StreamWriter("clans/clanlist1.txt"))
                        {
                            string line;
                            while ((line = sr.ReadLine()) != null)
                            {
                                if (!line.Contains((string)p.ExtraData["clan"]))
                                {
                                    sw.WriteLine();
                                }
                            }
                        }
                        File.Delete("clans/clanlist.txt");
                        File.Move("clans/clanlist1.txt", "clans/clanlist.txt");
                        Directory.Delete("clans/" + p.ExtraData["clan"]);
                        p.ExtraData["clan"] = "";
                    }
                    else
                    {
                        Player.SendMessage(p, "You are not the owner of " + p.ExtraData["clan"]);
                    }
                    return;
            }
        }
        public override void Help(Player p)
        {
            Player.SendMessage(p, "/clan home -- sends you to home sweet home");
            Player.SendMessage(p, "/clan spawn -- sets your clan home's spawn");
            Player.SendMessage(p, "/clan chat <message> -- chat to your clan");
            Player.SendMessage(p, "/clan list/info -- see clan info");
            Player.SendMessage(p, "/clan kick -- kick someone from your clan");
            Player.SendMessage(p, "/clan del -- delete your clan");
            Player.SendMessage(p, "/clan leave -- leave your clan");
            Player.SendMessage(p, "/clan join/leave -- leave/join a clan");
        }
    }
}
What a beast...
User avatar
ismellike
Coder
 
Posts: 731
Joined: 31 Oct 2012, 04:04
Location: Kansas

Re: /clan

Postby dryfly21 » 06 Jun 2013, 20:22

oosome :D ima try it out thank you :D
dryfly21
 
Posts: 135
Joined: 07 Apr 2012, 03:27

Re: /clan

Postby dryfly21 » 06 Jun 2013, 20:29

there's no way to make a clan since there is no /clan new <name>
dryfly21
 
Posts: 135
Joined: 07 Apr 2012, 03:27

Re: /clan

Postby ismellike » 06 Jun 2013, 20:31

The only way to create a clan is to do /clan create ;)
What a beast...
User avatar
ismellike
Coder
 
Posts: 731
Joined: 31 Oct 2012, 04:04
Location: Kansas

Re: /clan

Postby dryfly21 » 06 Jun 2013, 20:36

very nice! i love it :D
dryfly21
 
Posts: 135
Joined: 07 Apr 2012, 03:27


Return to Requests for Addon

Who is online

Users browsing this forum: No registered users and 4 guests

cron