/ircsay

/ircsay

Postby Breakdown901 » 28 Jul 2013, 19:02

I tried this, but I think your only allowed the IRCBot string if your Dzienny.

Code: Select all
//Made by Breakdown901
using System;
namespace MCDzienny
{
   public class CmdIrcsay : Command
   {
      public override string name { get { return "ircsay"; } }
      public override string shortcut { get { return "isay"; } }
      public override string type { get { return "other"; } }
      public override bool museumUsable { get { return false; } }
      public override LevelPermission defaultRank { get { return LevelPermission.Admin; } }
      public override void Use(Player p, string message)
      {
         if (message == "") { Help(p); return; }

                Player who = Player.Find(message);
         {   
            IRCBot.Say(message);
            Player.GlobalMessage("/ircsay was used by " + p.color + p.PublicName);
         }
      }      
         
      public override void Help(Player p)
      {
         Player.SendMessage(p, "/ircsay - Makes the IRC bot say something. DO NOT TRY IF IRC IS DISABLED ON YOUR SERVER.");
      }
   }
}


Error:

Code: Select all
-------------------------

Error CS0122
Message: 'MCDzienny.IRCBot' is inaccessible due to its protection level
Line: 18
Owner of:
Breakdown901 Lava Survival/Zombie Survival/Freebuild
Host of NeonGaming Lava Survival.
Breakdown901
 
Posts: 320
Joined: 24 May 2013, 12:54

Re: /ircsay

Postby Breakdown901 » 28 Jul 2013, 19:05

I edited it, but I still have a compiler error.

Code: Select all
//Made by Breakdown901
using System;
namespace MCDzienny
{
   public class CmdIrcsay : Command
   {
      public override string name { get { return "ircsay"; } }
      public override string shortcut { get { return "isay"; } }
      public override string type { get { return "other"; } }
      public override bool museumUsable { get { return false; } }
      public override LevelPermission defaultRank { get { return LevelPermission.Admin; } }
      public CmdIRCSay() { }
      
      public override void Use(Player p, string message)
      {
         if (message == "") { Help(p); return; }

                Player who = Player.Find(message);
         {   
            IRCBot.Say(message);
            Player.GlobalMessage("/ircsay was used by " + p.color + p.PublicName);
         }
      }      
         
      public override void Help(Player p)
      {
         Player.SendMessage(p, "/ircsay - Makes the IRC bot say something. DO NOT TRY IF IRC IS DISABLED ON YOUR SERVER.");
      }
   }
}


Error:

Code: Select all
-------------------------

Error CS1520
Message: Method must have a return type
Line: 12
Owner of:
Breakdown901 Lava Survival/Zombie Survival/Freebuild
Host of NeonGaming Lava Survival.
Breakdown901
 
Posts: 320
Joined: 24 May 2013, 12:54

Re: /ircsay

Postby tinyCreeper » 28 Jul 2013, 19:31

Change
Code: Select all
      public CmdIRCSay() { }


to
Code: Select all
      public CmdIrcsay() { }
tinyCreeper
 
Posts: 48
Joined: 05 Jul 2013, 12:21

Re: /ircsay

Postby Breakdown901 » 28 Jul 2013, 19:40

tinyCreeper wrote:Change
Code: Select all
      public CmdIRCSay() { }


to
Code: Select all
      public CmdIrcsay() { }


I did what you said, but I'm getting the old error message again.

Code: Select all


Command:

Code: Select all
//Made by Breakdown901
using System;
namespace MCDzienny
{
   public class CmdIrcsay : Command
   {
      public override string name { get { return "ircsay"; } }
      public override string shortcut { get { return "isay"; } }
      public override string type { get { return "other"; } }
      public override bool museumUsable { get { return false; } }
      public override LevelPermission defaultRank { get { return LevelPermission.Admin; } }
      public CmdIrcsay() { }   
   
      public override void Use(Player p, string message)
      {

                Player who = Player.Find(message);
            
         {   
            IRCBot.Say(message);
            Player.GlobalMessage("/ircsay was used by " + p.color + p.PublicName);
         }
      }      
         
      public override void Help(Player p)
      {
         Player.SendMessage(p, "/ircsay - Makes the IRC bot say something. DO NOT TRY IF IRC IS DISABLED ON YOUR SERVER.");
      }
   }
}


Error:

Code: Select all
-------------------------

Error CS0122
Message: 'MCDzienny.IRCBot' is inaccessible due to its protection level
Line: 20
Owner of:
Breakdown901 Lava Survival/Zombie Survival/Freebuild
Host of NeonGaming Lava Survival.
Breakdown901
 
Posts: 320
Joined: 24 May 2013, 12:54

Re: /ircsay

Postby Breakdown901 » 28 Jul 2013, 19:43

Is it saying its inaccessible because only Dzienny can open that part of code?
Owner of:
Breakdown901 Lava Survival/Zombie Survival/Freebuild
Host of NeonGaming Lava Survival.
Breakdown901
 
Posts: 320
Joined: 24 May 2013, 12:54

Re: /ircsay

Postby tinyCreeper » 28 Jul 2013, 19:51

I'm not sure about that, you'd have to ask someone more familiar with the software.
tinyCreeper
 
Posts: 48
Joined: 05 Jul 2013, 12:21

Re: /ircsay

Postby Conor » 29 Jul 2013, 01:56

Nice attempts to modify the code but they won't do anything about this error.

I like your guess that maybe only Dzienny can use it as it says "Inaccessible due to its protection level" :)

The actual problem is because the IRCBot.Say method has a modifier (public/private/internal/protected) which you cannot access from your command. This more than likely means the method is private and not public, and thus you cannot call it from outside of the IRCBot class.
Conor (Conanza121)
User avatar
Conor
Coder
 
Posts: 390
Joined: 10 Oct 2012, 21:36
Location: @21Conor

Re: /ircsay

Postby Breakdown901 » 29 Jul 2013, 10:49

I thought that, I've been looking at the MCLawl source code recently as I thought this would help me to learn more methods and further my learning in coding. I had never seen the IRCBot.SAy method used before in MCDzienny, and now I know why :D Thanks Conor, your help is highly appreicated.
Owner of:
Breakdown901 Lava Survival/Zombie Survival/Freebuild
Host of NeonGaming Lava Survival.
Breakdown901
 
Posts: 320
Joined: 24 May 2013, 12:54


Return to Help in Coding

Who is online

Users browsing this forum: No registered users and 0 guests

cron