ALERT!
Click here to register with a few steps and explore all our cool stuff we have to offer!
Home
Upgrade
Credits
Help
Search
Awards
Achievements
 1807

HELP WITH "ATTACHMENT PROTECTION OBJECT" OPTION

by ELSANTO1 - 07-31-2019 - 02:47 PM
#1
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.
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;
}
}
Reply
#2
use pool is better and delete all object
This account is currently banned
Ban reason: Leeching and Spamming is not allowed, please read the forum Rules upon your return.
Reply
#3
(07-31-2019 - 07:07 PM)NoNameV2345 Wrote: use pool is better and delete all object
Thanks, but i don't use pool. Would do you give me an example, please?
Reply
#4
(07-31-2019 - 02:47 PM)ELSANTO1 Wrote: 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.
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;
}
}

Where you put this code?
Reply
#5
(08-01-2019 - 05:06 AM)thelasModder Wrote:
(07-31-2019 - 02:47 PM)ELSANTO1 Wrote: 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.
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;
}
}

Where you put this code?
What?
I put char* PROPS[ ] in enum and the code in function, then i call the function through a loop.
Reply
#6
I'm gonna go crazy. I change and try it, I change and I try it, ... and I don't get results. ooohh!
Reply
#7
whats the problem with this code?
Reply
#8
(08-10-2019 - 06:59 PM)BModzMasterTM Wrote: whats the problem with this code?

When I activate it, the game stops every moment. It must be because of the large number of accessories that I've added in "char PROPS[ ]".  

Do you know any solution to make this work more fluid?

?
Reply

Users browsing: 1 Guest(s)