PDA

View Full Version : Little Question :>



KillerBoB
21st December 2012, 22:17
I need a idea how to solve this :)

If the event not happen in 5sec. it breaks :>



timer = 0;
while(timer < 5)
{

do i need a if here?
{
self waittill("EVENT");
break;
}
timer += 0.05;
wait 0.05;
}

kung foo man
21st December 2012, 22:54
Hi, that should work:



function onlyFiveSeconds()
{
self endon("fiveSeconds");
while (1)
{
self waittill("EVENT");
self iprintlnbold("Hello in less then 5 seconds!");
}
}

function killThread()
{
wait 5;
self notify("fiveSeconds");
}


spawnplayer() // some random function
{
self onlyFiveSeconds()
self killThread();
}