A Problem About Timer
#1

Code:
newtimer;
newtime=12;
newinred=0;

publicOnPlayerEnterCheckpoint(playerid)
{
	if(GetPlayerTeam(playerid)==2&&!IsPlayerInAnyVehicle(playerid)&&inred==0)
	{
		timer=SetTimer("RedPoint",1000,true);
	}
	return true;
}

publicRedPoint()
{
	newinPoint=0;
	for(newi=0;i<MAX_PLAYERS;i++)
		{
			if(GetPlayerTeam(i)==2&&IsPlayerInCheckpoint(i))
				{
					inPoint=1;
					inred=1;
					break;
				}
		}
	if(inPoint==0)
		{
			KillTimer(timer);
			time=12;
			inred=0;
			return true;
		}

	if(time!=0)
		{
			newstr[16];
			format(str,sizeof(str),"~r~%d",time);
			PlaySoundForAll(1056);
			GameTextForAll(str,800,4);
			time--;
		}
	else
		{
			KillTimer(timer);
			GameTextForAll("~r~Red~w~TeamWins!",15000,5);
			for(newi=0;i<MAX_PLAYERS;i++)
			{
				if(gLogged[i]==1&&GetPlayerTeam(i)==2)
					{
						PlayerInfo[i][pScore]+=50;
					}
				TogglePlayerControllable(i,0);
				PlayerPlaySound(i,1058,0.0,0.0,0.0);
				SetPlayerCameraPos(i,1073.0526,-345.5891,94.8660);
				SetPlayerCameraLookAt(i,1045.6394,-316.2937,81.8911);
			}
		}
	return true;
}
This is a bettle, if red team enter checkpoint,time will reduce to 0 and red team win.
the timer not run unless a red team people in checkpoint.
but when a red team people dead in checkpoint , the timer wont be stopped and will delay 3s-4s.
i want to know why,please.
Reply


Messages In This Thread
A Problem About Timer - by VivianKris - 24.04.2011, 13:14
Re: A Problem About Timer - by judothijs - 24.04.2011, 13:48
Re: A Problem About Timer - by VivianKris - 24.04.2011, 15:05

Forum Jump:


Users browsing this thread: 2 Guest(s)