SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts > Tools and Files

Thread Tools Display Modes
Old 06/09/2018, 05:36 PM   #1
Little Clucker
labiyebu's Avatar
Join Date: Dec 2016
Location: Latvia
Posts: 10
Reputation: 0
Default How to obtain the color of a vehicle?

Hello, I do not know if you ever tried to get the primary and secondary color of a vehicle, there is an include for this but it is not necessary, here I give you a very quick way of doing this.

Step 1
new Color[MAX_VEHICLES][2];
Step 2

Replace all CreateVehicle to CreateVehicleEx and add this function

CreateVehicleEx(vehicletype, Float:x, Float:y, Float:z, Float:rotation, color1, color2, respawn_delay, bool:addsiren = false)
	new vehiclespawned = INVALID_VEHICLE_ID;
 	vehiclespawned = CreateVehicle(vehicletype, Float:x, Float:y, Float:z, Float:rotation, color1, color2, respawn_delay, addsiren);
	Color[vehiclespawned][0] = color1;
	Color[vehiclespawned][1] = color2;
	printf("Vehicled spawned > Model: %d / C1: %d / C2: %d.", vehicletype, Color[vehiclespawned][0], Color[vehiclespawned][1]);
	return vehiclespawned;
The parameters of CreateVehicle and CreateVehicleEx are the same.

Example of use

CMD:obtenercolor(playerid, params[])
	if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) // If you are a driver of any vehicle.
	    new autito = GetPlayerVehicleID(playerid);
		SendClientMessage(playerid, -1, "Hello, the colors of your vehicle are:");
		new str[32];
		format(str, sizeof(str), "Primary: %d / Secondary: %d", Color[autito][0], Color[autito][1]);
		SendClientMessage(playerid, -1, str);
	return 1;
labiyebu is offline   Reply With Quote
Old 06/09/2018, 05:48 PM   #2
Huge Clucker
Join Date: Sep 2017
Posts: 318
Reputation: 81
Default Re: How to obtain the color of a vehicle?

Since max color is 255

it can be done like this:

PHP Code:
new Color[MAX_VEHICLES][2 char]; 

PHP Code:
Color[vehicleid]{0} = color1;
Color[vehicleid]{1} = color2
Lokii is offline   Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to obtain age from date of birth? Jose_grana Scripting Help 7 13/08/2018 01:08 AM
Get Player color and change vehicle color to the player color gurmani11 Scripting Help 4 03/07/2015 11:34 AM
Vehicle color help! LuckyPlaya` Scripting Help 3 22/01/2013 06:53 PM
How to obtain this back. AustinJ Client Support 4 22/04/2012 07:09 AM
how to obtain such textdraw maxi459 Help Archive 2 21/11/2010 08:20 AM

All times are GMT. The time now is 04:34 AM.

Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.