Skip to content
View in the app

A better way to browse. Learn more.

LCPDFR.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Make Objects Persistent

Featured Replies

Heya!

 

I'm currently trying to figure out how to make objects not despawn. I've tried setting them as persistent, however IsPersistent seems to only work on Ped's since everything else gets cleaned up by GTA.

 

I know it must be possible somehow since stuff likee Map Editors etc. can load up 1000s of objects no matter how far away you are from them without GTA cleaning those up.

 

Does anyone know how to make those Persistent ?

  • Author
56 minutes ago, Rich said:

Setting an entity as persistent should work.  Can you give an example of something it doesn't seem to be working with?

For example I use this code to spawn in Police Barriers

 

for (int i = 0; i < BarrierLocations.Count; i++)
            {
                Rage.Object barrier = new Rage.Object("prop_barrier_work05", BarrierLocations[i], BarrierHeadings[i]);
                barrier.IsPersistent = true;
                AllSpawnedObjects.Add(barrier);
            }

 

or vehicles too

SuspectVehicle = new Vehicle("primo", SuspectVehicleLocation, SuspectVehicleHeading);
SuspectVehicle.IsPersistent = true;

So far so good. However as soon as I leave the area (aprox. 100 - 200m) the object despawn. If I drive back the only thing still persistent is Peds. Cars and objects (doesn't matter which object it is, they all despawn) disappeared. 

  • Author
1 minute ago, Rich said:

You could run a loop on an object displaying it's persistence status.  See at what point (distance) the status changes.  I haven't encountered this issue, so I wonder if something else is changing their persistence.

That's my workaround for now, running a loop and whenever they despawned and the character is within a certain distance they get spawned in again. But since I would like to add a couple of locations and having a loop for every single one is rather inconvinient than just having them persistent just like peds

  • Management Team

Something is definitely cleaning up your entities, as a persistent entity is never freed. Try without any other plugins and see if you get the same result (note: you should not).

Please do not PM me unless really necessary (knowing you helps). If you think you need my attention in a topic, tag me.

  • Author
3 hours ago, LMS said:

Something is definitely cleaning up your entities, as a persistent entity is never freed. Try without any other plugins and see if you get the same result (note: you should not).

I just tried it with no plugins except LSPDFR and my callouts but they still despawn. Cars and Objects despawned, Ped's stayed persistent

On 12/23/2020 at 6:23 PM, RinPai said:

I just tried it with no plugins except LSPDFR and my callouts but they still despawn. Cars and Objects despawned, Ped's stayed persistent

Try checking the object/vehicle exists first.

 

i.e

Rage.Object barrier = new Rage.Object(stuff);
if(barrier.Exists()){
  barrier.isPersistent = true;
  //stuff
}

 

I've ran into things like this a few times, I suspect it is hardware/strain on your game that affects it.

 

If you create an object and in the next line, try to alter that object (set it as persistent for example), it's entirely possible that it hasn't actually finished loading into the game yet you're trying to make changes to it.

 

I could be wrong and it could be something else, however as a general rule of thumb, check things exist first anyway. Saves you crashing for silly reasons.

Live Streaming daily from 8pm GMT (UK) at https://twitch.tv/OfficialLukeD - I play a variety of things 😄

Join my official discord server for support, general chat and my stream schedule! https://discord.gg/Mddj7PQ

  • Author
On 12/30/2020 at 3:17 PM, LukeD said:

Try checking the object/vehicle exists first.

 

i.e


Rage.Object barrier = new Rage.Object(stuff);
if(barrier.Exists()){
  barrier.isPersistent = true;
  //stuff
}

 

I've ran into things like this a few times, I suspect it is hardware/strain on your game that affects it.

 

If you create an object and in the next line, try to alter that object (set it as persistent for example), it's entirely possible that it hasn't actually finished loading into the game yet you're trying to make changes to it.

 

I could be wrong and it could be something else, however as a general rule of thumb, check things exist first anyway. Saves you crashing for silly reasons.

I've tried that. What is weird is:

 

When I first spawned the object, it was automatically set persistent by the game without me doing it.

 

However: Once I got away from the object again, around 100-300m the object disappeared, despite being persistent

  • Management Team
7 hours ago, RinPai said:

I've tried that. What is weird is:

 

When I first spawned the object, it was automatically set persistent by the game without me doing it.

 

However: Once I got away from the object again, around 100-300m the object disappeared, despite being persistent

 

Objects (and entities in general) that are created by scripts are persistent by default, so nothing wrong there. The automatic disposal is certainly bizarre, though. I don't think we run any aggressive garbage collection for entities not owned by us, but I will also double check that if you say it happens with just LSPDFR loaded.

Please do not PM me unless really necessary (knowing you helps). If you think you need my attention in a topic, tag me.

  • Author
21 minutes ago, LMS said:

 

Objects (and entities in general) that are created by scripts are persistent by default, so nothing wrong there. The automatic disposal is certainly bizarre, though. I don't think we run any aggressive garbage collection for entities not owned by us, but I will also double check that if you say it happens with just LSPDFR loaded.

I can sent you the exact callout script I use, where it doesn't work, if you want to test it yourself

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

Similar Content

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.