コード例 #1
0
 public static void UpgradeClan(virtualUser User)
 {
     if (User.ClanID == -1)
     {
         User.send(new PACKET_CHAT("SYSTEM", PACKET_CHAT.ChatType.Whisper, "SYSTEM >> You doesn't own a clan!", User.SessionID, User.Nickname));
     }
     else if (User.ClanRank != 2)
     {
         User.send(new PACKET_CHAT("SYSTEM", PACKET_CHAT.ChatType.Whisper, "SYSTEM >> You're not the owner of the clan!", User.SessionID, User.Nickname));
     }
     else if (User.Cash - 10000 < 0)
     {
         User.send(new PACKET_CHAT("SYSTEM", PACKET_CHAT.ChatType.Whisper, "SYSTEM >> Not enough money!", User.SessionID, User.Nickname));
     }
     else if (getClan(User.ClanID).maxUsers >= 100)
     {
         User.send(new PACKET_CHAT("SYSTEM", PACKET_CHAT.ChatType.Whisper, "SYSTEM >> Your clan cannot be extended more!!", User.SessionID, User.Nickname));
     }
     else
     {
         int MaxUsers = getClan(User.ClanID).maxUsers;
         getClan(User.ClanID).maxUsers += 20;
         int NewMaxUsers = getClan(User.ClanID).maxUsers;
         foreach (virtualUser ClanUser in getClanUsers(User.ClanID))
         {
             ClanUser.send(new PACKET_CHAT("ClanSystem", PACKET_CHAT.ChatType.Clan, "ClanSystem >> " + User.Nickname + " has upgraded clan slots from: " + MaxUsers + " to: " + NewMaxUsers + ":)!", User.ClanID, "NULL"));
         }
         DB.runQuery("UPDATE clans SET maxusers=maxusers+20 WHERE id='" + User.ClanID + "'");
     }
 }
コード例 #2
0
 public static void ChangeName(virtualUser User, string oldName, string newName)
 {
     string[] GetCheck = DB.runReadRow("SELECT * FROM clans WHERE clanname='" + newName + "'");
     if (GetCheck.Length == 0) // Prevent double clan name!
     {
         if (User.Cash - 5000 >= 0)
         {
             if (User.ClanRank == 5) // Check if user is master
             {
                 User.send(new PACKET_CHAT("SYSTEM", PACKET_CHAT.ChatType.Whisper, "SYSTEM >> You've changed clan name for 5,000 cash!", User.SessionID, User.Nickname));
                 foreach (virtualUser ClanUser in getClanUsers(User.ClanID))
                 {
                     ClanUser.ClanName = newName;
                     ClanUser.send(new PACKET_CHAT("ClanSystem", PACKET_CHAT.ChatType.Clan, "ClanSystem >> Clan name was changed from: " + oldName + " to: " + newName, ClanUser.ClanID, ClanUser.Nickname));
                 }
                 User.Cash -= 5000;
                 DB.runQuery("UPDATE users SET cash=cash-2500 WHERE id='" + User.UserID + "'");
                 DB.runQuery("UPDATE clans SET clanname='" + newName + "' WHERE id='" + User.ClanID + "'");
             }
             else
             {
                 User.send(new PACKET_CHAT("SYSTEM", PACKET_CHAT.ChatType.Whisper, "SYSTEM >> You cannot change the clan name because you're not the master!", User.SessionID, User.Nickname));
             }
         }
         else
         {
             User.send(new PACKET_CHAT("SYSTEM", PACKET_CHAT.ChatType.Whisper, "SYSTEM >> Not enough cash!", User.SessionID, User.Nickname));
         }
     }
     else
     {
         User.send(new PACKET_CHAT("SYSTEM", PACKET_CHAT.ChatType.Whisper, "SYSTEM >> This clan name is already in use!", User.SessionID, User.Nickname));
     }
 }
コード例 #3
0
        public static void SetMemberRank(virtualUser User, string Nickname, string Rank)
        {
            bool UserFound = true;

            // Set a user to leader / operator / member
            foreach (virtualUser Client in UserManager.getAllUsers())
            {
                if (Client.Nickname.ToLower().Equals(Nickname.ToLower()) || Client.Username.ToLower().Equals(Nickname.ToLower()))
                {
                    if (Client.UserID == User.UserID || User.ClanID == -1 && User.ClanRank != 2)
                    {
                        return;
                    }
                    if (Client.ClanID != User.ClanID) // If user is the same
                    {
                        User.send(new PACKET_CHAT("SYSTEM", PACKET_CHAT.ChatType.Whisper, "SYSTEM >> " + Client.Nickname + " is not in your clan!", User.SessionID, User.Nickname));
                    }
                    else if (Client.ClanID == User.ClanID && User.ClanRank == 2) // If client has same clan of the user
                    {
                        if (Rank == "leutnant")                                  // Check if there exist another leutnant
                        {
                            string[] CheckData = DB.runReadRow("SELECT nickname FROM users WHERE clanid='" + User.ClanID + "' AND clanrank='13'");
                            if (CheckData.Length > 0)
                            {
                                User.send(new PACKET_CHAT("SYSTEM", PACKET_CHAT.ChatType.Whisper, "SYSTEM >> " + CheckData[0] + " is leader of the clan, leaders cannot be more than one!", User.SessionID, User.Nickname));
                                return;
                            }
                        }
                        else if (Rank == "operator")
                        {
                            int[] operatorLength = DB.runReadColumn("SELECT nickname FROM users WHERE clanid='" + User.ClanID + "' AND clanrank='15'", 0, null);
                            if (operatorLength.Length >= 5)
                            {
                                User.send(new PACKET_CHAT("SYSTEM", PACKET_CHAT.ChatType.Whisper, "SYSTEM >> There are already 5 (max) operators!", User.SessionID, User.Nickname));
                                return;
                            }
                        }
                        /*Calculate rank*/
                        int ClanRank = 1;
                        if (Rank == "leutnant")
                        {
                            ClanRank = 13;
                        }
                        else if (Rank == "operator")
                        {
                            ClanRank = 15;
                        }
                        else if (Rank == "member")
                        {
                            ClanRank = 1;
                        }
                        else
                        {
                            User.send(new PACKET_CHAT("SYSTEM", PACKET_CHAT.ChatType.Whisper, "SYSTEM >> Invalid rank! Please choose one of those: member, operator, leutnant!", User.SessionID, User.Nickname));
                            return;
                        }

                        if (Client.ClanRank == ClanRank)
                        {
                            User.send(new PACKET_CHAT("SYSTEM", PACKET_CHAT.ChatType.Whisper, "SYSTEM >> " + Client.Nickname + " has already this clan rank!", User.SessionID, User.Nickname));
                            return;
                        }

                        Rank = char.ToUpper(Rank[0]) + Rank.Substring(1);

                        foreach (virtualUser ClanUser in getClanUsers(User.ClanID))
                        {
                            ClanUser.send(new PACKET_CHAT("ClanSystem", PACKET_CHAT.ChatType.Clan, "ClanSystem >> " + Client.Nickname + " rank has been changed to " + Rank + " :)!", User.ClanID, "NULL"));
                        }
                        Client.ClanRank = ClanRank;
                        DB.runQuery("UPDATE users SET clanrank='" + ClanRank + "' WHERE id='" + Client.UserID + "'");
                        return;
                    }
                }
                else
                {
                    UserFound = false;
                }
            }
            if (UserFound == false)
            {
                User.send(new PACKET_CHAT("SYSTEM", PACKET_CHAT.ChatType.Whisper, "SYSTEM >> The user " + Nickname + " isn't online or doesn't exist!", User.SessionID, User.Nickname));
            }
        }