Need help with bugged timer
#1

Hey,

Iґve got a nice war mode, 30 players average. In every "country" thereґs a place enemy players can place a bomb. When this happens, a timer getґs activated and players are getting respawned. But, this timer is bugged somehow, you get respawned 5 times every 2 seconds.

Hereґs the code of the bomb putting:

Код:
public OnPlayerPickUpPickup(playerid, pickupid)
{
		if(pickupid == usa)
	  {
				if(GetPlayerTeam(playerid) == TEAM_Romania)
				{
					SendClientMessage(playerid,COLOR_YELLOW,"You're putting the bomb ! ");
					ApplyAnimation(playerid, "BOMBER","BOM_Plant_Loop",4.0,1,0,0,0,0);
					SetTimerEx("bombusa", 20000, false, "d", playerid);
					SetTimerEx("bombeject", 15000, false, "d", playerid);
					GameTextForAll("RUSSIA IS UNDER BOMB ATTACK!", 5000, 4);
				}
      		if(GetPlayerTeam(playerid) == TEAM_Rusia)
				{
					SendClientMessage(playerid,COLOR_YELLOW,"You're putting the bomb ! ");
					ApplyAnimation(playerid, "BOMBER","BOM_Plant_Loop",4.0,1,0,0,0,0);
					SetTimerEx("bombusa", 20000, false, "d", playerid);
					SetTimerEx("bombeject", 15000, false, "d", playerid);
					GameTextForAll("RUSSIA IS UNDER BOMB ATTACK!", 5000, 4);
				}
      		if(GetPlayerTeam(playerid) == TEAM_USA)
				{
					SendClientMessage(playerid,COLOR_YELLOW,"Defusing coming soon. ");


				}
		}
		if(pickupid == rus)
	  {
				if(GetPlayerTeam(playerid) == TEAM_Romania)
				{
					SendClientMessage(playerid,COLOR_YELLOW,"You're putting the bomb ! ");
					ApplyAnimation(playerid, "BOMBER","BOM_Plant_Loop",4.0,1,0,0,0,0);
					SetTimerEx("bombrus", 20000, false, "d", playerid);
					SetTimerEx("bombeject", 15000, false, "d", playerid);
					GameTextForAll("CHINA IS UNDER BOMB ATTACK!", 5000, 4);
				}
      		if(GetPlayerTeam(playerid) == TEAM_USA)
				{
					SendClientMessage(playerid,COLOR_YELLOW,"You're putting the bomb ! ");
					ApplyAnimation(playerid, "BOMBER","BOM_Plant_Loop",4.0,1,0,0,0,0);
					SetTimerEx("bombrus", 20000, false, "d", playerid);
					SetTimerEx("bombeject", 15000, false, "d", playerid);
					GameTextForAll("CHINA IS UNDER BOMB ATTACK!", 5000, 4);
				}
      		if(GetPlayerTeam(playerid) == TEAM_Rusia)
				{
					SendClientMessage(playerid,COLOR_YELLOW,"Defusing coming soon ");

				}
		}
		if(pickupid == rom)
	  {
				if(GetPlayerTeam(playerid) == TEAM_Rusia)
				{
					SendClientMessage(playerid,COLOR_YELLOW,"You're putting the bomb ! ");
					ApplyAnimation(playerid, "BOMBER","BOM_Plant_Loop",4.0,1,0,0,0,0);
					SetTimerEx("bombrom", 20000, false, "d", playerid);
          SetTimerEx("bombeject", 15000, false, "d", playerid);
					GameTextForAll("USA IS UNDER BOMB ATTACK!", 5000, 4);
				}
      		if(GetPlayerTeam(playerid) == TEAM_USA)
				{
					SendClientMessage(playerid,COLOR_YELLOW,"You're putting the bomb ! ");
					ApplyAnimation(playerid, "BOMBER","BOM_Plant_Loop",4.0,1,0,0,0,0);
					SetTimerEx("bombrom", 20000, false, "d", playerid);
					SetTimerEx("bombeject", 15000, false, "d", playerid);
					GameTextForAll("USA IS UNDER BOMB ATTACK!", 5000, 4);
				}
      		if(GetPlayerTeam(playerid) == TEAM_Romania)
				{
					SendClientMessage(playerid,COLOR_YELLOW,"Defusing coming soon ");

				}
		}
}
And hereґs the code of the bomb activated:

Код:
forward bombusa(playerid);
public bombusa(playerid)
{
  RemovePlayerFromVehicle(playerid);
	CreateExplosion(-240.2157,2716.0264,62.6875, 7, 10.0);
	GameTextForAll("USA Base Exploded", 3000, 4);
	new pTeam=GetPlayerTeam(playerid);
	new string[64];
	format(string, sizeof(string),"~r~ Russia has lost the war!", pTeam);
	GameTextForAll(string, 3000, 4);
  for(new i = 0; i < MAX_PLAYERS; i++)
	{
	SpawnPlayer(i);
  }

}
forward bombrus(playerid);
public bombrus(playerid)
{
  RemovePlayerFromVehicle(playerid);
	CreateExplosion(413.7413,2537.5007,19.1484, 7, 10.0);
	GameTextForAll("Russia Base Exploded", 3000, 4);
	new pTeam=GetPlayerTeam(playerid);
	new string[64];
	format(string, sizeof(string),"~r~ China has lost the war!", pTeam);
	GameTextForAll(string, 3000, 4);
  for(new i = 0; i < MAX_PLAYERS; i++)
	{
	SpawnPlayer(i);
  }
}
forward bombrom(playerid);
public bombrom(playerid)
{
	RemovePlayerFromVehicle(playerid);
	CreateExplosion(241.5529,1860.2664,17.9121, 7, 10.0);
	GameTextForAll("China Base Exploded", 3000, 4);
	new pTeam=GetPlayerTeam(playerid);
	new string[64];
	format(string, sizeof(string),"~r~ USA has lost the war!", pTeam);
	GameTextForAll(string, 3000, 4);
  for(new i = 0; i < MAX_PLAYERS; i++)
	{
	SpawnPlayer(i);
  }
}
Whatґs wrong?
Reply
#2

When you stand on the pickup, do you get the message more than one time?

OnPlayerPickUpPickup is called like a timer, it will keep calling while you're standing on the pickup.
Reply
#3

Yes, you get it several times, and after that respawn several times.
Reply
#4

How can I fix it then? Set the players above it, so it doesnt get activated again?
Reply
#5

Well add a check then to see if you've already picked up the PickUp, because it's called constantly while standing on it.

pawn Код:
new PickedUp[MAX_PLAYERS] = 0;

// When he picks it up
PickedUp[playerid] = 1;

//And before doing the pickup code
if(PickedUp[playerid] == 0)
{
//Do the code
}
Reply
#6

Iґve done as you said, and even added a SetPlayerHealth so they get killed when entering the checkpoint, but the bug is here, still.
Reply
#7

How are you defining the pickupid's ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)