Welcome and Farewell Problems

Welcome and Farewell Problems

Postby creamchef » 28 Feb 2013, 02:10

/welcome and /farewell can only be used in lava and zombie. Is it possible to change it to freebuild?
Owner of Infection Time![Zombie Survival]
creamchef
 
Posts: 60
Joined: 09 Jul 2012, 23:54

Re: Welcome and Farewell Problems

Postby Ultima » 02 Mar 2013, 16:37

You can make a custom command for it.

Setfarewell:

Code: Select all
namespace MCDzienny
{
    using System;

    public class CmdSetFarewell : Command
    {
        public override void Help(Player p)
        {
            Player.SendMessage(p, "/setfarewell [message] - Gives you the custom message on disconnecting.");
            Player.SendMessage(p, "If no [message] is given, your farewell message is set to default.");
        }

        public override void Use(Player p, string message)
        {
         Player player = p;
         if (message == "")
         {
            player.farewellMessage = "";
            Player.GlobalChat(null, string.Format("{0} had his farewell message removed.", player.color + player.name + Server.DefaultColor), false);
            DBInterface.ExecuteQuery("UPDATE Players SET farewellMessage = '' WHERE Name = '" + player.name + "'", false);
         }
         else if (message.Length > 0x25)
         {
            Player.SendMessage(p, "Welcome message must be under 37 letters.");
         }
         else
         {
            Player.GlobalChat(null, string.Format("{0} was given the farewell message: {1}.", player.color + player.name + Server.DefaultColor, message), false);
            DBInterface.ExecuteQuery("UPDATE Players SET farewellMessage = '" + message.Replace("'", "''") + "' WHERE Name = '" + player.name + "'", false);
            player.farewellMessage = message;
            p.boughtFarewell = false;
         }
        }

        public override bool ConsoleAccess
        {
            get
            {
                return false;
            }
        }

        public override LevelPermission defaultRank
        {
            get
            {
                return LevelPermission.Guest;
            }
        }

        public override bool museumUsable
        {
            get
            {
                return true;
            }
        }

        public override string name
        {
            get
            {
                return "setfarewell";
            }
        }

        public override string shortcut
        {
            get
            {
                return "";
            }
        }

        public override string type
        {
            get
            {
                return "other";
            }
        }
    }
}



Setwelcome:

Code: Select all
namespace MCDzienny
{
    using System;

    public class CmdSetWelcome : Command
    {
        public override void Help(Player p)
        {
            Player.SendMessage(p, "/setwelcome [message] - Gives you the custom message on joining server.");
            Player.SendMessage(p, "If no [message] is given, your welcome message is set to default.");
        }

        public override void Use(Player p, string message)
        {
         Player player = p;
         if (message == "")
         {
            player.welcomeMessage = "";
            Player.GlobalChat(null, player.color + player.PublicName + Server.DefaultColor + " had his welcome message removed.", false);
            DBInterface.ExecuteQuery("UPDATE Players SET welcomeMessage = '' WHERE Name = '" + player.name + "'", false);
         }
         else if (message.Length > 0x25)
         {
            Player.SendMessage(p, "Welcome message must be under 37 letters.");
         }
         else
         {
            Player.GlobalChat(null, string.Format("{0} was given the welcome message: {1}.", player.color + player.PublicName + Server.DefaultColor, message), false);
            DBInterface.ExecuteQuery("UPDATE Players SET welcomeMessage = '" + message.Replace("'", "''") + "' WHERE Name = '" + player.name + "'", false);
            player.welcomeMessage = message;
            p.boughtWelcome = false;
         }
        }

        public override bool ConsoleAccess
        {
            get
            {
                return false;
            }
        }

        public override LevelPermission defaultRank
        {
            get
            {
                return LevelPermission.Guest;
            }
        }

        public override bool museumUsable
        {
            get
            {
                return true;
            }
        }

        public override string name
        {
            get
            {
                return "setwelcome";
            }
        }

        public override string shortcut
        {
            get
            {
                return "";
            }
        }

        public override string type
        {
            get
            {
                return "other";
            }
        }
    }
}




If you want to use /welcome and /farewell, read this how to override core commands: viewtopic.php?f=21&t=971
Otherwise use the commands that i gave you and use /setfarewell and /setwelcome in-game.
User avatar
Ultima
 
Posts: 953
Joined: 19 Aug 2011, 23:45

Re: Welcome and Farewell Problems

Postby HeyMan7 » 02 Mar 2013, 21:12

How would one go about adding these custom commands?
User avatar
HeyMan7
 
Posts: 70
Joined: 31 Jan 2013, 03:18

Re: Welcome and Farewell Problems

Postby Ultima » 03 Mar 2013, 01:21

Make 2 files, 1 named CmdSetfarewell.cs and 1 names CmdSetWelcome.cs

Paste the content of the post above into the files.
Place these 2 files into extra -> commands -> source map

Open up the server and type:

compile setfarewell
compile setwelcome

Next you can load the commands on the server. Type:

cmdload setfarewell
cmdload setwelcome

You can now use the commands on the server.
If you dont wish to load them manually each time, open the cmdautoload.txt located in the text folder.
User avatar
Ultima
 
Posts: 953
Joined: 19 Aug 2011, 23:45

Re: Welcome and Farewell Problems

Postby HeyMan7 » 03 Mar 2013, 03:06

It won't let me create a .cs file. I've tried saying: rightclick -> new -> text document then renaming the doc to CmdSetfarwell.CS
But no luck, help please.
User avatar
HeyMan7
 
Posts: 70
Joined: 31 Jan 2013, 03:18

Re: Welcome and Farewell Problems

Postby Ultima » 04 Mar 2013, 19:10

Place these 2 files into your extra -> commands map.

Then load them with cmdload.
Attachments
cmd.zip
(3.94 KiB) Downloaded 35 times
User avatar
Ultima
 
Posts: 953
Joined: 19 Aug 2011, 23:45


Return to Help

Who is online

Users browsing this forum: No registered users and 17 guests

cron