if(strcmp(cmdtext, "/plantbomb", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(PlayerInfo[playerid][pBombs] == 0)
{
SendClientMessage(playerid,COLOR_GRAD2," You don't have any C4 Explosives !");
return 1;
}
if(IsPlayerInAnyVehicle(playerid))
{
SendClientMessage(playerid,COLOR_GRAD2," You can't do that while in a vehicle !");
return 1;
}
if(PlayerTied[playerid] != 0 || PlayerCuffed[playerid] != 0 || PlayerFrozen[playerid] != 0)
{
SendClientMessage(playerid, COLOR_GREY, " You can't do that at this time !");
return 1;
}
new Float:X,Float:Y,Float:Z,Float:A;
ApplyAnimation(playerid, "BOMBER", "BOM_Plant", 4.0, 0, 0, 0, 0, 1);
GetPlayerPos(playerid,X,Y,Z);
GetPlayerFacingAngle(playerid, A);
DestroyDynamicObject(BombID[playerid]);
X += (1 * floatsin(-A, degrees));
Y += (1 * floatcos(-A, degrees));
BombID[playerid] = CreateDynamicObject(1654, X, Y, Z-0.9, 0, 90, 0);
ResetPlayerWeapons(playerid);
GivePlayerGun(playerid, 40);
PlayerInfo[playerid][pBombs]--;
SendClientMessage(playerid, COLOR_LIGHTBLUE,"* You have placed the C4, the device is now armed.");
return 1;
}
return 1;
}
|
DestroyDynamicObject(BombID[playerid]);
LOL you took the literal meaning.Destroy here means delete an object.The above code will just delete the object and make it disappear. So the object disappears. What did you expected it to do and what do you mean by destroy? |
|
You need to store the X, Y, and Z into a global variable and use it where your detonate command is.
|
new Float:x, Float:Y, Float:Z
if(BombID[playerid] != 0)
{
if(GetPlayerWeapon(playerid) == 0)
{
if(!IsPlayerInAnyVehicle(playerid))
{
ClearAnimations(playerid);
ApplyAnimation(playerid,"PED","bomber",4.0,0,0,0,0,0);
}
new Float:X,Float:Y,Float:Z;
GetObjectPos(BombID[playerid],X,Y,Z);
DestroyDynamicObject(BombID[playerid]);
CreateExplosion(X,Y,Z,12,1);
BombID[playerid] = 0;
SetPlayerWeapons(playerid);
new killerid = GoChase[playerid];
if(IsPlayerInRangeOfPoint(killerid,3,X,Y,Z))
{
if(GoChase[playerid] == killerid)
{
if(PlayerInfo[killerid][pHeadValue] > 0)
{
new price = PlayerInfo[killerid][pHeadValue];
new name[MAX_PLAYER_NAME];
new killa[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
GetPlayerName(killerid, killa, sizeof(killa));
PlayerInfo[killerid][pCash] = PlayerInfo[killerid][pCash]-price/2;
GivePlayerMoney(killerid, -price/2);
PlayerInfo[playerid][pCash] = PlayerInfo[playerid][pCash]+price/2;
GivePlayerMoney(playerid, price/2);
format(string,128,"Hitman %s has fulfilled the contract on %s and collected $%d.",name,killa,price/2);
SendFamilyMessage(8, COLOR_YELLOW, string);
format(string,128,"You have been critically injured by a hitman and lost $%d.",price/2);
SendClientMessage(killerid, COLOR_YELLOW, string);
SetPlayerHealth(killerid, 0);
ClearContract(killerid);
GoChase[playerid] = 999;
PlayerInfo[playerid][pCHits]++;
}
}
}
}
}
}