Code:
mob/shopkeeper
icon = 'dyluck.dmi'
verb/Buy()//b in selling
set src in view(2)// Makes sure that the shopkeeper is in view of the player
var/selling = input("What do you wish to buy?") in list("Rusty Shortsword","Rusty Dagger","Rusty Halberd","An old Club") // list of what the shopkeeper sells
var/cost
if(selling == "Sword")
cost = 15
if(selling == "Dagger")
cost = 5
if(selling == "Spear")
cost = 10
if(selling == "Axe")
cost = 20
var/choice = input("That will be [cost] Gold. You have [usr.gold] Gold") in list("Yes","No")
if(choice == "Yes") // If the user says yes and he can afford the weapon, give it to him.
// Define the costs of each weapon
if(usr.gold >= cost)
usr.gold -= cost
if(selling=="Dagger") new/obj/dagger(usr)
if(selling=="Death Dagger") new/obj/deathdagger(usr)
if(selling=="The Stone Sword") new/obj/stonesword(usr)
if(selling== "The Tomb Sword") new/obj/tombsword(usr)
else
usr<<"You don't have enough Gold!"
Errors:
Death Tomb.dm:597:error:usr.gold:bad var
Death Tomb.dm:600:error:usr.gold:bad var
Death Tomb.dm:601:error:usr.gold:bad var
Please help thanx :)
ID:151149
Mar 6 2001, 5:10 am
|
|
In response to Gazoot
|
|
On 3/6/01 3:33 pm Gazoot. wrote:
The error you get is because usr hasn't got a gold variable. If your player is of type /mob/player, you can do a "var/player/mob/M = usr" in the beginning of the verb and replace all usr with M, then it will work. The FAQ talks about this and provides some sample code for solving it (basically what Andreas said) at: BYOND FAQ bad var discussion |
/Andreas