uberEmulator license system, help!

Zeno

Member
May 28, 2011
49
0
Hello,

I have followed all the instructions to add the uber Emulator license system by Bill although I have two errors on this line:
string[] weblic = new string[6]; the two symbols underlined are giving the error.

Error 1: Identifier expected
Error 2: Preprocessor directives must appear as the first non-whitespace character on a line.


Help, I'm new to C#!
 

Zeno

Member
May 28, 2011
49
0
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
using Uber.Collections;
using Uber.Core;
using Uber.Storage;
using Uber.Net;
using Uber.HabboHotel;
 
namespace Uber
{
    class UberEnvironment
    {
        private static Logging Logging;
        private static ConfigurationData Configuration;
        private static DatabaseManager DatabaseManager;
        private static Encoding DefaultEncoding;
        private static TcpConnectionManager ConnectionManager;
        private static MusSocket MusSocket;
        private static Game Game;
       
 
        public static String PrettyVersion
        {
            get
            {
                return "uberemu";
            }
        }
 
        public static void Initialize()
        {
            Console.Title = PrettyVersion;
 
            string[] news = new string[6];
            news[0] = new System.Net.WebClient().DownloadString(Decode("something"));
            string[] title = new string[6];
 
            title[0] = new System.Net.WebClient().DownloadString(Decode("something"));
            string[] upgrade = new string[6];
 
            upgrade[0] = new System.Net.WebClient().DownloadString(Decode("something"));
 
            DefaultEncoding = Encoding.Default;
 
            Logging = new Logging();
            Logging.MinimumLogLevel = LogLevel.Debug;
            Console.ForegroundColor = ConsoleColor.Green;
 
            Console.WriteLine("" + title[0]);
 
            Console.ForegroundColor = ConsoleColor.Blue;
            Console.WriteLine("--------------------------------------------------------------------------------");
            Console.WriteLine("Latest News: here");
            Console.WriteLine("--------------------------------------------------------------------------------" + Environment.NewLine);
           
       
            Console.ResetColor();
 
            Console.ForegroundColor = ConsoleColor.Red;
 
 
            Console.WriteLine("" + upgrade[0]);
            try
            {
                Console.ForegroundColor = ConsoleColor.White;
                Configuration = new ConfigurationData("config.conf");
               
              if (UberEnvironment.GetConfig().data["license.key"].Length == 0)
/* License System Optimized by Bill - www.bzdev.com.br */
                {
                    throw new Exception("# You don't have a configured license key !");
                }
 
                string[] weblic = new string[6];
                weblic[0] = new System.Net.WebClient().DownloadString(Decode("my encoded key here")); // hosted File with licenses
                weblic[3] = UberEnvironment.GetConfig().data["license.key"];
                weblic[2] = UberEnvironment.GetConfig().data["license.name"];
 
 
                if (weblic[0].Contains(weblic[3] + "=" + weblic[2]))
                {
                    Console.WriteLine("Your license is correct! Starting Server...");
                }
                else
                {
                    Console.WriteLine(" License Key is Invalid  ! please check the configuration file or obtain a License!");
                    System.Threading.Thread.Sleep(5000); //Wait 5 seconds
                    UberEnvironment.Destroy();
                }
 
                if (UberEnvironment.GetConfig().data["db.password"].Length == 0)
                {
                    throw new Exception("For security reasons, your MySQL password cannot be left blank. Please change your password to start the server.");
                }
 
             
 
                DatabaseServer dbServer = new DatabaseServer(
                    UberEnvironment.GetConfig().data["db.hostname"],
                    uint.Parse(UberEnvironment.GetConfig().data["db.port"]),
                    UberEnvironment.GetConfig().data["db.username"],
                 
                    UberEnvironment.GetConfig().data["db.password"]);
 
                Database db = new Database(
                    UberEnvironment.GetConfig().data["db.name"],
                    uint.Parse(UberEnvironment.GetConfig().data["db.pool.minsize"]),
                    uint.Parse(UberEnvironment.GetConfig().data["db.pool.maxsize"]));
 
                DatabaseManager = new DatabaseManager(dbServer, db);
 
                MusSocket = new MusSocket(UberEnvironment.GetConfig().data["mus.tcp.bindip"],
                    int.Parse(UberEnvironment.GetConfig().data["mus.tcp.port"]),
                    UberEnvironment.GetConfig().data["mus.tcp.allowedaddr"].Split(';'), 20);
 
                Game = new Game();
                ConnectionManager = new TcpConnectionManager(
                    UberEnvironment.GetConfig().data["game.tcp.bindip"],
                    int.Parse(UberEnvironment.GetConfig().data["game.tcp.port"]),
                    int.Parse(UberEnvironment.GetConfig().data["game.tcp.conlimit"]));
                ConnectionManager.GetListener().Start();
                UberEnvironment.GetLogging().WriteLine("");
                UberEnvironment.GetLogging().WriteLine("uber Emulator - Ready for connections!");
                Console.WriteLine("");
                Console.WriteLine("");
               
                Console.Beep();
            }
 
            catch (KeyNotFoundException)
            {
                Logging.WriteLine("Please enter the correct information in config");
                Logging.WriteLine("Press any key to shutdown", LogLevel.Error);
 
                Console.ReadKey(true);
                UberEnvironment.Destroy();
 
                return;
            }
 
            catch (InvalidOperationException e)
            {
                Logging.WriteLine("Failed to load uberEMU" + e.Message, LogLevel.Error);
                Logging.WriteLine("Press any key to shut down ...", LogLevel.Error);
 
                Console.ReadKey(true);
                UberEnvironment.Destroy();
 
 
                return;
       
    }
        }
 
     
        public static bool EnumToBool(string Enum)
        {
            if (Enum == "1")
            {
                return true;
            }
 
            return false;
        }
 
        public static string Decode(string str)
        {
            byte[] decbuff = Convert.FromBase64String(str);
            return System.Text.Encoding.UTF8.GetString(decbuff);
        }
 
        public static string BoolToEnum(bool Bool)
        {
            if (Bool)
            {
                return "1";
            }
 
            return "0";
        }
 
        public static int GetRandomNumber(int Min, int Max)
        {
            RandomBase Quick = new Quick();
            return Quick.Next(Min, Max);
        }
 
        public static Double GetUnixTimestamp()
        {
            TimeSpan ts = (DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0));
            return ts.TotalSeconds;
        }
 
        public static string FilterInjectionChars(string Input)
        {
            return FilterInjectionChars(Input, false);
        }
 
        public static string FilterInjectionChars(string Input, bool AllowLinebreaks)
        {
            Input = Input.Replace(Convert.ToChar(1), ' ');
            Input = Input.Replace(Convert.ToChar(2), ' ');
            Input = Input.Replace(Convert.ToChar(9), ' ');
 
            if (!AllowLinebreaks)
            {
                Input = Input.Replace(Convert.ToChar(13), ' ');
            }
 
            return Input;
        }
 
        public static bool IsValidAlphaNumeric(string inputStr)
        {
            if (string.IsNullOrEmpty(inputStr))
            {
                return false;
            }
 
            for (int i = 0; i < inputStr.Length; i++)
            {
                if (!(char.IsLetter(inputStr[i])) && (!(char.IsNumber(inputStr[i]))))
                {
                    return false;
                }
            }
 
            return true;
        }
 
        public static ConfigurationData GetConfig()
        {
            return Configuration;
        }
 
        public static Logging GetLogging()
        {
            return Logging;
        }
 
        public static DatabaseManager GetDatabase()
        {
            return DatabaseManager;
        }
 
        public static Encoding GetDefaultEncoding()
        {
            return DefaultEncoding;
        }
 
        public static TcpConnectionManager GetConnectionManager()
        {
            return ConnectionManager;
        }
 
        public static Game GetGame()
        {
            return Game;
        }
 
        public static void Destroy()
        {
            UberEnvironment.GetLogging().WriteLine("Shutting down uber");
 
            if (GetGame() != null)
            {
                GetGame().Destroy();
                Game = null;
            }
 
            if (GetConnectionManager() != null)
            {
                UberEnvironment.GetLogging().WriteLine("Shutting down");
                GetConnectionManager().GetListener().Stop();
                GetConnectionManager().GetListener().Destroy();
                GetConnectionManager().DestroyManager();
                ConnectionManager = null;
            }
 
            if (GetDatabase() != null)
            {
                UberEnvironment.GetLogging().WriteLine("Destroying database manager.");
                GetDatabase().StopClientMonitor();
                GetDatabase().DestroyClients();
                GetDatabase().DestroyDatabaseManager();
                DatabaseManager = null;
            }
 
            Logging.WriteLine("Uninitialized successfully. Closing.");
 
            Environment.Exit(0);
        }
    }
}

There you go adil.
 

Users who are viewing this thread

Top