It only deletes objects if I put them myself, where is the error?
if(AttachObjectsProtection)
{
if (ObjectsProtectionDelayME < GET_GAME_TIMER())
{
vector3 MyPos = GET_ENTITY_COORDS(PLAYER_PED_ID(), false);
for (int i = 0; i < 59; i++)
{
int obj = GET_CLOSEST_OBJECT_OF_TYPE(MyPos.x, MyPos.y, MyPos.z, 2.0f, GET_HASH_KEY(props_1[i]), 0, 1, 1);
if (DOES_ENTITY_EXIST(obj) && IS_ENTITY_ATTACHED_TO_ENTITY(obj, PLAYER_PED_ID()))
{
NETWORK_REQUEST_CONTROL_OF_ENTITY(obj);
if (NETWORK_REQUEST_CONTROL_OF_ENTITY(obj))
{
SET_ENTITY_AS_MISSION_ENTITY(obj, 0, 1);
DETACH_ENTITY(obj, 1, 1);
SET_ENTITY_COORDS(obj, 6000.0, 6000.0, 6000.0, true, false, false, true);
DELETE_ENTITY(&obj);
}
else
{
SET_ENTITY_AS_MISSION_ENTITY(obj, 0, 1);
DETACH_ENTITY(obj, 1, 1);
SET_ENTITY_COORDS(obj, 6000.0, 6000.0, 6000.0, true, false, false, true);
DELETE_ENTITY(&obj);
}
}
}
ObjectsProtectionDelayME = GET_GAME_TIMER() + 500;
}
}
if(AttachObjectsProtection)
{
if (ObjectsProtectionDelayME < GET_GAME_TIMER())
{
vector3 MyPos = GET_ENTITY_COORDS(PLAYER_PED_ID(), false);
for (int i = 0; i < 59; i++)
{
int obj = GET_CLOSEST_OBJECT_OF_TYPE(MyPos.x, MyPos.y, MyPos.z, 2.0f, GET_HASH_KEY(props_1[i]), 0, 1, 1);
if (DOES_ENTITY_EXIST(obj) && IS_ENTITY_ATTACHED_TO_ENTITY(obj, PLAYER_PED_ID()))
{
NETWORK_REQUEST_CONTROL_OF_ENTITY(obj);
if (NETWORK_REQUEST_CONTROL_OF_ENTITY(obj))
{
SET_ENTITY_AS_MISSION_ENTITY(obj, 0, 1);
DETACH_ENTITY(obj, 1, 1);
SET_ENTITY_COORDS(obj, 6000.0, 6000.0, 6000.0, true, false, false, true);
DELETE_ENTITY(&obj);
}
else
{
SET_ENTITY_AS_MISSION_ENTITY(obj, 0, 1);
DETACH_ENTITY(obj, 1, 1);
SET_ENTITY_COORDS(obj, 6000.0, 6000.0, 6000.0, true, false, false, true);
DELETE_ENTITY(&obj);
}
}
}
ObjectsProtectionDelayME = GET_GAME_TIMER() + 500;
}
}