CreateVehicleServerSetter not spawning any vehicle in screen


I executed the command spawn and none of them spawned to the playerCoordinates

After recovering CreateVehicleServerSetter I tried to use it to spawn any vehicle in server-side but none of them are spawning in my client screen. My server just thinks they exist but none of them are visible.

Here’s the code:

RegisterCommand(
  "spawn",
  (source: number, args: string[]) => {
    const playerCoords = GetEntityCoords(GetPlayerPed(source.toString()));
    const vehicle = CreateVehicleServerSetter("cheetah", "automobile", playerCoords[0], playerCoords[1], playerCoords[2], 90.0);

    if (DoesEntityExist(vehicle)) {
      console.log(`^2Created vehicle at ${playerCoords}^7`);
    } else {
      console.log(`^1Failed to create vehicle at ${playerCoords}^7`);
    }
  },
  false,
);

I’m pretty sure this needs to be a hash; you can use GetHashKey, something like:

const vehicle = CreateVehicleServerSetter(GetHashKey("cheetah"), "automobile", playerCoords[0], playerCoords[1], playerCoords[2], 90.0);
1 Like

I tried that and it didn’t help

Instead of returning the player’s coords, perhaps print a GetEntityCoords of the vehicle and see where the game thinks it is?

1 Like

Im so dumb I didn’t SetEntityRoutingBucket for the vehicle and my players was in bucket

That fixed the issue

Cheers.

Haha, at least it was an easy fix :slight_smile:

1 Like

“easy” is the objective I spent last 2 days trying to figure this out before coming to the forums :rofl:

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.