# Thread: How does the system calculate the average of prices

1. Originally Posted by JimIzPro
How does the system calculate the average of prices?

Player trades and vends or there's a fixed price

and also, why are there some items that have no value checks
Code:
```std::map<short, float> prices;

void OnTrade(int item, int count, int locks)
{
float price = (float)locks / (float)count;
bool isPer = price < 1;
if (isPer)
prices[item] = (float)(-((float)count / (float)locks) + prices[item]) / 2;
else
prices[item] = (float)(price + prices[item]) / 2;
}```
somewhat how I think it works (average so one price does not overwrite another immediately

- - - Updated - - -

Originally Posted by Starkos
We'd really rather not get into specifics on this one in order to reduce the possibility of manipulation. We've done a few things to hedge against it already, but you can never be too careful, y'know?

Even without knowing how it works behind the scenes, I really hope you all enjoy the update. We've been working on this one for a while! I know it may seem like a small thing, these pricing checks, but believe me, getting all the tracking in place and funneling it correctly was a ton of work!
"a while"
literally changed the trade function to also calculate prices stored in a std::map *** is wrong with you how's that a while's worth of work

2. Originally Posted by pannenkoek2012
"a while"
literally changed the trade function to also calculate prices stored in a std::map *** is wrong with you how's that a while's worth of work

3. I wonder why these eggs are cheap.

4. Originally Posted by GodEater
I wonder why these eggs are cheap.
Imma sell my eggs for 25/1 then

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•