Jump to content
McKay Development

FallingLight

Member
  • Posts

    6
  • Joined

  • Last visited

Reputation Activity

  1. Like
    FallingLight got a reaction from SnaBe in [HELP] how to continue?   
    Thanks Man. Meanwhile, I realized a few things.
    Check if the offer is accepted
    And if he/she is accept the offer -> bot receive of course items ->
     
    for(var i = 0, len = items.length; i < len; i++){var itemnames = items.market_hash_name;}  console.log("Received items: " + itemnames); Big Thanks to you man. You helped me so much and i learned so much thing about javascript.I know it's late, but Happy Christmas & New Year.
  2. Like
    FallingLight reacted to SnaBe in [HELP] how to continue?   
    You're very close, here's how I would do it.
    //Load the inventory manager.getUserInventoryContents(steamID, 730, 2, true, function(err, inventory) { if(err) { console.log('Error getting their inventory: ' + err); } else { console.log('Checking if user: ' + steamID + ' has any CS:GO keys we accept.'); for(var n = 0; n < inventory.length; n++) { if(config.csgo.acceptedKeys.indexOf(inventory[n].market_hash_name) >= 0) { console.log(inventory[n].market_hash_name); } } } }); acceptedKeys is an array containing all the current CS:GO keys, you can always remove or add keys to meet your needs.
    "acceptedKeys": [ "Glove Case Key", "Spectrum Case Key", "Gamma 2 Case Key", "Clutch Case Key", "Huntsman Case Key", "Gamma Case Key", "Spectrum 2 Case Key", "Operation Breakout Case Key", "Shadow Case Key", "Chroma 3 Case Key", "Falchion Case Key", "Winter Offensive Case Key", "Revolver Case Key", "Chroma 2 Case Key" ] To store the keys for a possible trade offer, you would have to add them in a new array. Like so: 
    (This should be done within the for-loop)
    //New empty array var theirKeys = []; //Add the keys to our array theirKeys.push(inventory[n]); After that, you can see how many keys the array contains.
    console.log('User has ' + theirKeys.length + ' key(s).'); I would suggest a custom function for easier use.
    function checkKeys(steamID) { //Their keys in a new array var theirKeys = []; //Load the inventory manager.getUserInventoryContents(steamID, 730, 2, true, function(err, inventory) { if(err) { console.log('Error getting their inventory: ' + err); } else { console.log('Checking if user: ' + steamID + ' has CS:GO keys.'); for(var n = 0; n < inventory.length; n++) { if(config.csgo.acceptedKeys.indexOf(inventory[n].market_hash_name) >= 0) { theirKeys.push(inventory[n]); console.log(inventory[n].market_hash_name); } } console.log('User has ' + theirKeys.length + ' key(s).'); } }); } Chat command example:
    client.on('friendMessage', function(steamID, message) { if(message.match('!check')) { client.chatMessage(steamID, 'Handling your request...'); checkKeys(steamID); } else { client.chatMessage(steamID, 'I don\'t know that command.'); } });
×
×
  • Create New...