Jump to content
McKay Development

Recommended Posts

Posted

Can I check which key the user has:

  1. The key can be tradable in 7 days (Old key)
  2. The key was bought in the game and it can not be traded or sold never (New key)

Here are the data I get using manager.getUserInventoryContents(FRIEND_SID, 730, 2, false, (ERR, DATA)

Old key:

CEconItem {
  appid: 730,
  contextid: '2',
  assetid: '18042278743',
  classid: '3737821870',
  instanceid: '143865972',
  amount: 1,
  pos: 1,
  id: '18042278743',
  background_color: '',
  icon_url: '-9a81dlWLwJ2UUGcVs_nsVtzdOEdtWwKGZZLQHTxDZ7I56KU0Zwwo4NUX4oFJZEHLbXX7gNTPcUxuxpJSXPbQv2S1MDeXkh6LBBOievrLVY2i6ebKDsbv47hw4TTlaSsZeKIxztQu8B03L2Y8Imh2Aftrhc-Z3ezetFDsuzS1g',
  descriptions: [
    {
      type: 'html',
      value: 'This key only opens Winter Offensive Cases'
    },
    { type: 'html', value: ' ' },
    { type: 'html', value: '', color: '00a000' }
  ],
  tradable: false,
  name: 'Winter Offensive Case Key',
  name_color: 'D2D2D2',
  type: 'Base Grade Key',
  market_name: 'Winter Offensive Case Key',
  market_hash_name: 'Winter Offensive Case Key',
  commodity: true,
  market_tradable_restriction: 7,
  marketable: true,
  tags: [
    {
      internal_name: 'CSGO_Tool_WeaponCase_KeyTag',
      name: 'Key',
      category: 'Type',
      color: '',
      category_name: 'Type'
    },
    {
      internal_name: 'normal',
      name: 'Normal',
      category: 'Quality',
      color: '',
      category_name: 'Category'
    },
    {
      internal_name: 'Rarity_Common',
      name: 'Base Grade',
      category: 'Rarity',
      color: 'b0c3d9',
      category_name: 'Quality'
    }
  ],
  is_currency: false,
  market_marketable_restriction: 0,
  fraudwarnings: []
}

UNKNOWN key:

CEconItem {
  appid: 730,
  contextid: '2',
  assetid: '17964401838',
  classid: '3586512622',
  instanceid: '143865972',
  amount: 1,
  pos: 2,
  id: '17964401838',
  background_color: '',
  icon_url: '-9a81dlWLwJ2UUGcVs_nsVtzdOEdtWwKGZZLQHTxDZ7I56KU0Zwwo4NUX4oFJZEHLbXX7gNTPcUxuxpJSXPbQv2S1MDeXkh6LBBOiev8ZQQ30KubIWVDudrgkNncw6-hY-2Fkz1S7JRz2erHodnzig2xqUVvYDrtZNjCAC7WDrU',
  descriptions: [
    { type: 'html', value: 'This key only opens Clutch cases' },
    { type: 'html', value: ' ' },
    { type: 'html', value: '', color: '00a000' },
    { type: 'html', value: ' ' },
    { type: 'html', value: '' }
  ],
  tradable: false,
  name: 'Clutch Case Key',
  name_color: 'D2D2D2',
  type: 'Base Grade Key',
  market_name: 'Clutch Case Key',
  market_hash_name: 'Clutch Case Key',
  commodity: true,
  market_tradable_restriction: 7,
  marketable: false,
  tags: [
    {
      internal_name: 'CSGO_Tool_WeaponCase_KeyTag',
      name: 'Key',
      category: 'Type',
      color: '',
      category_name: 'Type'
    },
    {
      internal_name: 'normal',
      name: 'Normal',
      category: 'Quality',
      color: '',
      category_name: 'Category'
    },
    {
      internal_name: 'Rarity_Common',
      name: 'Base Grade',
      category: 'Rarity',
      color: 'b0c3d9',
      category_name: 'Quality'
    }
  ],
  is_currency: false,
  market_marketable_restriction: 0,
  fraudwarnings: []
}

As I see, I have to check to see the parameter "marketable"?

Should this parameter always be true for all old keys and false for all new keys? Regardless of how the key was received (on the market / trade / purchased in the game long ago).

Thanks.

Posted (edited)
  • appid, contextid, assetid, classid, instanceid, amount, name, market_name, market_hash_name
  • id
    • Same as assetid
  • pos
    • Not always present; this is the item's position in the user's inventory (starting at 1)
  • background_color
    • Hex code for the background color rendered for this item in the Steam inventory
  • name_color
    • Hex code for the name and border color rendered for this item in the Steam inventory
  • icon_url
  • descriptions
    • Array of objects containing human-readable description text lines
  • tradable, marketable
    • Self-explanatory
  • type
    • The text that goes under the game's name to the right of the square game logo in the Steam inventory when this item is viewed
  • commodity
    • Determines whether this item's Market listing uses buy orders exclusively (true), or individual listings with the possibility to submit buy orders (false)
  • market_tradable_restriction
    • Length in days that this item will be untradable after it's bought on the market
  • market_marketable_restriction
    • Length in days that this item will be unmarketable after it's bought on the market
  • tags
    • Array of tag objects; tags are used in the Steam inventory for filtering
  • is_currency
    • Always going to be false except for some Spiral Knights stuff (I think). You really don't want to deal with currencies, trust me.
  • fraudwarnings
    • Array of warnings that will be rendered in red when this item is viewed. If fraudwarnings exist, the item gets a red (!) icon in the Steam inventory
Edited by Dr. McKay
Better formatting
  • 2 weeks later...
Posted (edited)

I'll just leave it in case someone needs.

// For test:
let CONFIG,
SENDER = "76561197983852931",
amountOfKeys = 10;
CONFIG.ACCEPTEDKEYSCS = ["CS20 Case Key""Prisma Case Key""Danger Zone Case Key""Horizon Case Key""Clutch Case Key",
"Spectrum 2 Case Key""Spectrum Case Key""Gamma 2 Case Key""Gamma Case Key""Glove Case Key""Chroma 3 Case Key",
"Operation Wildfire Case Key""Falchion Case Key""Chroma 2 Case Key""Chroma Case Key""Operation Vanguard Case Key",
"Operation Breakout Case Key""Huntsman Case Key""Operation Phoenix Case Key""Shadow Case Key""Revolver Case Key",
"Winter Offensive Case Key""eSports Key""CS:GO Case Key"];
 
// Getting Inventory:
manager.getUserInventoryContents(SENDER7302false, (ERRUSERINVENTORY=> { // (!!!) false
    if (ERR) {
        console.log(ERR);
    } else {
        let hisKeys = [],
            notMarketable = 0,
            notTradable = 0;
        for (let i = 0i < USERINVENTORY.lengthi++) {
            if (hisKeys.length == amountOfKeys) {
                break;
            } else if (CONFIG.ACCEPTEDKEYSCS.includes(USERINVENTORY[i].market_hash_name)) { // This key is accepted
                if (USERINVENTORY[i].tradable && USERINVENTORY[i].marketable) {
                    hisKeys.push(USERINVENTORY[i]);
                } else if (!USERINVENTORY[i].marketable) { // This key is not marketable, never
                    notMarketable++;
                } else if (!USERINVENTORY[i].tradable) { // This key is not tradable, delay up to 7 days
                    notTradable++;
                }
            }
        }
 
        // Cancel if the user does not have keys or their quantity is not enough:
        if (hisKeys.length < amountOfKeys) {
            let addInfo = "";
            if (notTradable) {
                addInfo += "\n\nSome of your keys (" + notTradable + ") have an exchange delay of up to 7 days.";
            }
            if (notMarketable) {
                addInfo += "\n\nSome of your keys (" + notMarketable + ") bought in the game and can not be exchanged or sold, never!"
                + "\nYou can return them back within 48 hours after purchase."
            }
            if (hisKeys.length < 1) { // No one
                client.chatMessage(SENDER"You do not have the keys that I accept." + addInfo);
            } else { // Less than need
                client.chatMessage(SENDER"You do not have enough keys." + addInfo);
            }
        } else {
            console.log(hisKeys.length + "/" + amountOfKeys);
            // trade.addTheirItems(hisKeys); // Adding keys to the trade (!!!)
        }
    }
});
Edited by PonyExpress

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