Destroy Object
#5

I tried that now but seems it doesne't work well. I was aiming with gun and shoot at random position and package dissapeared (i was not aiming in object), not even counting 50 health.

Code:
public OnPlayerShootDynamicObject(playerid, weaponid, STREAMER_TAG_OBJECT objectid, Float:x, Float:y, Float:z)
{
	for(new val = 0; val < MAX_CRATES; val++)
	{
		if(crateexists[val])
		{
		    new obb = ArmyCrate[val];
			if(IsValidDynamicObject(obb))
			{
				new Float:oX, Float:oY, Float:oZ;
				GetDynamicObjectPos(obb,oX, oY, oZ);
				if(IsPlayerInRangeOfPoint(playerid, 5, oX, oY, oZ))
				{
				    ArmyCrate[val] -= 1;
				    if(ArmyCrate[val] > 0)
				    {
						DestroyDynamicObject(obb);
						Delete3DTextLabel(armylabel[val]);
						SendClientMessage(playerid, -1, "You have picked up a weapon from the package");
						new rand = random(8);
						switch(rand)
						{
							case 0: GivePlayerWeapon(playerid, 16, 2);
							case 1: GivePlayerWeapon(playerid, 18, 2);
							case 2: GivePlayerWeapon(playerid, 26, 300);
							case 3: GivePlayerWeapon(playerid, 28, 300);
							case 4: GivePlayerWeapon(playerid, 29, 300);
							case 5: GivePlayerWeapon(playerid, 32, 300);
							case 6: GivePlayerWeapon(playerid, 37, 400);
							case 7: GivePlayerWeapon(playerid, 35, 1);
						}
						crateexists[val] = false;
						KillTimer(CrateDespawnTimer[val]);
						ArmyCrate[val] = -1;
						break;
 					}
				}
			}
		}
	}
 	return 1;
}
Reply


Messages In This Thread
Destroy Object - by Hunud - 10.07.2018, 15:31
Re: Destroy Object - by NaS - 10.07.2018, 15:37
Re: Destroy Object - by Hunud - 10.07.2018, 15:45
Re: Destroy Object - by NaS - 10.07.2018, 15:50
Re: Destroy Object - by Hunud - 10.07.2018, 16:06
Re: Destroy Object - by NaS - 10.07.2018, 17:43

Forum Jump:


Users browsing this thread: 1 Guest(s)