Skip to content
This repository has been archived by the owner on Jul 30, 2024. It is now read-only.

SimpleUserHandler Help! #257

Closed
ghost opened this issue Apr 23, 2013 · 21 comments
Closed

SimpleUserHandler Help! #257

ghost opened this issue Apr 23, 2013 · 21 comments

Comments

@ghost
Copy link

ghost commented Apr 23, 2013

Hey, I'm currently using the SteamBot and I want to import the SimpleUserHandler.cs Posted for scrapbanking here But when I put that in Steambot/SimpleUserHandler.cs and I launch the SteamBot.exe it runs fine but it doesn't load the Handler I loaded. All it can do is take scrap and when I try to put in items it just says There was an error in your trade. This is the whole chat:

[TradeBot] MBot: Success. Please put up your items. 18:03:32
You added The Loch-n-Load 18:03:35
You added The Candy Cane 18:03:36
You are ready 18:03:42
[TradeBot] MBot: There were errors in your trade: 18:03:43
[TradeBot] MBot: Item The Loch-n-Load is not a metal. 18:03:44
[TradeBot] MBot: Item The Candy Cane is not a metal. 18:03:45
[TradeBot] MBot: You must put up at least 1 scrap. 18:03:45
[TradeBot] MBot: Scrap: 0 18:03:46

This is my settings file(renamed settings.json):

{
"Admins":["234567"],
"ApiKey":"(api key)",
"mainLog": "syslog.log",
"UseSeparateProcesses": "false",
"Bots": [
        {
            "Username":"(Account Username)",
            "Password":"(Account Password)",
            "DisplayName":"MBot",
            "ChatResponse":"Welcome To MBot Trading Service!",
            "logFile": "MBot.log",
            "BotControlClass": "SteamBot.SimpleUserHandler",
            "MaximumTradeTime":300,
            "MaximumActionGap":30,
            "DisplayNamePrefix":"[TradeBot] ",
            "TradePollingInterval":800,
            "LogLevel":"Success"
        }
    ]
}

I would greatly appreciate the help for this if you can help me! Thanks!-Mgamer

@teliosdev
Copy link
Contributor

Why did you rename the settings file to settings.jsp?

@ghost
Copy link
Author

ghost commented Apr 24, 2013

Thanks @FunkyLoveCow I Tried to edit out everything... forgot that though. redjazz96 I renamed it settings.jsp because it said to in the configuration Guide. It said, "In order to run SteamBot you need to configure your bots propertly. This is done by creating a settings.json file located in the same place as the SteamBot executable or by renaming the settings-template.json" Was I not supposed to do that?I'll try it wih settings-template.json.Thanks For The Help So Far!-Mgamer

@ghost
Copy link
Author

ghost commented Apr 24, 2013

Update: @redjazz96 Actually settings.jsp was a typo in my post. Sorry about that it is actually settings.json.

@waylaidwanderer
Copy link
Contributor

Have you tried adding ScrapUserHandler as a separate file?

Like this: http://puu.sh/2G35C.png

Name it ScrapUserHandler.cs and change "BotControlClass": "SteamBot.SimpleUserHandler", to "BotControlClass": "SteamBot.ScrapUserHandler",

@ghost
Copy link
Author

ghost commented Apr 24, 2013

Yeah I've tried that but Then another error came up in the console in red and when I tried to trade it the trade would open then just close and the bot would go offline. By any chance waylaidwanderer would you let me have a file that you use for your bots but edit out all your important imformation. Maybe I can run that with my information and it will work? If you can't it's fine.Thanks For The Help Guys!
This is the error in the console:

[MBot 2013-04-22 18:13:11] SUCCESS: User Authenticated!
[MBot 2013-04-22 18:13:11] INFO: Downloading Schema...
[MBot 2013-04-22 18:13:11] SUCCESS: Schema Downloaded!
[MBot 2013-04-22 18:13:11] SUCCESS: Steam Bot Logged In Completely!
[MBot 2013-04-22 18:13:11] DEBUG: SteamKit2.SteamFriends+PersonaStateCallback
[MBot 2013-04-22 18:13:11] DEBUG: SteamKit2.SteamFriends+PersonaStateCallback
[MBot 2013-04-22 18:13:16] DEBUG: SteamKit2.SteamTrading+TradeProposedCallback
[MBot 2013-04-22 18:13:17] DEBUG: SteamKit2.SteamTrading+SessionStartCallback
[MBot 2013-04-22 18:13:18] DEBUG: SteamTrading.SessionStartCallback handled successfully. Trade Opened.
[MBot 2013-04-22 18:13:51] DEBUG: SteamKit2.SteamFriends+FriendMsgCallback
[MBot 2013-04-24 06:57:44] DEBUG: Initializing Steam Bot...
[MBot 2013-04-24 06:57:44] INFO: Connecting...
[MBot 2013-04-24 06:57:44] SUCCESS: Done Loading Bot!
[MBot 2013-04-24 06:57:45] DEBUG: SteamKit2.SteamClient+ConnectedCallback
[MBot 2013-04-24 06:57:45] DEBUG: Connection Callback: OK
[MBot 2013-04-24 06:57:46] DEBUG: SteamKit2.SteamUser+LoggedOnCallback
[MBot 2013-04-24 06:57:46] DEBUG: Logged On Callback: OK
[MBot 2013-04-24 06:57:46] DEBUG: SteamKit2.SteamUser+AccountInfoCallback
[MBot 2013-04-24 06:57:46] DEBUG: SteamKit2.SteamApps+VACStatusCallback
[MBot 2013-04-24 06:57:46] DEBUG: SteamKit2.SteamFriends+FriendsListCallback
[MBot 2013-04-24 06:57:46] DEBUG: SteamKit2.SteamApps+LicenseListCallback
[MBot 2013-04-24 06:57:46] DEBUG: SteamKit2.SteamApps+GuestPassListCallback
[MBot 2013-04-24 06:57:46] DEBUG: SteamKit2.SteamUser+WalletInfoCallback
[MBot 2013-04-24 06:57:46] DEBUG: SteamKit2.SteamApps+GameConnectTokensCallback
[MBot 2013-04-24 06:57:46] DEBUG: SteamKit2.SteamUser+SessionTokenCallback
[MBot 2013-04-24 06:57:46] DEBUG: SteamKit2.SteamFriends+PersonaStateCallback
[MBot 2013-04-24 06:57:46] DEBUG: SteamKit2.SteamFriends+PersonaStateCallback
[MBot 2013-04-24 06:57:46] DEBUG: SteamKit2.SteamFriends+PersonaStateCallback
[MBot 2013-04-24 06:57:50] DEBUG: SteamKit2.SteamUser+LoginKeyCallback
[MBot 2013-04-24 06:57:52] SUCCESS: User Authenticated!
[MBot 2013-04-24 06:57:52] INFO: Downloading Schema...
[MBot 2013-04-24 06:57:54] SUCCESS: Schema Downloaded!
[MBot 2013-04-24 06:57:54] SUCCESS: Steam Bot Logged In Completely!
[MBot 2013-04-24 06:57:54] DEBUG: SteamKit2.SteamFriends+PersonaStateCallback
[MBot 2013-04-24 06:57:54] DEBUG: SteamKit2.SteamFriends+PersonaStateCallback
[MBot 2013-04-24 06:58:04] DEBUG: SteamKit2.SteamTrading+TradeProposedCallback
[MBot 2013-04-24 06:58:06] ERROR: Unhandled exceptions in bot MBot callback thread: 
 System.ArgumentException: Configured control class type was null. You probably named it wrong in your configuration file.
Parameter name: bot
   at SteamBot.BotManager.UserHandlerCreator(Bot bot, SteamID sid) in C:\Users\(Name)\SteamBot\SteamBot\BotManager.cs:line 176
   at SteamBot.Bot.GetUserHandler(SteamID sid) in C:\Users\(Name)\SteamBot\SteamBot\Bot.cs:line 482
   at SteamBot.Bot.<HandleSteamMessage>b__9(TradeProposedCallback callback) in C:\Users\(Name)\SteamBot\SteamBot\Bot.cs:line 425
   at SteamKit2.CallbackMsg.Handle[T](Action`1 handler) in C:\Users\(Name)\SteamBot\Lib\SteamKit2\SteamKit2\Steam3\SteamClient\CallbackMgr\CallbackMsg.cs:line 72
   at SteamBot.Bot.HandleSteamMessage(CallbackMsg msg) in C:\Users\(Name)\SteamBot\SteamBot\Bot.cs:line 399
   at SteamBot.Bot.BackgroundWorkerOnDoWork(Object sender, DoWorkEventArgs doWorkEventArgs) in C:\Users\(Name)\SteamBot\SteamBot\Bot.cs:line 627
   at System.ComponentModel.BackgroundWorker.OnDoWork(DoWorkEventArgs e)
   at System.ComponentModel.BackgroundWorker.WorkerThreadStart(Object argument)
[MBot 2013-04-24 06:58:06] INFO: This bot died. Stopping it..
[MBot 2013-04-24 06:58:06] DEBUG: Tryring to shut down bot thread.

@ghost
Copy link
Author

ghost commented Apr 24, 2013

Now I changed it to SteamBot.ScrapUserHandler and the file name is ScrapUserHandler in the directory of C:\Users(Name)\SteamBot\SteamBot

@ghost
Copy link
Author

ghost commented Apr 24, 2013

Actually I didnt just change it but It was changed before I got the error

@cwhelchel
Copy link
Contributor

Everyone, please note that the file name for your BotControlClass is completely irrelevant!

It must be the fully-qualified type name. If you had a type SteamBot.MyUserHandler in the file SteamBot\SomeOtherDirectory\ICantNameClassFilesCorrectly.cs you would have to put SteamBot.MyUserHandler in the settings file.

Granted, if following good programming practice, the type name (including namespace hierarchy) and file name and path should match. For example:

The type:

class SteamBot.UserHandlers.MyTestHandler

should be at:

$ .\SteamBot\UserHandlers\MyTestHandler.cs

The issues is, this is not mandatory. That type could be in any file, in any directory in the project.

Also, @mgamer5279 are you recompiling the project after you make your changes?

@ghost
Copy link
Author

ghost commented Apr 24, 2013

Sorry I dont have experience with coding but how do you recompile the project?

@ghost
Copy link
Author

ghost commented Apr 25, 2013

Thanks guys for the amazing help on my first post on github! The Problem Was Solved! Thank You Pheonix!

@ghost ghost closed this as completed Apr 25, 2013
@lastofspades
Copy link

@mgamer5279; what was the solution?

@iMagooo
Copy link

iMagooo commented Jun 17, 2013

Solution:

This sort of thing has been covered 20x over.

The instructions lay it all out, read them. If you're just using the SimpleUserHandler, all you need to do is rename the settings-template.json to settings.json.

If you're using a different UserHandler:

  1. Add the handler to the solution file.
  2. Rename the BotControlClass in the settings.json file.
  3. Ensure that the CustomUserHandler correctly inherits from UserHandler
  4. Recompile the project.

@teliosdev
Copy link
Contributor

@iMagooo that was uncalled for. @lastofspades was just asking @mgamer5279 how he solved the problem, which he should have posted here.

@iMagooo
Copy link

iMagooo commented Jun 17, 2013

Yes, you're right, apologies to @lastofspades, I hadn't had my morning coffee. I shall edit the post now.

@lastofspades
Copy link

@iMagooo No problem, and I've obviously read all of the comments before posting. I've ran enough game servers to know JSON config files well enough. However, I do apologize for replying on a ~2 month old thread. I know people get mad when "necro-ing" threads, but no idea what the convention is like on Github.

"Step #3 - Ensure that the CustomUserHandler correctly inherits from UserHandler"

I think this might be the thing I'm looking for. I've already tried to compile it, and I had an error that said:

'SteamBot.ScrapUserHandler' does not implement inherited abstract member 'SteamBot.UserHandler.OnLoginCompleted()'

I could literally not find the solution to this until now. I've Googled and found some complicated code fix on StackOverflow, but I don't know the language C# itself well enough to get anything useful out of it.

That being said, thanks for the reply. Even if it was a harsh one at first. ;-)

@cwhelchel
Copy link
Contributor

Look at where OnLoginCompleted is implemented in other handlers. Also google C# abstract types or see this. You're getting into #307 territory tho.

@lastofspades
Copy link

@cwhelchel Thanks, I solved it right away after reading your first sentence. :-)

@bennyd87708
Copy link

@lastofspades Hate to necro post, but how did you solve that OnLoginCompleted error? I have had it for a while now and have tried everything...

@scholtzm
Copy link
Contributor

@bennyd87708 #427 & #527
Also googling that error and clicking the first result works.

This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants
@teliosdev @lastofspades @cwhelchel @scholtzm @waylaidwanderer @iMagooo @bennyd87708 and others