timers
#1

Guys i need some help with timers,i make when player enter the Checkpoint and type /rob it will start countdown 7,6,5,4,3,2,1,winer ...

but how i can make if player leave this CP1 this timer wont countdown anymore if he leave the CP

i make under GamemodeInit ...

Code:
timer1 = SetTimer("Seven", 1000, 0);
	timer2 = SetTimer("Six", 2000, 0);
	timer3 = SetTimer("Five", 3000, 0);
	timer4 = SetTimer("Four", 4000, 0);
	timer5 = SetTimer("Three", 5000, 0);
	timer6 = SetTimer("Two", 6000, 0);
	timer7 = SetTimer("One", 7000, 0);
	timer8 = SetTimer("Winner", 8000, 0);
sure before this timer i have , new timer1; , new timer2; etc etc

than i have Command

Code:
if (strcmp("/rob", cmdtext, true, 10) == 0)
	{
	if(gTeam[playerid] != TEAM_GROVE)
	{
	SendClientMessage(playerid,0x33CCFFAA,"You Must Be In Grove Team To Rob Jefferson Motel!");
	return 1;
	}
	if(IsPlayerInCheckpoint(playerid))
	{
	  SetTimer("Seven", 1000, 0);
	  SetTimer("Six", 2000, 0);
	  SetTimer("Five", 3000, 0);
	  SetTimer("Four", 4000, 0);
		SetTimer("Three", 5000, 0);
		SetTimer("Two", 6000, 0);
		SetTimer("One", 7000, 0);
		SetTimer("Winner", 8000, 0);
		
		format(string, sizeof(string), "%s(%d) Is Robbing Jefferson It Will Take 8 Seconds To Complete Robbery!",pname,giveplayerid);
		SendClientMessage(TEAM_COP,0xFFFF00AA,string);
		return 1;
	}
	else
	{
	SendClientMessage(playerid,0xFF0000AA,"You Must Be In Checkpoint To Rob!");
	}
	return 1;
	}
	return 0;
}
this command its not tested yet if its right but i get no errors for now , i must just test those strings etc

so when player will write in CP1 /rob it will start countdown

but how i can make if player leave this CP1 it will cancle the count down i try with that

CODE:

Code:
public OnPlayerLeaveCheckpoint(playerid)
{
	if (IsPlayerInCheckpoint(playerid) == CP1)
	{
	KillTimer(timer1);
	KillTimer(timer2);
	KillTimer(timer3);
	KillTimer(timer4);
	KillTimer(timer5);
	KillTimer(timer6);
	KillTimer(timer7);
	KillTimer(timer8);
	}
  return 1;
}
but it wont stop the countdown when i exit the CP1

any help please ?
Reply
#2

so any help ?
Reply
#3

why are you putting isplayerincheckpoint under onplayerleavecheackpoint ? when onplayerleavecheckpoint is called the player isnt in the cp anymore.
Reply
#4

cuz i dont know how i can make that the timers will work...

here is the full game mode but i must do alot more that it will work ok , team kills etc ...

http://pastebin.com/m32d74f1c

EDIT: Hope you can help now
Reply
#5

just remove the if statement
Code:
public OnPlayerLeaveCheckpoint(playerid)
{
	KillTimer(timer1);
	KillTimer(timer2);
	KillTimer(timer3);
	KillTimer(timer4);
	KillTimer(timer5);
	KillTimer(timer6);
	KillTimer(timer7);
	KillTimer(timer8);
    return 1;
}
Reply
#6

i do but still wont stop the countdown ...
Reply
#7

any other help ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)