ID:148044
 
Ok, can someone please tell me why this doesnt work.
-----------------------------------------------------------
obj/npcs/Merchant
icon='npcs.dmi'
icon_state="14"
density=1
contents = newlist(/obj/Knife,/obj/Short_Sword,/obj/Broad_Sword,/obj/ Pedal_Staff,/obj/Mace)
verb/Buy()
set src in oview(2)
alert("Hello, I sell weapons, what can I get for you?")
usr.buying = 1
usr.buycontents = src.contents
verb/Sell()
set src in oview(2)
alert("What would you like to sell?")
usr.selling = 1
usr.sellcontents = usr.contents
mob/proc/createobjs()
var/item = pick(typesof(/obj))
new item(usr)
obj/var/cost
obj/var/sellcost
obj/Knife
icon = 'items.dmi'
icon_state = "1"
cost=100
sellcost=50
DblClick()
if(src in usr.buycontents)
if(usr.gold <= src.cost)
usr << "You can't afford it!"
else
switch(alert("Are you sure you wish to buy the [src] for [src.cost] gold?","Buy?","Yes","No"))
if("Yes")
usr.gold -= src.cost
new /obj/weapons/Knife(usr)
if("No")
return
if(src in usr.sellcontents)
src.loc = usr.buyer
switch(alert("Would you like to sell the [src] for [src.sellcost]?","Sell?","Yes","No"))
if("Yes")
usr.gold+=src.sellcost
usr.contents -= src
if("No")
return
else
return 0
Click()
usr<<"This weapons strength is 6."
usr<<"
This weapon costs [src.cost] gold."

obj/Short_Sword
icon = 'items.dmi'
icon_state = "2"
cost=240
sellcost=120
DblClick()
if(src in usr.buycontents)
if(usr.gold <= src.cost)
usr << "You can't afford it!"
else
switch(alert("Are you sure you wish to buy the [src] for [src.cost] gold?","Buy?","Yes","No"))
if("Yes")
usr.gold -= src.cost
new /obj/weapons/Short_Sword(usr)
if("No")
return
if(src in usr.sellcontents)
src.loc = usr.buyer
switch(alert("Would you like to sell the [src] for [src.sellcost]?","Sell?","Yes","No"))
if("Yes")
usr.gold+=src.sellcost
usr.contents -= src
if("No")
return
else
return 0
Click()
usr<<"This weapons strength is 12."
usr<<"
This weapon costs [src.cost] gold."
obj/Broad_Sword
icon = 'items.dmi'
icon_state = "3"
cost=440
sellcost=220
DblClick()
if(src in usr.buycontents)
if(usr.gold <= src.cost)
usr << "You can't afford it!"
else
switch(alert("Are you sure you wish to buy the [src] for [src.cost] gold?","Buy?","Yes","No"))
if("Yes")
usr.gold -= src.cost
new /obj/weapons/Broad_Sword(usr)
if("No")
return
if(src in usr.sellcontents)
src.loc = usr.buyer
switch(alert("Would you like to sell the [src] for [src.sellcost]?","Sell?","Yes","No"))
if("Yes")
usr.gold+=src.sellcost
usr.contents -= src
if("No")
return
else
return 0
Click()
usr<<"This weapons strength is 18."
usr<<"
This weapon costs [src.cost] gold."
obj/Pedal_Staff
icon = 'items.dmi'
icon_state = "4"
cost=480
sellcost=240
DblClick()
if(src in usr.buycontents)
if(usr.gold <= src.cost)
usr << "You can't afford it!"
else
switch(alert("Are you sure you wish to buy the [src] for [src.cost] gold?","Buy?","Yes","No"))
if("Yes")
usr.gold -= src.cost
new /obj/weapons/Pedal_Staff(usr)
if("No")
return
if(src in usr.sellcontents)
src.loc = usr.buyer
switch(alert("Would you like to sell the [src] for [src.sellcost]?","Sell?","Yes","No"))
if("Yes")
usr.gold+=src.sellcost
usr.contents -= src
if("No")
return
else
return 0
Click()
usr<<"This weapons strength is 16."
usr<<"
This weapon costs [src.cost] gold."
obj/Mace
icon = 'items.dmi'
icon_state = "5"
cost=620
sellcost=310
DblClick()
if(src in usr.buycontents)
if(usr.gold <= src.cost)
usr << "You can't afford it!"
else
switch(alert("Are you sure you wish to buy the [src] for [src.cost] gold?","Buy?","Yes","No"))
if("Yes")
usr.gold -= src.cost
new /obj/weapons/Mace(usr)
if("No")
return
if(src in usr.sellcontents)
src.loc = usr.buyer
switch(alert("Would you like to sell the [src] for [src.sellcost]?","Sell?","Yes","No"))
if("Yes")
usr.gold+=src.sellcost
usr.contents -= src
if("No")
return
else
return 0
Click()
usr<<"This weapons strength is 24."
usr<<"
This weapon costs [src.cost] gold."
mob/var
buying
buycontents
selling
sellcontents
buyer
mob
Stat()
..()
if(src.buying)
statpanel("Purchase",src.buycontents)
if(src.selling)
statpanel("Sell",src.sellcontents)

mob/Move()
if(usr.buying && usr.selling)
usr.buying = null
usr.selling = null
if(usr.buying)
usr.buying = null
if(usr.selling)
usr.selling = null
..()

-----------------------------------------------------------
And tell me why this DOES work.
-----------------------------------------------------------
obj/npcs/Merchant
icon='npcs.dmi'
icon_state="jtrain"
density=1
contents = newlist(/obj/Iron_Knife,/obj/Steel_Knife,/obj/Steel_Dagger,/ obj/Short_Sword,/obj/Long_Sword)
verb/Buy()
set src in oview(2)
alert("Hello, I sell weapons, what can I get for you?")
usr.buying = 1
usr.buycontents = src.contents
verb/Sell()
set src in oview(2)
alert("What would you like to sell?")
usr.selling = 1
usr.sellcontents = usr.contents
mob/proc/createobjs()
var/item = pick(typesof(/obj))
new item(usr)
obj/var/cost
obj/var/sellcost
obj/Iron_Knife
icon = 'equipment.dmi'
icon_state = "w1"
cost=100
sellcost=50
DblClick()
if(src in usr.buycontents)
if(usr.gold <= src.cost)
usr << "You can't afford it!"
else
switch(alert("Are you sure you wish to buy the [src] for [src.cost] gold?","Buy?","Yes","No"))
if("Yes")
usr.gold -= src.cost
new /obj/swords/Iron_Knife(usr)
if("No")
return
if(src in usr.sellcontents)
src.loc = usr.buyer
switch(alert("Would you like to sell the [src] for [src.sellcost]?","Sell?","Yes","No"))
if("Yes")
usr.gold+=src.sellcost
usr.contents -= src
if("No")
return
else
return 0
Click()
usr<<"This weapons strength is 5."
usr<<"
This weapon costs [src.cost] gold."

obj/Steel_Knife
icon = 'equipment.dmi'
icon_state = "w2"
cost=240
sellcost=120
DblClick()
if(src in usr.buycontents)
if(usr.gold <= src.cost)
usr << "You can't afford it!"
else
switch(alert("Are you sure you wish to buy the [src] for [src.cost] gold?","Buy?","Yes","No"))
if("Yes")
usr.gold -= src.cost
new /obj/swords/Steel_Knife(usr)
if("No")
return
if(src in usr.sellcontents)
src.loc = usr.buyer
switch(alert("Would you like to sell the [src] for [src.sellcost]?","Sell?","Yes","No"))
if("Yes")
usr.gold+=src.sellcost
usr.contents -= src
if("No")
return
else
return 0
Click()
usr<<"This weapons strength is 10."
usr<<"
This weapon costs [src.cost] gold."
obj/Steel_Dagger
icon = 'equipment.dmi'
icon_state = "w3"
cost=360
sellcost=180
DblClick()
if(src in usr.buycontents)
if(usr.gold <= src.cost)
usr << "You can't afford it!"
else
switch(alert("Are you sure you wish to buy the [src] for [src.cost] gold?","Buy?","Yes","No"))
if("Yes")
usr.gold -= src.cost
new /obj/swords/Steel_Dagger(usr)
if("No")
return
if(src in usr.sellcontents)
src.loc = usr.buyer
switch(alert("Would you like to sell the [src] for [src.sellcost]?","Sell?","Yes","No"))
if("Yes")
usr.gold+=src.sellcost
usr.contents -= src
if("No")
return
else
return 0
Click()
usr<<"This weapons strength is 15."
usr<<"
This weapon costs [src.cost] gold."
obj/Short_Sword
icon = 'equipment.dmi'
icon_state = "w4"
cost=480
sellcost=240
DblClick()
if(src in usr.buycontents)
if(usr.gold <= src.cost)
usr << "You can't afford it!"
else
switch(alert("Are you sure you wish to buy the [src] for [src.cost] gold?","Buy?","Yes","No"))
if("Yes")
usr.gold -= src.cost
new /obj/swords/Short_Sword(usr)
if("No")
return
if(src in usr.sellcontents)
src.loc = usr.buyer
switch(alert("Would you like to sell the [src] for [src.sellcost]?","Sell?","Yes","No"))
if("Yes")
usr.gold+=src.sellcost
usr.contents -= src
if("No")
return
else
return 0
Click()
usr<<"This weapons strength is 20."
usr<<"
This weapon costs [src.cost] gold."
obj/Long_Sword
icon = 'equipment.dmi'
icon_state = "w5"
cost=700
sellcost=350
DblClick()
if(src in usr.buycontents)
if(usr.gold <= src.cost)
usr << "You can't afford it!"
else
switch(alert("Are you sure you wish to buy the [src] for [src.cost] gold?","Buy?","Yes","No"))
if("Yes")
usr.gold -= src.cost
new /obj/swords/Long_Sword(usr)
if("No")
return
if(src in usr.sellcontents)
src.loc = usr.buyer
switch(alert("Would you like to sell the [src] for [src.sellcost]?","Sell?","Yes","No"))
if("Yes")
usr.gold+=src.sellcost
usr.contents -= src
if("No")
return
else
return 0
Click()
usr<<"This weapons strength is 25."
usr<<"
This weapon costs [src.cost] gold."
mob/var
buying
buycontents
selling
sellcontents
buyer
mob
Stat()
..()
if(src.buying)
statpanel("Purchase",src.buycontents)
if(src.selling)
statpanel("Sell",src.sellcontents)

mob/Move()
if(usr.buying && usr.selling)
usr.buying = null
usr.selling = null
if(usr.buying)
usr.buying = null
if(usr.selling)
usr.selling = null
..()
No put usr in procs. Ungh.

Use DM tags.

<-Airjoe->
In response to Airjoe
Airjoe wrote:
No put usr in procs. Ungh.

Use DM tags.

<-Airjoe->

Sounds familiar, but usr is acceptable in Click, or so I'm lead to believe. :)

To topic creator,
You should be more specific about your problem, as it will help people solve it quicker. Do you get errors when compiling? What about when the game is running? What are the errors? Where does it start to go wrong? If none of the items are able to be bought, just show one or two of them as a demo. I'm going to look through this some more and post if I see anything fishy, in the meantime please edit your post to put a <dm> tag infront of your code and a <dm> tag at the end of it. :)
In response to Jnco904
mob/Move()
if(usr.buying && usr.selling)
usr.buying = null
usr.selling = null
if(usr.buying)
usr.buying = null
if(usr.selling)
usr.selling = null
..()

=)
usr, I thought, was really not good in Move()
In response to Airjoe
Oops, I kind of skipped through the bold part, sorry about that. :P

I don't see any big differences in either one. Are you using both at the same time? If so I would try merging them, for instance you don't need two Move() procs for the same thing and I'm defining the same mob twice isn't good(likely problem). :P
In response to Jnco904
I'm not using both at the same time, i just tried them at different times. One in one project and one in another. And only ONE worked lol. But what happens is if i test it, I go to the shopkeeper and hit buy, but the new statpanel to purchase things doesnt come up. I will try the putting in usr.
In response to Tetra41
I was wondering... Could something I coded conflict with the shopkeeper code? Although it doesnt say when i compile. It has no errors when i compile.
In response to Tetra41
That would be my only guess, try switching them and see if the same one works.
In response to Jnco904
I tried that, it still doesnt work. I think it is conflicting with another code i have but im not sure what one. i dont understand what one either.
In response to Tetra41
It's kinda weird to say that a code works on one game, but the EXACT same code doesn't work on another. Its like... hell i dont know what its like but its screwed up. someone plz help me!!!! (this is annoying)
In response to Tetra41
I'm beginning to think my problem lies somewhere in this code.
 (i used the tag)

mob
Stat()
..()
if(src.buying)
statpanel("Purchase",src.buycontents)
if(src.selling)
statpanel("Sell",src.sellcontents)

mob/Move()
if(usr.buying && usr.selling)
usr.buying = null
usr.selling = null
if(usr.buying)
usr.buying = null
if(usr.selling)
usr.selling = null
..()

i think so just because when you use the verb buy, the new statpanel doesnt come up. owell tell me what you think.
In response to Tetra41
Nope. It doesnt but i was able to narrow it down. What i did was copy the exact code that worked and pasted it into my game, and edited the items to the names they said:
obj/npcs/Merchant
icon='npcs.dmi'
icon_state="14"
density=1
contents = newlist(/obj/Knife,/obj/Short_Sword,/obj/Broad_Sword,/obj/Pedal_Staff,/obj/Mace)
verb/Buy()
set src in oview(2)
alert("Hello, I sell weapons, what can I get for you?")
usr.buying = 1
usr.buycontents = src.contents
verb/Sell()
set src in oview(2)
alert("What would you like to sell?")
usr.selling = 1
usr.sellcontents = usr.contents
mob/proc/createobjs()
var/item = pick(typesof(/obj))
new item(usr)
obj/var/cost
obj/var/sellcost
obj/Knife
icon = 'items.dmi'
icon_state = "1"
cost=100
sellcost=50
DblClick()
if(src in usr.buycontents)
if(usr.gold <= src.cost)
usr << "You can't afford it!"
else
switch(alert("Are you sure you wish to buy the [src] for [src.cost] gold?","Buy?","Yes","No"))
if("Yes")
usr.gold -= src.cost
new /obj/weapons/Iron_Knife(usr)
if("No")
return
if(src in usr.sellcontents)
src.loc = usr.buyer
switch(alert("Would you like to sell the [src] for [src.sellcost]?","Sell?","Yes","No"))
if("Yes")
usr.gold+=src.sellcost
usr.contents -= src
if("No")
return
else
return 0
Click()
usr<<"<B>This weapons strength is 5."
usr<<"<B>This weapon costs [src.cost] gold."

SO i was all happy and stuff, but where it says contents = newlist, that is where the problem is. What i did was changed the /obj/ items to what i wanted them to be called and edited them below, it didnt appear when i tried it. But it did if i left it all the same. Kinda confusing hopefully you know what i mean.
In response to Tetra41
Sry about the continuous posting but i found another thing. My code was in a file called "Merchants". I compiled it, tried it, and it didnt work. Now this is the odd part. I copied it exactly, and pasted it in a file called "TEST" and it worked! But i deleted that, and pasted it into a file called "Shopkeepers." but it didnt work!!! Confusing, i put it bakc into "TEST" and it worked. Please clear up my confusion!!
In response to Tetra41
Ever heard of editing...
In response to Koolguy900095
Yes ive heard of editing but thats not the problem here. If you read my last post i did the file thing numerous times and found out that the only one that worked was "TEST"
How about,
No one's going to help you if you post that much code. (Or at least I'm not.) Try just posting the relevent sections and telling everyone what the problem you're having is. (Generally when you get error messages, they'll point to the line thats the problem.)
In response to Tetra41
He meant editing your posts so that your not spamming. Anyway if the window doesn't show up I think it could be that you have to call Stat(). You should try calling Stat() at the end of the buy verb. Other than that, I don't know.