/Hug - Need a Warm Hug?

Re: /Hug - Need a Warm Hug?

Postby Clowny » 17 Jul 2013, 18:46

thats weird it compile and everything but when i try with tight option it does it with regular message instead
Founder Of MC Classic Hosting Community http://mcclassichosting.webs.com
Founder of MC Classic Software MCReborn http://mcreborn.tk
Professional Hoster and Basic C# Coder
Image
User avatar
Clowny
 
Posts: 112
Joined: 14 Jul 2013, 03:53

Re: /Hug - Need a Warm Hug?

Postby tinyCreeper » 17 Jul 2013, 19:25

Try mine again, I don't think you copy and pasted it correctly or something, line 26 is just bracket. Make sure you do /cmdunload on all your hug cmds, and delete all ur .dll files of them. Then compile and load mine.
tinyCreeper
 
Posts: 48
Joined: 05 Jul 2013, 12:21

Re: /Hug - Need a Warm Hug?

Postby Clowny » 17 Jul 2013, 20:17

Tinycreeper it did indeed compile and load successfully but I'm getting the same problem as I have with breakdown's when I try /hug (player) tight it show the default hug message instead of tight one
Founder Of MC Classic Hosting Community http://mcclassichosting.webs.com
Founder of MC Classic Software MCReborn http://mcreborn.tk
Professional Hoster and Basic C# Coder
Image
User avatar
Clowny
 
Posts: 112
Joined: 14 Jul 2013, 03:53

Re: /Hug - Need a Warm Hug?

Postby Warren1001 » 17 Jul 2013, 20:17

Here you go.
Code: Select all
   //Created By Clowny
   using System;
   namespace MCDzienny
   {
      public class CmdHug : Command
      {
         public override string name { get { return "hug"; } }
         public override string shortcut { get { return "hg"; } }
         public override string type { get { return "other"; } }
         public override bool museumUsable { get { return true; } }
         public override LevelPermission defaultRank { get { return LevelPermission.Operator; } }
         public override bool ConsoleAccess { get { return false; } }
         public override void Use(Player p, string message)
         {
            if (message == null) // its better to use == null instead of == ""
            {
               Help(p); // better to lay it all out then to push together as before.
               return;
            }
            Player who = Player.Find(message.Split(' ')[0]);
            if (who == null)
            {
               Player.SendMessage(p, "Player is not online.");
               return; // if you have a return;, you don't need a else statement. else statement will only occur if the if statement wasn't completed, while return; will just stop the if statement if it wasn't completed.
            }
            string reason = message.Split(' ')[1]; // if you try to use the string message, it'll think ur going to type /hug tight, which you arent. you are going to type /hug [player] tight.
            if (reason == "tight")
            {
               Player.GlobalMessage(p.color + p.PublicName + " &shugged " + who.color + who.PublicName + " &stightly, maybe a little too tight..."); // also, you do not need the p, at the beginning of a GlobalMessage (not GlobalChat), or the , false at the end.
               return; // also, shortcuts to Server.DefaultColor is just putting & or %s as a color code, also if you are going to use p.name or who.name in a message, use p.PublicName or who.PublicName so it doesn't show the email.
            }
            Player.GlobalMessage(p.color + p.PublicName + " &sgave " + who.color + who.PublicName + " &sa warm hug.");
         }
         public override void Help(Player p)
         {
            Player.SendMessage(p, "/hug [player] (tight) - Gives someone a nice, warm hug."); // fixed some grammatically errors.
         }
      }
   }
Warren1001
 
Posts: 197
Joined: 08 Aug 2012, 03:50

Re: /Hug - Need a Warm Hug?

Postby Clowny » 17 Jul 2013, 20:24

Thanks Warren I'll use the advice you put in for future codes :D however there was a little error when I was testing it whenever I want to do the normal hug I can't do /hug (player) it has to be /hug (player) (something random)
Founder Of MC Classic Hosting Community http://mcclassichosting.webs.com
Founder of MC Classic Software MCReborn http://mcreborn.tk
Professional Hoster and Basic C# Coder
Image
User avatar
Clowny
 
Posts: 112
Joined: 14 Jul 2013, 03:53

Re: /Hug - Need a Warm Hug?

Postby Warren1001 » 17 Jul 2013, 20:28

Try that.
Code: Select all
   //Created By Clowny
   using System;
   namespace MCDzienny
   {
      public class CmdHug : Command
      {
         public override string name { get { return "hug"; } }
         public override string shortcut { get { return "hg"; } }
         public override string type { get { return "other"; } }
         public override bool museumUsable { get { return true; } }
         public override LevelPermission defaultRank { get { return LevelPermission.Operator; } }
         public override bool ConsoleAccess { get { return false; } }
         public override void Use(Player p, string message)
         {
            if (message == null) // its better to use == null instead of == ""
            {
               Help(p); // better to lay it all out then to push together as before.
               return;
            }
            Player who = Player.Find(message.Split(' ')[0]);
            if (who == null || who.hidden) // ~ make sure to put who.hidden or else people can use it on people that are hidden and be proven they are online. ~
            {
               Player.SendMessage(p, "Player is not online.");
               return; // if you have a return;, you don't need a else statement. else statement will only occur if the if statement wasn't completed, while return; will just stop the if statement if it wasn't completed.
            }
            string reason = message.Split(' ')[1]; // if you try to use the string message, it'll think ur going to type /hug tight, which you arent. you are going to type /hug [player] tight.
            if (reason == "tight")
            {
               Player.GlobalMessage(p.color + p.PublicName + " &shugged " + who.color + who.PublicName + " &stightly, maybe a little too tight..."); // also, you do not need the p, at the beginning of a GlobalMessage (not GlobalChat), or the , false at the end.
               // also, shortcuts to Server.DefaultColor is just putting & or %s as a color code, also if you are going to use p.name or who.name in a message, use p.PublicName or who.PublicName so it doesn't show the email.
            }
            else // ~ that is where a else statement comes in handy :p ~
            {
               Player.GlobalMessage(p.color + p.PublicName + " &sgave " + who.color + who.PublicName + " &sa warm hug.");
            }
         }
         public override void Help(Player p)
         {
            Player.SendMessage(p, "/hug [player] (tight) - Gives someone a nice, warm hug."); // fixed some grammatically errors.
         }
      }
   }
Warren1001
 
Posts: 197
Joined: 08 Aug 2012, 03:50

Re: /Hug - Need a Warm Hug?

Postby tinyCreeper » 17 Jul 2013, 20:35

That's weird, because it worked perfect when I tested it, here I just revised it a little and it worked perfectly again when I tested it:

Code: Select all
//Created By Clowny
using System;
namespace MCDzienny
{
    public class CmdHug : Command
    {
        public override string name { get { return "hug"; } }
        public override string shortcut { get { return "hg"; } }
        public override string type { get { return "other"; } }
        public override bool museumUsable { get { return false; } }
        public override LevelPermission defaultRank { get { return LevelPermission.Operator; } }
        public override void Use(Player p, string message)
        {
            if (message == "") { Help(p); return; }
            string[] mess = message.Split(' ');
            Player who = Player.Find(mess[0]);

            if (who == null)
            {
                Player.SendMessage(p, "Player is not online.");
                return;
            }
            else if (mess.Length == 2)
            {
                if (mess[1] == "tight")
                {
                    Player.GlobalMessage(p.color + p.name + Server.DefaultColor + " hugged " + who.color + who.name + Server.DefaultColor + " tightly, maybe a little too tightly...");
                }
            }
            else if (mess.Length == 1)
            {
                Player.GlobalMessage(p.color + p.name + Server.DefaultColor + " gave " + who.color + who.name + Server.DefaultColor + " a warm hug.");
            }
        }

        public override void Help(Player p)
        {
            Player.SendMessage(p, "/hug [player] - Gives someone a nice warm hug");
            Player.SendMessage(p, "/hug [player] tight - Gives someone a tight hug");
        }
    }
}


And again, you can easily add more hug types to this one.
Last edited by tinyCreeper on 17 Jul 2013, 20:39, edited 1 time in total.
tinyCreeper
 
Posts: 48
Joined: 05 Jul 2013, 12:21

Re: /Hug - Need a Warm Hug?

Postby tinyCreeper » 17 Jul 2013, 20:38

Also, it's not always a good thing to have who.hidden used to say the player is offline, especially if you have a zombie server. People who ref are 'hidden'
tinyCreeper
 
Posts: 48
Joined: 05 Jul 2013, 12:21

Re: /Hug - Need a Warm Hug?

Postby Clowny » 17 Jul 2013, 20:40

hmm waren same problem I was thinking something like if (reason == "") but don't know
Founder Of MC Classic Hosting Community http://mcclassichosting.webs.com
Founder of MC Classic Software MCReborn http://mcreborn.tk
Professional Hoster and Basic C# Coder
Image
User avatar
Clowny
 
Posts: 112
Joined: 14 Jul 2013, 03:53

Re: /Hug - Need a Warm Hug?

Postby Clowny » 17 Jul 2013, 20:46

Alright Thanks tiny yours fully works :D
Founder Of MC Classic Hosting Community http://mcclassichosting.webs.com
Founder of MC Classic Software MCReborn http://mcreborn.tk
Professional Hoster and Basic C# Coder
Image
User avatar
Clowny
 
Posts: 112
Joined: 14 Jul 2013, 03:53

Previous

Return to Custom Commands

Who is online

Users browsing this forum: No registered users and 4 guests

cron