Jump to content
McKay Development

Recommended Posts

Posted

Need Some Help with the problem

{ Error: The request is a duplicate and the action has already occurred in the past, ignored this time

The Code i am using

function craftScrap(){
	manager.getInventoryContents(440, 2, true, function (err, inventory){
		if (err) {
			console.log(err);
		} else {
			var rec = inventory.filter(function (item) {
				return item.name == "Reclaimed Metal"
			});
			var ref = inventory.filter(function (item) {
				return item.name == "Refined Metal"
			});
			var recCount = rec.length;
			var refCount = ref.length;
			
			if (recCount || refCount > 0){
				console.log("User can smelt metals");
				if(recCount == 0){
					for (let i = 0; i < refCount; i++) {
						tf2.craft([ref[i].id]);
					}
					manager.getInventoryContents(440, 2, true, function (err, inventory){
						var rec1 = inventory.filter(function (item) {
							return item.name == "Reclaimed Metal"
						});
						var rec1Count = rec1.length;
						for (let i = 0; i < rec1Count; i++) {
							tf2.craft([rec1[i].id]);
						}
					})
				} else {
					for (let i = 0; i < recCount; i++) {
						tf2.craft([rec[i].id]);
					}
				}
			} else {
				console.log("No metal to smelt");
				return;
			}
		}
	})
}

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