EE2 Bot Owner Only And Admin Only commands

// First we must make an Listbox, for admin commands.

//Add an ListBox and name it Admins
//Now add an button, text it Add and name it add
//And then, add another button, text it Remove and name it remove.

//Now, add an text box and name it addText, after Add button, and then, another text box and name it removeText, after Remove button.
// Okay, that's good for now.


// now, the commands.

// add this to your variables:


string worldowner, str; // World Owner Commands



// now go to case "say":
// if you dont have it, add it.

case "say":

if (str.StartsWith("!admin "))
{
 // !admin [blank space] for username.
 string[] username = str.Split(' '); // now we got the username.
 if (worldowner.Contains(names[m.GetInt(0)])) // worldowner is the string we added in variables, that EE2 considers World Owner.
 {
   if (names.ContainsValue(username[1])
   {
      // now user is in world, so let's admin him.
      if (!Admins.Items.Contains(username[1]))
      {
        con.Send("say", "[Bot] " + names[m.GetInt(0)].ToUpper() + ": " + username[1] + " is now a admin.");
        Admins.Items.Add(username[1]);
      }
      else {
         con.Send("say", "[Bot] " + names[m.GetInt(0)].ToUpper() + ": " + username[1] + " is already an admin.");
      }
   else {
     con.Send("say", "[Bot] " + names[m.GetInt(0)].ToUpper() + ": " + username[1] + " is not in this world or isn't an user.");
   }
 else {
   con.Send("say", "[Bot] " + names[m.GetInt(0)].ToUpper() + ": You are not the world owner!");
 }

if (str.StartsWith("!unadmin "))
{
 // !unadmin [blank space] for username.
 string[] username = str.Split(' '); // now we got the username.
 if (worldowner.Contains(names[m.GetInt(0)])) // worldowner is the string we added in variables, that EE2 considers World Owner.
 {
   if (names.ContainsValue(username[1])
   {
      // now user is in world, so let's admin him.
      if (Admins.Items.Contains(username[1]))
      {
        con.Send("say", "[Bot] " + names[m.GetInt(0)].ToUpper() + ": " + username[1] + " is no longer a admin.");
        Admins.Items.Remove(username[1]);
      }
      else {
         con.Send("say", "[Bot] " + names[m.GetInt(0)].ToUpper() + ": " + username[1] + " is not an admin admin.");
      }
   else {
     con.Send("say", "[Bot] " + names[m.GetInt(0)].ToUpper() + ": " + username[1] + " is not in this world or isn't an user.");
   }
 else {
   con.Send("say", "[Bot] " + names[m.GetInt(0)].ToUpper() + ": You are not the world owner!");
 }
return;

// Owner commands (basic) are done.

if (str == "!a owner command")
{
 if (worldowner.Contains(names[m.GetInt(0)]))
 {
    // Code is placed here.
 }
 else
 {
    // Code is placed here and runs when user isn't owner.
 }
}


if (str == "!a admin command")
{
 if (Admins.Items.Contains(names[m.GetInt(0)]))
 {
   // Code is placed here.
 }
 else
 {
   // Code is placed here and runs when user isn't admin.
 }
}


// And that's all! ;)

No comments:

Post a Comment