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
#2

make something like with public OnPlayerDeath(playerid, killerid, reason)
And then, make it look like, if he dies while being in the marker, use KillTimer()

like this:

Code:
public OnPlayerDeath(playerid, killerid, reason)
{
      if (IsPlayerInCheckPoint(playerid))
      {
             KillTimer("Your_Timer");
      }
      return 1;
}
Hope it helps
Reply
#3

Code:
public OnPlayerDeath(playerid, killerid, reason)
{
    SendDeathMessage(killerid, playerid, reason);
    
	/* Check The Stats of CheckPoint */
	new inPoint = 0;
	for(new i=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;
		}
}
tested,but the problem still not been resolved.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)