server-beta icon indicating copy to clipboard operation
server-beta copied to clipboard

PlayerTextDrawGetPreviewVehicleColours

Open Dante-1337 opened this issue 11 months ago • 2 comments

Describe the bug Unable to GET the colors of the car in a textdraw UNLESS using PlayerTextDrawSetPreviewVehicleColours beforehand.

To Reproduce Steps to reproduce the behavior:

  • Create a textdraw and display a vehicle model WITHOUT using PlayerTextDrawSetPreviewVehicleColours.
  • Try to get the color randomly generated without using the PlayerTextDrawGetPreviewVehicleColours function.

Expected behavior I expected this to work since the vehicle in the textdraw already gets shown with random colors when using PlayerTextDrawSetPreviewModel to display a car.

Release version OMP v1.4.0.2779

Dante-1337 avatar Apr 04 '25 08:04 Dante-1337

Examining the code in the TextDrawBase class, it appears that the vehicle colors are initialized to -1 if you don't set them explicitly.

When PlayerTextDrawSetPreviewModel is called to set a vehicle model without explicitly setting colors, these -1 values are kept. The vehicle would still be shown with random colors client-side, but when PlayerTextDrawGetPreviewVehicleColours is called, it returns these -1 values since they were never explicitly set.

I can think of a solution, which would be to set random colors (using rand) on the server-side instead of -1. Not sure if it's the best idea, though. I'll wait for someone else to pitch in as well.

vsmxd avatar Jun 06 '25 08:06 vsmxd

Examining the code in the TextDrawBase class, it appears that the vehicle colors are initialized to -1 if you don't set them explicitly.

When PlayerTextDrawSetPreviewModel is called to set a vehicle model without explicitly setting colors, these -1 values are kept. The vehicle would still be shown with random colors client-side, but when PlayerTextDrawGetPreviewVehicleColours is called, it returns these -1 values since they were never explicitly set.

I can think of a solution, which would be to set random colors (using rand) on the server-side instead of -1. Not sure if it's the best idea, though. I'll wait for someone else to pitch in as well.

It would make more sense to use a random colour pair from carcols.dat, which AFAIK is what -1 does anyway.

BeckzyBoi avatar Jun 06 '25 10:06 BeckzyBoi