[HELP] Finding a cars colour
#1

I'm sorry if this has been covered before, but is it possible to find a cars colour in a script, for example GetVehicleColour()
thanks.
Reply
#2

No, you have to make your own function(s).
Reply
#3

Use this it can help you : http://forum.sa-mp.com/index.php?action=search
Reply
#4

Quote:
Originally Posted by x-unit
As it happens, x-unit, I did make a search, but I'm not prepared to sift through reams and reams of scripting discussions to find one thing. Thanks TimmehBoy.
Reply
#5

You could make your own "CreateVehicle" or addstaticvehicle function and save the color in 2 variables

EDIT: like this

top of script
pawn Код:
static Colors[MAX_VEHICLES][2];
pawn Код:
stock CreateVehicleX(model, Float:x, Float:y, Float:z, Float:a, color1, color2, respawn) {
  new v;
  v = CreateVehicle(model, x, y, z, a, color1, color2, respawn);
  Colors[v][0] = color1;
  Colors[v][1] = color2;
  return v;
}
The rest is up to you
Reply
#6

pawn Код:
new carcolor[MAX_VEHICLES][2]

stock SetVehicleColor(vehicleid, color1, color2)
{
  ChangeVehicleColor(vehicleid, color1, color2);
  carcolor[vehicleid][0] = color1;
  carcolor[vehicleid][1] = color2;
}

stock GetVehicleColor(vehicleid, bool:primary) return primary?carcolor[vehicleid][0]:carcolor[1][vehicleid];
/*if the second parameter is true, it will return the primary color, else secondary*/
Here's just an example. It can be done better. Also GetVehicleColor wont work if you don't do SetVehicleColor first
Reply
#7

Thanks to all responses. After this:
Quote:
Originally Posted by TimmehBoy
No, you have to make your own function(s).
I started making my own.
For the sake of anybody else who has had this problem, this is the code i used:
Код:
new CarColour[256];
.....
public OnGameModeInit()
{
  ColourAddStaticVehicle(476,-1657.362061,-155.683640,15.318590, 270,1,1);
  ColourAddStaticVehicle(476,-1647.219849,-165.189056,15.318590, 270,1,1);
  return 1;
}
.....
stock FindCarColour(playerid)
{
  if (!IsPlayerConnected(playerid) || !IsPlayerInAnyVehicle(playerid)) return 0;
  return CarColour[GetPlayerVehicleID(playerid)];
}

stock ColourAddStaticVehicle(ModelID,Float:spawn_X,Float:spawn_Y,Float:spawn_Z, Float:zangle, C1,C2)
{
  new carID;
  carID = AddStaticVehicle(ModelID,spawn_X,spawn_Y,spawn_Z,zangle,C1,C2);
  CarColour[carID] = C1;
  return carID;
}
To all nitpickers (lots of you out there): My script doesn't have more than 256 cars, so there won't be a problem with it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)