Skip to content

pick random preview vehicle colours on the server (PlayerTextDrawGetPreviewVehCol fix) - #1286

Open
noiseXYZ wants to merge 1 commit into
openmultiplayer:masterfrom
noiseXYZ:fix/textdraw-preview-colours
Open

noiseXYZ wants to merge 1 commit into
openmultiplayer:masterfrom
noiseXYZ:fix/textdraw-preview-colours

Conversation

@noiseXYZ

Copy link
Copy Markdown

Fixes #1071

When a model preview textdraw shows a vehicle and the colours were never set, the server keeps them as -1 and sends -1 to the client. The client then picks a random colour from carcols on its own, so the server never knows what is actually shown, and "(Player)TextDrawGetPreviewVehCol" returns "-1, -1". This change makes the server pick the colours instead, using "getRandomVehilceColour" (the same that vehicles use when spawned with -1 colours). The picked colors is what gets sent to clients and what the get returns, so they always match.

Details:

  • The value passed to "SetPreviewVehCol" is still kept as is, so -1 keeps meaning "random". A new pair is picked when the preview model or the colours change.
  • Showing the textdraw again keeps the same colours.

before, each client picked its own random colour on every show, so different players could see different colours on the same global textdraw. Now the colour is picked once per textdraw and everyone sees the same one, which makes more sense to me.

Tested on Windows with latest 1.6.7.3218 realase.

@GuiBoneVowt

Copy link
Copy Markdown

Tested this on top of current master (72bf89c), Windows.

Getter first: on master TextDrawGetPreviewVehicleColours and PlayerTextDrawGetPreviewVehicleColours give -1, -1 for a vehicle preview with no colours set. With this PR they give a pair that really exists in carcols for that model (checked against GetRandomCarColPair), it stays the same after hide/show, and -1, 1 only randomizes the first colour. Explicit colours and non-vehicle models work like before.

Then in game (0.3.7-R5): two Infernus previews side by side, the left one with no colours and the right one set to whatever the server reports for the left one. On master they come out different (blue and red in my case), since the server says -1, -1 and the client rolls its own. With this PR both show the same colour every time, also after recreating them a few times, and hiding/showing the left one doesn't change it.

Same idea as #1232, which got closed without a review. LGTM from testing.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PlayerTextDrawGetPreviewVehicleColours

3 participants