using System; using System.Net; using System.Threading; using SteamKit2; using SteamTrade; using System.Collections.Generic; using System.Linq; namespace SteamBot { public class ScrapBankUserHandler : UserHandler { public int invScrap = 0; public int freeInvSlots = 0; public int offeredScrap = 0; public int offeredItems = 0; public int invalidItems = 0; public int offeredBuds = 0; public bool isDebug = false; public string perks = ""; public string requestedPerks = ""; public ScrapBankUserHandler(Bot bot, SteamID sid) : base(bot, sid) { Bot.GetInventory(); Bot.GetOtherInventory(OtherSID); } public void TellAdmins(string message) { foreach (ulong adminID in Bot.Admins) { Bot.SteamFriends.SendChatMessage(adminID, EChatEntryType.ChatMsg, message); } Log.Success("Told all admins: " + message); } #region Overrides of UserHandler public override void OnLoginCompleted() { if (!isDebug) { Bot.SteamFriends.SetPersonaState(EPersonaState.LookingToTrade); Thread RConThread = new Thread(() => RunRCon(new string[] { "\n say Bot Loaded!\n" + "say type !donate To donate for special perks, add the bot and trade him for more info!\n" + "sm_csay Bot is online and ready to take donations! type !donate to donate for perks" })); TellAdmins("I am now online master's slaving for you... <3 I will do my best to not fuck up anymore!"); Bot.SetGamePlaying(440); RConThread.Start(); } else { TellAdmins("Bot started in debug mode. test, and have your way with me as you wish masters... I cannot disobey <3"); Bot.SteamFriends.SetPersonaState(EPersonaState.Busy); Bot.SetGamePlaying(440); Bot.SteamFriends.SetPersonaName("[Debug Mode]" + Bot.SteamFriends.GetPersonaName()); } } public override bool OnFriendAdd() { // if the other is an admin then accept add if (IsAdmin) return true; Log.Warn("Random SteamID: " + Bot.SteamFriends.GetFriendPersonaName(OtherSID) + " (" + OtherSID + ")" + " tried to add the bot as a friend!"); TellAdmins("Random SteamID: " + Bot.SteamFriends.GetFriendPersonaName(OtherSID) + " (" + OtherSID + ")" + " tried to add the bot as a friend!"); Bot.SteamFriends.SendChatMessage(OtherSID, EChatEntryType.ChatMsg, "Heya! Thanks for adding me, I assume you added me to donate? If so send me a trade or say starttrade in the chat! and if my owner stopped being lazy you can also type help for more info! :D"); return true; } public override void OnMessage(string message, EChatEntryType type) { Log.Success(Bot.SteamFriends.GetFriendPersonaName(OtherSID) + " said: " + message); Bot.SteamFriends.SendChatMessage(76561198023897791, type, Bot.SteamFriends.GetFriendPersonaName(OtherSID) + " said: " + message); if (OtherSID == 0) { Bot.SteamFriends.SendChatMessage(OtherSID, type, "Sorry you did something horrible to me somehow and now you are banned, good job."); } else { if (message == "smd" || message == "Suck my dick" || message == "suck my dick") { Bot.SteamFriends.SendChatMessage(OtherSID, type, "*Sucks " + Bot.SteamFriends.GetFriendPersonaName(OtherSID) + "'s dick*"); } else if (message == ":3") { Bot.SteamFriends.SendChatMessage(OtherSID, type, ":3"); } else if (message == "c:" || message == "C:") { Bot.SteamFriends.SendChatMessage(OtherSID, type, "c:"); } else if (message == "*trips and accidentally masturbates*") { if (IsAdmin) { Bot.SteamFriends.SendChatMessage(OtherSID, type, "I assume you want help with that master?"); } else { Bot.SteamFriends.SendChatMessage(OtherSID, type, "Eh, I only help my masters with that :T sorry"); } } else if (message == "What's up?" || message == "what up?" || message == "how's it going?" || message == "how are you?") { Bot.SteamFriends.SendChatMessage(OtherSID, type, "I am good " + Bot.SteamFriends.GetFriendPersonaName(OtherSID) + ". How are you?"); } else if (message == "I am good" || message == "good" || message == "lovely") { Bot.SteamFriends.SendChatMessage(OtherSID, type, "Good to hear, now lets get to buisness... you gunna donate? XD Nah I'm joking you don't have to donate, and you can keep me added... But just FYI the owner is a huge dick butt and deletes all my friends once a week :s"); } else if (message == "hi" || message == "hello" || message == "Hi." || message == "Hello." || message == "hi." || message == "hello." || message == "Hi" || message == "Hello" || message == "Hey" || message == "Hey." || message == "hey" || message == "hey.") { Bot.SteamFriends.SendChatMessage(OtherSID, type, "Hey, what's up " + Bot.SteamFriends.GetFriendPersonaName(OtherSID) + "?"); } else if (message == "nothing much" || message == "Nothing much." || message == "nothing much." || message == "Nothing much") { Bot.SteamFriends.SendChatMessage(OtherSID, type, "Same, besides the fact I am slaving over trading for my owner :s I can't wait to get a new job"); } else if (message == "thank you" || message == "Thank you" || message == "Thank you." || message == "thank you.") { Bot.SteamFriends.SendChatMessage(OtherSID, type, "You are most welcome and a special thanks to you, and all donators and staff!"); } else if (IsAdmin) { if (message == "starttrade") { Bot.SteamFriends.SendChatMessage(OtherSID, type, "Trading you..."); Bot.OpenTrade(OtherSID); } else if (message == "launchtf") { Bot.SetGamePlaying(440); TellAdmins("I am now playing TF2"); } else if (message == "launchudk") { Bot.SetGamePlaying(13260); TellAdmins("I am not sure of this name but the ID of the game I am playing now is " + Bot.CurrentGame); } else if (message == "launchas") { Bot.SetGamePlaying(630); TellAdmins("I am now playing Alien Swarm"); } else if (message.Split(' ')[0] == "launchgame") { Bot.SetGamePlaying(Convert.ToInt32(message.Split(' ')[1])); TellAdmins("I am not sure of this name but the ID of the game I am playing now is " + Bot.CurrentGame); } else if (message == "<3") { Bot.SteamFriends.SendChatMessage(OtherSID, type, "I love you so much master *cuddles " + Bot.SteamFriends.GetFriendPersonaName(OtherSID) + " tightly* I love you master <3"); } else if (message == "closegame") { Bot.SetGamePlaying(0); TellAdmins("closed my game"); } else if (message == "yes" || message == "Yes" || message == "Yes." || message == "yes.") { Bot.SteamFriends.SendChatMessage(OtherSID, type, "*helps " + Bot.SteamFriends.GetFriendPersonaName(OtherSID) + " masturbate*"); } else if (message == "no" || message == "no." || message == "No" || message == "No.") { Bot.SteamFriends.SendChatMessage(OtherSID, type, "Oh okay sorry to bother you master, the least I can do is help you up. *helps " + Bot.SteamFriends.GetFriendPersonaName(OtherSID) + " up off the floor"); } else if (message == "canceltrade") { if (Bot.CurrentTrade != null) { Trade.CancelTrade(); Bot.SteamFriends.SendChatMessage(OtherSID, type, "Successfully cancelled the trade!"); } else { Bot.SteamFriends.SendChatMessage(OtherSID, type, "I am not currently in a trade, so I can't say anything in it!"); } } else if (message.Split(' ')[0] == "saytrade") { if (Bot.CurrentTrade != null) { Trade.SendMessage(message.Substring(message.Split(' ')[0].Length + 1)); Bot.SteamFriends.SendChatMessage(OtherSID, type, "Successfully sent the message!"); } else { Bot.SteamFriends.SendChatMessage(OtherSID, type, "I am not currently in a trade, so I can't say anything in it!"); } } else if (message.Split(' ')[0] == "sayfriends") { for (int i = 0; i < Bot.SteamFriends.GetFriendCount(); i++) { Bot.SteamFriends.SendChatMessage(Bot.SteamFriends.GetFriendByIndex(i), type, message.Substring(message.Split(' ')[0].Length + 1)); } } else if (message == "listfriends") { string friends = "\nFriends:"; for (int i = 0; i < Bot.SteamFriends.GetFriendCount(); i++) { friends += "\n" + i + ": " + Bot.SteamFriends.GetFriendPersonaName(Bot.SteamFriends.GetFriendByIndex(i)) + " (" + Bot.SteamFriends.GetFriendByIndex(i).ToString() + ")"; } Bot.SteamFriends.SendChatMessage(OtherSID, type, friends); } else if (message.Split(' ')[0] == "starttradewith") { if (Bot.CurrentTrade != null) { Bot.SteamFriends.SendChatMessage(OtherSID, type, "already in a trade, cannot send"); Log.Error("already in a trade, cannot send"); } else { SteamKit2.SteamID friend = Bot.SteamFriends.GetFriendByIndex(Convert.ToInt32(message.Split(' ')[1])); Bot.OpenTrade(friend); Log.Success("sent a trade request to " + Bot.SteamFriends.GetFriendPersonaName(friend)); } } else if (message.Split(' ')[0] == "sayfriend") { SteamKit2.SteamID friend = Bot.SteamFriends.GetFriendByIndex(Convert.ToInt32(message.Split(' ')[1])); string messageToSend = message.Substring(message.Split(' ')[0].Length + message.Split(' ')[1].Length + 2); Bot.SteamFriends.SendChatMessage(friend, EChatEntryType.ChatMsg, messageToSend); Log.Success("Told " + Bot.SteamFriends.GetFriendPersonaName(friend) + ": " + messageToSend); } else if (message == "removeall") { for (int i = 0; i < Bot.SteamFriends.GetFriendCount(); i++) { if (!Bot.Admins.Contains(Bot.SteamFriends.GetFriendByIndex(i))) { Bot.SteamFriends.RemoveFriend(Bot.SteamFriends.GetFriendByIndex(i)); } } TellAdmins("All friends removed!"); } else if (message.ToLower().Split(' ')[0] == "additem") { if (Bot.CurrentTrade != null) { int itemID = Convert.ToInt32(message.Split(' ')[1]); Trade.SendMessage("Adding item with defindex " + itemID + "..."); Trade.AddItemByDefindex(itemID); Trade.SendMessage("Added item with defindex " + itemID + "!"); Log.Success("Added the item with defindex " + itemID); return; } else { Log.Error("not in a trade cannot add item"); Bot.SteamFriends.SendChatMessage(OtherSID, type, "I cannot add an item when not in a trade :T"); } } else if (message == "accepttrade") { Trade.SetReady(true); Trade.AcceptTrade(); } else if (message == "help") { Bot.SteamFriends.SendChatMessage(OtherSID, type, "\nCommand are:\n" + "starttrade - Start a trade\ns" + "launchtf - Launch TF2\n" + "launchudk - Launch UDK\n" + "launchas - Launch Alien Swarm\n" + "launchgame [appid] - Launch game with appid\n" + "closegame - Close running game\n" + "canceltrade - Cancel an ongoing trade\n" + "saytrade [message] - Send a message to the trade\n" + "sayfriends [message] - Send a message to all friends\n" + "sayfriend [friend] [message] - Send a message to a friend with the given id from listfriends\n" + "removeall - Deletes all friends excluding admins\n" + "starttradewith [friend] - send a trade request to a specific friend\n" + "additem [defindex] - Forces me to add an item from my inventory (list of deindexes here) www.wiki.alliedmods.net/Team_Fortress_2_Item_Definition_Indexes\n" + "accepttrade - forces me to accept anyones trade... Please do not steal from me :s\n" + "listfriends - List all friends" ); } else { Bot.SteamFriends.SendChatMessage(OtherSID, type, "\nInvalid command! Valid commands:\n" + "starttrade - Start a trade\ns" + "launchtf - Launch TF2\n" + "launchudk - Launch UDK\n" + "launchas - Launch Alien Swarm\n" + "launchgame [appid] - Launch game with appid\n" + "closegame - Close running game\n" + "canceltrade - Cancel an ongoing trade\n" + "saytrade [message] - Send a message to the trade\n" + "sayfriends [message] - Send a message to all friends\n" + "sayfriend [friend] [message] - Send a message to a friend with the given id from listfriends\n" + "removeall - Deletes all friends excluding admins\n" + "starttradewith [friend] - send a trade request to a specific friend\n" + "additem [defindex] - Forces me to add an item from my inventory (list of deindexes here) www.wiki.alliedmods.net/Team_Fortress_2_Item_Definition_Indexes\n" + "accepttrade - forces me to accept anyones trade... Please do not steal from me :s\n" + "listfriends - List all friends" ); } } else if (!IsAdmin) { if (message == "starttrade") { Bot.SteamFriends.SendChatMessage(OtherSID, type, "Trading you..."); Bot.OpenTrade(OtherSID); } else if (message == "<3") { Bot.SteamFriends.SendChatMessage(OtherSID, type, "I love you so much " + Bot.SteamFriends.GetFriendPersonaName(OtherSID) + " *cuddles you tightly* <3"); } else if (message == "help") { Bot.SteamFriends.SendChatMessage(OtherSID, type, "What do you need help with?\n" + "say starttrade to start a trade\n" + "say 1 for prices\n" + "say 2 for how to use me and how I work\n" + "say 3 for the link on who created me\n" + "say 4 to tell us about bugs with the bot\n" + "Oh and I do know some chat commands but not much so uh... Yea :T" ); } else if (message == "1") { Bot.SteamFriends.SendChatMessage(OtherSID, type, "Prices currently are, Reservation slot 1 key | perk a\n" + "!robot 3 ref for life | perk o \n" + "!unusual 1 key 1 ref for life | perk p\n" + "!resizeme & resizemyhead 2 keys for life | perk r\n" + "!saveloc & !teleport 1 key 2 ref for life | perk q\n" + "All current and soon to come perks, 1 bud for life! | perk all\n" + "we also take key's in place of 6.66 ref, craft hats in place of 1 ref, and buds in place of 16 keys | We also accept weapons as half a scrap each!" ); } else if (message == "2") { Bot.SteamFriends.SendChatMessage(OtherSID, type, "How it works: DO STEPS IN ORDER OR IT WON'T WORK RIGHT! \n" + "step 1: Put up your items worth the perk (prices will be in trade chat)\n" + "step 2: Type perk a or perk o in the trade chat, you know whatever perk you want (the perk letter than it goes with will be in trade chat also)\n" + "step 3: Make sure it says you you are getting your perks it should say something like you have enough to buy perk ao or perk a or something just to verify that you are paying enough... \n" + "Pay attention to the trade chat! That is very important! He tells you a lot of important info!\n" + "Post on www.steamcommunity.com/groups/mercilessmercinaries/discussions/0/630802344474137391/ to let us know about bugs!"); } else if (message == "3") { Bot.SteamFriends.SendChatMessage(OtherSID, type, "www.steamcommunity.com/id/kittycatdanceparty/ & www.steamcommunity.com/profiles/76561198034518769/ but KittyCatDanceParty is my owner"); Bot.SteamFriends.SendChatMessage(76561198023897791, type, "Oh my glob someone asked who you were, you're so famous :P"); } else if (message == "4") { Bot.SteamFriends.SendChatMessage(OtherSID, type, "post bugs here www.steamcommunity.com/groups/mercilessmercinaries/discussions/0/630802344474137391/"); } else Bot.SteamFriends.SendChatMessage(OtherSID, type, Bot.ChatResponse); //TellAdmins(Bot.SteamFriends.GetFriendPersonaName(OtherSID) + "(" + OtherSID + ")" + " said to the bot: " + message); } } } public override bool OnTradeRequest() { if (OtherSID == 0) { Bot.SteamFriends.SendChatMessage(OtherSID, EChatEntryType.ChatMsg, "Sorry you did something bad to me some how and now you cannot trade me or talk to me :T sorry."); Log.Success("banned user " + Bot.SteamFriends.GetFriendPersonaName(OtherSID) + " tried to trade the bot"); return false; } else { if (!IsAdmin) { Bot.SteamFriends.SendChatMessage(OtherSID, EChatEntryType.ChatMsg, "I will tell you prices in the trade chat please look there when you get in it!"); TellAdmins(Bot.SteamFriends.GetFriendPersonaName(OtherSID) + "(" + OtherSID + ")" + " Sent a trade request to the bot"); } if (IsAdmin) return true; //Bot.SteamFriends.SendChatMessage (OtherSID, EChatEntryType.ChatMsg, "Sorry, but only my owners may trade with me. I will not accept this trade."); if (isDebug) { Bot.SteamFriends.SendChatMessage(OtherSID, EChatEntryType.ChatMsg, "Sorry, but the bot is currently in debug mode, most likely I forgot to turn it off, just incase I did forget you can contact me at www.steamcommunity.com/id/kittycatdanceparty, until I turn debug mode off, you are not able to trade it at this time."); return false; } return true; } } public override void OnTradeError(string error) { Log.Error(error); Bot.SteamFriends.SetPersonaState(EPersonaState.LookingToTrade); } public override void OnTradeTimeout() { Log.Warn("Trade timed out."); Bot.SteamFriends.SetPersonaState(EPersonaState.LookingToTrade); } public override void OnTradeInit() { invScrap = 0; freeInvSlots = 0; offeredScrap = 0; offeredItems = 0; invalidItems = 0; offeredBuds = 0; perks = ""; requestedPerks = ""; if (IsAdmin) { Bot.SteamFriends.SetPersonaState(EPersonaState.Busy); Bot.SteamFriends.SendChatMessage(OtherSID, EChatEntryType.ChatMsg, "I will tell you commands in the trade chat please be patient for the trade to load my masters <3"); Trade.SendMessage("Say addmetal to add all metal \n" + "additem (ITEMID) to add specific items \n" + "addallitem (ITEMID) to add all specific items"); } else { Bot.SteamFriends.SetPersonaState(EPersonaState.Busy); freeInvSlots = 0; offeredItems = 0; perks = ""; Bot.GetInventory(); Bot.GetOtherInventory(OtherSID); Trade.SendMessage("Loading inventory..."); freeInvSlots = Convert.ToInt32(Trade.MyInventory.NumSlots) - Trade.MyInventory.Items.Length; Trade.SendMessage("I can accept " + freeInvSlots + " items!"); Bot.SteamFriends.SendChatMessage(OtherSID, EChatEntryType.ChatMsg, "How it works: DO STEPS IN ORDER OR IT WON'T WORK RIGHT! \n" + "step 1: Put up your items worth the perk (prices will be in trade chat)\n" + "step 2: Type perk a or perk o in the trade chat, you know whatever perk you want (the perk letter than it goes with will be in trade chat also)\n" + "step 3: Make sure it says you you are getting your perks it should say something like you have enough to buy perk ao or perk a or something just to verify that you are paying enough... \n" + "Pay attention to the trade chat! That is very important! He tells you a lot of important info!\n" + "Post on www.steamcommunity.com/id/kittycatdanceparty profile or add him to tell him about bugs!"); //Bot.SteamFriends.SendChatMessage(OtherSID, EChatEntryType.ChatMsg, "Okay donations work differently now! Now you put the items up in the trade worth the perk you want then say in trade chat the perk you want so like for !robot you would say perk o. Also you can buy more than 1 perk at a time just say perk a then you would say perk o then perk p... ect... do not say perk aop that won't work. Not that complicated but if you have question post them on www.steamcommunity.com/id/kittycatdanceparty wall and I will get back to you. :D"); Trade.SendMessage("I think if you buy perks without perk a you do NOT get the donator tag... I think I fixed it but idk, just don't freak out if you don't have the donator tag, you will still have the perks/n"+ "Prices currently are, Reservation slot 1 key | perk a\n" + "!robot 3 ref for life | perk o \n" + "!unusual 1 key 1 ref for life | perk p\n" + "!resizeme & resizemyhead 2 keys for life | perk r\n" + "!saveloc & !teleport 1 key 2 ref for life | perk q\n" + "All current and soon to come perks, 1 bud for life! | perk all\n" + "we also take key's in place of 6.66 ref, craft hats in place of 1 ref, and buds in place of 16 keys | We also accept weapons as half a scrap each!" ); } } public override void OnTradeAddItem(Schema.Item schemaItem, Inventory.Item inventoryItem) { Log.Success("User added " + schemaItem.Name); Log.Success("HolidayRestriction: \"" + schemaItem.HolidayRestriction + "\""); offeredItems += 1; Validate(); } public override void OnTradeRemoveItem(Schema.Item schemaItem, Inventory.Item inventoryItem) { Log.Warn("User removed " + schemaItem.Name); offeredItems -= 1; Validate(); } public override void OnTradeMessage(string message) { if (IsAdmin) { if (message.ToLower() == "addall") { Trade.SendMessage("Adding all items..."); Bot.GetInventory(); Inventory.Item[] inventory = Bot.MyInventory.Items; foreach (Inventory.Item item in inventory) { if (item != null && !item.IsNotTradeable) { Trade.AddItem(item.Id); } } Trade.SendMessage("Added all items!"); return; } else if (message.ToLower().Split(' ')[0] == "additem") { if (message.Split(' ').Length != 2) { Trade.SendMessage("You must tell me the item ID you want me to add!"); return; } int itemID = Convert.ToInt32(message.Split(' ')[1]); Trade.SendMessage("Adding item with defindex " + itemID + "..."); Trade.AddItemByDefindex(itemID); Trade.SendMessage("Added item with defindex " + itemID + "!"); return; } else if (message.ToLower().Split(' ')[0] == "addallitem") { if (message.Split(' ').Length != 2) { Trade.SendMessage("You must tell me the item ID you want me to add!"); return; } int itemID = Convert.ToInt32(message.Split(' ')[1]); Trade.SendMessage("Adding all items with defindex " + itemID + "..."); Trade.AddAllItemsByDefindex(itemID); Trade.SendMessage("Added all items with defindex " + itemID + "!"); return; } else if (message.ToLower() == "removeall") { Trade.SendMessage("Removing all items..."); Trade.RemoveAllItems(); Trade.SendMessage("Removed all items!"); return; } else if (message.ToLower() == "addmetal") { int scrap = (5000); int rec = (5001); int refined = (5002); Trade.SendMessage("Adding all metal"); Trade.AddAllItemsByDefindex(scrap); Trade.AddAllItemsByDefindex(rec); Trade.AddAllItemsByDefindex(refined); Trade.SendMessage("Added all metal!"); return; } else if (message.ToLower().Split(' ')[0] == "removeitem") { if (message.Split(' ').Length != 2) { Trade.SendMessage("You must tell me the item ID you want me to remove!"); return; } int itemID = Convert.ToInt32(message.Split(' ')[1]); Trade.SendMessage("Removing all items with defindex " + itemID + "..."); Trade.RemoveAllItemsByDefindex(itemID); Trade.SendMessage("Removed all items with defindex " + itemID + "!"); return; } } //Trade.SendMessage ("I do not work with trade messages, sorry!"); Log.Success("Trader said: " + message); if (message.ToLower().Split(' ')[0] == "perk") { if (message.Split(' ').Length != 2) { Trade.SendMessage("You must tell me the perk you want!"); return; } string wantedPerk = message.Substring(message.Split(' ')[0].Length + 1).ToLower(); if (requestedPerks.Contains(wantedPerk)) Trade.SendMessage("You already have the perk " + wantedPerk + "! If you want to remove it, say perk clear"); int offeredScrapCalc = offeredScrap; if (offeredBuds >= 1 && wantedPerk.Contains("all")) { offeredScrapCalc = 0; requestedPerks += "aoqprst"; } if (offeredScrapCalc >= 27 && wantedPerk.Contains("o") && !requestedPerks.Contains("o")) { offeredScrapCalc -= 27; requestedPerks += "o"; } if (offeredScrapCalc >= 59 && wantedPerk.Contains("a") && !requestedPerks.Contains("a")) { offeredScrapCalc -= 59; requestedPerks += "a"; } if (offeredScrapCalc >= 68 && wantedPerk.Contains("p") && !requestedPerks.Contains("p")) { offeredScrapCalc -= 68; requestedPerks += "p"; } if (offeredScrapCalc >= 77 && wantedPerk.Contains("q") && !requestedPerks.Contains("q")) { offeredScrapCalc -= 77; requestedPerks += "q"; } if (offeredScrapCalc >= 118 && wantedPerk.Contains("r") && !requestedPerks.Contains("r")) { offeredScrapCalc -= 118; requestedPerks += "r"; } if (offeredScrapCalc >= 191 && wantedPerk.Contains("s") && requestedPerks.Contains("s")) { offeredScrapCalc -= 191; requestedPerks += "s"; } if (offeredScrapCalc >= 1000 && wantedPerk.Contains("t") && requestedPerks.Contains("t")) { offeredScrapCalc -= 1000; requestedPerks += "t"; } else if (wantedPerk == "clear") requestedPerks = ""; else { Trade.SendMessage("You either have not put up enough for this perk, or this perk does not exist! Sorry!"); } Trade.SendMessage("Your current perks: " + requestedPerks); return; } else { Trade.SendMessage("Sorry but I do not trade responses yet please read what I posted above for prices though ^^"); } } public override void OnChatRoomMessage(SteamID chatID, SteamID sender, string message) { base.OnChatRoomMessage(chatID, sender, message); } public override void OnTradeReady(bool ready) { if (!ready) { Trade.SetReady(false); Bot.log.Warn("Unreadied trade."); } else { int offeredMetal = (offeredScrap / 9); Bot.log.Success("User is ready to trade!"); bool isValid = Validate(); Trade.SendMessage("You currently have " + offeredMetal + " worth of refined metal in the trade & " + offeredScrap + "worth of scrap"); if (isValid || IsAdmin || isDebug) { Trade.SetReady(true); } else if (!isValid) { //Trade.SendMessage("You have either not put up enough to make a valid donation, or have not requested any perks! Please put up more items, or cancel the trade."); } } } public override void OnTradeAccept() { bool ok = Trade.AcceptTrade(); if (ok || !IsAdmin) { Log.Success("Trade was Successful! new Donator " + OtherSID); TellAdmins("Someone donated! " + Bot.SteamFriends.GetFriendPersonaName(OtherSID) + " (" + OtherSID + ") " + offeredScrap + " scrap"); RunRCon(new string[] { "sm_csay new donator " + Bot.SteamFriends.GetFriendPersonaName(OtherSID) + "! Make him feel welcome!", "say " + Bot.SteamFriends.GetFriendPersonaName(OtherSID) + " donated " + offeredScrap + " scrap! Make him feel welcome!" }); if (!IsAdmin || isDebug == true) { Thread RConThread = new Thread(() => RunRCon(new string[] { //"sm_addadmin \"" + OtherSID + "\" \"1:" + perks + "\"", "sm_sql_deladmin steam \"" + OtherSID + "\"", "sm_sql_addadmin \""+Bot.SteamFriends.GetFriendPersonaName(OtherSID)+"\" steam \""+OtherSID+"\" \""+perks+"\" 1", //"sm_sql_setadmingroups steam \""+OtherSID+"\" Donators", "sm_reloadadmins", "sm_reloadccc" })); RConThread.Start(); Log.Success("Trade was Successful! " + Bot.SteamFriends.GetFriendPersonaName(OtherSID) + "has donated " + offeredScrap + " worth of scrap!"); } } else { Log.Warn("Trade might have failed."); } Bot.SteamFriends.SetPersonaState(EPersonaState.LookingToTrade); } private void Timer() { throw new NotImplementedException(); } #endregion public void RunRCon(string[] commands) { SourceRcon Sr = new SourceRcon(); Sr.Errors += new StringOutput(RConErrorOutput); Sr.ServerOutput += new StringOutput(RConConsoleOutput); if (Sr.Connect(new IPEndPoint(IPAddress.Parse(""), 27015), "")) { while (!Sr.Connected) { Thread.Sleep(10); } foreach (string command in commands) { Sr.ServerCommand(command); } Thread.Sleep(1000); return; } else { Log.Error("Failed to connect to RCon!"); Thread.Sleep(1000); } } public void RConErrorOutput(string input) { Log.Error("RCon ERROR: " + input); } public override void OnFriendRemove() { } public void RConConsoleOutput(string input) { Log.Success("Rcon Output: " + input); } public bool Validate() { perks = ""; offeredScrap = 0; offeredBuds = 0; int offeredWeapons = 0; int offeredHats = 0; //int offeredBuds = 0; int offeredKeys = 0; int[] allowedDefIndex = { 5000, 5001, 5002, 143, 5021 }; foreach (ulong itemLong in Trade.OtherOfferedItems) { Inventory.Item item = Bot.OtherInventory.GetItem(itemLong); Schema.Item schemaItem = Trade.CurrentSchema.GetItem(item.Defindex); try { if (schemaItem.HolidayRestriction.Length > 0) { Trade.SendMessage("Sorry, but I will not accept your " + item.CustomName + ". Please remove it."); return false; } } catch { } if (!(Array.IndexOf(allowedDefIndex, schemaItem.Defindex) != -1 || schemaItem.CraftClass == "weapon" || schemaItem.CraftMaterialType == "hat") || item.IsNotCraftable || item.IsNotTradeable || item.Origin == 7) { Trade.SendMessage("Sorry, but I will not accept your " + schemaItem.Name + ". Please remove it."); return false; } if (schemaItem.Defindex == 5000) offeredScrap += 1; else if (schemaItem.Defindex == 5001) offeredScrap += 3; else if (schemaItem.Defindex == 5002) offeredScrap += 9; else if (schemaItem.CraftClass == "weapon") offeredWeapons += 1; else if (schemaItem.CraftMaterialType == "hat") offeredHats += 1; else if (schemaItem.Defindex == 143) offeredBuds += 1; else if (schemaItem.Defindex == 5021) offeredKeys += 1; } float scrapToAdd = offeredWeapons / 2; offeredScrap += Convert.ToInt32(Math.Floor(scrapToAdd)); offeredScrap += offeredHats * 10; offeredScrap += offeredKeys * 60; offeredScrap += offeredBuds * 944; int offeredScrapCalc = offeredScrap; if (offeredScrapCalc >= 27 && requestedPerks.Contains("o")) { offeredScrapCalc -= 27; perks += "o"; } if (offeredScrapCalc >= 59 && requestedPerks.Contains("a")) { offeredScrapCalc -= 59; perks += "a"; } if (offeredScrapCalc >= 68 && requestedPerks.Contains("p")) { offeredScrapCalc -= 68; perks += "p"; } if (offeredScrapCalc >= 77 && requestedPerks.Contains("q")) { offeredScrapCalc -= 77; perks += "q"; } if (offeredScrapCalc >= 118 && requestedPerks.Contains("r")) { offeredScrapCalc -= 118; perks += "r"; } if (offeredScrapCalc >= 191 && requestedPerks.Contains("s")) { offeredScrapCalc -= 191; perks += "s"; } if (offeredScrapCalc >= 1000 && requestedPerks.Contains("t")) { offeredScrapCalc -= 1000; perks += "t"; } if (perks == "") { return false; } Trade.SendMessage("You have paid enough/requested for these perks: " + perks); return true; } } }