ID:262794
 
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.

Ok, first of all, in your code, if you had two of an item and they both had the same name, it would trade all of them to the other player. There's some other problems, but I am tired so try something a little like this...

mob
verb
Trade()
var/list/l=new()//New list
for(var/mob/M in view(usr))//Checks all mobs in usr's view...
if(M.client)//If they are a player
l+=M//Adds 'em
var/mob/M=input("Who do you want to trade with?")in l//Select a player to trade with
switch(input(M,"Do you wish to trade with [usr]?")in list("Yes","No"))//Asks other person if they want to trade
if("Yes")
var/obj/O=input(usr,"What item do you wish to offer?")in usr.contents
var/obj/I=input(M,"What item do you wish to offer?")in M.contents//Has them select offers
switch(input(usr,"Do you wish to trade your [O] for [M]'s [I]?")in list("Yes","No"))//Asks usr if they accept
if("Yes")
switch(input(M,"[usr] has accepted. Do you wish to trade your [I] for [usr]'s [O]?")in list("Yes","No"))
if("Yes")//Accepted
O.Move(M.contents)//Moves O into M's contents
I.Move(usr.contents)//Moves I into usr's contents
usr<<"Trade completed."
M<<"Trade completed."
if("No")//Cancelled.
usr<<"Trade cancelled."
M<<"Trade cancelled."
if("No")//Cancelled.
usr<<"Trade cancelled."
M<<"Trade cancelled."
if("No")//Cancelled.
usr<<"Trade cancelled."
M<<"Trade cancelled."


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.
In response to XxDragonFlarexX (#1)
thst leaves you with 3 warnings, all calling the switch statement empty
In response to Pyro_dragons (#2)
why does it say empty switch statement? it look like it should work, but it doesnt.
In response to Pyro_dragons (#3)
bump
In response to Pyro_dragons (#4)
Reindent it, then it should work. Sorry bout the late post heh. And my brain is a little durrr right now and I am sick so I forgot if I did something wrong on them >_>.

(EDIT)
This is XxDragonFlarexX, forgot to change keys.. >_>
In response to Void Entertainment (#5)
what is "it"?
In response to Pyro_dragons (#6)
Please don't bump unless 24 hours have passed and it is off the first page.
In response to Audeuro (#7)
sorry, but he didn't specify what "it" is it says empty switch type

mob
verb
Trade()
var/list/l=new()
for(var/mob/M in view(usr)).
if(M.client)
l+=M
var/mob/M=input("Who do you want to trade with?")in l
switch(input(M,"Do you wish to trade with [usr]?")in list("Yes","No"))
if("Yes")
var/obj/O=input(usr,"What item do you wish to offer?")in usr.contents
var/obj/I=input(M,"What item do you wish to offer?")in M.contents
switch(input(usr,"Do you wish to trade your [O] for [M]'s [I]?")in list("Yes","No"))
if("Yes")
switch(input(M,"[usr] has accepted. Do you wish to trade your [I] for [usr]'s [O]?")in list("Yes","No"))
if("Yes")
O.Move(M.contents)
I.Move(usr.contents)
usr<<"Trade completed."
M<<"Trade completed."
if("No")
usr<<"Trade cancelled."
M<<"Trade cancelled."
if("No").
usr<<"Trade cancelled."
M<<"Trade cancelled."
if("No")
usr<<"Trade cancelled."
M<<"Trade cancelled."
In response to Pyro_dragons (#8)
You indented wrong. It should look like this...

switch(input("X")in list("Y","N"))
if("Y")
...
if("N")
...


Instead, you have it like this...

switch(input("X")in list("Y","N"))
if("Y")
...
if("N")
...


By "it", I meant the entire thing. Just to make sure it was all indented correctly.
In response to XxDragonFlarexX (#9)
ok, it works, but i get this completely WTF runtime error with a part that not even in the proc.

mob
verb
Trade()
var/list/l=new()
for(var/mob/M in view(usr)).
if(M.client)
l+=M
var/mob/M=input("Who do you want to trade with?")in l
switch(input(M,"Do you wish to trade with [usr]?")in list("Yes","No"))
if("Yes")
var/obj/O=input(usr,"What item do you wish to offer?")in usr.contents
var/obj/I=input(M,"What item do you wish to offer?")in M.contents
switch(input(usr,"Do you wish to trade your [O] for [M]'s [I]?")in list("Yes","No"))
if("Yes")
switch(input(M,"[usr] has accepted. Do you wish to trade your [I] for [usr]'s [O]?")in list("Yes","No"))
if("Yes")
O.Move(M.contents)
I.Move(usr.contents)
usr<<"Trade completed."
M<<"Trade completed."
if("No")
usr<<"Trade cancelled."
M<<"Trade cancelled."
if("No").
usr<<"Trade cancelled."
M<<"Trade cancelled."
if("No")
usr<<"Trade cancelled."
M<<"Trade cancelled.


runtime error: undefined proc or verb /list/Enter().

proc name: Trade (/mob/verb/Trade)
usr: <FONT COLOR=... (/mob/Pyro_Dragons/GM)
src: <FONT COLOR=... (/mob/Pyro_Dragons/GM)
call stack:
<FONT COLOR=... (/mob/Pyro_Dragons/GM): Trade()

what the heck where is /list/enter()? i don't see that anywhere.

In response to Pyro_dragons (#10)
Pyro_dragons wrote:
ok, it works, but i get this completely WTF runtime error with a part that not even in the proc.

mob
> verb
> Trade()
> var/list/l=new()
> for(var/mob/M in view(usr)).
> if(M.client)
> l+=M
> var/mob/M=input("Who do you want to trade with?")in l
> switch(input(M,"Do you wish to trade with [usr]?")in list("Yes","No"))
> if("Yes")
> var/obj/O=input(usr,"What item do you wish to offer?")in usr.contents
> var/obj/I=input(M,"What item do you wish to offer?")in M.contents
> switch(input(usr,"Do you wish to trade your [O] for [M]'s [I]?")in list("Yes","No"))
> if("Yes")
> switch(input(M,"[usr] has accepted. Do you wish to trade your [I] for [usr]'s [O]?")in list("Yes","No"))
> if("Yes")
> O.Move(M.contents)
> I.Move(usr.contents)
> usr<<"Trade completed."
> M<<"Trade completed."
> if("No")
> usr<<"Trade cancelled."
> M<<"Trade cancelled."
> if("No").
> usr<<"Trade cancelled."
> M<<"Trade cancelled."
> if("No")
> usr<<"Trade cancelled."
> M<<"Trade cancelled.


runtime error: undefined proc or verb /list/Enter().

proc name: Trade (/mob/verb/Trade)
usr: <FONT COLOR=... (/mob/Pyro_Dragons/GM)
src: <FONT COLOR=... (/mob/Pyro_Dragons/GM)
call stack:
<FONT COLOR=... (/mob/Pyro_Dragons/GM): Trade()

what the heck where is /list/enter()? i don't see that anywhere.


I am not too good with runtimes but if I had to guess I would think that it's the period after the for(var/mob/M in view(usr)). So just delete that period and I think it should work. Also, if you didn't add an if("No") for the first switch input, you might want to do that.
In response to XxDragonFlarexX (#11)
nope no change
In response to Pyro_dragons (#12)
see above posts plz. it wokrs up until the items are supposed to change to the other player.