OnPlayerShootDynamicObject issue -
TwinkiDaBoss - 07.06.2016
Alright so there is one problem with this, it will delete the entire map for some reason.
PHP Code:
public OnPlayerShootDynamicObject(playerid, weaponid, objectid, Float:x,Float:y,Float:z) {
for(new i = 0; i < sizeof(dInfo); i++) {
if(objectid == dInfo[i][DeerObject]) {
if(IsValidDynamicObject(dInfo[i][DeerObject])) {
new Float:Pos[3];
GetDynamicObjectPos(dInfo[i][DeerObject],Pos[0],Pos[1],Pos[2]);
new Float:rr = frandomEx(1.00,10.00);
CreateMeatObject(rr,Pos[0],Pos[1],Pos[2],0.0,0.0,0.0);
SetDynamicObjectPos(dInfo[i][DeerObject],0.0,0.0,2500.0);
DestroyDynamicObject(dInfo[i][DeerObject]);
printf("Breaking object ID: %i",objectid);
break;
}
}
}
printf("Breaking object ID: %i",objectid);
return 1;
}
It will only print the object ID that it has destroyed but it will destroy all CreateDynamicObject
Re: OnPlayerShootDynamicObject issue -
IstuntmanI - 07.06.2016
When you destroy dInfo[i][DeerObject] set its value to 0. Also, you shouldn't set its position right before destroying it.
pawn Code:
DestroyDynamicObject(dInfo[i][DeerObject]);
dInfo[i][DeerObject] = 0;
The problem about deleting the entire map (I guess not the GTA:SA map ?) of CreateDynamicObject s (?) is a problem from your storing of IDs.
Re: OnPlayerShootDynamicObject issue -
TwinkiDaBoss - 07.06.2016
Yeah I was testing something with the SetDynamicObjectPos so I left it there, forgot to remove it
Regarding the object id's, not sure mate.. It reads the ID correctly. It prints out that object ID 85 has been removed and after 1 sec it removes the entire map lol (all dynamic objects from the map)
EDIT: This is the code which spawns it
PHP Code:
public DeerRespawn() {
new SpawnTimes = 0;
for(new i = 0; i < sizeof(dInfo); i++) {
new rand = random(sizeof(DeerLocation));
DestroyDynamicObject(dInfo[i][DeerObject]);
dInfo[i][dx] = DeerLocation[rand][0];
dInfo[i][dy] = DeerLocation[rand][1];
dInfo[i][dz] = DeerLocation[rand][2];
dInfo[i][DeerObject] = CreateDynamicObject(19315,dInfo[i][dx],dInfo[i][dy],dInfo[i][dz],0.0,0.0,0.0);
printf("Deer %i spawned at %.2f,%.2f,%.2f",i,DeerLocation[rand][0],DeerLocation[rand][1],DeerLocation[rand][2]);
SpawnTimes += 1;
}
}
The first deer doesnt remove the map, only the second one does.
Map respawns when the deer respawns and then after X seconds it dissapears again.
Re: OnPlayerShootDynamicObject issue -
TwinkiDaBoss - 07.06.2016
AHA seems that something else is causing it
Without the function CreateMeatObject it delete anything but with it it does.
PHP Code:
CreateMeatObject(rr,Pos[0],Pos[1],Pos[2],0.0,0.0,0.0);
CreateMeatObject(Float:amount, Float:X, Float:Y, Float:Z, Float:RX, Float:RY, Float:RZ) {
for(new i = 0; i < sizeof(mInfo); i++) {
mInfo[i][meatObject] = CreateDynamicObject(2806, X, Y, Z, RX, RY, RZ);
mInfo[i][mX] = X;
mInfo[i][mY] = Y;
mInfo[i][mZ] = Z;
mInfo[i][meatAmount] = amount;
}
}
enum MEAT_DATA {
Float:mX,
Float:mY,
Float:mZ,
Float:meatAmount,
meatObject
};
new mInfo[MAX_MEAT][MEAT_DATA];
#define MAX_MEAT 255
Instead of spawning 2nd meat, it deletes the map
Also after shooting the 2nd deer, its giving me some different results
PHP Code:
[22:02:33] Breaking object ID: 375
[22:02:35] Breaking object ID: 194