ID:273622
 
Hi,
I have created a game called Lego Paintball, and am having a little problem. During the wait stage between game set up and game start, the time in which players can choose to join, i want to ask players if they would like to join. However, i have tried to do this before, and the code i used made the player be asked before the timer started, but the timer wouldnt start counting down until all users had answered. As you can imagine, this would create problems if there was even one single player that had gone AFK (i dont have an AFK status thing on it, but you get the idea).

Can anyone help?
Try starting the timer before players answer. If they answer after the time is up, just send them a message saying they waited too long in an if statement.
As an addendum to what OrangeWeapons said, a trick you can use to automatically cancel an input() is to call input() in a throwaway object that you then delete when you want to stop the input(). An example:

input_timer
proc/CallInput(mob/m)
return input(m, "blah blah", "blah") in list("foo", "bar", "baz", "wombat")

mob/verb/TestTimedInput()
var/input_timer/i = new input_timer()
spawn() i.CallInput(src)
spawn(50) del i

In response to Jp
That's neat and definitely useful information right there :D
In response to Spunky_Girl
I might have gotten the trick wrong in that code fragment - didn't test it - but basically it relies on any procedures on an object being killed when you delete the object. It's less useful than it sounds - you really shouldn't be using input if you can avoid it.

I don't remember where I got it from - I think there was a library/demo by Falacy(?) that did it, but I might have seen the trick before then.
In response to Jp
Jp wrote:
I might have seen the trick before

My guess is [link] by Nadrew.
In response to Schnitzelnagler
I have read that thread, so my guess is that I've seen that and the library/demo by someone else that implemented it. Good catch.
In response to Jp
Jp wrote:
As an addendum to what OrangeWeapons said, a trick you can use to automatically cancel an input() is to call input() in a throwaway object that you then delete when you want to stop the input(). An example:

> input_timer
> proc/CallInput(mob/m)
> return input(m, "blah blah", "blah") in list("foo", "bar", "baz", "wombat")
>
> mob/verb/TestTimedInput()
> var/input_timer/i = new input_timer()
> spawn() i.CallInput(src)
> spawn(50) del i
>


Can i ask how i would incoporate it into this?
proc/SetGame()
//... Code before this
GameWait = 1
WaitTimer = 60
while(WaitTimer > 0)
sleep(10)
WaitTimer -= 1
GameWait = 0
//... Code after this