Jump to content
McKay Development

Recommended Posts

Posted

Hello everyone !

So I spent the last few weeks trying to create a bot that basically trades random steam cards for Steam Game Keys (with a lot of help from Vanilla ;p )

 

I am now pretty much done with all the trading stuff, and the last thing that I need is to get the Steam Key from my file.

 

Basically, my goal is to

- Count how many keys in total are in my .txt or .csv or .anything file and get that to a variable so I can add a line earlier in the code which checks if i have enough keys left before accepting the cards

- Get the key(s) from the file (in order to send them in chat)

-move the used keys to another file or modify their line to mark them as 'inactive' or something.

 

Here is the part where I stopped :

else {
    totalKeyWeGive = cardCount / cardToKey;
    console.log("We will give "+totalKeyWeGive+ " SteamKey");
    
    offer.accept();
    console.log("OFFER ACCEPTED");
    
    //loop on how much we give the key
    for (i = 0; i < totalKeyWeGive; i++) {
        //get steamkey from file here ----------------------------------------------------------------------------
        
     
    }
    
    var textMsg = "Hello ! You bought "+totalKeyWeGive+ " Game keys. Your keys are: ";
    }
    
    client.chatMessage(offer.partner.getSteamID64(), textMsg);
    

}

I already have most of the variables setup, and processed earlier in the code : 

 

cardToKey - How many cards are needed for one key

cardCount - How many cards are there in the offer

totalKeyWeGive - If everything is okay in the trade, how many keys should we give

 

 

 

Any advices on how I should handle this ?

Posted

The first problem I see is that you aren't handling the callback to offer.accept, which could fail.

 

Secondly, you can use the fs module to read from a file. If it's newline-delimited, you could call split("\n") to get an array containing each line in the file.

Posted

Then how should I handle the callback ? I'm currently getting errors on offer.decline(offer) , while offer.accept(offer) is fully working ?

 

 

(btw I finally managed to make something functional out of the fs module, thank you for the advice !)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...