ID:267981
 
The shopkeeper does not give the weapon when you buy it

Heres The Code:
mob
Shopkeeper2
icon = 'player1.dmi'
verb
Buy()
set src in oview(3)
set category = "Shoppers Magazine"
switch(input("Hello! What do you wish to buy?") in list ("Sword","Nothing"))
if("NinjaSword")
if(usr.gold <= 24)
usr << "<b>You need 25 GOLD!"
if(usr.gold >= 25)
usr << "<b>You get a Sword"
usr.contents += new /obj/weapons1/NSword
usr.gold -= 25
if("Nothing")
usr << "<b>Ok"


Can anyone fix this or point me in the right direction?
new /obj/Weapons/NSword(usr)
You should close your tags.

Also, you probably want a more flexible system than that. Think of two things:

1. What is similar between all shopkeepers?
2. What is different between all (or most) shopkeepers?

The first becomes the proc that they share, and the second becomes the variables that modifies what the proc does.

If you don't understand, answer those two questions, and I'll help.

Or, you can continue doing what you're doing, resulting in large amouts of repeated typing, a larger possibility for mistakes, and a larger file for players to download.
In response to Airjoe
Airjoe wrote:
new /obj/Weapons/NSword(usr)

That doesn't work.
In response to Vash_616
There's no reason why it shouldn't. It creates a /obj/Weapons/NSword, and places it in usr's contents.
Exactly how does it not work?
In response to Jon88
mob
Shopkeeper2
icon = 'player1.dmi'
verb
Buy()
set src in oview(3)
set category = "Shoppers Magazine"
switch(input("Hello! What do you wish to buy?") in list ("NinjaSword","Nothing"))
if("NinjaSword")
if(usr.gold <= 24)
usr << "<b>You need 25 GOLD!"
if(usr.gold >= 25)
usr << "<b>You get a NinjaSword"

usr.contents += new /obj/weapons1/NinjaSword(usr)
usr.gold -= 25
if("Nothing")
usr << "Thank You Come Again!"
In response to Vash_616
No, do not add the object to the player's contents. Simply create it with the player as the target. It will be done for you automatically(just like creating something in/on a turf places it in the turf's contents automatically).