10.07.2018, 15:31
I've been working on destroyable object for carepack system but seems like doesen't work. When i shoot with gun in object, it won't destroy. What's the problem ?
Code:
new ArmyCrate[MAX_CRATES];
Code:
for(new i=0; i < MAX_CRATES; i++) { ArmyCrate[i] = 50; //This should be like object health i want to destroy pCarePackage[i][CarePackagePlane] = pCarePackage[i][CarePackageParachute] = -1; }
Code:
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ) { if(hittype == BULLET_HIT_TYPE_OBJECT) { 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 got some weapons from pack."); new rand = random(4); switch(rand) { case 0: GivePlayerWeapon(playerid, 29, 300); case 1: GivePlayerWeapon(playerid, 32, 300); case 2: GivePlayerWeapon(playerid, 37, 400); case 3: GivePlayerWeapon(playerid, 35, 1); } crateexists[val] = false; KillTimer(CrateDespawnTimer[val]); ArmyCrate[val] = -1; break; } } } } } }