ID:145364
 
Code: Shopkeeper
Im Kinda a newb at this o.o

    Shopkeeper
icon = 'Mobs.dmi'
icon_state = "shop1"
Click()
set src in oview(2)
switch(input("What would you like to buy?") in list ("Health Potion","Dagger","Sword","Shield","None"))
if("Health Potion")
src.contents.Add(new/obj/Health_potion)
if("Dagger")
if (usr.gold <= 50)
usr << "You do not have enough gold!"
if (usr.gold > 50)
usr.gold -= 50
src.contents.Add(new/obj/dagger)
if("Sword")
if (usr.gold <= 100)
usr << "You do not have enough gold!"
if (usr.gold > 100)
usr.gold -= 100
src.contents.Add(new/obj/sword)
if("Shield")
if (usr.gold <= 150)
usr << "You do not have enough gold!"
if (usr.gold > 150)
usr.gold -= 150
src.contents.Add(new/obj/shield)
if("None")
return


Problem description: The item isnt apearing in the inventory, just wondering why?


In Click(), usr is the clicker, and src is whatever you're clicking, so you're adding the item to the inventory of the shopkeeper instead of the player. And, you don't need "set src in oview(2)", that's for verbs. You'd want something more like this:
Click()
if(!src in oview(1)) return //if the thing clicked isnt within one square of the clicker, do nothing
//continue the procedure, they must be close enough
In response to Detnom
LOL xD okay thanks alot
Edit: Ok now its saying bad argument definition =/
In response to SSJGohan27
new/obj/lololitemplz(usr)


That should work.
In response to DivineO'peanut
DivineO'peanut wrote:
> new/obj/lololitemplz(usr)
>

Contents is not the same thing as an object that is placed in usr.

Actually it is, but using new/itempath(usr) is far better than usr.contents+=new/itempath().

Incidentally, I implore you to stop using "lololitemplz" and other similar garbage in your posts. And by implore, I mean insist. Be plain, be clear, or don't bother posting code help to people. A number of your "helping" posts have already been deleted because they were pure rubbish and did not help at all, plus the use of this leetspeak crap gives them a mocking quality.

Lummox JR
In response to Lummox JR
Lummox JR wrote:
DivineO'peanut wrote:
> > new/obj/lololitemplz(usr)
> >

Contents is not the same thing as an object that is placed in usr.

Actually it is, but using new/itempath(usr) is far better than usr.contents+=new/itempath().

Incidentally, I implore you to stop using "lololitemplz" and other similar garbage in your posts. And by implore, I mean insist. Be plain, be clear, or don't bother posting code help to people. A number of your "helping" posts have already been deleted because they were pure rubbish and did not help at all, plus the use of this leetspeak crap gives them a mocking quality.

Lummox JR

Alright, I apologize for these silly posts. I'll try to be more informing from now in.
SSJGohan27 wrote:
Code: Shopkeeper
Im Kinda a newb at this o.o

>   Shopkeeper
> icon = 'Mobs.dmi'
> icon_state = "shop1"
> Click()
> set src in oview(2)
> switch(input("What would you like to buy?") in list ("Health Potion","Dagger","Sword","Shield","None"))
> if("Health Potion")
> src.contents.Add(new/obj/Health_potion)
> if("Dagger")
> if (usr.gold <= 50)
> usr << "You do not have enough gold!"
> if (usr.gold > 50)
> usr.gold -= 50
> src.contents.Add(new/obj/dagger)
> if("Sword")
> if (usr.gold <= 100)
> usr << "You do not have enough gold!"
> if (usr.gold > 100)
> usr.gold -= 100
> src.contents.Add(new/obj/sword)
> if("Shield")
> if (usr.gold <= 150)
> usr << "You do not have enough gold!"
> if (usr.gold > 150)
> usr.gold -= 150
> src.contents.Add(new/obj/shield)
> if("None")
> return
>
>

Problem description: The item isnt apearing in the inventory, just wondering why?

For one: i think your supposed to put
if("Dagger")
> if (usr.gold <= 49)
> usr << "You do not have enough gold!"
> if (usr.gold > 50)
> usr.gold -= 50
> src.contents.Add(new/obj/dagger)

And for two: i dont think you specified where thhe items supposed to be going.

And finally for three: im a newb coder so im just trying to fix your problem the best way i can.(if you havent already fixed it yourself)