C # I have a Steam swap bot and it returns the error "Object reference not set to an instance of an object" [closed]

3

I searched all other threads and saw several answers but I can not apply them to my application because I do not know anything about C # ... My site is for CS bets: GO and I have a C # bot that works normally as it should (when it completes the amount of items in the pot it makes the draw) but I need it to also activate when the time to deposit skins So I just got the command that it runs when the pot gets full and I paste it in the part where the time runs out.

The command that works (parts of it) is this:

namespace SteamBot
{
public class DepositTradeOfferUserHandler : UserHandler
{
    public DepositTradeOfferUserHandler(bot bot, SteamID sid) : base(bot,       sid) { }
...
...
...
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);

This part works perfectly ... Now the part that I created that is activated when the time ends and the draw is done:

Task f = Task.Factory.StartNew(() =>
    {

        int count = 1;


        while (count <= 1)
        {
...
...
...
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>();

Note that this is the same command, but in this second block the code does not work. Error message: CS0120 C# An object reference is required for the non-static field, method, or property 'bot.NewTradeOffer(SteamID)'

I know it should be something simple, but I do not understand anything about C # and I really need your help, thank you. If you need any more code or explanation, just talk. Thank you in advance!

EDIT: I noticed that the two codes were not similar so I renamed "bot" to "Bot" so that it stays the same, and now the error message is this: CS0236 C# A field initializer cannot reference the non-static field, method, or property 'UserHandler.Bot'

    
asked by anonymous 24.09.2015 / 05:31

0 answers