# How do I make Trading

Get help using Construct 2

### » Mon Jan 04, 2016 12:27 am

Here's the story. I have 4 items that i can trade at a shop. Each item has a fixed basic price (5, 10, 15, 20 as placeholders-you sell and buy stuff at the same price). On that price is added random number and that final number is the displayed one and the item's actual price.
I've set up that item count goes up and down when you're buying/selling (i still need to set the limit so that you can't sell items that you don't have-could use some help on that too )
The thing is, i can't for the life of me set things up so that when you buy/sell stuff, the final money value is added / substracted from your inventory. Finding out how to limit the trade so that you can't buy things you can't afford would be great too!
Also, i have some questions about randomizing prices, so help with that would be great!
B
3
Posts: 6
Reputation: 187

### » Mon Jan 04, 2016 1:02 am

jouzeph wrote:I've set up that item count goes up and down when you're buying/selling (i still need to set the limit so that you can't sell items that you don't have-could use some help on that too )

If you store the amount of items the player is carrying in your player object as variables. (Item_1, Item_2, Item_3...etc) you can check against these to see whether the player have enough of them to sell. Simply but doing a Item_1 > 0.
And you can do the same for the shop.

The thing is, i can't for the life of me set things up so that when you buy/sell stuff, the final money value is added / substracted from your inventory. Finding out how to limit the trade so that you can't buy things you can't afford would be great too!

This can be done the same way as above. In this case you just make a variable called "Player_money" and you add/subtract from this and again you can use this value to test vs the price of the item the player want to buy.

Player_money >= Item_1_cost

Also, i have some questions about randomizing prices, so help with that would be great!

You can create random numbers using the following code:
Code: Select all
`Random(Number)Random(10)   <- Will give you a random number between 0 and 10, including decimal numbers.Int(Random(Number))Int(Random(10))  <- Will give you a random integer between 0 and 10.Int(Random(Number) + 1)Int(Random(10) + 1)  <- Will give you a random integer between 1 and 10.`

So you can create random prices for your items like so:

Item_1_cost = int(random(100) + 1)

Will set the price to a random number between 1 and 100.

But I might have misunderstood how your inventory works and that this is not what you meant.
B
45
S
12
G
3
Posts: 1,210
Reputation: 7,559

### » Mon Jan 04, 2016 1:16 am

I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

### » Mon Jan 04, 2016 9:49 am

It says that it's made in Construct version 219 or newer and that i have 216. I've tried reinstalling it, still nothing
B
3
Posts: 6
Reputation: 187

### » Mon Jan 04, 2016 12:50 pm

I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775