Jump to content

[C#] Example/Wrapper for fetching world objects. 1.0.0

   (0 reviews)

1 Screenshot

About This File

Just an example/wrapper on how to properly use "GetClosestObjectOfType" and fetch data from an object.

I've been using this in my server for a while now to make it easier to get XYZ and rotation of objects in bulk, instead of having to go through them in codewalker which can be a pain.


  • Move client_packages to your client_packages folder
  • Move Serverside C#/GetWorldObjects.cs to your gamemode or script.
  • Move objectLocations.json to your server root directory.



The JSON file included in the zip contains the pacific bank vault door as an example object. Use the /getworldobjects or /gwo command to run through all the items in the JSON file and fetch the X, Y, Z and XYZ Rotation of the object.

As of right now it'll simply log the object to your server console and continue to the next object in the list, you can extend this functionality by editing the "REMOTE_EVENT_OnWorldObjectFetched" method in GetWorldObjects.cs server-side script.

JSON file object info

 public class ObjectLocation
        // The model name to look for, you can fetch this from CodeWalker or RAGEMP objectdb for example.
        public string Model { get; set; }

        // The model that should replace the model at this location, optional. I personally used this to store in the database and then on server start it'd delete the world object and replace it with the object model specified here.
        public string ReplacementModel { get; set; } = "";

        // A position within X distance of the object you want to get the data of, distance can be specified by the Radius.
        public Vector3 Position { get; set; }

        // An optional type you can pass to the method so you can use it later on for data storage purposes(eg keep objects of certain types separated by an ID)
        public int Type { get; set; } = 0;

        // The radius to find the object, doesn't have to be too precise altho I generally recommend putting the player's teleport coordinates as close to the object as possible and decreasing range to 5 or 10.
        public int Radius { get; set; }
    "Model": "v_ilev_bk_vaultdoor",
    "ReplacementModel": "v_ilev_bk_vaultdoor",
    "Type": 0,
    "Radius": 25,
    "Position": {
      "X": 254.2859,
      "Y": 225.3845,
      "Z": 101.8757
    "Model": "another_object_model_name",
    "ReplacementModel": "another_object_model_name_to_replace",
    "Type": 0,
    "Radius": 10,
    "Position": {
      "X": 1234.567,
      "Y": 123.456,
      "Z": 12.345

All you have to do is add more items to the JSON file and it'll run thru all of them.

User Feedback

Create an account or sign in to leave a review

You need to be a member in order to leave a review

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

There are no reviews to display.

  • Create New...