I have a problem with Attachment Protect Objects option. When I activate it, my player stops every bit. It must be because of the large amount of props I have added.
Does anyone know how to fix this?
Thank you.
Does anyone know how to fix this?
Thank you.
Code:
char* PROPS[] = {
"p_seabed_whalebones", ........};
int AttachPrevention = 0;
bool AttachProtectProp;
void DeleteNearbyProps()
{
if (AttachPrevention < GET_GAME_TIMER())
{
float Rango = 2.0f;
if (!AttachProtectProp)
Rango = 10.0f;
vector3 playerPosition = GET_ENTITY_COORDS(PLAYER_PED_ID(), 0);
for (int i = 0; i < (sizeof(PROPS)); i++)
{
int objeto = GET_CLOSEST_OBJECT_OF_TYPE(playerPosition.x, playerPosition.y, playerPosition.z, Rango, GET_HASH_KEY(PROPS[i]), 0, 0, 1);
if (DOES_ENTITY_EXIST(objeto))
{
bool Continua = true;
if (AttachProtectProp)
{
if (GET_ENTITY_ATTACHED_TO(objeto) != PLAYER_PED_ID())
Continua = false;
}
if (Continua)
{
if (NETWORK_REQUEST_CONTROL_OF_ENTITY(objeto) && NETWORK_HAS_CONTROL_OF_ENTITY(objeto))
{
DETACH_ENTITY(objeto, 1, 1);
SET_ENTITY_COORDS(objeto, 6000.0, 6000.0, 6000.0, 1, 0, 0, 1);
DELETE_ENTITY(&objeto);
print("~r~ Prop removed.", 2000);
}
}
}
}
AttachPrevention = GET_GAME_TIMER() + 1000;
}
}