Join the Game4Freak Discord Get exclusive plugin sneak peeks, talk directly with VisEntities, never miss important updates, and unlock special discount codes!

Solved Questions About How Vehicles Are Saved and Restored

BacardiAdi

Customer
The plugin sounds very interesting, exactly what I'm looking for. But I still have a few questions about it.

  • Does the vehicle get the same Net ID or does it get a new one?
  • Are there any hooks that can be used when parking/unparking?
  • What about other entities attached to the vehicle, such as the radio, additional storage, license plate?
  • Would it be possible to set it so that a vehicle can only be parked out of the same spot where it was parked?
  • Is it possible to save the SkinnID when refueling?
The plugin would be perfect for us to save Enites and thus improve performance. The only problem is the additional plugins we use, which is where the questions arose from :).
 
  • Like
Reactions: 0v0
Does the vehicle get the same Net ID or does it get a new one?
It gets a new net id when spawned, I'll see if restoring the original is possible, though I doubt it, but I'll dig into it and look for another solution if needed

Are there any hooks that can be used when parking/unparking?
I can add some api methods and hooks for that, let me know your exact use case so I can cover it properly

What about other entities attached to the vehicle, such as the radio, additional storage, license plate?
Child entities like code locks and turrets can be handled. For more specific stuff, I'd need to know exactly what plugin is attaching it so I can support it properly, but yeah, definitely doable and important for compatibility

Would it be possible to set it so that a vehicle can only be parked out of the same spot where it was parked?
I can add an option for that, no problem

Is it possible to save the SkinnID when refueling?
Can you clarify what you mean? Skin id of what, the fuel item itself or something else? Not sure I fully understood that part
 
Last edited:
For the last point, we use the plugin, and it has a SkinnID for different fuels:
https://codefling.com/clients/purchases/34477-heli-speed/

Unfortunately, we currently still use various plugins for the attached entities, including one we wrote ourselves.
For example
Storage on helicopter
Wooden panel with a number Panel with a picture at the top
https://umod.org/plugins/sirens
I can add some api methods and hooks for that, let me know your exact use case so I can cover it properly
I'll have to see if everything else works. That would be secondary. We have a key plugin based on Net ID.
 
Another suggestion: make sure there is nothing inside the storage boxes. Otherwise, it's a good safe.
It already saves the contents of storage containers and restores them when the vehicle is spawned. But if you mean blocking players from storing the vehicle when any container has items in it, that's a solid idea, I can add that
 
A small update, it's almost done, just been working through a bunch of edge cases

By the way you mentioned wooden signs with paintings on them, I'm guessing you would want the drawings saved as well?
 
Can be used, but most people draw it by hand.



1760900343441.png
 
Just released the new update (v1.3.0)

What about other entities attached to the vehicle, such as the radio, additional storage, license plate?
Car radio on modular cars is now preserved
I also added support for saving and restoring storage containers attached to vehicles, limited to StorageContainer type for now, but that already covers most stuff like furnaces, workbenches, lockers, etc.

Wooden signs are preserved too (as long as you're using my Vehicle License Plate plugin, which you are), nothing else needed for that

Now, if you (or other plugins) attach more custom stuff to vehicles, like signs, sirens, alarms, or whatever, I added two new hooks for that:
  • OnVirtualGarageSaveAttachments
  • OnVirtualGarageRestoreAttachments
You can use those to handle saving/restoring whatever your plugin spawns. I didn't make Virtual Garage try to save every child entity automatically because it just wouldn't work right, especially for electrical stuff. Like if a plugin wires something up or triggers it with hooks, simply saving and restoring it from Virtual Garage wouldn't bring it back to life, it'd just be a dead prop. Same with a few other things. So for now I'm sticking to storage containers (and locks are coming soon)

Is it possible to save the SkinnID when refueling?
I made it store the fuel item's shortname, custom name, and skin id now. I haven't fully tested it yet but it's in
JSON:
          "Fuel Inventory": {
            "Short Name": "lowgradefuel",
            "Custom Name": null,
            "Skin Id": 0,
            "Amount": 500
          },

Does the vehicle get the same Net ID or does it get a new one?
That was technically possible, as long as the net id was lower than the current top one (so nothing else would try to reuse it). But I didn't go with that approach, felt a bit sketchy. Instead I went with storing all custom stuff as metadata and using the new hooks to bring back whatever your plugin added to the vehicle. You can check out an example here


A few of your other suggestions that got missed will be added in the next update
 
Last edited:
Back
Top
Chat commands start with a /, while console commands can be entered directly in the F1 console or server console. Use find <keyword> in console to search for available commands related to the plugin. Parameters in < > are required, while [ ] are optional.
This plugin uses Oxide's permission system. Grant or revoke permissions using oxide.grant and oxide.revoke. You can assign them to individual players or groups using their Steam id or group name.
Settings are stored in the config file found under the config/ directory. You can edit this file manually, then reload the plugin to apply your changes.
Persistent data is saved in the data/ directory. This includes things like saved settings, usage stats, or player progress depending on the plugin. Deleting a data file will reset stored progress or customizations.
Language files are located in the lang/ folder. To translate messages, copy the en.json file into your target language folder (e.g. fr, de) and edit the values. Reload the plugin after changes to apply new messages.
This section lists public methods exposed by the plugin for use in other plugins. You can call these via the CallHook method. Ensure the plugin is loaded before calling its API to avoid null reference errors.
These are custom hooks that other plugins can listen for. Simply define a method with the same name and expected parameters in your plugin to handle the event. Hooks are triggered at key moments and are useful for extending or reacting to plugin behavior.
These hooks are injected into the game's code using Harmony. They let the plugin run code at key points in the game's internal logic. You can return values to block or modify behavior. Use with caution — these are powerful and can affect core mechanics.
Cart