Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

Unban command

Newbie Spellweaver
Joined
Feb 18, 2007
Messages
21
Reaction score
0
Hello,

I've been working on a unban command but I don't seem to get it working ^^

Code:
                                        }
                                        if (Splitter[0] == "/ban")
                                        {
                                            foreach (DictionaryEntry DE in World.AllChars)
                                            {
                                                Character Char = (Character)DE.Value;

                                                if (Char.Name == Splitter[1])
                                                {
                                                    World.SendMsgToAll(Splitter[1] + " has been banned by " + MyChar.Name, "SYSTEM", 2011);
                                                    ExternalDatabase.DatabaseQueue.Enqueue(new MySqlCommand("UPDATE `Accounts` SET `LogonType` = 3 WHERE `Charr` = '"+ Splitter[1] +"'", ExternalDatabase.Connection));
                                                    Char.MyClient.Drop();
                                                }
                                                else
                                                {
                                                    SendPacket(General.MyPackets.SendMsg(MessageId, "SYSTEM", MyChar.Name, "Sorry the Character:" + Splitter[1] + " is offline...Please try again later", 2000));
                                                }
                                            }

This is the ban command, but now I want a /unban too.

I noticed I needed to change something with
Code:
foreach (DictionaryEntry DE in World.AllChars)

Since this one picks the online characters.


Could anyone help?

Thanks.
 
Newbie Spellweaver
Joined
Jan 1, 2008
Messages
98
Reaction score
0
Copy the ban command from Database and change the LogonType back to 1 :)
Then use it as unban command in your /unban and you done :)
 
Newbie Spellweaver
Joined
Feb 18, 2007
Messages
21
Reaction score
0
Yup, I thought that too.

But it doesn't seem to work cause it keeps saying the character is offline and it wont execute then.
 
Newbie Spellweaver
Joined
Mar 2, 2007
Messages
14
Reaction score
0
Code:
if(Splitter[0] == "/unban")
{
    string toUnban = Splitter[1];
    // Make a check here wether the player exists and/if it's banned no idea how to do it in mysql
    ExternalDatabase.DatabaseQueue.Enqueue(new MySqlCommand("UPDATE `Accounts` SET `LogonType` = 1 WHERE `Charr` = '"+ toUnban +"'", ExternalDatabase.Connection));
}

I'd say the method to check wether char is banned would be something like this

Code:
public static bool CharExists(string Name)
    {
        MySqlDataAdapter DA = new MySqlDataAdapter("SELECT * FROM `Accounts` WHERE `Charr` = \"" + Name + "\"", Connection);
        DataSet DS = new DataSet();
        DA.Fill(DS, "Accounts");
        if (DS.Tables["Accounts"].Rows.Count >= 1)
            return true;
        else
            return false;
    }

And the code to check wether the char is banned would be something along these lines


Code:
public static bool IsBanned(string CharName)
{
	MySqlDataAdapter DA = new MySqlDataAdapter("SELECT * FROM `Accounts` WHERE `Charr` = \"" + Name 	+ "\"", Connection);
	DataSet DS = new DataSet();

        DA.Fill(DS, "Accounts");
        if (DS.Tables["Accounts"].Rows.Count <= 0)
            return;
    
        DataRow DR = DS.Tables["Accounts"].Rows[0];
        
        if((int)(DR["LogonType"]) == 3) 
          return true;
        return false;
}

Code:
if(Splitter[0] == "/unban")
{
    string toUnban = Splitter[1];
    if(ExternalDatabase.IsBanned(toUnban) && ExternalDatabase.CharExists(toUnban))
       ExternalDatabase.DatabaseQueue.Enqueue(new MySqlCommand("UPDATE `Accounts` SET `LogonType` = 1 WHERE `Charr` = '"+ toUnban +"'", ExternalDatabase.Connection));
}

I'm not sure wether this works or not, but you should get the idea to be able to fix it on your own.
 
Newbie Spellweaver
Joined
Jan 1, 2008
Messages
98
Reaction score
0
I cant give Code coz i dont have Ban if i Ban an Player he goes to BotJail :D
 
Experienced Elementalist
Joined
Jun 12, 2008
Messages
237
Reaction score
0
lol.....what a hard work...
Code:
                                            if (Splitter[0] == "/ban")
                                            {
                                                foreach (DictionaryEntry DE in World.AllChars)
                                                {
                                                    Character Char = (Character)DE.Value;

                                                    if (Char.Name == Splitter[1])
                                                    {
                                                       Char.Teleport(6001,  30, 75);
                                                      
                                                        World.SendMsgToAll(Splitter[1] + " was banned from server by " + MyChar.Name + "and sent automaticaly in BotJail", "SYSTEM", 2011);

                                                    }
                                                }
                                            }
And also u have to add somethings in item usage so u cant use scrolls in BotJail.
 
Newbie Spellweaver
Joined
Jan 1, 2008
Messages
98
Reaction score
0
I dont say anything like Hard Work i only say i cant give my Code for unban :juggle:
 
Back
Top