ID:145043
 
Code:
                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}

var/amountof=input("How much of [o] would you like to sell?") as null|num
if(amountof<src.amountof)
usr<<"Don't be trying to rip me off!"
else
switch(alert("I'll give you [o.value*amountof] gold for [amountof] [o]. Sell?",src,"Yes","No"))
if("Yes")
usr.Gold+=o.value*amountof
del(src)
usr<<"<b>You sold [amountof] [o] for [o.value*amountof] gold</b>"
usr<<"<font color=green><b>[src]:</font></b> Thank you."
if("No")
usr<<"<font color =green><b>[src]:</font></b><font color=red><b> Stop waisting my time!</font></b>"


Problem description:
just says NPCs.dm:44:error:src.amountof:undefined var

i don't know how its undefined, or how to define it.
if the src is a mob:

mob
var
amountof = [what ever you want]


If the src is a obj or what ever, replace mob with the type.
In response to Y2kEric
Yes, you just set amountof as a var. If src is an obj it has to be an obj/var or if its a mob it must be a mob/var.
Those 2 variables must be assigned outside the sell code.
In response to Pyro_dragons
ok thx you very much, but:
del(src)

what would i change this code to so that it would delete the right amount of obj, and the right obj from the players inventory. Right now it deletes the shopkeeper. The code for my sell is in my first post. but here it is again.
                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}

var/amountof=input("How much of [o] would you like to sell?") as null|num
if(amountof<src.amountof)
usr<<"Don't be trying to rip me off!"
else
switch(alert("I'll give you [o.value*amountof] gold for [amountof] [o]. Sell?",src,"Yes","No"))
if("Yes")
usr.Gold+=o.value*amountof
del(src) // Or del(o), depends what system you want.
usr<<"<b>You sold [amountof] [o] for [o.value*amountof] 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>"
In response to FriesOfDoom
Shouldn't be src... Should be o.

var/atom/t=new o.type
for(amountof,amountof>0,amountof--)
for(var/obj/O in usr.contents)
if(istype(O,t.type))
del(O)


I made atom/t because I am pretty sure that if I made it check to see if O was o.type, then it might have deleted o and then you would probably get a runtime. However, that should work.
In response to Exophus
i didn't work :(:::::
i got this runtime:
<font color=red>
runtime error: Cannot read null.value
proc name: Shop (/mob/NPC/Shopkeeper/verb/Shop)
source file: NPCs.dm,55
usr: FriesOfDoom the King Dragon (/mob/player)
src: Shopkeeper (/mob/NPC/Shopkeeper)
call stack:
Shopkeeper (/mob/NPC/Shopkeeper): Shop()
</font>

here is my code
                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}

var/amountof=input("How much of [o] would you like to sell?") as null|num
if(amountof<src.amountof)
usr<<"Don't be trying to rip me off!"
else
switch(alert("I'll give you [o.value*amountof] gold for [amountof] [o]. Sell?",src,"Yes","No"))
if("Yes")
var/atom/t=new o.type
for(amountof,amountof>0,amountof--)
for(var/obj/O in usr.contents)
if(istype(O,t.type))
del(O)
usr.Gold+=o.value*amountof
del(src) // Or del(o), depends what system you want.
usr<<"<b>You sold [amountof] [o] for [o.value*amountof] 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>"


some one plz help, im losing hope of ever figuring this out. Any suggestions on just making the selling a click to sell thing?
In response to FriesOfDoom
have you assigned value as an object varible.....
In response to A.T.H.K
A.T.H.K wrote:
have you assigned value as an object varible.....

no clue, this is my first game, and my first time coding one, if you could tell me how and what it looks like i would greatly appreciate it
In response to FriesOfDoom
obj/var/value
or it mob/? your assigning the varible to an object so it should be the first one ^
In response to A.T.H.K
I've notice this is incorrect:

var/obj/o=input("What do you wish to sell?",src) as obj in null|usr


Correct way:

var/obj/o = input(usr,"What do you wish to sell?","Sell Item") as null|anything in usr.contents // Or it could be usr
In response to A.T.H.K
A.T.H.K wrote:
obj/var/value
or it mob/? your assigning the varible to an object so it should be the first one ^

oh ok value, i though you were talking like a number not the var/value, and yes i did.
In response to Y2kEric
k, i fixed that but it still get the error. Is there a way i could make it so you could just click on the items to sell them? how? I tryed to do this the first time but a friend didnt explain it well and i couldnt figure out how to.
thx so much for the help so far :P
In response to FriesOfDoom
Look at your other post here [link]

- GhostAnime