Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!

    1. Red Dead Redemption 2

      1. PC
      2. Gameplay
      3. Missions
      4. Help & Support
    2. Red Dead Online

      1. Gameplay
      2. Find Lobbies & Outlaws
      3. Help & Support
      4. Frontier Pursuits
    1. Crews & Posses

      1. Recruitment
    2. Events

    1. GTA Online

      1. Diamond Casino & Resort
      2. DLC
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Grand Theft Auto Series

    3. GTA 6

    4. GTA V

      1. PC
      2. Guides & Strategies
      3. Help & Support
    5. GTA IV

      1. Episodes from Liberty City
      2. Multiplayer
      3. Guides & Strategies
      4. Help & Support
      5. GTA IV Mods
    6. GTA Chinatown Wars

    7. GTA Vice City Stories

    8. GTA Liberty City Stories

    9. GTA San Andreas

      1. Guides & Strategies
      2. Help & Support
      3. GTA SA Mods
    10. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
      3. GTA VC Mods
    11. GTA III

      1. Guides & Strategies
      2. Help & Support
      3. GTA III Mods
    12. Top Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    13. Wiki

      1. Merchandising
    1. GTA Modding

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    3. Featured Mods

      1. DYOM
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Red Dead Redemption

    2. Rockstar Games

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Programming
      5. Movies & TV
      6. Music
      7. Sports
      8. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. News

    2. Forum Support

    3. Site Suggestions

julionib

Detect "owner" or "creator" of game object

Recommended Posts

julionib

Hey guys, someone knows if its possible detect if a object/ped/car was created by game or by a custom script (.net, .asi, etc.)?

Share this post


Link to post
Share on other sites
LordOfTheBongs

it sounds like u would want to hook the native function for creating peds/vehicles/objects and then when game tries to spawn a ped it calls your detoured function and maybe like that u can identify what is calling the function... u probably will need some reversing skills... take a look at thaCursedPie's github... he made a project to hook native functions... could at least give u a starting place

Share this post


Link to post
Share on other sites
julionib

the idea is reuse objects when i use command reloadscripts or avoid to use objects created by other scripts

Share this post


Link to post
Share on other sites
InfamousSabre

the idea is reuse objects when i use command reloadscripts or avoid to use objects created by other scripts

looks like you already did this with death race. care to share how you accomplished that?

Share this post


Link to post
Share on other sites
pedro2555

I'm not seeing this being possible without implementation on the creating scripts. But even then I'm not seeing how it might work.

Share this post


Link to post
Share on other sites
julionib

 

the idea is reuse objects when i use command reloadscripts or avoid to use objects created by other scripts

looks like you already did this with death race. care to share how you accomplished that?

 

 

Nope, death race is using any object that already exists or objects already created by the script that are in a "idle" list of objects

 

 

 

pedro2555: the biggest problem with object creation for me at least is that after some 20 creations they start to freeze, and only Load game solves the issue, this behavior seems to be more "agressive" with users that have not much video memory, some users with 512 mb of vid mem. had this issue with tank + buzzard while others with 1 gb didnt, here only happens after a lot reloadscripts command

Share this post


Link to post
Share on other sites
LordOfTheBongs

the idea is reuse objects when i use command reloadscripts or avoid to use objects created by other scripts

then do something like this when ur script needs to create an object, not sure why u need to know where it came from, if another script needs the object it will be marked required for mission and maybe just ignore those objects...

private GTA.Object FindOrCreateObject(Model model, Vector3 position, float range){    foreach (GTA.Object obj in World.GetAllObjects())    {        if (!Game.Exists(obj)) continue;        if (obj.Model != model) continue;        if (obj.Position.DistanceTo(position) > range) continue;         return obj;    }     return World.CreateObject(model, position);}
Edited by LordOfTheBongs

Share this post


Link to post
Share on other sites
InfamousSabre

 

the idea is reuse objects when i use command reloadscripts or avoid to use objects created by other scripts

then do something like this when ur script needs to create an object, not sure why u need to know where it came from, if another script needs the object it will be marked required for mission and maybe just ignore those objects...

private GTA.Object FindOrCreateObject(Model model, Vector3 position, float range){    foreach (GTA.Object obj in World.GetAllObjects())    {        if (!Game.Exists(obj)) continue;        if (obj.Model != model) continue;        if (obj.Position.DistanceTo(position) > range) continue;         return obj;    }     return World.CreateObject(model, position);}

very nice.

another way would be to save object handles to a file (theres probably a better way to say this, but i just woke up), then check the file on script load

Share this post


Link to post
Share on other sites
julionib

thx for the ideas, the file with objects handles idea may work i guess

Share this post


Link to post
Share on other sites
pedro2555

I think what Julio asked didn't get along to everyone.

 

Image the situation, your script populates multiple objects on calling a specific function. While debugging that function you will be doing a lot of 'reloadscripts', which means your function will recreate the same objects which another (older) instance of the same script had created. What he wants to achieve is garbage collection across script reloading, am I right on this Julio ?

Share this post


Link to post
Share on other sites
LordOfTheBongs

make a debug script that deletes stuff then... i have these features in my trainer i made for myself... make a reset world function or in the constructor of his script he can clean stuff up

Share this post


Link to post
Share on other sites
InfamousSabre

Lol trust me, I know the problem.. I have this issue with Silence! as well. I end up with multiple silencers attached to my arm after a few reloads.
Also with Pickups2.0... all these weapons laying around, and I cant pick them up after a reload =\

you can either delete the old objects and create new ones, or just re-use the old objects

 

if you know their position, LordOfTheBongs' method should work fine.

If not, saving their handle should allow you to do whatever you want with them. Its basically just using the file as memory that is safe from being erased by reloadscripts

Share this post


Link to post
Share on other sites
julionib

my biggest issue is the new objects "frozen", even if i ask game to delete them setting NoLongerNeeded + distant position after some time new objects will freeze, it also affects cars and peds, its interesting that R* does this very well because if we equip each cop with a rocket launcher they dont will cause this bug with their cj_rpg_rocket models, the create_obejct method have some misterious params for me, maybe one of them is the secret to avoid this "freeze" behavior

Share this post


Link to post
Share on other sites
LordOfTheBongs

i think it is because it is just a bad port from console and the memory isnt managed like a good pc port... read this

 

http://devblog.lcpdfr.com/author/lms/

 

http://devblog.lcpdfr.com/2013/07/engine-insights-why-iveflc-crashes/

 

i think the best thing to do is reduce the ped density and/or car density if u plan on doing a lot of spawning. I made a braveheart battle and i spawn 60 peds in less than a second, and never fails because i set the ped density to 0 and this stops the game spawning and messing up the ped pool which has a fixed length and when u overload gta with spawning the system breaks and u will see gta to begin acting weird

 

when u see peds start freezing it is because gta can't handle all the objects and it loses track of objects in memory which is probably why they freeze and u cant delete... the game cant even delete because they are lost... trhose articles explain the technical details... good job to lms ;)

 

edit: i just re read article and pool is 120 peds in game so if i delete all peds and set density to 0 i can make a 60 vs 60 battle xD

Edited by LordOfTheBongs

Share this post


Link to post
Share on other sites
julionib

nice, i did some tests with my ironman code (taht was causing the issue with more frequency) and made he only create to objects when equip armor or when get close to fixed objects in map (like saved cars).
also im reusing the objects instead of creating new ones, only issue that remains is that this method can pickobjects from other mods, but this is not easy to happen because will happen randomly because is the user who decide when equip the armor for first time, i will make a test release and see if people will get errors with other mods.

Share this post


Link to post
Share on other sites
julionib

i made a test today and reduced my video memory to 450 +/- and reduce graphics quality until use half video memory (236 +/-) and tested same mods, the result was frozen objects after some tries, so, im almost sure that amount of video memory is directly related to the frozen objects issue.

at least now i have a "excuse" for the users ^^

Share this post


Link to post
Share on other sites
NTAuthority

physical streaming memory should only ever cause issues for, well, streaming; the only thing I can imagine some kind of emergency cleanup routine gets triggered that breaks your entities in a similar way to how building entities get removed in these scenarios

Share this post


Link to post
Share on other sites
jenksta

What do you mean when you say they become 'frozen'?

 

If you're mean no collision loaded for them, it's probably because of the CMissionCleanup class, everything script created/loaded is added to the CMissionCleanup class so the game can delete/unload objects from certain scripts or missions as and when it needs to. However unfortunately theres only 256 slots in the class, and as everything you create/load from scripts is added to the same slots (peds, vehicles, objects, blips, decision makers, ptfx, txds, viewports, groups, models) it fills up pretty quickly, and because (for some strange reason) the collision for vehicles, peds and objects is loaded by this class, as soon as all slots are filled this causes collision to not be loaded for any newly created vehicles, peds or objects. you should be able to fix this by calling the SET_LOAD_COLLISION_FOR_CAR/PED/OBJECT_FLAG native with 1 as the second parameter on the frozen entity.

Edited by jenksta

Share this post


Link to post
Share on other sites
julionib

frozen with collision enabled, they get stuck on spawn or detach position like if freezePosition is set to true, if we set they as noLongerNeeded and move then to a distant place we can start creating new ones without the "bug"

Share this post


Link to post
Share on other sites
LordOfTheBongs

@jenksta when GTA starts bugging out because some script is maybe screwing up the game's memory or maybe u spawned too many peds then a common bug is peds being loaded frozen in place... they have collision and can be killed but they stay in the same animation.. u can even drive a car full speed into them and they wont move, u will just wreck your car

 

a good way to avoid when u spawn a lot of peds is to reduce the ped density so gta and your script are not competing for positions in the ped pool

Edited by LordOfTheBongs

Share this post


Link to post
Share on other sites
jenksta

It's not an issue with the games pools as if there were no slots left the ped wouldn't spawn whatsoever, and the population peds/vehicles are only spawned if there's at least 5 slots in the ped/vehicle pool, on top of that there's also a ClearSpaceForMissionEntity function which will delete any population around the area the entity is spawned, the reason it's fixed by calling MarkAsNoLongerNeeded is because that function removes the entity from CMissionCleanup (which obviously frees slots for the next entity your creating) and (from what I remember) marks it as a population entity so that the game will delete it when it wants. You could fix this issue with a simple hook which would force the game to use your own custom CMissionCleanup structure with more than 256 slots. (Also if the mission cleanup has no slots the collision will still be loaded for the entity but physics isn't applied to it so it'll just be stuck where it is like your describing).

Edited by jenksta

Share this post


Link to post
Share on other sites
julionib

its interesting that the issue happens faster when we limit video memory, here on my tests with full vid mem it happens after some 100 cj_rpg_rocket spawns, and with 500 mb +/- of vid mem it happens with some 30 objects, and is not exact, sometimes we can create more sometimes less, the big issue here is that we cant make sure that other scripts are removing their objects when they dont need anymore, if they keep the objects, one time our script will obtain this issue when creating a new object.

my ironman mod was causing this issue, i had to rethink great part of code days ago to make it able to only create the objects when equipping armor

Share this post


Link to post
Share on other sites
LordOfTheBongs

yeah maybe... i just notice when it happens that there is usually access violation exceptions in the console dialog

Share this post


Link to post
Share on other sites
jenksta

If you want I can create you an asi to increase the mission cleanup slots to see if it solves your issue?

Share this post


Link to post
Share on other sites
LordOfTheBongs

yeah u should make it and if it works it would only allow scripters to push gta further, i think it is something worth making and if ur will ing to share the source that would be cool as i never heard of this class before, i also have not done any reversing with gta

Share this post


Link to post
Share on other sites
julionib

thats good

Share this post


Link to post
Share on other sites
jenksta

Ok see if this fixes your issue, haven't properly tested myself yet, supports IV patch 7 and EFLC patch 2 (source included).

Place limits.asi wherever your asi loader requires then just run the game as usual.

 

http://jenksta.iv-m.com/iv/mission_cleanup.zip

Share this post


Link to post
Share on other sites
LordOfTheBongs

nice job man, thanks for sharing, i learned something new ;)

Edited by LordOfTheBongs

Share this post


Link to post
Share on other sites
julionib

ok thx

Share this post


Link to post
Share on other sites
pedro2555

 


Wrong post, sorry.

 

Edited by pedro2555

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.