mjavad_mllw Posted 6 hours ago Report Posted 6 hours ago (edited) Hi, i wrote a script to use backpack expander to not run game anymore this script is simple 1. log in to steam 2. run the tf2 3. get backpack data and slots amount 4. find the backpack expander 5. use backpack 6. check for more backpack and do process 5 again my main question is that how can i check if i used item cuase the "useItem" method dont throw any thing and i tried that and also i have found two events "itemRemoved" and "accountUpdate" which one should i check ? i know i should try it my self but it take time and also cost me some backpacks to find out the answer here is my code that i wrote about useItem method: function checkForExpanders() { if (!tf2.backpack || tf2.backpack.length === 0) { console.log("⏳ Backpack not loaded yet..."); setTimeout(() => checkForExpanders(), 5000); return; } const expanders = tf2.backpack.filter((item) => { const defindex = item.def_index || item.defIndex || item.defindex; const schemaItem = tf2.itemSchema?.itemsByDefindex?.[defindex]; const name = schemaItem?.item_name?.toLowerCase() || ""; return defindex === 5050 || name.includes("backpack expander"); }); if (expanders.length === 0) { console.log("❌ No Backpack Expander found in your inventory."); askToCheckAgain(); return; } console.log(`🧳 Found ${expanders.length} Backpack Expander(s).`); const expander = expanders[0]; rl.question( "❓ Do you want to use a Backpack Expander? (y/n): ", (answer) => { if (answer.toLowerCase() === "y") { console.log(`🔧 Trying to use Backpack Expander... (item_id: ${expander.id})`); tf2.useItem(expander.id, (err) => { if (err) { console.error("❌ Failed to use item:", err); } else { console.log("✅ Used Backpack Expander successfully."); } setTimeout(() => { console.log("🔄 Refreshing backpack info..."); showBackpackInfo(); setTimeout(() => checkForExpanders(), 5000); }, 5000); }); } else { console.log("❎ Operation cancelled by user."); askToCheckAgain(); } } ); } Edited 6 hours ago by mjavad_mllw Quote
Recommended Posts
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.