Jump to content
Sign in to follow this  
Naiss

Loop not working

Recommended Posts

So im trying to make like a round timer but when ever it start it seems like the minute is being the seconds

//Server Loop
SD_Loops_Server_Match = {
	[] spawn {
		while {SD_MatchStarted} do {
			if (SD_MatchTime_S <= 0 && SD_MatchTime_M >= 1) then {
				SD_MatchTime_M = SD_MatchTime_M - 1;
				SD_MatchTime_S = 59;

				publicVariable "SD_MatchTime_M";
				publicVariable "SD_MatchTime_S";
			};
			if (SD_MatchTime_S <= 0 && SD_MatchTime_M <= 0) exitWith {
				_msg = "Round timer ran out.";
				[_msg] call SD_Message_Global;
			};
			
			sleep 1;
			SD_MatchTime_S = SD_MatchTime_S - SD_MatchTime_S;
			publicVariable "SD_MatchTime_S";
		};
	};
};
//Clinet Loop
SD_Client_MatchStart = {
	[] spawn {
		while {SD_MatchStarted} do {
			hintSilent format ["Round Time left: %1:%2",SD_MatchTime_M,SD_MatchTime_S];
		};
	};
};

i can't see any errors here

Share this post


Link to post
Share on other sites

its counting down the seconds, sleep 1 and then remove 1 second and when the second is 0 and the minute is not 0 it will make the seconds 59 and remove one minute and then if the seconds and minute is 0 it will end the loop

Share this post


Link to post
Share on other sites

its counting down the seconds, sleep 1 and then remove 1 second and when the second is 0 and the minute is not 0 it will make the seconds 59 and remove one minute and then if the seconds and minute is 0 it will end the loop

i m sure that KK saw that in ur script. anyway a description is always helpful.

but u should think about what KK said because that pointless line is always 0.

you can write this instead:

SD_MatchTime_S = 0;

thats the same and maybe as pointless as your line...

Share this post


Link to post
Share on other sites

oh wait lol i f*** up HAHA

 

SD_MatchTime_S = SD_MatchTime_S - SD_MatchTime_S;

 

should be

 

SD_MatchTime_S = SD_MatchTime_S - 1;

Share this post


Link to post
Share on other sites

This seems like a very weird way to do a countdown BTW. Why not just count down seconds and then convert this number to minutes and seconds when you need to display it?

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  

×