ID:147832
 
Ok... my one... littlew... itty... bitty... problem is.... I want to have my characters sell only certain types of items to shopkeepers.... and I'm too tired to remember what I used before.... ok... not too tired... too lazy.

well anyway... heres what I got

mob
Weaponer
icon = 'mobs.dmi'
icon_state = "weaponist"
name = "Weapon Sellsman"
NPC = 1
Click()
switch(input("Hello! What do you want to do?", "Weapon Shop", text) in list (Buy", "Sell", "Nothing"))
if("Buy")
switch(input("Hello! What do you wish to buy?", "Weapon Shop",text) in list ("Short Sword", "Nothing"))
if("Short Sword")
if(usr.gold <= 79)
alert("You do not have enough gold!")
if(usr.gold >= 80)
alert("You bought a Short Sword!")
usr.contents += new /obj/weapons/shortsword
usr.gold -= 80
usr.invent += 1
if("Nothing")
usr << "Thank you come again."
if("Sell")
var/obj/S = input("What do you want to Sell?","Sell") as null|obj in usr.contents
if(!S)
return
else
switch(input("Do you want to sell [S] for [S.sellprice]?")in list("Yes","No"))
if("Yes")
usr.contents -= S
if("No")
return
obj/var/sellprice
obj/weapons/shortsword
sellprice = 40
mob/proc/Sell(mob/M)


thats it.... can anyone help me?
before I get stupid replies... I want the weaponer to buy only weapons from players.... no other objs
In response to SilentFoe
Look up istype in dm (type it, highlight it and press F1)

If you still have problems after that then IM me when i get home...Kros Trikare (AIM)
In response to K'ros Trikare
that just confused the hell outta me... can someone else try?
In response to SilentFoe
If you're lucky, I might look at your code if you put it in
<TT> tags.
mob
NPC
merchant
var/buyprice = 0.5 // 0.5 for half of selling price, 1 for full selling price, etc.
var/list/buytypes
Click()
switch(input("Hello! What do you want to do?", "Shop", text) in list ("Buy", "Sell", "Nothing"))
if("Buy")
var/obj/selection = input("Hello! What do you wish to buy?", "Weapon Shop",text) in contents //Let them buy something from the shopkeeper's contents.
if(alert("The [selection] costs [selection.price] gold. Are you sure you wish to buy it?", "Yes", "No") == "Yes")
if(selection.price > usr.gold)
usr << "You do not have enough gold!"
else
usr << "Here you go!"
usr.gold -= selection.price
new selection(usr)
if("Sell")
var/list/sellable = list()
for(var/obj/O in usr)
for(var/T in buytypes)
if(istype(O, T))
sellable += O
break
var/selling = input(sellable)
if(alert("I'll give you [selling.price * buyprice] for it. Deal?", "Yes", "No") == "Yes")
usr << "Thank you for your business!"
usr.gold += selling.price * buyprice
del(selling)

Weapon_Smith //Weapon is not a verb, so "weaponer" is not correct
buytypes = list(/obj/weapons/)
contents = list( new /obj/weapons/shortsword )