protected override void execute(Steamworks.CSteamID executorID, string parameter)
 {
     // Dedicator.isDedicated?
     if (!Provider.isServer)
     {
         CommandWindow.LogError("You are not the server!");
         return;
     }
     Commands sys = UnturnedFreneticMod.Instance.CommandSystem.System;
     // TODO: FreneticScript Core methods to ease this.
     foreach (ScriptEvent evt in sys.Events.Values)
     {
         foreach (KeyValuePair<int, CommandScript> handl in new List<KeyValuePair<int, CommandScript>>(evt.Handlers))
         {
             evt.RemoveEventHandler(handl.Value.Name);
         }
     }
     sys.Functions.Clear();
     for (int i = Commander.commands.Count - 1; i >= 0; i--)
     {
         if (Commander.commands[i] is UnturnedCustomCommand)
         {
             Commander.commands.RemoveAt(i);
         }
     }
     UnturnedFreneticMod.Instance.PlayerCommands.Clear();
     UnturnedFreneticMod.Instance.AutorunScripts();
     SysConsole.Output(OutputType.INFO, "Reloaded succesfully!");
 }
Beispiel #2
0
        static void InitSteam2()
        {
            DebugLog.AppendText("Initializing Steam2...");

            if (!Steamworks.LoadSteam())
            {
                throw new InvalidOperationException("Unable to load steam.dll");
            }

            DebugLog.AppendText("Getting Steam2 interface: ISteam006... ");

            Steam = Steamworks.CreateSteamInterface <ISteam006>();
            DebugLog.AppendText(string.Format("ISteam006 = 0x{0:8X}", Steam.Interface));


            if (Steam == null)
            {
                throw new InvalidOperationException("Unable to get ISteam006.");
            }

            TSteamError error = new TSteamError();

            DebugLog.AppendText("ISteam006::Startup()...");

            if (Steam.Startup(0, ref error) == 0)
            {
                throw new InvalidOperationException("Unable to startup steam interface: " + error.szDesc);
            }

            DebugLog.AppendText("Steam2 startup success." + Environment.NewLine);
        }
Beispiel #3
0
        private static ErrorCodes ConnectToSteam()
        {
            if (!Steamworks.Load(true))
            {
                return(ErrorCodes.SteamworksFail);
            }

            _steamClient = Steamworks.CreateInterface <ISteamClient017>();
            if (_steamClient == null)
            {
                return(ErrorCodes.ClientFail);
            }

            var pipe = _steamClient.CreateSteamPipe();

            if (pipe == 0)
            {
                return(ErrorCodes.PipeFail);
            }

            var user = _steamClient.ConnectToGlobalUser(pipe);

            if (user == 0)
            {
                return(ErrorCodes.UserFail);
            }

            _steamApp = _steamClient.GetISteamApps <ISteamApps006>(user, pipe);
            return(_steamApp == null ? ErrorCodes.AppsFail : ErrorCodes.Success);
        }
Beispiel #4
0
        private bool InitSteam()
        {
            ISteamClient012 steamclient = Steamworks.CreateInterface <ISteamClient012>();

            if (steamclient == null)
            {
                Console.WriteLine("steamclient is null !");
                return(false);
            }

            int pipe = steamclient.CreateSteamPipe();

            if (pipe == 0)
            {
                Console.WriteLine("Failed to create a pipe");
                return(false);
            }

            int user = steamclient.ConnectToGlobalUser(pipe);

            if (user == 0 || user == -1)
            {
                Console.WriteLine("Failed to connect to global user");
                return(false);
            }

            steamuser = steamclient.GetISteamUser <ISteamUser016>(user, pipe);
            if (steamuser == null)
            {
                Console.WriteLine("steamuser is null !");
                return(false);
            }
            return(true);
        }
Beispiel #5
0
        public void StartBigPicture()
        {
            string installPath = Steamworks.GetInstallPath();
            string steamEXE    = Path.Combine(installPath, @"steam.exe");

            Process.Start(steamEXE, "steam://open/bigpicture");
        }
Beispiel #6
0
 private void OnDestroy()
 {
     // Only cleanup if the object being destroyed "owns" the Steam instance.
     if (activeInstance == this)
     {
         activeInstance = null;
         Cleanup();
     }
 }
Beispiel #7
0
 private void Form1_FormClosed(object sender, FormClosedEventArgs e)
 {
     //SetStatus(1);
     Steamworks.Load(false);
     if (gsl != null)
     {
         gsl.Stop();
     }
     Application.ExitThread();
     Environment.Exit(0);
 }
        public Server()
        {
            antiGCList  = new List <object>();
            IRCCommands = new IRCCommandList();

            BaseIRCLib.Database.SetDatabase(this);
            BaseIRCLib.Server.SetServer(this);

            Steamworks.Load();
            steamClient  = Steamworks.CreateInterface <ISteamClient009>("SteamClient009");
            clientEngine = Steamworks.CreateInterface <IClientEngine>("CLIENTENGINE_INTERFACE_VERSION001");

            pipe = steamClient.CreateSteamPipe();
            user = steamClient.ConnectToGlobalUser(pipe);

            clientFriends = Steamworks.CastInterface <IClientFriends>(clientEngine.GetIClientFriends(user, pipe, "CLIENTFRIENDS_INTERFACE_VERSION001"));
            clientUser    = Steamworks.CastInterface <ISteamUser014>(steamClient.GetISteamUser(user, pipe, "SteamUser014"));
            //clientUser = Steamworks.CastInterface<IClientUser>(clientEngine.GetIClientUser(user, pipe, "CLIENTUSER_INTERFACE_VERSION001"));

            Callback <PersonaStateChange_t>    stateChange   = new Callback <PersonaStateChange_t>(StateChange, PersonaStateChange_t.k_iCallback);
            Callback <FriendChatMsg_t>         friendMessage = new Callback <FriendChatMsg_t>(FriendMessage, FriendChatMsg_t.k_iCallback);
            Callback <ChatRoomMsg_t>           chatMessage   = new Callback <ChatRoomMsg_t>(ChatMessage, ChatRoomMsg_t.k_iCallback);
            Callback <ChatMemberStateChange_t> chatResult    = new Callback <ChatMemberStateChange_t>(ChatResult, ChatMemberStateChange_t.k_iCallback);
            Callback <ChatRoomInvite_t>        chatInvite    = new Callback <ChatRoomInvite_t>(ChatInvite, ChatRoomInvite_t.k_iCallback);

            if (File.Exists("clients.list"))
            {
                clientList = ClientList.LoadClients("clients.list");
            }
            else
            {
                clientList = new ClientList();
                clientList.Save("clients.list");
            }

            foreach (string f in Directory.GetFiles(Path.Combine(Directory.GetCurrentDirectory(), "Commands"), "*.dll"))
            {
                Assembly fA = Assembly.LoadFile(f);
                foreach (Type m in fA.GetTypes())
                {
                    object a = fA.CreateInstance(m.FullName);
                    if (a == null)
                    {
                        Console.WriteLine("Skipping implementation of {0}", m.Name);
                        continue;
                    }

                    antiGCList.Add(a);

                    RegisterCommands(a);
                }
            }
        }
        internal void Try()
        {
            bool failed = false;

            if (!Steamworks.native.utils.IsAPICallCompleted(Call, ref failed))
            {
                return;
            }

            Steamworks.UnregisterCallResult(this);

            RunCallback();
        }
Beispiel #10
0
        static void InitSteam3()
        {
            DebugLog.AppendText("Initializing Steam3...");

            if (!Steamworks.LoadSteamClient())
            {
                throw new InvalidOperationException("Unable to load steamclient.dll");
            }

            DebugLog.AppendText("Getting Steam3 interface: ISteamClient009...");
            SteamClient = Steamworks.CreateInterface <ISteamClient009>();
            DebugLog.AppendText(string.Format("ISteamClient009 = 0x{0:8X}", SteamClient.Interface));

            DebugLog.AppendText("Getting Steam3 interface: IClientEngine...");
            ClientEngine = Steamworks.CreateInterface <IClientEngine>();
            DebugLog.AppendText(string.Format("IClientEngine = 0x{0:8X}{1}", ClientEngine.Interface, Environment.NewLine));

            if (SteamClient == null || ClientEngine == null)
            {
                throw new InvalidOperationException("Unable to get required steamclient interfaces.");
            }


            DebugLog.AppendText("Creating steam pipe...");
            HSteamPipe = SteamClient.CreateSteamPipe();
            DebugLog.AppendText(string.Format("HSteamPipe = {0}", HSteamPipe));

            DebugLog.AppendText("Connecting to global user...");
            HSteamUser = SteamClient.ConnectToGlobalUser(HSteamPipe);
            DebugLog.AppendText(string.Format("HSteamUser = {0}{1}", HSteamUser, Environment.NewLine));

            if (HSteamUser == 0 || HSteamPipe == 0)
            {
                throw new InvalidOperationException("Unable to connect to global user.");
            }

            DebugLog.AppendText("Getting IClient interface: IClientApps...");
            ClientApps = ClientEngine.GetIClientApps <IClientApps>(HSteamUser, HSteamPipe);
            DebugLog.AppendText(string.Format("IClientApps = 0x{0:8X}", ClientApps.Interface));

            DebugLog.AppendText("Getting IClient interface: IClientUser...");
            ClientUser = ClientEngine.GetIClientUser <IClientUser>(HSteamUser, HSteamPipe);
            DebugLog.AppendText(string.Format("IClientUser = 0x{0:8X}", ClientUser.Interface));

            if (ClientApps == null || ClientUser == null)
            {
                throw new InvalidOperationException("Unable to get required interfaces.");
            }

            DebugLog.AppendText("Steam3 startup success." + Environment.NewLine);
        }
Beispiel #11
0
        public static void Main()
        {
            File.WriteAllText("steam_appid.txt", "630");

            Steamworks.Load(true);

            ISteamClient006 steamclient = Steamworks.CreateInterface <ISteamClient006>();

            int pipe = steamclient.CreateSteamPipe();
            int user = steamclient.ConnectToGlobalUser(pipe); // steamclient.CreateLocalUser(ref pipe); // steamclient.ConnectToGlobalUser(pipe);

            ISteamUser004 steamuser = steamclient.GetISteamUser <ISteamUser004>(user, pipe);


            ISteam003 steam003 = Steamworks.CreateSteamInterface <ISteam003>();

            StringBuilder version = new StringBuilder();

            version.EnsureCapacity(256);

            steam003.GetVersion(version);

            TSteamError   error = new TSteamError();
            uint          sz    = 0;
            StringBuilder email = new StringBuilder();

            email.EnsureCapacity(256);

            steam003.GetCurrentEmailAddress(email, ref sz, ref error);

            CSteamID steamid = steamuser.GetSteamID();

            ISteamFriends003 friends  = steamclient.GetISteamFriends <ISteamFriends003>(user, pipe);
            ISteamFriends002 friends2 = steamclient.GetISteamFriends <ISteamFriends002>(user, pipe);

            int num = friends.GetFriendCount(EFriendFlags.k_EFriendFlagAll);

            for (int i = 0; i < num; i++)
            {
                CSteamID id   = friends.GetFriendByIndex(i, EFriendFlags.k_EFriendFlagAll);
                string   name = friends.GetFriendPersonaName(id);

                if (name == "Stan")
                {
                    byte[] buff = Encoding.ASCII.GetBytes("Oidy.");
                    friends2.SendMsgToFriend(id, EChatEntryType.k_EChatEntryTypeChatMsg, buff);
                }

                Debug.WriteLine(name);
            }
        }
Beispiel #12
0
        public bool GetSteamClient()
        {
            if ( !Steamworks.Load() )
                return false;

            steamClient = Steamworks.CreateInterface<ISteamClient008>( "SteamClient008" );
            clientEngine = Steamworks.CreateInterface<IClientEngine>( "CLIENTENGINE_INTERFACE_VERSION002" );

            if ( steamClient == null )
                return false;

            if ( clientEngine == null )
                return false;

            return true;
        }
Beispiel #13
0
		/// <summary>
		/// Initializes the <c>SteamManager</c>.
		/// This MUST be called before other Steam operations are executed.
		/// </summary>
		/// <returns><c>true</c> if everything initialized properly, <c>false</c> otherwise.</returns>
		public static bool Init()
		{
			if (Enabled)
			{
				_log.Warn("Tried to call Init method when SteamManager has already been initialized! Aborting...");
				return false;
			}
			_log = LogManager.GetLogger(typeof(SteamManager));
			try
			{
				if (!Steamworks.Load())
				{
					_log.Error("Steamworks failed to load, throwing exception!");
					throw new SteamException("Steamworks failed to load.", SteamExceptionType.SteamworksLoadFail);
				}

				Client = Steamworks.CreateInterface<ISteamClient010>("SteamClient010");
				if (Client == null)
				{
					_log.Error("Steamclient is NULL!! Throwing exception!");
					throw new SteamException("Steamclient failed to load! Is the client running? (Sharpcraft.Steam.SteamManager.Client == null!)",
											 SteamExceptionType.SteamLoadFail);
				}

				Pipe = Client.CreateSteamPipe();
				User = Client.ConnectToGlobalUser(Pipe);

				Friends = Steamworks.CastInterface<ISteamFriends002>(Client.GetISteamFriends(User, Pipe, "SteamFriends002"));

				if (Friends == null)
					return false;

				FriendList = new SteamFriendList();

				_steamWatcher = new Timer(SteamCheck, null, 0, 1000);
			}
			catch (SteamException ex)
			{
				_log.Warn("Warning! SteamManager caught a SteamException exception, returning FALSE. Steam components will NOT LOAD!");
				_log.Warn("The SteamException type was: " + System.Enum.GetName(typeof(SteamExceptionType), ex.Type));
				return false;
			}
			_log.Info("SteamManager has been initialized!");
			SteamLoaded = true;
			Enabled = true;
			return true;
		}
Beispiel #14
0
        public void Update()
        {
            Callback        callback;
            SteamCallHandle steamCall;

            if (Steamworks.Steam_BGetCallback(pipe, out callback, out steamCall))
            {
                if (callback.CallbackNum == FriendChatMsg.Callback)
                {
                    FriendChatMsg chatMsg = null;

                    try
                    {
                        chatMsg = ( FriendChatMsg )callback.CallbackObject;
                    }
                    catch
                    {
                        Steamworks.Steam_FreeLastCallback(pipe);
                        OnLogFailure(new LogFailureEventArgs("Recieved callback was not in the correct format, call a programmer!"));
                        return;
                    }

                    string        message = string.Empty;
                    FriendMsgType type;

                    SteamID reciever = new SteamID(chatMsg.Reciever);

                    steamFriends.GetChatMessage(reciever, ( int )chatMsg.ChatID, out message, 1024 * 4, out type);

                    LogMessage log = new LogMessage();

                    log.Sender     = new SteamID(chatMsg.Sender);
                    log.SenderName = steamFriends.GetFriendPersonaName(log.Sender);

                    log.Reciever     = reciever;
                    log.RecieverName = steamFriends.GetFriendPersonaName(log.Reciever);

                    log.Message     = message;
                    log.MessageTime = DateTime.Now;
                    log.MessageType = type;

                    AddLog(log);
                }

                Steamworks.Steam_FreeLastCallback(pipe);
            }
        }
Beispiel #15
0
        private int LoadSteam()
        {
            if (Steamworks.Load(true))
            {
                Console.WriteLine("Ok, Steam Works!");
            }
            else
            {
                MessageBox.Show("Failed, Steam Works!");
                Console.WriteLine("Failed, Steam Works!");

                return(-1);
            }

            steam006 = Steamworks.CreateSteamInterface <ISteam006>();

            steamclient     = Steamworks.CreateInterface <ISteamClient012>();
            pipe            = steamclient.CreateSteamPipe();
            user            = steamclient.ConnectToGlobalUser(pipe);
            steamuser       = steamclient.GetISteamUser <ISteamUser016>(user, pipe);
            steamfriends013 = steamclient.GetISteamFriends <ISteamFriends013>(user, pipe);
            steamfriends002 = steamclient.GetISteamFriends <ISteamFriends002>(user, pipe);
            CSteamID steamID = steamuser.GetSteamID();

            CurrentState = steamfriends002.GetFriendPersonaState(steamID);

            string ConvertTo64 = steamID.ConvertToUint64().ToString();

            txtBox_steamID.Text = ConvertTo64;
            steamid             = steamID;
            if (steam006 == null)
            {
                Console.WriteLine("steam006 is null !");
                return(-1);
            }
            if (steamclient == null)
            {
                Console.WriteLine("steamclient is null !");
                return(-1);
            }


            return(0);
        }
 public decimal GetBounty(Steamworks.CSteamID id)
 {
     decimal output = 0;
     try
     {
         MySqlConnection connection = CreateConnection();
         MySqlCommand command = connection.CreateCommand();
         command.CommandText = "SELECT `bounty` FROM `" + FeexHitman.Instance.Configuration.Instance.DatabaseTableName + "` WHERE `steamId` = '" + id.ToString() + "'";
         connection.Open();
         object result = command.ExecuteScalar();
         if (result != null) Decimal.TryParse(result.ToString(), out output);
         connection.Close();
     }
     catch (Exception ex)
     {
         Logger.LogException(ex);
     }
     return output;
 }
Beispiel #17
0
        private static bool ConnectToSteam()
        {
            var    steamError = new TSteamError();
            string errorText  = "";

            if (!Steamworks.Load(true))
            {
                errorText = "Steamworks failed to load.";
                Console.WriteLine(errorText);
                return(false);
            }

            _steam006 = Steamworks.CreateSteamInterface <ISteam006>();
            if (_steam006.Startup(0, ref steamError) == 0)
            {
                errorText = "Steam startup failed. Is Steam running?";
                Console.WriteLine(errorText);
                return(false);
            }

            _steamClient012 = Steamworks.CreateInterface <ISteamClient012>();
            _clientEngine   = Steamworks.CreateInterface <IClientEngine>();

            _pipe = _steamClient012.CreateSteamPipe();
            if (_pipe == 0)
            {
                errorText = "Failed to create user pipe.";
                Console.WriteLine(errorText);
                return(false);
            }

            _user = _steamClient012.ConnectToGlobalUser(_pipe);
            if (_user == 0 || _user == -1)
            {
                errorText = "Failed to connect to global user.";
                Console.WriteLine(errorText);
                return(false);
            }

            _clientBilling = _clientEngine.GetIClientBilling <IClientBilling>(_user, _pipe);
            _clientUser    = _clientEngine.GetIClientUser <IClientUser>(_user, _pipe);
            return(true);
        }
Beispiel #18
0
        public string ActivateKey(string key)
        {
            if (Utils.ValidateCDKey(key))
            {
                if (connectToSteam())
                {
                    callbackHandlerThread = new Thread(() =>
                    {
                        _waitingForActivationResp = true;
                        CallbackMsg_t callbackMsg = new CallbackMsg_t();
                        while (callbackHandlerThread.ThreadState != ThreadState.AbortRequested && callbackHandlerThread.ThreadState != ThreadState.Aborted)
                        {
                            while (Steamworks.GetCallback(_pipe, ref callbackMsg) && callbackHandlerThread.ThreadState != ThreadState.AbortRequested && callbackHandlerThread.ThreadState != ThreadState.Aborted)
                            {
                                switch (callbackMsg.m_iCallback)
                                {
                                case PurchaseResponse_t.k_iCallback:
                                    onPurchaseResponse((PurchaseResponse_t)Marshal.PtrToStructure(callbackMsg.m_pubParam, typeof(PurchaseResponse_t)));
                                    break;
                                }

                                Steamworks.FreeLastCallback(_pipe);
                            }

                            Thread.Sleep(100);
                        }
                    }
                                                       );
                    callbackHandlerThread.Start();

                    _clientBilling.PurchaseWithActivationCode(key);

                    while (_waitingForActivationResp)
                    {
                        Thread.Sleep(100);
                    }

                    return(_result);
                }
            }
            return("Something went wrong");
        }
Beispiel #19
0
        public bool Initialize()
        {
            if (!Steamworks.Load())
            {
                return(false);
            }

            SteamClient = Steamworks.CreateInterface <ISteamClient008>("SteamClient008");
            if (SteamClient == null)
            {
                return(false);
            }


            Pipe = SteamClient.CreateSteamPipe();
            if (Pipe == 0)
            {
                return(false);
            }

            User = SteamClient.ConnectToGlobalUser(Pipe);
            if (User == 0)
            {
                return(false);
            }


            SteamFriends = Steamworks.CastInterface <ISteamFriends002>(SteamClient.GetISteamFriends(User, Pipe, "SteamFriends002"));
            if (SteamFriends == null)
            {
                return(false);
            }


            SteamUser = Steamworks.CastInterface <ISteamUser013>(SteamClient.GetISteamUser(User, Pipe, "SteamUser013"));
            if (SteamUser == null)
            {
                return(false);
            }

            return(true);
        }
Beispiel #20
0
        static IFace GetInterface <IFace>(GetterFunc func, string errMsg)
            where IFace : INativeWrapper, new()
        {
            IFace iface = default(IFace);

            try
            {
                iface = Steamworks.CastInterface <IFace>(func());
            }
            catch (Exception ex)
            {
                throw new SteamException(errMsg, ex);
            }

            if (iface == null)
            {
                throw new SteamException(errMsg);
            }

            return(iface);
        }
Beispiel #21
0
        private void _callbacks_DoWork(object sender, DoWorkEventArgs e)
        {
            CallbackMsg_t callbackMsg = new CallbackMsg_t();

            while (!_callbackBwg.CancellationPending)
            {
                while (Steamworks.GetCallback(_pipe, ref callbackMsg) && !_callbackBwg.CancellationPending)
                {
                    switch (callbackMsg.m_iCallback)
                    {
                    case PurchaseResponse_t.k_iCallback:
                        onPurchaseResponse((PurchaseResponse_t)Marshal.PtrToStructure(callbackMsg.m_pubParam, typeof(PurchaseResponse_t)));
                        break;
                    }

                    Steamworks.FreeLastCallback(_pipe);
                }

                Thread.Sleep(100);
            }
        }
Beispiel #22
0
        static void Main(string[] args)
        {
            CSteamID qq = 133724098;


            if (!Steamworks.Load())
            {
                return;
            }

            ISteamClient008 steamclient = Steamworks.CreateInterface <ISteamClient008>("SteamClient008");

            Console.WriteLine("client: " + steamclient);

            int pipe = steamclient.CreateSteamPipe();
            int user = steamclient.ConnectToGlobalUser(pipe);

            Console.WriteLine(user);
            Console.WriteLine(pipe);

            ISteamUtils004   utils   = Steamworks.CastInterface <ISteamUtils004>(steamclient.GetISteamUtils(pipe, "SteamUtils004"));
            ISteamFriends005 friends = Steamworks.CastInterface <ISteamFriends005>(steamclient.GetISteamFriends(user, pipe, "SteamFriends005"));

            int num = friends.GetFriendCount(EFriendFlags.k_EFriendFlagAll);

            for (int i = 0; i < num; i++)
            {
                CSteamID id   = friends.GetFriendByIndex(i, (int)EFriendFlags.k_EFriendFlagAll);
                string   name = friends.GetFriendPersonaName(id);

                Debug.WriteLine(name);
            }

            CallbackDispatcher.SpawnDispatchThread(pipe);
            Thread.Sleep(5000);
            CallbackDispatcher.StopDispatchThread(pipe);

            steamclient.ReleaseUser(pipe, user);
            steamclient.ReleaseSteamPipe(pipe);
        }
Beispiel #23
0
        private static bool ConnectToSteam()
        {
            if (!Steamworks.Load(true))
            {
                ShowError("Steamworks failed to load.");
                return(false);
            }

            _steamClient012 = Steamworks.CreateInterface <ISteamClient012>();
            if (_steamClient012 == null)
            {
                ShowError("Failed to create Steam Client inferface.");
                return(false);
            }

            int pipe = _steamClient012.CreateSteamPipe();

            if (pipe == 0)
            {
                ShowError("Failed to create Steam pipe.");
                return(false);
            }

            int user = _steamClient012.ConnectToGlobalUser(pipe);

            if (user == 0)
            {
                ShowError("Failed to connect to Steam user.");
                return(false);
            }

            _steamApps001 = _steamClient012.GetISteamApps <ISteamApps001>(user, pipe);
            if (_steamApps001 == null)
            {
                ShowError("Failed to create Steam Apps inferface.");
                return(false);
            }

            return(true);
        }
Beispiel #24
0
        public bool GetSteamClient()
        {
            if (!Steamworks.Load())
            {
                return(false);
            }

            steamClient  = Steamworks.CreateInterface <ISteamClient008>("SteamClient008");
            clientEngine = Steamworks.CreateInterface <IClientEngine>("CLIENTENGINE_INTERFACE_VERSION001");

            if (steamClient == null)
            {
                return(false);
            }

            if (clientEngine == null)
            {
                return(false);
            }

            return(true);
        }
        public bool CheckExists(Steamworks.CSteamID id)
        {
            try
            {
                MySqlConnection connection = CreateConnection();
                MySqlCommand command = connection.CreateCommand();
                int exists = 0;
                command.CommandText = "SELECT COUNT(1) FROM `" + FeexHitman.Instance.Configuration.Instance.DatabaseTableName + "` WHERE `steamId` = '" + id.ToString() + "'";
                connection.Open();
                object result = command.ExecuteScalar();
                if (result != null) Int32.TryParse(result.ToString(), out exists);
                connection.Close();

                if (exists == 0) { return false; }
                else { return true; }
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
                return false;
            }
        }
Beispiel #26
0
        private void UIDCheck()
        {
            var isSteamRunning = Steamworks.Load(true);

            if (steamuser == null)
            {
                InitSteam();
            }
            string str = string.Empty;

            try
            {
                str = steamuser.GetSteamID().ConvertToUint64().ToString();
            }
            catch
            {
                str = "None";
            }
            UID.Text         = isSteamRunning ? "Steam UID : " + str : "Steam UID : " + str;
            SteamID          = str;
            Continue.Enabled = isSteamRunning ? Continue.Enabled = true : Continue.Enabled = false;
        }
Beispiel #27
0
        private bool connectToSteam()
        {
            var steamError = new TSteamError();

            if (!Steamworks.Load(true))
            {
                lblError.Text = "Steamworks failed to load.";
                return(false);
            }

            _steam006 = Steamworks.CreateSteamInterface <ISteam006>();
            if (_steam006.Startup(0, ref steamError) == 0)
            {
                lblError.Text = "Пожалуйста, включите программу Steam.";
                return(false);
            }

            _steamClient012 = Steamworks.CreateInterface <ISteamClient012>();
            _clientEngine   = Steamworks.CreateInterface <IClientEngine>();

            _pipe = _steamClient012.CreateSteamPipe();
            if (_pipe == 0)
            {
                lblError.Text = "Failed to create user pipe.";
                return(false);
            }

            _user = _steamClient012.ConnectToGlobalUser(_pipe);
            if (_user == 0 || _user == -1)
            {
                lblError.Text = "Failed to connect to global user.";
                return(false);
            }

            _clientBilling = _clientEngine.GetIClientBilling <IClientBilling>(_user, _pipe);
            _clientUser    = _clientEngine.GetIClientUser <IClientUser>(_user, _pipe);
            return(true);
        }
Beispiel #28
0
        public void InstallGame(UInt64 GameID)
        {
            CGameID gameID = new CGameID(GameID);

            switch (gameID.AppType)
            {
            // Basic Steam App
            case CGameID.EGameID.k_EGameIDTypeApp:
            {
                string InstallCommand = $"steam://install/{GameID}";
                string installPath    = Steamworks.GetInstallPath();
                string steamEXE       = Path.Combine(installPath, @"steam.exe");
                Process.Start(steamEXE, InstallCommand);
            }
            break;

            case CGameID.EGameID.k_EGameIDTypeGameMod:
                break;

            case CGameID.EGameID.k_EGameIDTypeShortcut:
                break;
            }
        }
 public void AddUpdateVictimAccount(Steamworks.CSteamID id, decimal bounty, string lastDisplayName)
 {
     try
     {
         MySqlConnection connection = CreateConnection();
         MySqlCommand command = connection.CreateCommand();
         if (CheckExists(id))
         {
             command.CommandText = "UPDATE `" + FeexHitman.Instance.Configuration.Instance.DatabaseTableName + "` SET `bounty` = bounty + (" + bounty + "), `lastDisplayName` = '" + lastDisplayName + "', `lastUpdated` = NOW() WHERE `steamId` = '" + id.ToString() + "'";
         }
         else
         {
             command.CommandText = "INSERT IGNORE INTO `" + FeexHitman.Instance.Configuration.Instance.DatabaseTableName + "` (steamId,bounty,lastDisplayName,lastUpdated) VALUES('" + id.ToString() + "','" + bounty + "','" + lastDisplayName + "',NOW())";
         }
         connection.Open();
         command.ExecuteNonQuery();
         connection.Close();
     }
     catch (Exception ex)
     {
         Logger.LogException(ex);
     }
 }
Beispiel #30
0
        private void InitSteamworks()
        {
            int error;

            steamClient = ( SteamClient008 )Steamworks.CreateInterface(SteamClient008.InterfaceVersion, out error);

            if (error > 0 || steamClient == null)
            {
                Util.ShowFatalError(null, "Unable get SteamClient interface.");
                Initialized = false;
                return;
            }

            pipe = steamClient.CreateSteamPipe();
            if (pipe == SteamPipeHandle.InvalidHandle)
            {
                Util.ShowFatalError(null, "Unable to create steam pipe.\n\nPlease ensure steam is running.");
                Initialized = false;
                return;
            }

            user = steamClient.ConnectToGlobalUser(pipe);
            if (user == new SteamUserHandle(0))
            {
                Util.ShowFatalError(null, "Unable to connect to global user.\n\nPlease ensure you are logged into steam.");
                Initialized = false;
                return;
            }

            steamFriends = ( SteamFriends001 )steamClient.GetISteamFriends(user, pipe, SteamFriends001.InterfaceVersion);
            if (steamFriends == null)
            {
                Util.ShowFatalError(null, "Unable to get SteamFriends interface.");
                Initialized = false;
                return;
            }
        }
Beispiel #31
0
        private bool connectToSteam()
        {
            var steamError = new TSteamError();

            if (!Steamworks.Load(true))
            {
                throw new SteamException("Steamworks failed to load.");
                return(false);
            }

            _steam006 = Steamworks.CreateSteamInterface <ISteam006>();
            if (_steam006.Startup(0, ref steamError) == 0)
            {
                throw new SteamException("Steam startup failed.");
                return(false);
            }

            _steamClient012 = Steamworks.CreateInterface <ISteamClient012>();
            _clientEngine   = Steamworks.CreateInterface <IClientEngine>();

            _pipe = _steamClient012.CreateSteamPipe();
            if (_pipe == 0)
            {
                throw new SteamException("Failed to create a pipe.");
                return(false);
            }

            _user = _steamClient012.ConnectToGlobalUser(_pipe);
            if (_user == 0 || _user == -1)
            {
                throw new SteamException("Failed to connect to global user.");
                return(false);
            }

            _clientBilling = _clientEngine.GetIClientBilling <IClientBilling>(_user, _pipe);
            return(true);
        }
        internal static void executeCommand(IRocketCommand command,Steamworks.CSteamID caller, string commandString)
        {
            if (!command.AllowFromConsole && !IsPlayer(caller))
            {
                Logger.Log("This command can't be called from console");
                return;
            }

            string[] collection = Regex.Matches(commandString, @"[\""](.+?)[\""]|([^ ]+)", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture).Cast<Match>().Select(m => m.Value.Trim('"').Trim()).ToArray();

            try
            {
                IRocketPlayer p = UnturnedPlayer.FromCSteamID(caller);
                if (p == null)
                {
                    p = new ConsolePlayer();
                }
                command.Execute(p, collection);
            }
            catch (Exception ex)
            {
                Logger.LogError("An error occured while executing command /" + command.Name + " " + commandString + ": " + ex.ToString());
            }
        }
Beispiel #33
0
        public bool GetInterface()
        {
            steamFriends = Steamworks.CastInterface<ISteamFriends002>( steamClient.GetISteamFriends( user, pipe, "SteamFriends002" ) );

            if ( steamFriends == null )
                return false;

            clientFriends = Steamworks.CastInterface<IClientFriends>( clientEngine.GetIClientFriends( user, pipe, "CLIENTFRIENDS_INTERFACE_VERSION001" ) );

            if ( clientFriends == null )
                return false;

            VTable vTable = new VTable( clientFriends.Interface );

            getChatMsg = vTable.GetFunc<NativeGetChatRoomEntry>( 99 );
            getChatName = vTable.GetFunc<NativeGetChatRoomName>( 117 );

            groupChatEnabled = true;
            groupStatusMsg = "Enabled with vtable offsets. (Dangerous)";

            CallbackDispatcher.SpawnDispatchThread( pipe );

            return true;
        }
 public bool RemoveVictimAccount(Steamworks.CSteamID id)
 {
     try
     {
         MySqlConnection connection = CreateConnection();
         MySqlCommand command = connection.CreateCommand();
         command.CommandText = "DELETE FROM `" + FeexHitman.Instance.Configuration.Instance.DatabaseTableName + "` WHERE `steamId`='" + id.ToString() + "'";
         connection.Open();
         command.ExecuteNonQuery();
         connection.Close();
         return true;
     }
     catch (Exception ex)
     {
         Logger.LogException(ex);
         return false;
     }
 }
 public static bool IsPlayer(Steamworks.CSteamID caller)
 {
     return (caller != null && !String.IsNullOrEmpty(caller.ToString()) && caller.ToString() != "0");
 }
 protected override void execute(Steamworks.CSteamID executorID, string parameter)
 {
     Execute(executorID, null, parameter);
 }
Beispiel #37
0
        public static void Init()
        {
            if (!Steamworks.Load())
            {
                throw new SteamException("Unable to load steamclient library.");
            }

            if (SteamClient == null)
            {
                SteamClient = Steamworks.CreateInterface <ISteamClient009>();

                if (SteamClient == null)
                {
                    throw new SteamException("Unable to get ISteamClient interface.");
                }
            }

            if (Pipe == 0)
            {
                Pipe = SteamClient.CreateSteamPipe();

                if (Pipe == 0)
                {
                    throw new SteamException("Unable to create steam pipe.");
                }
            }

            if (User == 0)
            {
                User = SteamClient.ConnectToGlobalUser(Pipe);

                if (User == 0)
                {
                    throw new SteamException("Unable to connect to global user.");
                }
            }

            if (SteamUser == null)
            {
                SteamUser = SteamClient.GetISteamUser <ISteamUser015>(User, Pipe);

                if (SteamUser == null)
                {
                    throw new SteamException("Unable to get ISteamUser interface.");
                }
            }

            if (SteamFriends == null)
            {
                SteamFriends = SteamClient.GetISteamFriends <ISteamFriends009>(User, Pipe);

                if (SteamFriends == null)
                {
                    throw new SteamException("Unable to get ISteamFriends interface.");
                }
            }

            if (SteamApps == null)
            {
                SteamApps = SteamClient.GetISteamApps <ISteamApps001>(User, Pipe);

                if (SteamApps == null)
                {
                    throw new SteamException("Unable to get ISteamApps interface.");
                }
            }

            CallbackDispatcher.SpawnDispatchThread(Pipe);
        }
 protected override void execute(Steamworks.CSteamID caller, string commandString)
 {
     executeCommand(Command,caller, commandString);
 }
 public void UpdateVictimDisplayName(Steamworks.CSteamID id, string lastDisplayName)
 {
     try
     {
         MySqlConnection connection = CreateConnection();
         MySqlCommand command = connection.CreateCommand();
         command.CommandText = "UPDATE `" + FeexHitman.Instance.Configuration.Instance.DatabaseTableName + "` SET `lastDisplayName` = '" + lastDisplayName + "' WHERE `steamId` = '" + id.ToString() + "'";
         connection.Open();
         command.ExecuteNonQuery();
         connection.Close();
     }
     catch (Exception ex)
     {
         Logger.LogException(ex);
     }
 }
Beispiel #40
0
        public Steam()
        {
            _log = LogManager.GetLogger(this);

            _log.Info("Steam initializing...");

            if (!Steamworks.Load())
            {
                _log.Error("Failed to load Steamworks.");
                throw new SteamException("Failed to load Steamworks");
            }

            _log.Debug("Creating SteamClient012 interface...");

            SteamClient012 = Steamworks.CreateInterface <ISteamClient012>();

            if (SteamClient012 == null)
            {
                _log.Error("Failed to create SteamClient012 interface");
                throw new SteamException("Failed to create SteamClient012 interface");
            }

            _log.Debug("Creating steam pipe and connecting to global user...");

            _pipe = SteamClient012.CreateSteamPipe();

            if (_pipe == 0)
            {
                _log.Error("Failed to create Steam pipe");
                throw new SteamException("Failed to create Steam pipe");
            }

            _user = SteamClient012.ConnectToGlobalUser(_pipe);

            if (_user == 0)
            {
                _log.Error("Failed to connect user");
                throw new SteamException("Failed to connect to global user");
            }

            _log.Debug("Getting SteamUtils005 interface...");

            SteamUtils005 = SteamClient012.GetISteamUtils <ISteamUtils005>(_pipe);

            if (SteamUtils005 == null)
            {
                _log.Error("Failed to obtain Steam utils");
                throw new SteamException("Failed to obtain Steam utils");
            }

            _log.Debug("Getting SteamUser016 interface...");

            SteamUser016 = SteamClient012.GetISteamUser <ISteamUser016>(_user, _pipe);

            if (SteamUser016 == null)
            {
                _log.Error("Failed to obtain Steam user interface");
                throw new SteamException("Failed to obtain Steam user interface");
            }

            _log.Debug("Getting SteamFriends002 interface...");

            SteamFriends002 = SteamClient012.GetISteamFriends <ISteamFriends002>(_user, _pipe);

            if (SteamFriends002 == null)
            {
                _log.Error("Failed to obtain Steam friends (002)");
                throw new SteamException("Failed to obtain Steam friends (002)");
            }

            _log.Debug("Getting SteamFriends014 interface...");

            SteamFriends014 = SteamClient012.GetISteamFriends <ISteamFriends014>(_user, _pipe);

            if (SteamFriends014 == null)
            {
                _log.Error("Failed to obtain Steam friends (013)");
                throw new SteamException("Failed to obtain Steam friends (013)");
            }

            SteamApps001 = SteamClient012.GetISteamApps <ISteamApps001>(_user, _pipe);

            if (SteamApps001 == null)
            {
                _log.Error("Failed to obtain SteamApps006");
                throw new SteamException("Failed to obtain SteamApps006");
            }

            SteamApps006 = SteamClient012.GetISteamApps <ISteamApps006>(_user, _pipe);

            if (SteamApps006 == null)
            {
                _log.Error("Failed to obtain Steam apps (006)");
                throw new SteamException("Failed to obtain Steam apps (006)");
            }

            SteamInstallPath = Steamworks.GetInstallPath();
            SteamConfigPath  = Path.Combine(SteamInstallPath, "config", "config.vdf");

            _log.DebugFormat("Steam installed at {0}, config at {1}", SteamInstallPath, SteamConfigPath);

            // Set up callbacks
            _log.Debug("Setting up Steam callbacks...");
            _personaStateChange        = new Callback <PersonaStateChange_t>(HandlePersonaStateChange);
            _friendProfileInfoResponse = new Callback <FriendProfileInfoResponse_t>(HandleFriendProfileInfoResponse);
            _friendAdded         = new Callback <FriendAdded_t>(HandleFriendAdded);
            _friendChatMessage   = new Callback <FriendChatMsg_t>(HandleFriendChatMessage);
            _appEventStateChange = new Callback <AppEventStateChange_t>(HandleAppEventStateChange);

            LocalUser = new LocalUser(this);
            Friends   = new Friends(this);
            Apps      = new Apps(this);

            // Spawn dispatch thread
            CallbackDispatcher.SpawnDispatchThread(_pipe);
        }
Beispiel #41
0
    private void Awake()
    {
		Steam.RestartAppIfNecessary(480);
	
        // Makes sure that only one instance of this object is in use at a time
        if (SteamInterface == null)
        {
            bool error = false;
            try
            {
                // Starts the library. This will, and can, only be done once.
                SteamInterface = Steam.Initialize();
            }
            catch (AlreadyLoadedException e)
            {
                status = "The native dll is already loaded, this should not happen if ReleaseManagedResources is used and Steam.Initialize() is only called once.";
                Debug.LogError(status, this);
                Debug.LogError(e.Message, this);
                error = true;
            }
            catch (SteamInitializeFailedException e)
            {
                status = "Could not initialize the native Steamworks API. This is usually caused by a missing steam_appid.txt file or if the Steam client is not running.";
                Debug.LogError(status, this);
                Debug.LogError(e.Message, this);
                error = true;
            }
            catch (SteamInterfaceInitializeFailedException e)
            {
                status = "Could not initialize the wanted versions of the Steamworks API. Make sure that you have the correct Steamworks SDK version. See the documentation for more info.";
                Debug.LogError(status, this);
                Debug.LogError(e.Message, this);
                error = true;
            }
            catch (DllNotFoundException e)
            {
                status = "Could not load a dll file. Make sure that the steam_api.dll/libsteam_api.dylib file is placed at the correct location. See the documentation for more info.";
                Debug.LogError(status, this);
                Debug.LogError(e.Message, this);
                error = true;
            }

            if (error)
            {
                SteamInterface = null;
            }
            else
            {
                status = "Steamworks initialized and ready to use.";
                
				#if UNITY_WINDOWS
				if (SteamInterface.Utils.IsSteamRunningInVR())
				{
					HmdError result;
					result = SteamInterface.Hmd.Init();
					Debug.Log("Result: " + result);
				}
				#endif
				
                // Prevent destruction of this object
                GameObject.DontDestroyOnLoad(this);
                activeInstance = this;

                // An event is used to notify us about any exceptions thrown from native code.
                SteamInterface.ExceptionThrown += ExceptionThrown;

                // Listen to when the game overlay is shown or hidden
                SteamInterface.Friends.GameOverlayActivated += OverlayToggle;

                hasLicense = SteamInterface.User.UserHasLicenseForApp(SteamInterface.User.GetSteamID(), SteamInterface.AppID);
            }
        }
        else
        {
            // Another Steamworks object is already created, destroy this one.
            Destroy(this);
        }
    }
Beispiel #42
0
 private void OnDestroy()
 {
     // Only cleanup if the object being destroyed "owns" the Steam instance.
     if (activeInstance == this)
     {
         activeInstance = null;
         Cleanup();
     }
 }
 public bool Execute(Steamworks.CSteamID executorID, string method, string parameter)
 {
     // TODO: Fire unknown command event!
     return false;
 }
        private bool CheckPlayer(Steamworks.CSteamID plr)
        {
            bool flag = false;
            foreach (SteamPlayer sp in Provider.clients)
            {
                if (sp.playerID.steamID == plr)
                {
                    flag = true;
                }
            }

            return flag;
        }
 public override bool check(Steamworks.CSteamID executorID, string method, string parameter)
 {
     return Execute(executorID, method, parameter);
 }