I have the protection of objects but I cannot get it to work online objects stick to me and they are not erased
//LOOP//
if (attachobject && AttachPreventionDelay < GAMEPLAY::GET_GAME_TIMER())
{
DeleteNearbyProps(true);
AttachPreventionDelay = GAMEPLAY::GET_GAME_TIMER() + 1000;
}
void DeleteNearbyProps(bool CheckAttached)
{
float Range = 2.0f;
if (!CheckAttached)
Range = 10.0f;
Vector3 playerPosition = ENTITY::GET_ENTITY_COORDS(PLAYER::PLAYER_PED_ID(), false);
for (int i = 0; i < 132; i++)
{
int obj = OBJECT::GET_CLOSEST_OBJECT_OF_TYPE1(playerPosition.x, playerPosition.y, playerPosition.z, Range, Props[i], false, false, true);
if (ENTITY::DOES_ENTITY_EXIST(obj))
{
bool Contin = true;
if (CheckAttached)
{
if (ENTITY::GET_ENTITY_ATTACHED_TO(obj) != PLAYER::PLAYER_PED_ID())
Contin = false;
}
if (Contin)
{
if (NETWORK::NETWORK_REQUEST_CONTROL_OF_ENTITY(obj) && NETWORK::NETWORK_HAS_CONTROL_OF_ENTITY(obj))
{
ENTITY::DETACH_ENTITY(obj, 1, 1);
ENTITY::SET_ENTITY_COORDS(obj, 6000.0, 6000.0, 6000.0, true, false, false, true);
ENTITY::DELETE_ENTITY(&obj);
}
}
}
}
}
//LOOP//
if (attachobject && AttachPreventionDelay < GAMEPLAY::GET_GAME_TIMER())
{
DeleteNearbyProps(true);
AttachPreventionDelay = GAMEPLAY::GET_GAME_TIMER() + 1000;
}
void DeleteNearbyProps(bool CheckAttached)
{
float Range = 2.0f;
if (!CheckAttached)
Range = 10.0f;
Vector3 playerPosition = ENTITY::GET_ENTITY_COORDS(PLAYER::PLAYER_PED_ID(), false);
for (int i = 0; i < 132; i++)
{
int obj = OBJECT::GET_CLOSEST_OBJECT_OF_TYPE1(playerPosition.x, playerPosition.y, playerPosition.z, Range, Props[i], false, false, true);
if (ENTITY::DOES_ENTITY_EXIST(obj))
{
bool Contin = true;
if (CheckAttached)
{
if (ENTITY::GET_ENTITY_ATTACHED_TO(obj) != PLAYER::PLAYER_PED_ID())
Contin = false;
}
if (Contin)
{
if (NETWORK::NETWORK_REQUEST_CONTROL_OF_ENTITY(obj) && NETWORK::NETWORK_HAS_CONTROL_OF_ENTITY(obj))
{
ENTITY::DETACH_ENTITY(obj, 1, 1);
ENTITY::SET_ENTITY_COORDS(obj, 6000.0, 6000.0, 6000.0, true, false, false, true);
ENTITY::DELETE_ENTITY(&obj);
}
}
}
}
}