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
 1466

Help attach object protection

by mamasita1515 - 09-06-2020 - 05:56 PM
#1
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;
}
}
Reply
#2
(09-06-2020 - 05:56 PM)mamasita1515 Wrote: 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;
}
}
Use Pool For this and it will work Fine
Disc = 0xemiil
Reply

Users browsing: 1 Guest(s)