SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 24/04/2011, 01:14 PM   #1
VivianKris
Big Clucker
 
Join Date: Jun 2010
Posts: 105
Reputation: 0
Question A Problem About Timer

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.
VivianKris is offline  
Old 24/04/2011, 01:48 PM   #2
judothijs
Big Clucker
 
Join Date: Dec 2010
Location: The Netherlands
Posts: 112
Reputation: 10
Default Re: A Problem About Timer

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
__________________
Code:
Filterscripts:
Area 51
Forum:
N/A
Server IP:
N/A Click to Play!
judothijs is offline  
Old 24/04/2011, 03:05 PM   #3
VivianKris
Big Clucker
 
Join Date: Jun 2010
Posts: 105
Reputation: 0
Question Re: A Problem About Timer

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.
VivianKris is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Timer problem Bilawal2050 Help Archive 2 19/03/2011 02:22 PM
Timer problem nejc001 Help Archive 3 05/10/2010 03:08 PM
Timer Problem yeswecanchange09 Help Archive 3 12/06/2010 03:26 PM
timer problem sandisk125 Help Archive 2 19/08/2009 09:56 PM
Problem with this timer... Zebadee Help Archive 0 18/02/2009 10:50 PM


All times are GMT. The time now is 01:35 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.