problem with C4
#1

Hey guys i hope you help me!, After Planting a bomb c4 [/plantbomb] and pressing on the left buttom, it should be destroyed but nothing happens, only the Object disappear, that's all

Код:
	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;
	}
Reply
#2

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?
Reply
#3

You need to store the X, Y, and Z into a global variable and use it where your detonate command is.
Reply
#4

Quote:
Originally Posted by Yashas
Посмотреть сообщение
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?
i mean destroying like explode, blowup...
Reply
#5

Quote:
Originally Posted by newbienoob
Посмотреть сообщение
You need to store the X, Y, and Z into a global variable and use it where your detonate command is.
explain more xD?
Reply
#6

Global Variable-Wikia
Store x,y,z- You need to store bomb cordinates into global variable outside command(
pawn Код:
new Float:x, Float:Y, Float:Z
)
Reply
#7

is the problem with this?

Код:
		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]++;
						}
					}
                }
			}
		}
	}
Reply
#8

Please help me?
Reply
#9

Hey Antoniohl, you should be clear with what you want exactly. Post your current /plantbomb and your OnPlayerKeyStateChange(or whatever you're using to detect the button to detonate).
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)