Jump to content
McKay Development

[Help] I want to send a single Item.


Hollo1001

Recommended Posts

Hello I'm trying to make some kind of withdrawing system.

And i want to send a single specific item but I don't get how

I'm just able to add all items like in the example

pls can you explain it to me

/**
 * OFFLOADER
 *
 * Once logged in, sends a trade offer containing this account's entire tradable CS:GO inventory.
 */


var SteamUser = require('steam-user');
var SteamCommunity = require('steamcommunity');
var SteamTotp = require('steam-totp');
var TradeOfferManager = require('steam-tradeoffer-manager'); // use require('steam-tradeoffer-manager') in production
var fs = require('fs');


var client = new SteamUser();
var manager = new TradeOfferManager({
"steam": client, // Polling every 30 seconds is fine since we get notifications from Steam
"domain": "example.com", // Our domain is example.com
"language": "en" // We want English item descriptions
});
var community = new SteamCommunity();


// Steam logon options
var logOnOptions = {
"accountName": "----",
"password": "---",
"twoFactorCode": SteamTotp.getAuthCode("----")
};


if (fs.existsSync('polldata.json')) {
manager.pollData = JSON.parse(fs.readFileSync('polldata.json'));
}


client.logOn(logOnOptions);


client.on('loggedOn', function() {
console.log("Logged into Steam");
client.setPersona(SteamUser.Steam.EPersonaState.Online);
});


client.on('webSession', function(sessionID, cookies) {
manager.setCookies(cookies, function(err) {
if (err) {
console.log(err);
process.exit(1); // Fatal error since we couldn't get our API key
return;
}


console.log("Got API key: " + manager.apiKey);


// Get our inventory
manager.loadInventory(730, 2, true, function(err, inventory) {
if (err) {
console.log(err);
return;
}


if (inventory.length == 0) {
// Inventory empty
console.log("CS:GO inventory is empty");
return;
}


console.log("Found " + inventory.length + " CS:GO items" + inventory);


// Create and send the offer
var offer = manager.createOffer("------");
offer.addMyItem(inventory);
offer.setMessage("You opened you advent calendar, here is your item!");
offer.send(function(err, status) {
if (err) {
console.log(err);
return;
}


if (status == 'pending') {
// We need to confirm it
console.log(`Offer #${offer.id} sent, but requires confirmation`);
community.acceptConfirmationForObject("-------", offer.id, function(err) {
if (err) {
console.log(err);
} else {
console.log("Offer confirmed");
}
});
} else {
console.log(`Offer #${offer.id} sent successfully`);
}
});
});
});


community.setCookies(cookies);
});


manager.on('sentOfferChanged', function(offer, oldState) {
console.log(`Offer #${offer.id} changed: ${TradeOfferManager.ETradeOfferState[oldState]} -> ${TradeOfferManager.ETradeOfferState[offer.state]}`);
});


manager.on('pollData', function(pollData) {
fs.writeFile('polldata.json', JSON.stringify(pollData));
});


/*
 * Example output:
 *
 * Logged into Steam
 * Got API key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
 * Found 117 CS:GO items
 * Offer #1601569319 sent, but requires confirmation
 * Offer confirmed
 */

Thx for your help

Link to comment
Share on other sites

offer.addMyItem(inventory)

inventory here is an array of items. If you want to grab the first item from your inventory then use inventory[0].

oh yeah thx and I now found a method in a other post how to check wich weapon it is.

Is it possible du check the Exterior/wear of the skin like (factory new,minimal wear ...)?

Edited by Hollo1001
Link to comment
Share on other sites

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...