Sign in to follow this  
Laelon

[C#] SharedData

Recommended Posts

Hi there! I'm trying to get the SharedData for a Vehicle working. But it looks like the Data is not getting set. Maybe you can help!

Server Code:

[Command("veh")]
public void CreateVehicle(Client player, string hash, int color1, int color2, string plate) {
    VehicleHash vehicleHash = NAPI.Util.VehicleNameToModel(hash);
    Vehicle vehicle = NAPI.Vehicle.CreateVehicle(vehicleHash, player.Position, 0, color1, color2);

    Random rnd = new Random();
    int guid = rnd.Next(100000000, 999999999);

    vehicle.SetSharedData("VehicleGUID", guid);

    //DEBUG
    NAPI.Util.ConsoleOutput("GUID: " + vehicle.GetSharedData("VehicleGUID"));
}

Output:

nv6xj3co.png

Share this post


Link to post
Share on other sites

Setting shared data takes some time, maybe that could be the reason.

Share this post


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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.