Variables Help
#1

Greeting Everyone!

Yesterday I was scripting a round system. So it's actually when the round ends, the bomb exploded variables should be reset, so i made a SetTimer on GameModeInIt with the exact same time the round ends, but i don't know why the bomb variables do not change and still appears that they are exploded.

Here's the script -
--> Bomb Variables.
Код:
new HBombed[9];
new HIsPlayerBombing[9];
new HUnderBomb[9];
new HtCB[9];
new HBCP[9];
new HTimer[9];
-->PLanting bomb command
Код:
CMD:hbomb(playerid, parmas[])
  {
if(gTeam[playerid] == TEAM_DEFENDERS) return SendClientMessage(playerid, -1, " What are you doing soldier! You have to protect the bomb sites not to destroy them!");
if(IsPlayerInRangeOfPoint(playerid, 1.5, -2709.8135, 601.6404, 14.5824))
{
 if( HBombed[SKY] == 1 && HBombed[FBI] == 1 && HBombed[TOWN] == 1 && HBombed[WANG] == 1 && HBombed[MARK] == 1 && HBombed[TRAM] == 1 )
   {
   
if(IsPlayerInAnyVehicle(playerid))return SendClientMessage(playerid,-1,"You cant plant bomb while youre On Vehicle!");//checking if Player is on vehicle while going to plant a bomb, it will return an error message
if(HtCB[HOSP] == gTeam[playerid])return SendClientMessage(playerid,-1,"This bomb area already bombed by your Team!");
if(HUnderBomb[HOSP] == 1)return SendClientMessage(playerid,-1,"This area is already bombed by someone else!");//checking if the zone already bombed by someone else, it will return an erorr message!
if(!IsPlayerInDynamicCP(playerid, HBCP[HOSP]))return SendClientMessage(playerid,-1,"You are not on bomb CP!");//checking if player is not on Bomb checkpoint,it will return an error message
HIsPlayerBombing[HOSP] = 1;//We setted the variable value turn to 1. That means, Player is Planting a bomb
HBombed[HOSP] = 0;//Bomb that planted here, not Exploded Yet!
HUnderBomb[HOSP] = 1;//That means, the zone is under Bomb by someone.
SendClientMessageToAll(COLOR_ORANGE, "[BOMB]: {FFFFFF}Bomb has been planted at {FF0000}'Hospital'{FFFFFF}. Defenders go defuse it before it's to late!");
HTimer[HOSP] = SetTimerEx("hexplodebomb",120000,false,"i",playerid);//Set a timer, that means on 10 seconds, Bomb will be exploded!You can change the time as you want.
ApplyAnimation(playerid, "BOMBER", "BOM_Plant", 4.0, 0, 0, 0, 0, 0);
  }
  else
     {
     SendClientMessage(playerid, COLOR_RED, "[BOMB]: You need to bomb Sky scraper and Wang Cars before detonating this bomb!");
     }
}
else
  {
	SendClientMessage(playerid, COLOR_RED, "[BOMB]: You are not on the bomb checkpoint!");
  }

return 1;
}
-->Bomb exploding timer -
Код:
forward hexplodebomb(playerid);
public hexplodebomb(playerid)
{
KillTimer(HTimer[HOSP]);//We kill a timer here. If we didnt, it will continously exploding!
HBombed[HOSP] = 1;//that means player already bombed the zone here!
HtCB[HOSP] = gTeam[playerid];//This is for checking, bomb zone controlled by his team. And if another team member going to plant a bomb here, it will return an error message!
HUnderBomb[HOSP] = 0;//That means, This zone is not under bombed anymore! ;)
CreateExplosion(-2255.6638, 540.7746, 35.1886, 0, 40.0);//We created an explosion here, dont forget to change the location as the coordinates of your Bomb Checkpoint!
SendClientMessage(playerid,-1,"Congratulation, you have Bombed this zone! ans earned 10 score and $2000");
SendClientMessageToAll(COLOR_ORANGE, "[BOMB]:{FFFFFF} The bomb successfully exploded at {FF0000}'Hospital'{FFFFFF}. Good Job Attackers!");
GivePlayerMoney(playerid,2000);//give bomber money
SetPlayerScore(playerid,GetPlayerScore(playerid)+10);//Give Player a score
return 1;
}
-->Defusing the bomb.
Код:
CMD:hdefuse(playerid, parmas[])
 {
   

  if(gTeam[playerid] == TEAM_ATTACKERS) return SendClientMessage(playerid, COLOR_RED, " What are you doing!");
  if(HUnderBomb[HOSP] == 0) return SendClientMessage(playerid, COLOR_RED, "There is no bomb planted yet!");
  if(IsPlayerInAnyVehicle(playerid))return SendClientMessage(playerid,-1,"You cant plant bomb while youre On Vehicle!");
  if(!IsPlayerInDynamicCP(playerid, HBCP[HOSP]))return SendClientMessage(playerid,-1,"You are not on bomb CP!");
  if(gTeam[playerid] == TEAM_DEFENDERS)
	 {
        
        KillTimer(HTimer[HOSP]);
        SendClientMessage(playerid, COLOR_LIGHTERBLUE, "You have successfully defused the bomb!");
        SetPlayerScore(playerid, GetPlayerScore(playerid)+5);
        GivePlayerMoney(playerid, 1000);
        HBombed[HOSP] = 0;//And this zone is not bombed here.
        HIsPlayerBombing[HOSP] = 0;//And player is not bombing anymore
        HUnderBomb[HOSP] = 0;
        ApplyAnimation(playerid, "BOMBER", "BOM_Plant", 4.0, 0, 0, 0, 0, 0);
        SendClientMessageToAll(-1, "{FF4500}[BOMB]:{FFFFFF}Bomb has been defused at{FF0000}'Hospital'{FFFFFF}. Good Job defenders!");
     }

  return 1;
}
-->Round system
Код:
new CountDownFromAmount;
forward CountDownTimer(playerid);
forward BombReset();
Код:
CountDownFromAmount = 1800; // 8min.
SetTimer("CountDownTimer", 999, 1);
SetTimer("BombReset", 1805000, 1);
Код:
public CountDownTimer(playerid)
{
	CountDownFromAmount--;
	if (CountDownFromAmount == 0)
	{
		 
		 
	   if(HBombed[HOSP] == 1 && HBombed[TRAM] == 1 && HBombed[HALL] == 1 && HBombed[FBI] == 1 && HBombed[SKY] == 1 && HBombed[TOWN] == 1 && HBombed[MARK] == 1 && HBombed[WANG] == 1)
	    {
          GameTextForAll("Attackers Won!", 8000, 5);
          SendClientMessageToAll( -1, "{FF0000}Attackers{FFFFFF} has won the round. Good job attackers!");
          SendClientMessageToAll(-1, "Attackers has been rewarded with 10 score and $5000 for detonating all the bomb areas.");
          SendClientMessageToAll(COLOR_YELLOW, "Get ready for the next round.");
          
          //Bomb resetted
		   if(gTeam[playerid] == TEAM_ATTACKERS)
            {
                 GivePlayerMoney(playerid, 5000);
                 SetPlayerScore(playerid, GetPlayerScore(playerid)+10);
                 SendClientMessage(playerid, COLOR_YELLOW, "You have been rewarded for supporting your team!");
       
                 
            }
          GameTextForAll("New Round Started!", 5000, 5);
        
		       
	   }
     else
	  {
		  GameTextForAll("Defenders Won!", 5000, 5);
          SendClientMessageToAll( -1, "{0000FF}Defenders{FFFFFF} has won the round. Good job defenders!");
          SendClientMessageToAll(-1, "Defenders has been rewarded with 10 score and $5000 for protecting the bomb areas.");
          SendClientMessageToAll(COLOR_YELLOW, "Server restarting. Get ready for the next round.");
		 
		  if(gTeam[playerid] == TEAM_DEFENDERS)
             {
                 GivePlayerMoney(playerid, 5000);
                 SetPlayerScore(playerid, GetPlayerScore(playerid)+10);
                 SendClientMessage(playerid, COLOR_YELLOW, "You have been rewarded for supporting your team!");
                  
             }
          GameTextForAll("New Round Started!", 5000, 5);
          
          
          
     }

  }
	return 1;
}
-->This Part should reset every bomb site, but it does not. Need help here.

Код:
public BombReset()
{
KillTimer(HTimer[WANG]);
KillTimer(HTimer[SKY]);
KillTimer(HTimer[TRAM]);
KillTimer(HTimer[TOWN]);
KillTimer(HTimer[MARK]);
KillTimer(HTimer[FBI]);
KillTimer(HTimer[HALL]);
KillTimer(HTimer[HOSP]);

HBombed[WANG] = 0;
HBombed[SKY] = 0;
HBombed[TRAM] = 0;
HBombed[TOWN] = 0;
HBombed[MARK] = 0;
HBombed[FBI] = 0;
HBombed[HALL] = 0;
HBombed[HOSP] = 0;

HIsPlayerBombing[WANG] = 0;
HIsPlayerBombing[SKY] = 0;
HIsPlayerBombing[TRAM] = 0;
HIsPlayerBombing[TOWN] = 0;
HIsPlayerBombing[MARK] = 0;
HIsPlayerBombing[FBI] = 0;
HIsPlayerBombing[HALL] = 0;
HIsPlayerBombing[HOSP] = 0;

HUnderBomb[WANG] = 0;
HUnderBomb[SKY] = 0;
HUnderBomb[TRAM] = 0;
HUnderBomb[TOWN] = 0;
HUnderBomb[MARK] = 0;
HUnderBomb[FBI] = 0;
HUnderBomb[HALL] = 0;
HUnderBomb[HOSP] = 0;

return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)