Skip to content

PlayerTextDrawGetPreviewVehicleColours #1071

Open

Description

@Dante-1337

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

Activity

  1. added
    bug
    on Apr 4, 2025
  2. added
    enhancement
    good first issue
    on Apr 4, 2025
  3. vsmxd commented on Jun 6, 2025

    @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.

  4. BeckzyBoi commented on Jun 6, 2025

    @BeckzyBoi

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugenhancementgood first issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions