trade problem in Developer Help
|
|
Code:
mob verb Trade(mob/M in oview()) usr << "You sent a trade invitation to [M]" M << "[usr] wants to trade with you." switch(input(M,"Do you accept their trade offer?","Trade with [usr]")as null | anything in list("Yes","No")) if("Yes") var/A = input(usr,"Which item do you want to trade?","Choose an item")as null var/B = input(M,"Which item do you want to trade?","Choose an item")as null switch(input("These are the item chosen to trade.","Trade items",A,B) in list("Yes","No")) if("Yes") switch(input("Do you accept this trade?") in list("Accept","Decline")) if("Accept") for(var/obj/O in usr.contents) if(O.name == A) set src in view() src.A.loc = M
for(var/obj/T in M.contents) if(T.name == B) set src in view() M.B.loc = src if("Decline") usr << "Trade cancelled" M << "Trade cancelled" return if("No") usr << "Trade cancelled" M << "Trade cancelled" return if("No") usr << "Trade cancelled" return
|
Problem description:
after both players have entered the item they want to trade, the trade cancels itself.
|
See how I defined O and I as objects? That way, it only lets them choose from objects. Also it has them pick out of their contents. This is just an example though, so you should be able to add multiple item trading from this example if you want to as well.