Jump to content
McKay Development

How to use descriptions in pricing an item


Lonster_Monster

Recommended Posts

i have a genuine killer exclusive with the australium paint on it

i done

  var item = ourItems[i].market_name;
  var des = ourItems[i].descriptions;
  console.log(item)
  console.log(des)
  if (item == stock[item] && des == stock[item].description){
  if (item == Prices[item] && des == Prices[item].description){
  console.log(Prices[item].sell)
  }
}

when it does the console log on item and des it shows

	"Genuine Killer Exclusive":
	[ { 
    type: "text",
    value: "Paint Color: Australium Gold",
    color: "756b5e",
    app_data: "" },
	{ 
    type: "text",
    value: "Break news, spirits and heads.",
    app_data: "" 
	} ]

i put the descriiption text in the stock under the item name and is the value of description like below

{
"Genuine Killer Exclusive":
 {
 "instock": 0,
 "stocklimit":1,
 "description": 
  [ { 
  "type": "text",
  "value": "Paint Color: Australium Gold",
  "color": "756b5e",
  "app_data": "" },
  { 
  "type": "text",
  "value": "Break news, spirits and heads.",
  "app_data": "" 
  } ]
 }
}

the problem is with the "" around type, value, color, app_data, type, value, app_data  it acts as if that is not the value but json wont work without the " " around the certain words

 

SOLUTION:

 

 

I finally fixed the problem in


var item = ourItems[i].market_name;
var des = ourItems[i].descriptions;
console.log(item)
console.log(des)
if (item == stock[item] && des == stock[item].description){
if (item == Prices[item] && des == Prices[item].description){
console.log(Prices[item].sell)
}
}

changed the code to the code below and i think it is cool how i can call stuff like this now


const filestockname = './/settings/Prices/Prices.json';
        const filestock = require(filestockname);
        for (var i in ourItems) {
            var item = ourItems[i].market_name;
            var des = ourItems[i].description
            console.log(item)
            console.log(des)
            if (filestock[item]){
            fs.readFile(filestockname, (err, data) => {
            if (err) throw err;
            console.log('File read');
            });
            filestock[item].description = des
            console.log('writing to ' + filestockname);
            fs.writeFile(filestockname, JSON.stringify(filestock, null, 2), function (err) {
            if (err) return console.log(err);
            console.log('writing to ' + filestockname);
            });
            }
        }    

that is only for the our items side i didnt post for the their items side of the trade becaseu it is basically the same

Edited by Lonster_Monster
Link to comment
Share on other sites

Objects would just work fine as string..

var object = {

    'this_works':'it actually did!'

};

 

console.log(object.this_works);

..?

so say i wanted to do the code i have above, what exactly would i do i mean as an object like i am wanting

 

Sorry if it is a noob question i am still kinda new to nodejs i have been making my own bot for about a year leanring new stuff in it

Edited by Lonster_Monster
Link to comment
Share on other sites

I finally fixed the problem in

  var item = ourItems[i].market_name;
  var des = ourItems[i].descriptions;
  console.log(item)
  console.log(des)
  if (item == stock[item] && des == stock[item].description){
  if (item == Prices[item] && des == Prices[item].description){
  console.log(Prices[item].sell)
  }
}

changed the code to the code below and i think it is cool how i can call stuff like this now

const filestockname = './/settings/Prices/Prices.json';
		const filestock = require(filestockname);
		for (var i in ourItems) {
			var item = ourItems[i].market_name;
			var des = ourItems[i].description
			console.log(item)
			console.log(des)
			if (filestock[item]){
			fs.readFile(filestockname, (err, data) => {
			if (err) throw err;
			console.log('File read');
			});
			filestock[item].description = des
			console.log('writing to ' + filestockname);
			fs.writeFile(filestockname, JSON.stringify(filestock, null, 2), function (err) {
			if (err) return console.log(err);
			console.log('writing to ' + filestockname);
			});
			}
		}	

that is only for the our items side i didnt post for the their items side of the trade becaseu it is basically the same

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