Jump to content
RAGE Multiplayer Community

Shared Data on Vehicle returns error


Recommended Posts

Hi,

Upon creating of a vehicle I want it to make the data shared and I got the Data stored in a Model.

But for any reason the SetEntityData works but the SetEntitySharedData returns an error?

Error:

Newtonsoft.Json.JsonSerializationException: 'Self referencing loop detected for property 'Trailer' with type 'GTANetworkAPI.Vehicle'. Path 'VehicleData.Trailer'.'

Code:

public VehicleGameModel(string vehicleName, double vehiclePosX, double vehiclePosY, double vehiclePosZ, float vehicleRotation, int vehicleColor1, int vehicleColor2, string vehicleLicensePlate, bool adminSpawned)
        {
            this.VehicleName = vehicleName;
            this.VehiclePosX = vehiclePosX;
            this.VehiclePosY = vehiclePosY;
            this.VehiclePosZ = vehiclePosZ;
            this.VehiclePosA = vehicleRotation;
            this.VehicleColor1 = vehicleColor1;
            this.VehicleColor2 = vehicleColor2;
            this.VehicleLicensePlate = vehicleLicensePlate;
            this.AdminSpawned = adminSpawned;

            VehicleHash vehicleModel = NAPI.Util.VehicleNameToModel(vehicleName);
            Vector3 vehiclePosition = new Vector3(this.VehiclePosX, this.VehiclePosY, this.VehiclePosZ);

            this.VehicleData = NAPI.Vehicle.CreateVehicle(vehicleModel, vehiclePosition, this.VehiclePosA, this.VehicleColor1, this.VehicleColor2, this.VehicleLicensePlate, 255, true);
            NAPI.Data.SetEntitySharedData(this.VehicleData, DataIndentifier, this);
            //GlobalGameModels.VehiclesList.Add(this);
        }

 

Link to post
Share on other sites

Create an account or sign in to comment

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

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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...