I give MOBs a trading verb, anyone close enough can click it, sellect a item from that person and offer something in return.
Because I don't want them to move at all during trading I lock them down by setting some var to be true (when moving, that var is checked and if it is true you can't move)
Now how would I beable to make sure that when someone trades, and prevents movement on both mobs untill trade is completed, this trade is canceled if one of the mobs takes to long to pick/offer/accept/decline or when one of the mobs is idle for to long?
The question is how to do this, not how this trade system should work. The trade system is just there to give you an idea of what the problem could be. (and I know it's one crappy way to implement trading in a game)
I thought I could spawn the input proc, then start a while proc which waits and only continues when either client is gone, when input is given or when a client is idle for to long.
But this just does not seem to work.
var/i = null
spawn() i = input(m,"Select","Trading") in list("Apple","Pear")
while(!i && m && m.inactivity < 600) //so as soon as we have input, or m is gone or m is idle for a minute this loop breaks, you would think ...
sleep(50)
world << "And we wait another 5 second, we have time ..."
if(m)
world << "We have a winner, [i]!"
else
world << "He strangely disappeared"
The basic thing is, if someone just disconnect when having a input window open this input proc is never returned and thus the other person can't ever move again because trade is not finished. (I sense a relog)
Anyways, that is the story, and my way of asking how to trigger input procs in a way that code will keep running if they are never returned.
Thanks in advance!