Exemple #1
0
 public static void CMDtcsay(CommandArgs args)
 {
     if (TCutils.AlreadyInClan(args.Player.UserAccountName))
     {
         //tcsay <msg>
         string msg = "";
         if (args.Parameters.Count > 0)
         {
             for (int i = 0; i < args.Parameters.Count; i++)
             {
                 msg = msg + " " + args.Parameters[i];
             }
             TCutils.ClanMsg(args.Player.UserAccountName, msg, 0, false);
         }
         else
         {
             args.Player.SendMessage("TerraClans.", Color.Red);
             args.Player.SendMessage("/tcsay <message>; /c <message> - sends message to your clan chat.", Color.Red);
         }
     }
     else
     {
         args.Player.SendMessage("You are not in clan!", Color.Red);
     }
 }
Exemple #2
0
        public static void TCAccept(CommandArgs incArgs)
        {
            var    plr       = incArgs.Player;
            string clanName  = "";
            string clanGroup = "";
            bool   isInvited = false;
            var    DBQuery   = TCdb.DB.QueryReader("SELECT clanname, clangroup, invites FROM Clans WHERE invites LIKE '%" + plr.UserAccountName + "%'");

            while (DBQuery.Read())
            {
                string[] arr = DBQuery.Get <string>("invites").ToString().Split(',');
                foreach (string i in arr)
                {
                    if (i == plr.UserAccountName)
                    {
                        clanName  = DBQuery.Get <string>("clanname").ToString();
                        clanGroup = DBQuery.Get <string>("clangroup").ToString();
                        isInvited = true;
                    }
                }
            }
            if (isInvited)
            {
                string        strInv  = "";
                string        strMem  = "";
                List <string> invites = new List <string>();
                invites = TCutils.GetInvites(clanName);
                invites.Remove(plr.UserAccountName);
                if (invites.Count > 0)
                {
                    strInv = string.Join(",", invites.ToArray());
                }
                List <string> members = new List <string>();
                members = TCutils.GetMembers(clanName);
                members.Add(plr.UserAccountName);
                if (members.Count > 0)
                {
                    strMem = string.Join(",", members.ToArray());
                }
                TCdb.DB.QueryReader("UPDATE Clans SET invites='" + strInv + "', members='" + strMem + "' WHERE clanname='" + clanName + "'");
                var user = new User();
                user.Name = plr.UserAccountName;
                if (!plr.Group.HasPermission("terraclans"))
                {
                    TShock.Users.SetUserGroup(user, clanGroup);
                }
                plr.SendMessage("You have joined to " + clanName, Color.Orange);
                plr.SendMessage("Please, relogin to apply new settings for your account.", Color.Orange);
                string msg = incArgs.Player.Name + " has joined the clan.";
                TCutils.ClanMsg(incArgs.Player.UserAccountName, msg, 1, true);
            }
            else
            {
                plr.SendMessage("You are not invited to any clan!", Color.Red);
            }
        }
Exemple #3
0
        public static void TCQuit(CommandArgs incArgs)
        {
            if (!incArgs.Player.IsLoggedIn)
            {
                incArgs.Player.SendMessage("You are not not logged in!", Color.Red);
                return;
            }
            if (!TCutils.AlreadyInClan(incArgs.Player.UserAccountName))
            {
                incArgs.Player.SendMessage("You are not in clan!", Color.Red);
                return;
            }
            if (TCutils.IsLeader(incArgs.Player.UserAccountName))
            {
                incArgs.Player.SendMessage("Leaders can't leave the clan!", Color.Red);
                return;
            }
            List <string> clName     = TCutils.GetClanByMember(incArgs.Player.UserAccountName);
            List <string> clMembers  = new List <string>();
            string        rawMembers = "";
            var           DBQuery    = TCdb.DB.QueryReader("SELECT members FROM Clans WHERE clanname='" + clName[0] + "'");

            while (DBQuery.Read())
            {
                string[] arr = DBQuery.Get <string>("members").Split(',');
                foreach (string i in arr)
                {
                    clMembers.Add(i);
                }
            }
            for (int c = 0; c < clMembers.Count; c++)
            {
                if (incArgs.Player.UserAccountName == clMembers[c])
                {
                    clMembers.RemoveAt(c);
                    break;
                }
            }
            if (clMembers.Count > 0)
            {
                rawMembers = string.Join(",", clMembers.ToArray());
            }
            TCutils.ClanMsg(incArgs.Player.UserAccountName, incArgs.Player.Name + " has left the clan!", 1, true);
            TCdb.DB.QueryReader("UPDATE Clans SET members='" + rawMembers + "' WHERE clanname='" + clName[0] + "'");
            var user = new User();

            user.Name = incArgs.Player.UserAccountName;
            if (!incArgs.Player.Group.HasPermission("terraclans"))
            {
                TShock.Users.SetUserGroup(user, TShock.Config.DefaultRegistrationGroupName);
            }
            incArgs.Player.SendMessage("You have left the clan!", Color.Yellow);
        }
Exemple #4
0
        public static void TCFoundRevoke(CommandArgs incArgs)
        {
            string clName      = "";
            string clFounder   = "";
            string clCoFounder = "";
            var    DBQuery     = TCdb.DB.QueryReader("SELECT * FROM FoundQueue WHERE founder='" + incArgs.Player.UserAccountName + "'");

            while (DBQuery.Read())
            {
                clName      = DBQuery.Get <string>("clanname");
                clFounder   = DBQuery.Get <string>("founder");
                clCoFounder = DBQuery.Get <string>("cofounder");
            }

            if (!incArgs.Player.IsLoggedIn)
            {
                incArgs.Player.SendMessage("You are not logged in!", Color.Red);
                return;
            }
            if (TCutils.AlreadyInClan(incArgs.Player.UserAccountName))
            {
                incArgs.Player.SendMessage("You are already in clan!", Color.Red);
                return;
            }
            List <string> strQueue = TCutils.InQueue(clName, TCutils.GetPlayersByName(incArgs.Player.Name)[0], TCutils.GetPlayersByName(incArgs.Player.Name)[0]);

            if (strQueue.Count == 0)
            {
                incArgs.Player.SendMessage("You didn't invite anyone!", Color.Red);
                return;
            }

            if (clName != "" && clFounder != "" && clCoFounder != "")
            {
                TCdb.DB.QueryReader("DELETE FROM FoundQueue WHERE founder='" + incArgs.Player.UserAccountName + "'");
                incArgs.Player.SendMessage("You have revoked invitation!", Color.Orange);
                if (TCutils.GetPlayersByUserName(clCoFounder).Count == 1)
                {
                    TCutils.GetPlayersByUserName(clCoFounder)[0].TSPlayer.SendMessage(incArgs.Player.Name + " has revoked invitation!", Color.Orange);
                    return;
                }
            }
            else
            {
                incArgs.Player.SendMessage("You didn't invite anyone!", Color.Red);
            }
        }
Exemple #5
0
        public static void TCdel(CommandArgs incArgs)
        {
            string clName  = "";
            string clGroup = "";
            var    DBQuery = TCdb.DB.QueryReader("SELECT clanname, clangroup FROM Clans WHERE clanname='" + incArgs.Parameters[1] + "'");

            while (DBQuery.Read())
            {
                clName  = DBQuery.Get <string>("clanname");
                clGroup = DBQuery.Get <string>("clangroup");
            }
            if (clName == "")
            {
                incArgs.Player.SendMessage("Clan \"" + incArgs.Parameters[1] + "\" doesn't exist!", Color.Red);
                return;
            }
            List <string> clMembers = TCutils.GetMembers(clName);
            List <string> clLeaders = TCutils.GetLeaders(clName);

            foreach (string i in clMembers)
            {
                var user = new User();
                user.Name = i;
                string gr = TShock.Users.GetUserByName(i).Group;
                if (!TShock.Utils.GetGroup(gr).HasPermission("terraclans"))
                {
                    TShock.Users.SetUserGroup(user, TShock.Config.DefaultRegistrationGroupName);
                }
            }
            string initPl = "";

            foreach (string i in clLeaders)
            {
                var user = new User();
                user.Name = i;
                initPl    = i;
                string gr = TShock.Users.GetUserByName(i).Group;
                if (!TShock.Utils.GetGroup(gr).HasPermission("terraclans"))
                {
                    TShock.Users.SetUserGroup(user, TShock.Config.DefaultRegistrationGroupName);
                }
            }
            TCutils.ClanMsg(initPl, "Your clan has been disbanded by " + incArgs.Player.Name + "!", 1, false);
            TCdb.DB.QueryReader("DELETE FROM Clans WHERE clanname = '" + clName + "'");
            TShock.Groups.DeleteGroup(clGroup);
        }
Exemple #6
0
 public static void CMDtcfound(CommandArgs args)
 {
     if (!TCutils.AlreadyInClan(args.Player.UserAccountName))
     {
         if (args.Parameters.Count == 2)
         {
             //tcfound
             TCFound(args);
         }
         else if (args.Parameters.Count == 1)
         {
             if (args.Parameters[0] == "accept")
             {
                 //tcfound accept
                 TCFoundAccept(args);
             }
             else if (args.Parameters[0] == "decline")
             {
                 //tcfound decline
                 TCFoundDecline(args);
             }
             else if (args.Parameters[0] == "revoke")
             {
                 TCFoundRevoke(args);
             }
             else
             {
                 args.Player.SendMessage("TerraClans:", Color.Orange);
                 args.Player.SendMessage("/tcfound accept - accepts founder's invitation.", Color.Orange);
                 args.Player.SendMessage("/tcfound decline - declines founder's invitation.", Color.Orange);
                 args.Player.SendMessage("/tcfound \"Clan Name\" \"co-founder\" - invite co-founder to found new clan with specified name.", Color.Orange);
             }
         }
         else
         {
             args.Player.SendMessage("TerraClans:", Color.Orange);
             args.Player.SendMessage("/tcfound accept - accepts founder's invitation.", Color.Orange);
             args.Player.SendMessage("/tcfound decline - declines founder's invitation.", Color.Orange);
             args.Player.SendMessage("/tcfound \"Clan Name\" \"co-founder\" - invite co-founder to found new clan with specified name.", Color.Orange);
         }
     }
     else
     {
         args.Player.SendMessage("You are already in clan!", Color.Red);
     }
 }
Exemple #7
0
 public void OnChat(messageBuffer msg, int sender, string text, HandledEventArgs e)
 {
     if (text.StartsWith("/"))
     {
         string cmd = text.Split(' ')[0];
         if (cmd == "/login")
         {
             if (TShock.Players[sender].IsLoggedIn)
             {
                 TCutils.TCGreetPlayer(sender);
             }
         }
     }
     else
     {
     }
 }
Exemple #8
0
        public static void TCDecline(CommandArgs incArgs)
        {
            var    plr       = incArgs.Player;
            string clanName  = "";
            string clanGroup = "";
            bool   isInvited = false;
            var    DBQuery   = TCdb.DB.QueryReader("SELECT clanname, clangroup, invites FROM Clans WHERE invites LIKE '%" + plr.UserAccountName + "%'");

            while (DBQuery.Read())
            {
                string[] arr = DBQuery.Get <string>("invites").ToString().Split(',');
                foreach (string i in arr)
                {
                    if (i == plr.UserAccountName)
                    {
                        clanName  = DBQuery.Get <string>("clanname").ToString();
                        clanGroup = DBQuery.Get <string>("clangroup").ToString();
                        isInvited = true;
                    }
                }
            }
            if (isInvited)
            {
                string        strInv  = "";
                List <string> invites = new List <string>();
                invites = TCutils.GetInvites(clanName);
                invites.Remove(plr.UserAccountName);
                if (invites.Count > 0)
                {
                    strInv = string.Join(",", invites.ToArray());
                }
                string msg = incArgs.Player.Name + " has declined invitation.";
                TCutils.ClanMsg(incArgs.Player.UserAccountName, msg, 1, false);
                TCdb.DB.QueryReader("UPDATE Clans SET invites='" + strInv + "' WHERE clanname='" + clanName + "'");
                plr.SendMessage("You have declined the invitation.", Color.Orange);
            }
            else
            {
                plr.SendMessage("You are not invited to any clan!", Color.Red);
            }
        }
Exemple #9
0
        public static void ClanMsg(string plUser, string msg, int type, bool ignoreInit)
        {
            var    clr      = Color.GreenYellow;
            string clanName = "";
            string prefix   = "Clan";
            var    DBQuery  = TCdb.DB.QueryReader("SELECT clanname FROM Clans WHERE leaders LIKE '%" + plUser + "%' OR members LIKE '%" + plUser + "%' OR invites LIKE '%" + plUser + "%'");

            while (DBQuery.Read())
            {
                clanName = DBQuery.Get <string>("clanname");
            }
            DBQuery = TCdb.DB.QueryReader("SELECT leaders, members FROM Clans WHERE (leaders LIKE '%" + plUser + "%' OR members LIKE '%" + plUser + "%') AND (clanname = '" + clanName + "')");
            List <string> recievers = new List <string>();

            while (DBQuery.Read())
            {
                string[] inClan = DBQuery.Get <string>("leaders").Split(',');
                foreach (string plr in inClan)
                {
                    recievers.Add(plr);
                    if (plUser == plr)
                    {
                        prefix = "Leader";
                        clr    = Color.SpringGreen;
                    }
                }
                inClan = DBQuery.Get <string>("members").Split(',');
                foreach (string plr in inClan)
                {
                    recievers.Add(plr);
                }
            }
            if (recievers.Count > 0)
            {
                for (int i = 0; i < recievers.Count; i++)
                {
                    foreach (Player player in TerraClans.Players)
                    {
                        if (player.TSPlayer.UserAccountName == recievers[i])
                        {
                            if (type == 0) // Chat Message
                            {
                                player.TSPlayer.SendMessage("[" + prefix + "] " + TCutils.GetPlayersByUserName(plUser)[0].TSPlayer.Name + ":" + msg, clr);
                            }
                            else if (type == 1) // Clan announcer
                            {
                                if (ignoreInit)
                                {
                                    if (player.TSPlayer.UserAccountName != plUser)
                                    {
                                        player.TSPlayer.SendMessage(msg, Color.Yellow);
                                    }
                                }
                                else
                                {
                                    player.TSPlayer.SendMessage(msg, Color.Yellow);
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                TCutils.GetPlayersByUserName(plUser)[0].TSPlayer.SendMessage("You are not in clan!", Color.Red);
            }
        }
Exemple #10
0
        public static void TCGreetPlayer(int plr)
        {
            string clanName = "";
            string motd     = "";
            bool   valid    = false;
            string plName   = TShock.Players[plr].UserAccountName;
            var    DBQuery  = TCdb.DB.QueryReader("SELECT clanname, motd FROM Clans WHERE leaders LIKE '%" + plName + "%' OR members LIKE '%" + plName + "%'");

            while (DBQuery.Read())
            {
                clanName = DBQuery.Get <string>("clanname");
                motd     = DBQuery.Get <string>("motd");
            }
            if (clanName != "")
            {
                List <string> members = new List <string>();
                members = TCutils.GetMembers(clanName);
                foreach (string i in members)
                {
                    if (i == plName)
                    {
                        valid = true;
                    }
                }
                List <string> leaders = new List <string>();
                leaders = TCutils.GetLeaders(clanName);
                foreach (string i in leaders)
                {
                    if (i == plName)
                    {
                        valid = true;
                    }
                }
                if (valid)
                {
                    TShock.Players[plr].SendMessage("[" + clanName + " MotD]:", Color.GreenYellow);
                    if (motd != "")
                    {
                        TShock.Players[plr].SendMessage(motd, Color.Yellow);
                    }
                    else
                    {
                        TShock.Players[plr].SendMessage("No message.", Color.Yellow);
                    }
                }
            }

            List <string> invites = new List <string>();

            invites = TCutils.GetAllInvites();
            bool isInvited = false;

            {
                for (int i = 0; i < invites.Count; i++)
                {
                    if (plName == invites[i])
                    {
                        isInvited = true;
                        break;
                    }
                }
            }
            if (isInvited)
            {
                DBQuery = TCdb.DB.QueryReader("SELECT clanname FROM Clans WHERE invites LIKE '%" + plName + "%'");
                while (DBQuery.Read())
                {
                    clanName = DBQuery.Get <string>("clanname");
                }

                TShock.Players[plr].SendMessage("You have been invited to join the clan: " + clanName, Color.Orange);
                TShock.Players[plr].SendMessage("/tclan accept - to join", Color.Orange);
                TShock.Players[plr].SendMessage("/tclan decline - to decline invitation.", Color.Orange);
            }

            string clCoFounder = "";
            string clName      = "";
            string clFounder   = "";

            DBQuery = TCdb.DB.QueryReader("SELECT * FROM FoundQueue WHERE cofounder == '" + plName + "' OR founder='" + plName + "'");
            while (DBQuery.Read())
            {
                clName      = DBQuery.Get <string>("clanname");
                clFounder   = DBQuery.Get <string>("founder");
                clCoFounder = DBQuery.Get <string>("cofounder");
            }
            if (clName != "" && clFounder != "" && clCoFounder == plName)
            {
                TShock.Players[plr].SendMessage("You have been invited by to found the clan: " + clanName, Color.Orange);
                TShock.Players[plr].SendMessage("/tcfound accept - to join", Color.Orange);
                TShock.Players[plr].SendMessage("/tcfound decline - to decline invitation.", Color.Orange);
            }
            else if (clName != "" && clFounder == plName && clCoFounder != "")
            {
                TShock.Players[plr].SendMessage("You are gonna found the clan: " + clanName, Color.Orange);
                TShock.Players[plr].SendMessage("/tcfound revoke - revokes invitation.", Color.Orange);
            }
        }
Exemple #11
0
        public static void TCAdd(CommandArgs incArgs)
        {
            bool error = false;

            var           DBQuery      = TCdb.DB.QueryReader("SELECT clangroup FROM Clans WHERE clangroup='" + incArgs.Parameters[3] + "'");
            List <string> existedGroup = new List <string>();

            while (DBQuery.Read())
            {
                existedGroup.Add(DBQuery.Get <string>("clangroup"));
            }

            DBQuery = TCdb.DB.QueryReader("SELECT clanname FROM Clans WHERE clanname='" + incArgs.Parameters[1] + "'");
            List <string> existedClan = new List <string>();

            while (DBQuery.Read())
            {
                existedClan.Add(DBQuery.Get <string>("clanname"));
            }

            List <Player> players = new List <Player>();

            players = TCutils.GetPlayersByName(incArgs.Parameters[2]);
            if (players.Count == 0)
            {
                incArgs.Player.SendMessage("Player " + incArgs.Parameters[2] + " doesn't exist!", Color.Red);
                error = true;
            }
            else
            {
                var leader = players[0].TSPlayer.IsLoggedIn;
                if (!leader)
                {
                    incArgs.Player.SendMessage("Player " + incArgs.Parameters[2] + " is not logged in!", Color.Red);
                    error = true;
                }
                else if (TCutils.AlreadyInClan(players[0].TSPlayer.UserAccountName))
                {
                    incArgs.Player.SendMessage("One of " + incArgs.Parameters[2] + "'s characters is alredy in clan!", Color.Red);
                    error = true;
                }
                List <string> invites = new List <string>();
                invites = TCutils.GetAllInvites();
                foreach (string pl in invites)
                {
                    if (pl == TCutils.GetPlayersByName(incArgs.Parameters[2])[0].TSPlayer.UserAccountName)
                    {
                        incArgs.Player.SendMessage(incArgs.Parameters[2] + " is already invited to another clan!", Color.Red);
                        error = true;
                    }
                }
            }

            var group = TShock.Groups.GroupExists(incArgs.Parameters[3]);

            if (existedGroup.Count > 0)
            {
                incArgs.Player.SendMessage("Group " + incArgs.Parameters[3] + " is already bound to another clan!", Color.Red);
                error = true;
            }
            if (existedClan.Count > 0)
            {
                incArgs.Player.SendMessage("Clan " + incArgs.Parameters[1] + " is already exist!", Color.Red);
                error = true;
            }
            List <string> strQueue = TCutils.InQueue(incArgs.Parameters[1], TCutils.GetPlayersByName(incArgs.Parameters[2])[0], TCutils.GetPlayersByName(incArgs.Parameters[2])[0]);

            if (strQueue.Count > 0)
            {
                incArgs.Player.SendMessage("Clan name is occupied or player is gonna found his own clan.", Color.Red);
                error = true;
            }

            if (!error)
            {
                if (!group)
                {
                    TShock.Groups.AddGroup(incArgs.Parameters[3], "default", "");
                    incArgs.Player.SendMessage("Creating new group: " + incArgs.Parameters[3], Color.LawnGreen);
                }
                else
                {
                    List <string> perms = new List <string>();
                    perms = TShock.Utils.GetGroup(incArgs.Parameters[3]).permissions;
                    //perms.Add("clanchat");
                    incArgs.Player.SendMessage("Binding clan to existing group: " + incArgs.Parameters[3], Color.LawnGreen);
                    TShock.Groups.AddPermissions(incArgs.Parameters[3], perms);
                }
                TCdb.DB.QueryReader("INSERT INTO Clans (clanname, clangroup, leaders, members, motd, invites) VALUES ('" + incArgs.Parameters[1] + "', '" + incArgs.Parameters[3] + "', '" + players[0].TSPlayer.UserAccountName + "', '', 'Welcome to " + incArgs.Parameters[1] + "!', '')");
                incArgs.Player.SendMessage("Added clan: " + incArgs.Parameters[1], Color.LawnGreen);
                var user = new User();
                user.Name = players[0].TSPlayer.UserAccountName;
                if (!players[0].TSPlayer.Group.HasPermission("terraclans"))
                {
                    TShock.Users.SetUserGroup(user, incArgs.Parameters[3]);
                }
                players[0].TSPlayer.SendMessage(incArgs.Player.Name + " created clan \"" + incArgs.Parameters[1] + "\" with you as leader!", Color.YellowGreen);
                players[0].TSPlayer.SendMessage("Please, relogin to apply new settings for your account.", Color.Orange);
            }
        }
Exemple #12
0
        public static void TCFound(CommandArgs incArgs)
        {
            if (!incArgs.Player.IsLoggedIn)
            {
                incArgs.Player.SendMessage("You are not logged in!", Color.Red);
                return;
            }
            if (TCutils.AlreadyInClan(incArgs.Player.UserAccountName))
            {
                incArgs.Player.SendMessage("You are already in clan!", Color.Red);
                return;
            }
            if (incArgs.Player.Name == incArgs.Parameters[1])
            {
                incArgs.Player.SendMessage("You cannot invite yourself!", Color.Red);
                return;
            }
            List <Player> coFounder = new List <Player>();

            coFounder = TCutils.GetPlayersByName(incArgs.Parameters[1]);
            if (coFounder.Count == 0)
            {
                incArgs.Player.SendMessage("Player " + incArgs.Parameters[1] + " doesn't exist!", Color.Red);
                return;
            }
            if (!coFounder[0].TSPlayer.IsLoggedIn)
            {
                incArgs.Player.SendMessage("Player " + coFounder[0].TSPlayer.Name + " is not logged in!", Color.Red);
                return;
            }
            if (TCutils.AlreadyInClan(coFounder[0].TSPlayer.UserAccountName))
            {
                incArgs.Player.SendMessage("Player " + coFounder[0].TSPlayer.Name + " is already in clan!", Color.Red);
                return;
            }
            List <string> invites = new List <string>();

            invites = TCutils.GetAllInvites();
            foreach (string i in invites)
            {
                if (i == incArgs.Player.UserAccountName)
                {
                    incArgs.Player.SendMessage("You are invited to another clan! Decline the invitation first!", Color.Red);
                    incArgs.Player.SendMessage("Type /tclan decline", Color.Red);
                    return;
                }
                if (i == coFounder[0].TSPlayer.UserAccountName)
                {
                    incArgs.Player.SendMessage("Player " + coFounder[0].TSPlayer.Name + " is invited to another clan!", Color.Red);
                    return;
                }
            }
            List <string> strQueue = TCutils.InQueue(incArgs.Parameters[0], TCutils.GetPlayersByName(incArgs.Player.Name)[0], coFounder[0]);

            if (strQueue.Count > 0)
            {
                foreach (string i in strQueue)
                {
                    incArgs.Player.SendMessage(i, Color.Red);
                }
                return;
            }

            TCdb.DB.QueryReader("INSERT INTO FoundQueue (clanname, founder, cofounder) VALUES ('" + incArgs.Parameters[0] + "', '" + incArgs.Player.UserAccountName + "', '" + coFounder[0].TSPlayer.UserAccountName + "')");

            coFounder[0].TSPlayer.SendMessage(incArgs.Player.Name + " invites you to found new clan: " + incArgs.Parameters[0], Color.Orange);
            coFounder[0].TSPlayer.SendMessage("/tcfound accept - accepts the invitation. ", Color.Orange);
            coFounder[0].TSPlayer.SendMessage("/tcfound decline - declines the invitation. ", Color.Orange);
            incArgs.Player.SendMessage("You have invited " + coFounder[0].TSPlayer.Name + " to found new clan.", Color.Orange);
        }
Exemple #13
0
        public static void TCFoundAccept(CommandArgs incArgs)
        {
            string clName      = "";
            string clFounder   = "";
            string clCoFounder = "";
            var    DBQuery     = TCdb.DB.QueryReader("SELECT * FROM FoundQueue WHERE cofounder='" + incArgs.Player.UserAccountName + "'");

            while (DBQuery.Read())
            {
                clName      = DBQuery.Get <string>("clanname");
                clFounder   = DBQuery.Get <string>("founder");
                clCoFounder = DBQuery.Get <string>("cofounder");
            }

            if (!incArgs.Player.IsLoggedIn)
            {
                incArgs.Player.SendMessage("You are not logged in!", Color.Red);
                return;
            }
            if (TCutils.AlreadyInClan(incArgs.Player.UserAccountName))
            {
                incArgs.Player.SendMessage("You are already in clan!", Color.Red);
                return;
            }
            List <string> strQueue = TCutils.InQueue(incArgs.Parameters[0], TCutils.GetPlayersByName(incArgs.Player.Name)[0], TCutils.GetPlayersByName(incArgs.Player.Name)[0]);

            if (strQueue.Count == 0)
            {
                incArgs.Player.SendMessage("You are not invited to any clan!", Color.Red);
                return;
            }
            if (TCutils.GetPlayersByUserName(clFounder).Count == 0)
            {
                incArgs.Player.SendMessage("Your inviter should be online!", Color.Red);
                return;
            }
            if (clName != "" && clFounder != "" && clCoFounder != "")
            {
                TCdb.DB.QueryReader("DELETE FROM FoundQueue WHERE cofounder='" + incArgs.Player.UserAccountName + "'");
                int    timestamp = TCutils.UnixTimestamp();
                string clGroup   = "clan" + timestamp.ToString();
                string clMotd    = "Welcome to " + clName + "!";
                TCdb.DB.QueryReader("INSERT INTO Clans (clanname, clangroup, leaders, members, motd, invites) VALUES ('" + clName + "', '" + clGroup + "', '" + clFounder + "," + incArgs.Player.UserAccountName + "', '', '" + clMotd + "', '')");
                incArgs.Player.SendMessage("Congratulations! You have founded clan: " + clName, Color.LawnGreen);
                incArgs.Player.SendMessage("Please, relogin to apply new settings for your account.", Color.Orange);
                TCutils.GetPlayersByUserName(clFounder)[0].TSPlayer.SendMessage("Congratulations! You have founded clan: " + clName, Color.LawnGreen);
                TCutils.GetPlayersByUserName(clFounder)[0].TSPlayer.SendMessage("Please, relogin to apply new settings for your account.", Color.Orange);
                TShock.Groups.AddGroup(clGroup, "default", "");
                var user = new User();
                user.Name = clFounder;
                if (!TCutils.GetPlayersByUserName(clFounder)[0].TSPlayer.Group.HasPermission("terraclans"))
                {
                    TShock.Users.SetUserGroup(user, clGroup);
                }
                var user2 = new User();
                user2.Name = incArgs.Player.UserAccountName;
                if (!incArgs.Player.Group.HasPermission("terraclans"))
                {
                    TShock.Users.SetUserGroup(user2, clGroup);
                }
            }
            else
            {
                incArgs.Player.SendMessage("You are not invited to any clan!", Color.Red);
            }
        }
Exemple #14
0
        public static void TCInvite(CommandArgs incArgs)
        {
            List <Player> players = new List <Player>();

            players = TCutils.GetPlayersByName(incArgs.Parameters[1]);
            if (players.Count == 0)
            {
                incArgs.Player.SendMessage("Player " + incArgs.Parameters[1] + " doesn't exist!", Color.Red);
            }
            else if (players.Count > 1)
            {
                incArgs.Player.SendMessage("There are at least 2 players match to " + incArgs.Parameters[1] + "!", Color.Red);
            }
            else
            {
                var reciever = players[0].TSPlayer.IsLoggedIn;
                if (!reciever)
                {
                    incArgs.Player.SendMessage("Player " + players[0].TSPlayer.Name + " is not logged in!", Color.Red);
                }
                else if (TCutils.AlreadyInClan(players[0].TSPlayer.UserAccountName))
                {
                    incArgs.Player.SendMessage("One of " + players[0].TSPlayer.Name + "'s characters is alredy in clan!", Color.Red);
                }
                else
                {
                    var           DBQuery = TCdb.DB.QueryReader("SELECT clanname FROM Clans WHERE leaders LIKE '%" + incArgs.Player.UserAccountName + "%' OR members LIKE '%" + incArgs.Player.UserAccountName + "%'");
                    List <string> Clan    = new List <string>();
                    while (DBQuery.Read())
                    {
                        Clan.Add(DBQuery.Get <string>("clanname"));
                    }
                    string        clanName = Clan[0];
                    List <string> invites  = new List <string>();
                    List <string> strQueue = TCutils.InQueue(clanName, players[0], players[0]);
                    if (strQueue.Count > 0)
                    {
                        incArgs.Player.SendMessage(incArgs.Parameters[1] + "is gonna found his own clan!", Color.Red);
                        return;
                    }
                    invites = TCutils.GetAllInvites();
                    bool isInvited = false;
                    if (invites.Count > 0)
                    {
                        for (int i = 0; i < invites.Count; i++)
                        {
                            if (players[0].TSPlayer.UserAccountName == invites[i])
                            {
                                isInvited = true;
                            }
                        }
                    }
                    if (isInvited)
                    {
                        incArgs.Player.SendMessage("Player " + players[0].TSPlayer.Name + " is already invited to another clan!", Color.Red);
                    }
                    else
                    {
                        invites = TCutils.GetInvites(clanName);
                        invites.Add(players[0].TSPlayer.UserAccountName);
                        string str = string.Join(",", invites.ToArray());
                        TCdb.DB.QueryReader("UPDATE Clans SET invites='" + str + "' WHERE clanname='" + clanName + "'");
                        players[0].TSPlayer.SendMessage(incArgs.Player.Name + " invites you to join the clan: " + clanName, Color.Orange);
                        players[0].TSPlayer.SendMessage("/tclan accept - to join", Color.Orange);
                        players[0].TSPlayer.SendMessage("/tclan decline - to decline invitation.", Color.Orange);
                        incArgs.Player.SendMessage("You invited " + players[0].TSPlayer.Name + " to join your clan!", Color.Yellow);
                    }
                }
            }
        }
Exemple #15
0
 public static void CMDtclan(CommandArgs args)
 {
     //tclan invite player
     if (args.Parameters.Count == 2)
     {
         if (args.Parameters[0] == "invite")
         {
             if (TCutils.AlreadyInClan(args.Player.UserAccountName))
             {
                 TCInvite(args);
             }
             else
             {
                 args.Player.SendMessage("You are not in clan!", Color.Red);
             }
         }
         else if (args.Parameters[0] == "kick")
         {
             //tclan kick player
             if (TCutils.AlreadyInClan(args.Player.UserAccountName))
             {
                 TCkick(args);
             }
             else
             {
                 args.Player.SendMessage("You are not in clan!", Color.Red);
             }
         }
     }
     else if (args.Parameters.Count == 1)
     {
         //tclan accept
         if (args.Parameters[0] == "accept" && !TCutils.AlreadyInClan(args.Player.UserAccountName))
         {
             TCAccept(args);
         }
         //tclan decline
         else if (args.Parameters[0] == "decline" && !TCutils.AlreadyInClan(args.Player.UserAccountName))
         {
             TCDecline(args);
         }
         //tclan leave/quit
         else if (args.Parameters[0] == "leave" || args.Parameters[0] == "quit")
         {
             TCQuit(args);
         }
         else
         {
             if (!TCutils.AlreadyInClan(args.Player.UserAccountName))
             {
                 args.Player.SendMessage("TerraClans:", Color.Red);
                 args.Player.SendMessage("/tclan accept/decline - accepts/declines invitation.", Color.Red);
             }
         }
     }
     else
     {
         if (TCutils.AlreadyInClan(args.Player.UserAccountName))
         {
             args.Player.SendMessage("TerraClans:", Color.Red);
             args.Player.SendMessage("/tcsay <message>; /c <message> - sends message to your clan chat", Color.Red);
             args.Player.SendMessage("/tclan invite <player> - invites player to your clan chat", Color.Red);
             if (TCutils.IsLeader(args.Player.UserAccountName))
             {
                 args.Player.SendMessage("/tclan kick <player> - kicks player from your clan.", Color.Red);
             }
             else
             {
                 args.Player.SendMessage("/tclan leave/quit - to leave the clan.", Color.Red);
             }
         }
         else
         {
             args.Player.SendMessage("/tclan accept/decline - accepts/declines invitation.", Color.Red);
         }
         if (args.Player.Group.HasPermission("manageclans"))
         {
             args.Player.SendMessage("/tcman add <clanname> <leader> <clangroup> - adds clan.", Color.Red);
         }
     }
 }
Exemple #16
0
        public static void TCkick(CommandArgs incArgs)
        {
            if (!incArgs.Player.IsLoggedIn)
            {
                incArgs.Player.SendMessage("You are not not logged in!", Color.Red);
                return;
            }
            if (!TCutils.AlreadyInClan(incArgs.Player.UserAccountName))
            {
                incArgs.Player.SendMessage("You are not in clan!", Color.Red);
                return;
            }
            if (!TCutils.IsLeader(incArgs.Player.UserAccountName))
            {
                incArgs.Player.SendMessage("You are not a leader!", Color.Red);
                return;
            }
            List <Player> victims = TCutils.GetPlayersByName(incArgs.Parameters[1]);

            if (victims.Count == 0)
            {
                incArgs.Player.SendMessage("Player does not exist!", Color.Red);
                return;
            }
            if (incArgs.Player.UserAccountName == TCutils.GetPlayersByName(incArgs.Parameters[1])[0].TSPlayer.UserAccountName)
            {
                incArgs.Player.SendMessage("You can't kick yourself!", Color.Red);
                return;
            }
            if (!victims[0].TSPlayer.IsLoggedIn)
            {
                incArgs.Player.SendMessage("Player is not logged in!", Color.Red);
                return;
            }
            if (!TCutils.IsValidMember(victims[0].TSPlayer.UserAccountName, incArgs.Player.UserAccountName))
            {
                incArgs.Player.SendMessage("Player is not in your clan!", Color.Red);
                return;
            }
            if (TCutils.IsLeader(victims[0].TSPlayer.UserAccountName))
            {
                incArgs.Player.SendMessage("You can't kick another leader!", Color.Red);
                return;
            }
            List <string> clName     = TCutils.GetClanByLeader(incArgs.Player.UserAccountName);
            List <string> clMembers  = new List <string>();
            string        rawMembers = "";
            var           DBQuery    = TCdb.DB.QueryReader("SELECT members FROM Clans WHERE clanname='" + clName[0] + "'");

            while (DBQuery.Read())
            {
                string[] arr = DBQuery.Get <string>("members").Split(',');
                foreach (string i in arr)
                {
                    clMembers.Add(i);
                }
            }
            for (int c = 0; c < clMembers.Count; c++)
            {
                if (victims[0].TSPlayer.UserAccountName == clMembers[c])
                {
                    clMembers.RemoveAt(c);
                    break;
                }
            }
            if (clMembers.Count > 0)
            {
                rawMembers = string.Join(",", clMembers.ToArray());
            }
            TCdb.DB.QueryReader("UPDATE Clans SET members='" + rawMembers + "' WHERE clanname='" + clName[0] + "'");
            var user = new User();

            user.Name = victims[0].TSPlayer.UserAccountName;
            if (!victims[0].TSPlayer.Group.HasPermission("terraclans"))
            {
                TShock.Users.SetUserGroup(user, TShock.Config.DefaultRegistrationGroupName);
            }
            TCutils.ClanMsg(incArgs.Player.UserAccountName, victims[0].TSPlayer.Name + " has been kicked from the clan!", 1, false);
            victims[0].TSPlayer.SendMessage("You have been kicked from the clan!", Color.Yellow);
        }