if("Sell")
var/obj/o=input("What do you wish to sell?",src) as obj in null|usr
if(!o){usr<<"<font color =green><b>[src]:</font></b><font color=red><b> Stop waisting my time!</font></b>";return}
switch(alert("I'll give you [o.value] gold for that [o]. Sell?",src,"Yes","No"))
if("Yes")
usr.Gold+=o.value
o.Move(src)
usr<<"<b>You sold the [o] for [o.value] gold</b>"
usr<<"<font color=green><b>[src]:</font></b> Thank you." // Quicky mart!
if("No")
usr<<"<font color =green><b>[src]:</font></b><font color=red><b> Stop waisting my time!</font></b>"
ID:166734
Jun 23 2006, 9:16 am
|
|
Below is my code for selling items, but you can only sell 1 at a time, which is kinda annoying if you multiple of the same item. How would i do this? How would I item stack in the inventory?
|
Jun 23 2006, 10:09 am (Edited on Jun 23 2006, 11:13 am)
|
|
In response to Shoe
|
|
Shoe wrote:
> var/sold=input("what sell?")as obj in usr it didnt work, it would do all let you chose the amount u wanted to sell but say the that the obj added up would be 0 gold. here is my code below: if("Sell") |
In response to FriesOfDoom
|
|
i put text by mistake there, change it to num.
|
In response to Shoe
|
|
ok, got it to work, but how would i make it check to see if the player actually had that many of the item they were selling?? And how would i make it take that much out of their inventory?
|
In response to FriesOfDoom
|
|
//take out |
In response to Shoe
|
|
Shoe wrote:
> //take out i got this error in the game when trying to sell. <font color=red>runtime error: Cannot read null.value proc name: Shop (/mob/NPC/Shopkeeper/verb/Shop) source file: NPCs.dm,51 usr: FriesOfDoom the King Dragon (/mob/player) src: Shopkeeper (/mob/NPC/Shopkeeper) call stack: Shopkeeper (/mob/NPC/Shopkeeper): Shop() </font> here is my current code: if("Sell") thank you so much so far for your help :P |
In response to FriesOfDoom
|
|
var/a=usr.contents
should be just var/a |
In response to Shoe
|
|
Shoe wrote:
var/a=usr.contentsyeah i tryed just var/a first and it gave me like the same error message |
In response to FriesOfDoom
|
|
um.....anyone?
|
In response to FriesOfDoom
|
|
There are two problems I was aware of after skimming this code. The first is that for(o in usr)del(o) would delete ALL of the items in their contents, and not just the amount they sold(Check my post to your other thread in code problems to fix that). The second is the runtime problem.
if("Yes") Notice the two messages to the player AFTER the object has been deleted? Since o has been deleted you no longer have access to it or it's variables. To get this to work, move the messages before the for(), like so. if("Yes") [edit] if("Yes") I took the liberty of adding my code. I made atom/t because if I were checking to see if O were o.type, and o was deleted earlier in the check you would get a runtime. I am pretty sure it will work, and whatever else isn't in there that you wanted you can probably add yourself from your previous code. -Exophus |