28.08.2016, 16:29
Hello all, I created a bombing system ( which works fine.) but, the problem is that when the player dies(the one who is planting the bomb) while planting the bomb, the bomb shall not get planted, but it does not happen like that and still the bomb get planted.
Here is my code:-
The timer:-
OnPlayerDeath:-
Here is my code:-
PHP код:
if(PRESSED(KEY_WALK))
{
if(IsPlayerInRangeOfPoint(playerid, 1.5, 276.7643, 4050.3779, 28.5322))
{
if(HUnderBomb[CASTLE] == 0 && gTeam[playerid] == TEAM_DEFENDERS) return SendClientMessage(playerid, COLOR_RED, "There is no bomb planted yet!");
if(HBombed[CASTLE] == 1 && gTeam[playerid] == TEAM_ATTACKERS) return SendClientMessage(playerid, COLOR_RED, "This area has already been bombed by someone!");
if(HUnderBomb[CASTLE] == 1 && gTeam[playerid] == TEAM_ATTACKERS) return SendClientMessage(playerid, COLOR_RED, "The area is already underbomb!");
if(IsPlayerInAnyVehicle(playerid) && gTeam[playerid] == TEAM_DEFENDERS) return SendClientMessage(playerid, COLOR_RED, "You can not defuse the bomb while you are in a vehicle");
if(IsPlayerInAnyVehicle(playerid) && gTeam[playerid] == TEAM_ATTACKERS) return SendClientMessage(playerid, COLOR_RED, "You can not plant a bomb while you are in a vehicle!");
if(gTeam[playerid] == TEAM_ATTACKERS && HBombed[CASTLE] == 0)
{
HIsPlayerBombing[playerid][CASTLE] = 1;
HBombed[CASTLE] = 0;
HUnderBomb[CASTLE] = 0;
SendClientMessage(playerid, COLOR_LIGHTERBLUE, "Planting...");
Timer[castle1] = SetTimerEx("castlebomb", 1000, false, "i", playerid);
ApplyAnimation(playerid, "BOMBER", "BOM_Plant", 4.0, 0, 0, 0, 0, 0);
}
if(gTeam[playerid] == TEAM_DEFENDERS && HUnderBomb[CASTLE] == 1)
{
SendClientMessage(playerid, COLOR_LIGHTERBLUE, "Defusing...");
HIsPlayerBombing[playerid][CASTLE] = 1;
HUnderBomb[CASTLE] = 1;
Timer[castled1] = SetTimerEx("castledefusebomb", 1000, false, "i", playerid);
ApplyAnimation(playerid, "BOMBER", "BOM_Plant", 4.0, 0, 0, 0, 0, 0);
}
}
}
PHP код:
forward castlebomb(playerid);
public castlebomb(playerid)
{
KillTimer(Timer[castle1]);
SendClientMessage(playerid, COLOR_LIGHTERBLUE, "Planting...");
Timer[castle2] = SetTimerEx("castlebomb2", 1000, false, "i", playerid);
HBombed[CASTLE] = 0;
HIsPlayerBombing[playerid][CASTLE] = 1;
HUnderBomb[CASTLE] = 1;
ApplyAnimation(playerid, "BOMBER", "BOM_Plant", 4.0, 0, 0, 0, 0, 0);
return 1;
}
forward castlebomb2(playerid);
public castlebomb2(playerid)
{
KillTimer(Timer[castle2]);
SendClientMessage(playerid, COLOR_LIGHTERBLUE, "Planting...");
Timer[castle3] = SetTimerEx("castlebomb3", 1000, false, "i", playerid);
HBombed[CASTLE] = 0;
HIsPlayerBombing[playerid][CASTLE] = 1;
HUnderBomb[CASTLE] = 1;
ApplyAnimation(playerid, "BOMBER", "BOM_Plant", 4.0, 0, 0, 0, 0, 0);
return 1;
}
forward castlebomb3(playerid);
public castlebomb3(playerid)
{
KillTimer(Timer[castle3]);
SendClientMessage(playerid, COLOR_LIGHTERBLUE, "Planting...");
Timer[castle4] = SetTimerEx("castlebomb4", 1000, false, "i", playerid);
HBombed[CASTLE] = 0;
HIsPlayerBombing[playerid][CASTLE] = 1;
HUnderBomb[CASTLE] = 1;
ApplyAnimation(playerid, "BOMBER", "BOM_Plant", 4.0, 0, 0, 0, 0, 0);
return 1;
}
forward castlebomb4(playerid);
public castlebomb4(playerid)
{
KillTimer(Timer[castle4]);
SendClientMessage(playerid, COLOR_LIGHTERBLUE, "Planting...");
SendClientMessage(playerid, COLOR_WHITE, "Bomb plant successful!");
HTimer[CASTLE] = SetTimerEx("explodecastle", 120000, false, "i", playerid);
HBombed[CASTLE] = 0;
HIsPlayerBombing[playerid][CASTLE] = 0;
HUnderBomb[CASTLE] = 1;
ApplyAnimation(playerid, "BOMBER", "BOM_Plant", 4.0, 0, 0, 0, 0, 0);
SendClientMessageToAll(COLOR_ORANGE, "[BOMB]: {FFFFFF}Bomb has been planted at {FF0000}'The Castle'{FFFFFF}. Defenders go defuse it before it's to late!");
for(new i = 0; i < MAX_PLAYERS; i++)
{
PlayAudioStreamForPlayer(i, "http://k003.kiwi6.com/hotlink/eg5ozskbs1/10*******.com_Bomb-Has-Been-Planted-Sound-Effect-CSGO_llCmtgvIqcY.mp3");
}
return 1;
}
forward explodecastle(playerid);
public explodecastle(playerid)
{
KillTimer(HTimer[CASTLE]);
HBombed[CASTLE] = 1;
HtCB[CASTLE] = gTeam[playerid];
HUnderBomb[CASTLE] = 0;
CreateExplosion(276.7643, 4050.3779, 28.5322, 0, 40.0);
SendClientMessage(playerid, COLOR_YELLOW, "You have earned +10 score and $20000 from successfully detonating the bomb!");
SendClientMessageToAll(COLOR_ORANGE, "[BOMB]:{FFFFFF} The bomb successfully exploded at {FF0000}'The Castle'{FFFFFF}. Good Job Attackers!");
GivePlayerMoney(playerid, 20000);
SetPlayerScore(playerid, GetPlayerScore(playerid)+10);
return 1;
}
forward castledefusebomb(playerid);
public castledefusebomb(playerid)
{
if(HBombed[CASTLE] == 1) return SendClientMessage(playerid, COLOR_GREY, "You failed to defuse the bomb.");
KillTimer(Timer[castled1]);
SendClientMessage(playerid, COLOR_LIGHTERBLUE, "Defusing...");
Timer[castled2] = SetTimerEx("castledefusebomb2", 1000, false, "i", playerid);
HIsPlayerBombing[playerid][CASTLE] = 1;
HUnderBomb[CASTLE] = 1;
ApplyAnimation(playerid, "BOMBER", "BOM_Plant", 4.0, 0, 0, 0, 0, 0);
return 1;
}
forward castledefusebomb2(playerid);
public castledefusebomb2(playerid)
{
if(HBombed[CASTLE] == 1) return SendClientMessage(playerid, COLOR_GREY, "You failed to defuse the bomb.");
KillTimer(Timer[castled2]);
SendClientMessage(playerid, COLOR_LIGHTERBLUE, "Defusing...");
Timer[castled3] = SetTimerEx("castledefusebomb3", 1000, false, "i", playerid);
HIsPlayerBombing[playerid][CASTLE] = 1;
HUnderBomb[CASTLE] = 1;
ApplyAnimation(playerid, "BOMBER", "BOM_Plant", 4.0, 0, 0, 0, 0, 0);
return 1;
}
forward castledefusebomb3(playerid);
public castledefusebomb3(playerid)
{
if(HBombed[CASTLE] == 1) return SendClientMessage(playerid, COLOR_GREY, "You failed to defuse the bomb.");
KillTimer(Timer[castled3]);
SendClientMessage(playerid, COLOR_LIGHTERBLUE, "Defusing...");
Timer[castled4] = SetTimerEx("castledefusebomb4", 1000, false, "i", playerid);
HIsPlayerBombing[playerid][CASTLE] = 1;
HUnderBomb[CASTLE] = 1;
ApplyAnimation(playerid, "BOMBER", "BOM_Plant", 4.0, 0, 0, 0, 0, 0);
return 1;
}
forward castledefusebomb4(playerid);
public castledefusebomb4(playerid)
{
if(HBombed[CASTLE] == 1) return SendClientMessage(playerid, COLOR_GREY, "You failed to defuse the bomb.");
new String[256];
KillTimer(Timer[castled4]);
KillTimer(HTimer[CASTLE]);
SendClientMessage(playerid, COLOR_LIGHTERBLUE, "Defusing...");
SendClientMessage(playerid, COLOR_LIGHTERBLUE, "Bomb defusion successful!");
format(String, sizeof(String), "%s has earned {FF0000}+5 score{FFFFFF} and {FF0000}$10000{FFFFFF} for defusing{FFFFFF} the bomb!", PlayerName(playerid));
SendClientMessageToAll(-1, String);
SendClientMessage(playerid, -1, "You have earned +5 score and $10000 for defusing the bomb.");
HIsPlayerBombing[playerid][CASTLE] = 0;
HUnderBomb[CASTLE] = 0;
HBombed[CASTLE] = 0;
ApplyAnimation(playerid, "BOMBER", "BOM_Plant", 4.0, 0, 0, 0, 0, 0);
return 1;
}
stock DBombCanceled(playerid)
{
KillTimer(HTimer[CASTLE]);
KillTimer(Timer[castled1]);
KillTimer(Timer[castled2]);
KillTimer(Timer[castled3]);
KillTimer(Timer[castled4]);
HIsPlayerBombing[playerid][CASTLE] = 0;
SendClientMessage(playerid, COLOR_GREY, "You have failed to defuse this zone!");
}
PHP код:
if(HIsPlayerBombing[playerid][CASTLE] == 1 && gTeam[playerid] == TEAM_ATTACKERS)
{
KillTimer(HTimer[CASTLE]);
KillTimer(Timer[castle1]);
KillTimer(Timer[castle2]);
KillTimer(Timer[castle3]);
KillTimer(Timer[castle4]);
HBombed[CASTLE] = 0;
HIsPlayerBombing[playerid][CASTLE] = 0;
HUnderBomb[CASTLE] = 0;
SendClientMessage(playerid, COLOR_GREY, "You have failed to bomb this zone!");
}
if(HIsPlayerBombing[playerid][CASTLE] == 1 && gTeam[playerid] == TEAM_DEFENDERS)
{
DBombCanceled(playerid);
}