ID:262958
 
Ok, i have searched for the problem in the code many times, and i just cant find it. So basically you guys are my last hope. The error occurs when you click the npc.

Here is the code that has the runtime error:


mob/NPC
Weapon_Buyer
icon = 'Mobs.dmi'
icon_state = "itemmerch"
char_name = "Weapons and armor buyer"
name = "Weapons and armor buyer"
pvp = "Non-Active"
safe=1
Age = 23
HP = 10
PP = 4196
class = "Buyer"
Click(var/obj/weapons/O in usr.contents)
switch(alert("Weapons and armor buyer: I am willing to buy [O.name] for [O.sellval]y, do you wish to part with it?","Weapons and armor buyer","Yes","No"))
if("Yes")
if(O.suffix == " Equipped")
usr<<"[src.name]: You cant sell it while it's equipped."
else
usr.yen += O.sellval
del(O)
usr<<"Weapons and armor buyer: Thank you for your buisness."

Here is the runtime error:

runtime error: undefined variable /turf/White_Tile/var/sellval
proc name: Click (/mob/NPC/Weapon_Buyer/Click)
source file: Graphics.dm,1516
usr: Krow (/mob)
src: Weapons and armor buyer (/mob/NPC/Weapon_Buyer)
call stack:
Weapons and armor buyer (/mob/NPC/Weapon_Buyer): Click(Crystal Quest (18,22,3) (/turf/White_Tile))

The line its refering to in the error:

switch(alert("Weapons and armor buyer: I am willing to buy [O.name] for [O.sellval]y, do you wish to part with it?","Weapons and armor buyer","Yes","No"))



HELP!!
'sup Dark Krow.

Umm, are you sending an argument to Click()? If not, don't place that variable there. Besides, it's not properly set anyway. Rather, use this.

var/obj/weapons/O = locate(/obj/weapons/) in usr.contents


Then check to see if O has a value of null, 0, or false. If it does' cancel the procedure. That should fix up your problem.
Just as a sidenote, you could use if(alert(trg,msg,title,opt1,opt2,opt3)==opt1)dostuff()
else dootherstuff()
to shorten it up a bit