public bool Invoke() { return Task.Run( async () => { try { SteamID targetUser = new SteamID( "76561198129947779" ); SteamClient client = new SteamClient(); client.Authenticator = UserAuthenticator.ForProtectedResource( AccessConstants.OAuthAccessToken ); chatClient.SteamChatConnectionChanged += chatClient_SteamChatConnected; chatClient.SteamChatMessagesReceived += chatClient_SteamChatMessagesReceived; chatClient.SteamChatUserStateChange += chatClient_SteamChatUserStateChange; chatClient.LogOn( client ).Wait(); while( true ) { switch( WriteConsole.Prompt( "Command (msg, status): " ) ) { case "msg": await chatClient.SendMessage( targetUser, WriteConsole.Prompt( "Type New Message: " ) ); break; case "dcn": await chatClient.Disconnect(); break; } } } catch( Exception e ) { WriteConsole.Error( e.Message + "\n" + e.ToString() ); return false; } } ).Result; }
public void SteamIDEquals() { SteamID one = new SteamID( "76561198129947779" ); SteamID two = new SteamID( "76561198129947779" ); Assert.IsTrue( ( one == two ) ); }
public GameServerStatsGetUserStatIntResult GetUserStatInt(SteamID steamIDUser, string name) { GameServerStatsGetUserStatIntResult result = new GameServerStatsGetUserStatIntResult(); result.Result = GetUserStat(steamIDUser, name, out result.IntValue); return result; }
//Thanks to Karl @ Stunlock Studios for giving me their function as he implemented utils.GetImage(Size/RGBA) into our library public Texture2D GetTextureFromSteamID(SteamID steamId) { IFriends friends = Steamworks.SteamInterface.Friends; IUtils utils = Steamworks.SteamInterface.Utils; ImageHandle avatarHandle = friends.GetLargeFriendAvatar(steamId); if (avatarHandle.IsValid) { uint width, height; if (utils.GetImageSize(avatarHandle, out width, out height)) { Texture2D texture = new Texture2D((int)width, (int)height, TextureFormat.RGBA32, true); Color32[] buffer = new Color32[width * height]; GCHandle bufferHandle = GCHandle.Alloc(buffer, GCHandleType.Pinned); try { System.IntPtr bufferPtr = Marshal.UnsafeAddrOfPinnedArrayElement(buffer, 0); if (utils.GetImageRGBA(avatarHandle, bufferPtr, (int)width * (int)height * 4)) { // Flip vertical for (int x = 0; x < width; x++) { for (int y = 0; y < height / 2; y++) { Color32 temp = buffer[x + (width * y)]; buffer[x + (width * y)] = buffer[x + (width * (height - 1 - y))]; buffer[x + (width * (height - 1 - y))] = temp; } } texture.SetPixels32(buffer); texture.Apply(); } } finally { bufferHandle.Free(); } return texture; } } return null; }
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 ); } }
/// <summary> /// Invokes LeaderboardScoresDownloaded /// </summary> /// <param name="handle"></param> /// <param name="users"></param> public void DownloadLeaderboardEntriesForUsers(LeaderboardHandle handle, SteamID[] users) { CheckIfUsable(); // We need to first convert the array of SteamID objects to a byte array byte[] rawData = NativeBuffer.ToBytes(users); using (NativeBuffer buffer = new NativeBuffer(rawData)) { // Copies the list of user ID's to unmanaged memory buffer.WriteToUnmanagedMemory(); NativeMethods.Stats_DownloadLeaderboardEntriesForUsers(handle.AsUInt64, buffer.UnmanagedMemory, users.Length); } }
public bool GetUserAchievementAndUnlockTime(SteamID steamID, string name, out bool achieved, out uint unlockTime) { CheckIfUsable(); achieved = false; unlockTime = 0; return NativeMethods.Stats_GetUserAchievementAndUnlockTime(steamID.AsUInt64, name, ref achieved, ref unlockTime); }
public bool GetUserAchievement(SteamID steamID, string name, out bool achieved) { CheckIfUsable(); achieved = false; return NativeMethods.Stats_GetUserAchievement(steamID.AsUInt64, name, ref achieved); }
public bool GetUserStat(SteamID steamID, string name, out float data) { CheckIfUsable(); data = 0; return NativeMethods.Stats_GetUserStatFloat(steamID.AsUInt64, name, ref data); }
public bool RequestLobbyData(SteamID steamIDLobby) { CheckIfUsable(); return NativeMethods.MatchMaking_RequestLobbyData(steamIDLobby.AsUInt64); }
private void CreateTradeOffer(Bot bot, GameServerRequest gsr) { float tradeValue = -1; string message = gsr.Arguments; //STEAM_0:1:42047781/2514414967/NULL/999900.00 //TOOOOOOOOO DOOOOOOOOOOOOOO string[] assetIDs = null; string[] myAssetIDs = null; string[] steamIDitems = message.Split('/'); SteamID steamid = new SteamID(steamIDitems[0]); TradeOffer to = bot.TradeOfferManager.NewOffer(steamid); GameServer gameServer = bot.Manager.GetServerByID(gsr.ServerID); if (steamIDitems[1].Length > 1 && steamIDitems[1] != "NULL") { assetIDs = steamIDitems[1].Split(','); List <long> contextId = new List <long>(); contextId.Add(2); bot.OtherGenericInventory.load((int)Games.CSGO, contextId, steamid); foreach (GenericInventory.Item item in bot.OtherGenericInventory.items.Values) { if (Array.IndexOf(assetIDs, item.assetid.ToString()) > -1) { GenericInventory.ItemDescription description = bot.OtherGenericInventory.getDescription(item.assetid); to.Items.AddTheirItem(item.appid, item.contextid, (long)item.assetid); } } bot.OtherGenericInventory.load((int)Games.TF2, contextId, steamid); foreach (GenericInventory.Item item in bot.OtherGenericInventory.items.Values) { if (Array.IndexOf(assetIDs, item.assetid.ToString()) > -1) { GenericInventory.ItemDescription description = bot.OtherGenericInventory.getDescription(item.assetid); to.Items.AddTheirItem(item.appid, item.contextid, (long)item.assetid); } } bot.OtherGenericInventory.load((int)Games.Dota2, contextId, steamid); foreach (GenericInventory.Item item in bot.OtherGenericInventory.items.Values) { if (Array.IndexOf(assetIDs, item.assetid.ToString()) > -1) { GenericInventory.ItemDescription description = bot.OtherGenericInventory.getDescription(item.assetid); to.Items.AddTheirItem(item.appid, item.contextid, (long)item.assetid); } } } if (steamIDitems[2].Length > 1 && steamIDitems[2] != "NULL") { myAssetIDs = steamIDitems[2].Split(','); List <long> contextId = new List <long>(); contextId.Add(2); bot.MyGenericInventory.load((int)Games.CSGO, contextId, steamid); foreach (GenericInventory.Item item in bot.OtherGenericInventory.items.Values) { if (Array.IndexOf(myAssetIDs, item.assetid.ToString()) > -1) { GenericInventory.ItemDescription description = bot.OtherGenericInventory.getDescription(item.assetid); to.Items.AddTheirItem(item.appid, item.contextid, (long)item.assetid); } } bot.MyGenericInventory.load((int)Games.TF2, contextId, steamid); foreach (GenericInventory.Item item in bot.OtherGenericInventory.items.Values) { if (Array.IndexOf(myAssetIDs, item.assetid.ToString()) > -1) { GenericInventory.ItemDescription description = bot.OtherGenericInventory.getDescription(item.assetid); to.Items.AddTheirItem(item.appid, item.contextid, (long)item.assetid); } } bot.MyGenericInventory.load((int)Games.Dota2, contextId, steamid); foreach (GenericInventory.Item item in bot.OtherGenericInventory.items.Values) { if (Array.IndexOf(myAssetIDs, item.assetid.ToString()) > -1) { GenericInventory.ItemDescription description = bot.OtherGenericInventory.getDescription(item.assetid); to.Items.AddTheirItem(item.appid, item.contextid, (long)item.assetid); } } } if (steamIDitems[3] != "NULL") { tradeValue = float.Parse(steamIDitems[3], CultureInfo.InvariantCulture); } string offerId; to.Send(out offerId, String.Format("\"{0}\" the {1}@{2}", gameServer.Name, DateTime.Now.ToString("dd/MM/yyyy"), DateTime.Now.ToString("HH:mm"))); if (offerId != "") { bot.Manager.Send(gsr.ServerID, gsr.ModuleID, NetworkCode.ASteambotCode.CreateTradeOffer, offerId); bot.TradeoffersGS.Add(offerId, gsr.ModuleID + "|" + tradeValue); bot.TradeOfferValue.Add(offerId, tradeValue); bot.AcceptMobileTradeConfirmation(offerId); } else { bot.Manager.Send(gsr.ServerID, gsr.ModuleID, NetworkCode.ASteambotCode.CreateTradeOffer, "-1"); } }
public BeginAuthSessionResult BeginAuthSession(System.IntPtr authTicket, int cbAuthTicket, SteamID steamID) { //CheckIfUsable(); return (BeginAuthSessionResult)NativeMethods.GameServer_BeginAuthSession(authTicket, cbAuthTicket, steamID.AsUInt64); }
private static EResult ResolveVanityURL(string input, EVanityURLType urlType, out SteamID steamID) { steamID = new SteamID(); using (dynamic steamUser = WebAPI.GetInterface("ISteamUser", Settings.Current.Steam.WebAPIKey)) { steamUser.Timeout = (int)TimeSpan.FromSeconds(5).TotalMilliseconds; KeyValue response; try { response = steamUser.ResolveVanityURL(vanityurl: input, url_type: (int)urlType); } catch (WebException) { return(EResult.Timeout); } var eResult = (EResult)response["success"].AsInteger(); if (eResult == EResult.OK) { steamID.SetFromUInt64((ulong)response["steamid"].AsLong()); } return(eResult); } }
void DumpType(object obj, TreeNode node) { Type propType = (obj != null ? obj.GetType() : null); if (obj == null) { node.Text += "<null>"; return; } if (propType != null) { if (propType.IsValueType) { node.Text += obj.ToString(); return; } else if (propType == typeof(string)) { node.Text += string.Format("\"{0}\"", obj); return; } else if (propType == typeof(SteamID)) { SteamID sId = obj as SteamID; node.Text += string.Format("{0} ({1}) ", sId.ConvertToUInt64(), sId.Render()); } else if (obj is byte[]) { byte[] data = obj as byte[]; node.Text += string.Format("byte[ {0} ]", data.Length); if (data.Length == 0) { return; } const int MaxBinLength = 400; if (data.Length > MaxBinLength) { node.Nodes.Add(string.Format("Length exceeded {0} bytes!", MaxBinLength)); return; } string strAscii = Encoding.ASCII.GetString(data).Replace("\0", "\\0"); string strUnicode = Encoding.UTF8.GetString(data).Replace("\0", "\\0"); string hexString = data.Aggregate(new StringBuilder(), (str, value) => str.Append(value.ToString("X2"))).ToString(); node.Nodes.Add(string.Format("{0}: {1}", "ASCII", strAscii)); node.Nodes.Add(string.Format("{0}: {1}", "UTF8", strUnicode)); node.Nodes.Add(string.Format("{0}: {1}", "Binary", hexString)); return; } else if (TypeIsDictionary(propType)) { IDictionary dict = obj as IDictionary; foreach (DictionaryEntry pair in dict) { TreeNode subNode = new TreeNode(string.Format( "[ {0} ]: ", pair.Key.ToString())); node.Nodes.Add(subNode); DumpType(pair.Value, subNode); } return; } else if (TypeIsArray(propType)) { Type innerType = null; int count = 0; bool truncated = false; foreach (var subObj in obj as IEnumerable) { innerType = subObj.GetType(); count++; if (count <= 100) { TreeNode subNode = new TreeNode(string.Format( "[ {0} ]: {1}", count - 1, (innerType.IsValueType ? "" : innerType.Name) )); node.Nodes.Add(subNode); DumpType(subObj, subNode); } else { truncated = true; } } if (truncated) { TreeNode truncNode = new TreeNode("Array truncated: more than 100 entries!"); node.Nodes.Add(truncNode); } node.Text += string.Format( "{0}[ {1} ]", (innerType == null ? propType.Name : innerType.Name), count ); return; } node.Text += propType.Name; } foreach (var property in obj.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance)) { var subObject = property.GetValue(obj, null); TreeNode subNode = new TreeNode(property.Name + ": "); node.Nodes.Add(subNode); DumpType(subObject, subNode); } }
public User(SteamID steamID) { this.steamID = steamID; data = new Dictionary <string, string>(); }
public UserHandler(Bot bot, SteamID sid) { Bot = bot; OtherSID = sid; GetOtherInventory(); }
/// <summary> /// Called when a chat message is sent in a chatroom /// </summary> /// <param name="chatID">The SteamID of the group chat</param> /// <param name="sender">The SteamID of the sender</param> /// <param name="message">The message sent</param> public virtual void OnChatRoomMessage(SteamID chatID, SteamID sender, string message) { }
public override bool respondToFriendMessage(SteamID userID, string message) { return(Respond(userID, userID, message, false)); }
public override bool respondToChatMessage(SteamID roomID, SteamID chatterId, string message) { return(Respond(roomID, chatterId, message, true)); }
public JKAConfig GetUserConfig(SteamID id) { if (configCache.ContainsKey(id)) { return configCache[id]; } return JKAConfig.FromSteamID(id, folderPrefix); }
public void SendUserDisconnect(SteamID steamIDUser) { //CheckIfUsable(); NativeMethods.GameServer_SendUserDisconnect(steamIDUser.AsUInt64); }
public virtual void Use(SteamID room, SteamID sender, string[] args) { Chat.Send(room, "Sorry '" + Steam.Friends.GetFriendPersonaName(sender) + "'! The command '" + args[1] + "' has no use."); }
public DailySteamMessage(DateTime when, SteamID steamId, string message) { When = when; SteamId = steamId; Message = message; }
private void AddGrid(Cheater cheater, int row) { void AddToGrid(UIElement element, int column) { this.GridCheaters.Children.Add(element); Grid.SetColumn(element, column); Grid.SetRow(element, row); } TextBox TextBoxCreate(string value) => new() { Text = value, Margin = new Thickness(5, 0, 5, 0), }; /* <Label Grid.Column="0">WhiteList</Label> * <Label Grid.Column="1">Name</Label> * <Label Grid.Column="2">Steam ID</Label> * <Label Grid.Column="3">Submitter</Label> * <Label Grid.Column="4">Cheat List</Label> * <Label Grid.Column="5">Notes</Label> * <Label Grid.Column="6">ThreatLevel</Label> * <Label Grid.Column="7"></Label>*/ BiaCheckBox wlCheckBox = new() { BoxBorderColor = new ByteColor((byte)(255 * .9), 200, 200, 200), Margin = CheckBoxThickness, }; Label lblName = new() { Content = cheater.LastKnownName, Style = TableRowLabelStyle }; Label lblSteamID = new() { Content = new SteamID(cheater.AccountID).Render(false).Replace("_", "__"), Style = TableRowLabelStyle }; TextBox txtSubmitter = TextBoxCreate(cheater.Submitter); TextBox txtCheatList = TextBoxCreate(cheater.CheatList); TextBox txtNotes = TextBoxCreate(cheater.Notes); TextBox txtThreat = TextBoxCreate(cheater.ThreatLevel.ToString()); Button btnRemove = new(); btnRemove.Content = "Remove"; AddToGrid(wlCheckBox, 0); AddToGrid(lblName, 1); AddToGrid(lblSteamID, 2); AddToGrid(txtSubmitter, 3); AddToGrid(txtCheatList, 4); AddToGrid(txtNotes, 5); AddToGrid(txtThreat, 6); AddToGrid(btnRemove, 7); btnRemove.Click += (object sender, RoutedEventArgs args) => { Cheaters.Remove(cheater); GridCheaters.Children.Remove(wlCheckBox); GridCheaters.Children.Remove(lblName); GridCheaters.Children.Remove(lblSteamID); GridCheaters.Children.Remove(txtSubmitter); GridCheaters.Children.Remove(txtCheatList); GridCheaters.Children.Remove(txtNotes); GridCheaters.Children.Remove(txtThreat); GridCheaters.Children.Remove(btnRemove); UpdateCounterLabels(); }; lblSteamID.MouseRightButtonDown += (object sender, MouseButtonEventArgs e) => { Clipboard.SetText($"{cheater.LastKnownName}, {cheater.CheatList}, {cheater.ThreatLevel}, {cheater.Notes} " + $"\nhttp://steamcommunity.com/profiles/{cheater.AccountID}"); lblSteamID.Content = "*Copied To Clipboard*"; var timer = new System.Timers.Timer(1000); timer.Elapsed += (object sender, System.Timers.ElapsedEventArgs e) => Dispatcher.Invoke(() => { lblSteamID.Content = new SteamID(cheater.AccountID).Render(false).Replace("_", "__"); timer.Dispose(); }); timer.Start(); }; lblName.MouseLeftButtonDown += (object sender, MouseButtonEventArgs e) => { try { Process.Start(new ProcessStartInfo($"http://steamcommunity.com/profiles/{cheater.AccountID}") { UseShellExecute = true }); } catch { } }; void HandleText(object sender, TextChangedEventArgs e) { cheater.CheatList = txtCheatList.Text; int.TryParse(txtThreat.Text, out int threat2); txtThreat.Text = threat2.ToString(); cheater.ThreatLevel = threat2; cheater.Submitter = string.IsNullOrEmpty(txtSubmitter.Text) ? Settings["UserNameOverride"] : txtSubmitter.Text; cheater.Notes = txtNotes.Text; Cheaters.Save(); } txtSubmitter.TextChanged += HandleText; txtCheatList.TextChanged += HandleText; txtNotes.TextChanged += HandleText; txtThreat.TextChanged += HandleText; } TextBox TextBoxCreate(string value) => new() { Text = value, Margin = new Thickness(5, 0, 5, 0), }; } }
public bool SetLinkedLobby(SteamID steamIDLobby, SteamID steamIDLobbyDependent) { CheckIfUsable(); return NativeMethods.MatchMaking_SetLobbyOwner(steamIDLobby.AsUInt64, steamIDLobbyDependent.AsUInt64); }
public override void OnNewTradeOffer(TradeOffer offer) { var escrow = Bot.GetEscrowDuration(offer.TradeOfferId); if (escrow.DaysMyEscrow != 0 || escrow.DaysTheirEscrow != 0) { doWebWithCatch(1, () => { if (offer.Decline()) { Log.Error("User has not been using the Mobile Authenticator for 7 days or has turned off trade confirmations, offer declined."); } }); } else { //Get password from file on desktop string pass = Bot.BotDBPassword; //Get items in the trade, and ID of user sending trade var theirItems = offer.Items.GetTheirItems(); var myItems = offer.Items.GetMyItems(); var userID = offer.PartnerSteamId; bool shouldDecline = false; //Check if they are trying to get items from the bot if (myItems.Count > 0 || theirItems.Count == 0) { //shouldDecline = true; Log.Error("Offer declined because the offer wasn't a gift; the user wanted items instead of giving."); } //Check to make sure all items are for CS: GO. foreach (TradeAsset item in theirItems) { if (item.AppId != 730) { shouldDecline = true; Log.Error("Offer declined because one or more items was not for CS: GO."); } } //Check if there are more than 10 items in the trade if (theirItems.Count > 10) { shouldDecline = true; Log.Error("Offer declined because there were more than 10 items in the deposit."); } if (shouldDecline) { doWebWithCatch(1, () => { if (offer.Decline()) { Log.Error("Offer declined."); } }); return; } Log.Success("Offer approved, accepting."); //Send items to server and check if all items add up to more than $1. //If they do, accept the trade. If they don't, decline the trade. string postData = "password="******"&owner=" + userID; string theirItemsJSON = JsonConvert.SerializeObject(theirItems); postData += "&items=" + theirItemsJSON; string url = Bot.BotWebsiteURL + "/php/check-items.php"; var request = (HttpWebRequest)WebRequest.Create(url); var data = Encoding.ASCII.GetBytes(postData); request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; request.ContentLength = data.Length; using (var stream = request.GetRequestStream()) { stream.Write(data, 0, data.Length); } var response = (HttpWebResponse)request.GetResponse(); var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd(); //Uncomment this line to view the response from check-items.php //Log.Success ("Response received from check-items.php: \n" + responseString); JSONClass responseJsonObj = JsonConvert.DeserializeObject <JSONClass>(responseString); if (responseJsonObj.success == 1) { //Get data array from json var jsonData = responseJsonObj.data; if (jsonData.minDeposit == 1) { doWebWithCatch(10, () => { if (offer.Accept()) { Log.Success("Offer accepted from " + userID); //Put items into the pot string urlPutItemsIn = Bot.BotWebsiteURL + "/php/deposit.php"; var requestUrlPutItemsIn = (HttpWebRequest)WebRequest.Create(urlPutItemsIn); string postDataPutItemsIn = "password="******"&owner=" + userID; postDataPutItemsIn += "&items=" + jsonData.allItems; //Log.Success (jsonData.allItems); var dataPutItemsIn = Encoding.ASCII.GetBytes(postDataPutItemsIn); requestUrlPutItemsIn.Method = "POST"; requestUrlPutItemsIn.ContentType = "application/x-www-form-urlencoded"; requestUrlPutItemsIn.ContentLength = dataPutItemsIn.Length; using (var stream = requestUrlPutItemsIn.GetRequestStream()) { stream.Write(dataPutItemsIn, 0, dataPutItemsIn.Length); } var responsePutItemsIn = (HttpWebResponse)requestUrlPutItemsIn.GetResponse(); string responsePutItemsInString = new StreamReader(responsePutItemsIn.GetResponseStream()).ReadToEnd(); //Uncomment this line to view the response from deposit.php //Log.Success ("Response received from deposit.php: " + responsePutItemsInString); JSONClass responseJsonObjPutItemsIn = JsonConvert.DeserializeObject <JSONClass>(responsePutItemsInString); jsonData = responseJsonObjPutItemsIn.data; } }); //Check if it should start the timer if (jsonData.startTimer == 1) { //Check if the timer is already running. if (!timerRunning) { timer = new System.Timers.Timer(); timer.Elapsed += new ElapsedEventHandler(timerEvent); timer.Interval = 1000; timer.Start(); timerRunning = true; } } //Check if the pot is over if (jsonData.potOver == 1) { //End the timer timerTime = 0; timer.Stop(); //Get items to give and keep, and the winner and their trade token var itemsToGive = jsonData.tradeItems; var itemsToKeep = jsonData.profitItems; string winnerSteamIDString = jsonData.winnerSteamId; SteamID winnerSteamID = new SteamID(winnerSteamIDString); string winnerTradeToken = jsonData.winnerTradeToken; Log.Success("Winner steam id: " + winnerSteamIDString + ", token: " + winnerTradeToken); //Get bot's inventory json string botInvUrl = "http://steamcommunity.com/profiles/" + Bot.SteamUser.SteamID.ConvertToUInt64() + "/inventory/json/730/2"; var botInvRequest = (HttpWebRequest)WebRequest.Create(botInvUrl); var botInvResponse = (HttpWebResponse)botInvRequest.GetResponse(); string botInvString = new StreamReader(botInvResponse.GetResponseStream()).ReadToEnd(); BotInventory botInventory = JsonConvert.DeserializeObject <BotInventory>(botInvString); if (botInventory.success != true) { Log.Error("An error occured while fetching the bot's inventory."); return; } var rgInventory = botInventory.rgInventory; //Create trade offer for the winner var winnerTradeOffer = Bot.NewTradeOffer(winnerSteamID); //Loop through all winner's items and add them to trade List <long> alreadyAddedToWinnerTrade = new List <long>(); foreach (CSGOItemFromWeb item in itemsToGive) { long classId = item.classId, instanceId = item.instanceId; //Loop through all inventory items and find the asset id for the item long assetId = 0; foreach (var inventoryItem in rgInventory) { var value = inventoryItem.Value; long tAssetId = value.id, tClassId = value.classid, tInstanceId = value.instanceid; if (tClassId == classId && tInstanceId == instanceId) { //Check if this assetId has already been added to the trade if (alreadyAddedToWinnerTrade.Contains(tAssetId)) { continue; //This is for when there are 2 of the same weapon, but they have different assetIds } assetId = tAssetId; break; } } //Log.Success ("Adding item to winner trade offer. Asset ID: " + assetId); winnerTradeOffer.Items.AddMyItem(730, 2, assetId, 1); alreadyAddedToWinnerTrade.Add(assetId); } //Send trade offer to winner if (itemsToGive.Count > 0) { string winnerTradeOfferId, winnerMessage = "Congratulations, you have won on " + Bot.BotWebsiteName + "! Here are your items."; doWebWithCatch(-1, () => { if (winnerTradeOffer.SendWithToken(out winnerTradeOfferId, winnerTradeToken, winnerMessage)) { Bot.AcceptAllMobileTradeConfirmations(); Log.Success("Offer sent to winner."); } }); } else { Log.Info("No items to give... strange"); } //Now, send all of the profit items to my own account //Put your own Steam ID here var profitTradeOffer = Bot.NewTradeOffer(new SteamID(Bot.ProfitAdmin)); //Loop through all profit items and add them to trade List <long> alreadyAddedToProfitTrade = new List <long>(); foreach (CSGOItemFromWeb item in itemsToKeep) { long classId = item.classId, instanceId = item.instanceId; //Loop through all inventory items and find the asset id for the item long assetId = 0; foreach (var inventoryItem in rgInventory) { var value = inventoryItem.Value; long tAssetId = value.id, tClassId = value.classid, tInstanceId = value.instanceid; if (tClassId == classId && tInstanceId == instanceId) { //Check if this assetId has already been added to the trade if (alreadyAddedToProfitTrade.Contains(tAssetId)) { continue; //This is for when there are 2 of the same weapon, but they have different assetIds } assetId = tAssetId; break; } } //Log.Success ("Adding item to winner trade offer. Asset ID: " + assetId); profitTradeOffer.Items.AddMyItem(730, 2, assetId, 1); alreadyAddedToProfitTrade.Add(assetId); } //Send trade offer to myself with profit items Log.Success(itemsToKeep.Count + ""); if (itemsToKeep.Count > 0) { string profitTradeOfferId, profitMessage = "Here are the profit items from the round."; doWebWithCatch(10, () => { if (profitTradeOffer.Send(out profitTradeOfferId, profitMessage)) { //Don't need the token because I am friends with the bot. Bot.AcceptAllMobileTradeConfirmations(); Log.Success("Profit trade offer sent."); } }); } } else { //Only try this one time, because even if it gives an error, it still gets declined. doWebWithCatch(1, () => { if (offer.Decline()) { Log.Error("Server deposit request failed, declining trade. Error message:\n" + responseJsonObj.errMsg); } }); } } else { //Only try this one time, because even if it gives an error, it still gets declined. doWebWithCatch(1, () => { if (offer.Decline()) { Log.Error("Minimum deposit not reached, offer declined."); } }); } } } }
/// <summary> /// Invokes UserStatsReceived /// </summary> /// <param name="steamID"></param> public void RequestUserStats(SteamID steamID) { CheckIfUsable(); NativeMethods.Stats_RequestUserStats(steamID.AsUInt64); }
private void timerEvent(object CancellationTokenSource, ElapsedEventArgs e) { timerTime++; //Check if the timer is at 2 minutes if (timerTime >= 120) { //If the timer is done, stop the timer and call to server to end the round/pick a winner timer.Stop(); timerTime = 0; timerRunning = false; //Get password from file on desktop string pass = Bot.BotDBPassword; string urlTimerEnd = Bot.BotWebsiteURL + "/php/timer-end.php"; var requestUrlTimerEnd = (HttpWebRequest)WebRequest.Create(urlTimerEnd); string postDataTimerEnd = "password="******"POST"; requestUrlTimerEnd.ContentType = "application/x-www-form-urlencoded"; requestUrlTimerEnd.ContentLength = dataTimerEnd.Length; using (var stream = requestUrlTimerEnd.GetRequestStream()) { stream.Write(dataTimerEnd, 0, dataTimerEnd.Length); } var responseTimerEnd = (HttpWebResponse)requestUrlTimerEnd.GetResponse(); string responseTimerEndString = new StreamReader(responseTimerEnd.GetResponseStream()).ReadToEnd(); //Uncomment this line to print out the response from timer-end.php //Log.Success ("Response received from timer-end.php: " + responseTimerEndString); JSONClass timerEndJsonObj = JsonConvert.DeserializeObject <JSONClass>(responseTimerEndString); if (timerEndJsonObj.success != 1) { Log.Error("Server request failed. Error message:\n" + timerEndJsonObj.errMsg); return; } Data timerEndData = timerEndJsonObj.data; //Get items to give and keep, and the winner and their trade token var itemsToGive = timerEndData.tradeItems; var itemsToKeep = timerEndData.profitItems; string winnerSteamIDString = timerEndData.winnerSteamId; SteamID winnerSteamID = new SteamID(winnerSteamIDString); string winnerTradeToken = timerEndData.winnerTradeToken; Log.Success("Winner steam id: " + winnerSteamIDString + ", token: " + winnerTradeToken); //Get bot's inventory json string botInvUrl = "http://steamcommunity.com/profiles/" + Bot.SteamUser.SteamID.ConvertToUInt64() + "/inventory/json/730/2"; var botInvRequest = (HttpWebRequest)WebRequest.Create(botInvUrl); var botInvResponse = (HttpWebResponse)botInvRequest.GetResponse(); string botInvString = new StreamReader(botInvResponse.GetResponseStream()).ReadToEnd(); BotInventory botInventory = JsonConvert.DeserializeObject <BotInventory>(botInvString); if (botInventory.success != true) { Log.Error("An error occured while fetching the bot's inventory."); return; } var rgInventory = botInventory.rgInventory; //Create trade offer for the winner var winnerTradeOffer = Bot.NewTradeOffer(winnerSteamID); //Loop through all winner's items and add them to trade List <long> alreadyAddedToWinnerTrade = new List <long>(); foreach (CSGOItemFromWeb item in itemsToGive) { long classId = item.classId, instanceId = item.instanceId; //Loop through all inventory items and find the asset id for the item long assetId = 0; foreach (var inventoryItem in rgInventory) { var value = inventoryItem.Value; long tAssetId = value.id, tClassId = value.classid, tInstanceId = value.instanceid; if (tClassId == classId && tInstanceId == instanceId) { //Check if this assetId has already been added to the trade if (alreadyAddedToWinnerTrade.Contains(tAssetId)) { continue; //This is for when there are 2 of the same weapon, but they have different assetIds } assetId = tAssetId; break; } } //Log.Success ("Adding item to winner trade offer. Asset ID: " + assetId); winnerTradeOffer.Items.AddMyItem(730, 2, assetId, 1); alreadyAddedToWinnerTrade.Add(assetId); } //Send trade offer to winner if (itemsToGive.Count > 0) { string winnerTradeOfferId, winnerMessage = "Congratulations, you have won on " + Bot.BotWebsiteName + "! Here are your items."; doWebWithCatch(-1, () => { winnerTradeOffer.SendWithToken(out winnerTradeOfferId, winnerTradeToken, winnerMessage); }); Bot.AcceptAllMobileTradeConfirmations(); Log.Success("Offer sent to winner."); } else { Log.Info("No items to give... strange"); } //Now, send all of the profit items to my own account var profitTradeOffer = Bot.NewTradeOffer(new SteamID(Bot.ProfitAdmin)); //Loop through all profit items and add them to trade List <long> alreadyAddedToProfitTrade = new List <long>(); foreach (CSGOItemFromWeb item in itemsToKeep) { long classId = item.classId, instanceId = item.instanceId; //Loop through all inventory items and find the asset id for the item long assetId = 0; foreach (var inventoryItem in rgInventory) { var value = inventoryItem.Value; long tAssetId = value.id, tClassId = value.classid, tInstanceId = value.instanceid; if (tClassId == classId && tInstanceId == instanceId) { //Check if this assetId has already been added to the trade if (alreadyAddedToProfitTrade.Contains(tAssetId)) { continue; //This is for when there are 2 of the same weapon, but they have different assetIds } assetId = tAssetId; break; } } //Log.Success ("Adding item to winner trade offer. Asset ID: " + assetId); profitTradeOffer.Items.AddMyItem(730, 2, assetId, 1); alreadyAddedToProfitTrade.Add(assetId); } //Send trade offer to myself with profit items if (itemsToKeep.Count > 0) { string profitTradeOfferId, profitMessage = "Here are the profit items from the round."; doWebWithCatch(10, () => { profitTradeOffer.Send(out profitTradeOfferId, profitMessage); }); Bot.AcceptAllMobileTradeConfirmations(); Log.Success("Profit offer sent."); } } }
public StatsGetUserStatResult GetUserStatFloat(SteamID steamID, string name) { StatsGetUserStatResult result = new StatsGetUserStatResult(); result.result = GetUserStat(steamID, name, out result.floatDataSender); return result; }
public override void Use(SteamID Room, SteamID Sender, string[] args) { Chat.Send(Room, Steam.Friends.GetFriendPersonaName(Sender) + ": " + Sender.AccountID.ToString()); }
public StatsGetUserAchievementResult GetUserAchievement(SteamID steamID, string name) { StatsGetUserAchievementResult result = new StatsGetUserAchievementResult(); result.result = GetUserAchievement(steamID, name, out result.sender); return result; }
public TradeOfferUserHandler(Bot bot, SteamID sid) : base(bot, sid) { }
public StatsGetUserAchievementAndUnlockTimeResult GetUserAchievementAndUnlockTime(SteamID steamID, string name) { StatsGetUserAchievementAndUnlockTimeResult result = new StatsGetUserAchievementAndUnlockTimeResult(); result.result = GetUserAchievementAndUnlockTime(steamID, name, out result.achievedSender, out result.unlockTimeSender); return result; }
public override void OnChatRoomMessage(SteamID chatID, SteamID sender, string message) { Log.Info(Bot.SteamFriends.GetFriendPersonaName(sender) + ": " + message); base.OnChatRoomMessage(chatID, sender, message); }
public SimpleUserHandler(Bot bot, SteamID sid) : base(bot, sid) { }
public UserHasLicenseForAppResult UserHasLicenseForApp(SteamID steamID, AppID appID) { //CheckIfUsable(); int tempreturn = NativeMethods.GameServer_UserHasLicenseForApp(steamID.AsUInt64, appID.AsUInt32); return (UserHasLicenseForAppResult)tempreturn; }
public bool SendUserConnectAndAuthenticate(uint ipClient, byte[] authenticationBlob, out SteamID steamIDUser) { //CheckIfUsable(); using (NativeBuffer blobBuffer = new NativeBuffer(authenticationBlob)) { blobBuffer.WriteToUnmanagedMemory(); ulong rawCreator = 0; bool result = NativeMethods.GameServer_SendUserConnectAndAuthenticate(ipClient, blobBuffer.UnmanagedMemory, (uint)blobBuffer.UnmanagedMemory, ref rawCreator); steamIDUser = new SteamID(rawCreator); return result; } }
public void AssociateWithClan(SteamID steamIDClan) { //CheckIfUsable(); NativeMethods.GameServer_AssociateWithClan(steamIDClan.AsUInt64); }
public bool UpdateUserData(SteamID steamIDUser, string playerName, uint score) { //CheckIfUsable(); return NativeMethods.GameServer_UpdateUserData(steamIDUser.AsUInt64, playerName, score); }
void HandleLogOnResponse( IPacketMsg packetMsg ) { if ( !packetMsg.IsProto ) { DebugLog.WriteLine( "CMClient", "Got non-proto logon response, this is indicative of no logon attempt after connecting." ); return; } var logonResp = new ClientMsgProtobuf<CMsgClientLogonResponse>( packetMsg ); if ( logonResp.Body.eresult == ( int )EResult.OK ) { SessionID = logonResp.ProtoHeader.client_sessionid; SteamID = logonResp.ProtoHeader.steamid; int hbDelay = logonResp.Body.out_of_game_heartbeat_seconds; // restart heartbeat heartBeatFunc.Stop(); heartBeatFunc.Delay = TimeSpan.FromSeconds( hbDelay ); heartBeatFunc.Start(); } }
public void EndAuthSession(SteamID steamID) { //CheckIfUsable(); NativeMethods.GameServer_EndAuthSession(steamID.AsUInt64); }
public override void Use(SteamID room, SteamID Sender, string[] args) { Chat.Send(room, "The time is: " + DateTime.UtcNow.ToShortTimeString() + " (UTC)"); }
public bool RequestUserGroupStatus(SteamID steamIDUser, SteamID steamIDGroup) { //CheckIfUsable(); return NativeMethods.GameServer_RequestUserGroupStatus(steamIDUser.AsUInt64, steamIDGroup.AsUInt64); }
public bool SetLobbyJoinable(SteamID steamIDLobby, bool lobbyJoinable) { CheckIfUsable(); return NativeMethods.MatchMaking_SetLobbyJoinable(steamIDLobby.AsUInt64, lobbyJoinable); }
public void ComputeNewPlayerCompatibility(SteamID steamIDNewPlayer) { //CheckIfUsable(); NativeMethods.GameServer_ComputeNewPlayerCompatibility(steamIDNewPlayer.AsUInt64); }
public SteamID GetLobbyOwner(SteamID steamIDLobby) { CheckIfUsable(); return new SteamID(NativeMethods.MatchMaking_GetLobbyOwner(steamIDLobby.AsUInt64)); }
void HandleLoggedOff( IPacketMsg packetMsg ) { SessionID = null; SteamID = null; heartBeatFunc.Stop(); }
public bool SetLobbyOwner(SteamID steamIDLobby, SteamID steamIDNewOwner) { CheckIfUsable(); return NativeMethods.MatchMaking_SetLobbyOwner(steamIDLobby.AsUInt64, steamIDNewOwner.AsUInt64); }