var/list/inventory = list()
name = "Shop Keeper"
set src in view(2)
switch(input(usr, "What would you like to do?") in list("Buy", "Sell"))
var/obj/O = input(usr, "What would you like to buy?") in inventory
if( >= O.value) -= O.value
usr.contents += new O
var/obj/O = input(usr, "Which object would you like to sell?") in usr.contents
O.value += 1
switch(input(usr, "Are you sure you want to sell []?") in list("Yes", "No"))
O.value /= 2
usr.contents -= O += O.value
inventory = list(/obj/TV, /obj/rug)

Problem description:
When i run this, and try to buy something from the shopkeeper, i get an error message saying:
runtime error: Cannot read /obj/TV (/obj/TV).value
proc name: Action (/mob/shopkeeper/Action)
usr: Darkoro (/mob)
src: Shop Keeper (/mob/shopkeeper/Viola)
call stack:
Shop Keeper (/mob/shopkeeper/Viola): Action()

I guessed that i did something wrong (No duh sherlock?). So, how would I fix it?

For the record, Viola is the name of the shop keeper from the city of Viola. Hence the inventory var being declared in shopkeeper, and being overwritten (each city has different items in stock).
You can't check variables of a type path, it has to be an existing object.
Try using newlist(/obj/TV, /obj/rug) instead. The newlist() proc acts like list(), but if you fill the list with paths, it will create new instances of them automatically as if you typed list(new/obj/TV, new/obj/rug).
In response to Kaiochao
runtime error: Cannot create objects of type /obj/card.
proc name: Action (/mob/shopkeeper/Action)
usr: Darkoro (/mob)
src: Shop Keeper (/mob/shopkeeper/Viola)
call stack:
Shop Keeper (/mob/shopkeeper/Viola): Action()

i created a new obj just for this, because when i tried it with TV and rug it failed, and i assumed it was down to the fact that TV and rug where placed on the map (i dunno what gave me that idea, but hey.).

Anyway, thats the new Error message i get.
In response to Darkoro
Now that issue is the opposite: new() is expecting a type path, but you are giving it an actual object (and then it gives you a confusing error message).

You need to do new O.type(usr) instead of just new O(usr).
In response to Garthor
Thank you garthor, the code works fine now.