SharpMod.Server.RegisterCommand C# (CSharp) Method

RegisterCommand() public static method

public static RegisterCommand ( string str, CommandDelegate cmd ) : bool
str string
cmd CommandDelegate
return bool
        public static bool RegisterCommand(string str, CommandDelegate cmd)
        {
            if (serverCommands.ContainsKey(str)) {
                return false;
            }

            MetaModEngine.engineFunctions.AddServerCommand(str, Marshal.GetFunctionPointerForDelegate(del));
            serverCommands[str] = cmd;
            return true;
        }

Usage Example

Beispiel #1
0
        public static void Init()
        {
            Version = new CVar("smod_version", "0.1");

            // load plugins

            Server.Print(License);
            Server.RegisterCommand("smod", smod);

            Verifier = new Verifier(Directory.GetCurrentDirectory(), Server.GameDirectory);

            try {
                var doc = new System.Xml.XmlDocument();
                doc.Load(Path.Combine(Server.ModDirectory, Path.Combine("cfg", "databases.xml")));
                try {
                    Database = DefaultDatabase.Load(Path.Combine(Server.ModDirectory, "SharpMod.Database.MySql.dll"));
                    Database.Load(doc);
                } catch (Exception e) {
                    Server.LogError("Database Interface failed to load, using default: {0}", e.Message);
                    Database = new DefaultDatabase();
                    Database.Load(doc);
                }
            } catch (Exception e) {
                Server.LogError("Failed to load cfg/databases.xml: {0}", e.Message);
            }

            Message.Init();
            MapCycle.Init();
        }
All Usage Examples Of SharpMod.Server::RegisterCommand