Jump to content
Sign in to follow this  
Worleman313

CREATING A TIME LIMIT

Recommended Posts

K, how in the heck are you suppose to make a time limit for the game?huh.gif? Every time i try to do it, it always seems to mess up!banghead.gifbanghead.gif Could someone please help me??? help.gifhelp.gif

Share this post


Link to post
Share on other sites

Multiplayer or Single Player?

In SP, all you gotta do is this:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_startTime = time;

_timeLimitInSeconds = 600;

while (time-_startTime < _timeLimitInSeconds) do

{

blah blah blah

blah blah blah

blah blah blah

};

That while loop will time out after 600 seconds.

Just one way of many to do it.

Another way I can reccomend if you just want the script to wait and do nothing for that time limit or a condition is met (the code is probably a little wrong here, but spending some time with the wiki will fix you up):

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_timeLimitInSeconds = 600;

waitUntil {(time-_startTime < _timeLimitInSeconds) or (other condition)};

Share this post


Link to post
Share on other sites

Someone else will have to answer that for sure, I'm not an MP editor.

It probably should though, imo. As long as it's executed server side for something that needs to be synchronised.

Share this post


Link to post
Share on other sites

This is the most accurate way I've done it so far:

Place at the end of init.sqs

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">;Time limit in seconds

_time = 1800

?!local server:goto "check"

ending = 0

publicvariable "ending"

#servercheck

?time >= _time:goto "serverend"

~0.01

goto "servercheck"

#serverend

ending = 1

publicvariable "ending"

#check

?ending == 1 : goto "end"

~0.01

goto "check"

#end

;only if the mission has an outro, the outro script should contain the ending command

;if there is no outro, replace with end=true

[] exec "outro.sqs"

exit

To trigger the real end of the mission, make a trigger with "End1" as one of the selections and a condition of end=true, the end section of your timer or outro script should have that same command to activate it. In my maps the activation box has forceEnd as a command to make sure, I'm not sure if it's needed.

The above is superior to triggers because it ends the game almost at the exact same time for all players, whereas triggers aren't known to be so precise (1-2 second margin of error compared to 5-20 seconds).

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×