Interior Vehicle Color Changing -
Tass007 - 26.09.2016
Hey guys. I have an issue whenever a player enters an interior and then exits the vehicles around change colors. I've looked for the callback RandomColor or something but I can't find it anywhere in my script. Any ideas?
Re: Interior Vehicle Color Changing -
Dayrion - 26.09.2016
I'm not sure bur; Your vehicles spawn with the int -1 on CreateVehicle or AddStaticVehicle. Something like that.
Re: Interior Vehicle Color Changing -
Tass007 - 26.09.2016
How is that going to change the color of the vehicle?
Re: Interior Vehicle Color Changing -
Dayrion - 26.09.2016
Because -1 set to random color. So, every time (i think) you will stream vehicles a new color will be set to the vehicle.
Re: Interior Vehicle Color Changing -
JaKe Elite - 26.09.2016
Set the vehicle's color to a specific color (0 for instance = black) instead of -1 which is random as @Dayrion mentions above.
Re: Interior Vehicle Color Changing -
Tass007 - 26.09.2016
I'm using this though
https://sampforum.blast.hk/showthread.php?tid=487641
Re: Interior Vehicle Color Changing -
JaKe Elite - 26.09.2016
Can you show us the part of the code where in the vehicle is being created? (CreateVehicle, AddStaticVehicle, etc...)
Re: Interior Vehicle Color Changing -
Tass007 - 26.09.2016
PHP код:
public SpawnVehicleOnSlot(slotid)
{
if(slotid < 0 || slotid >= MAX_VEHICLE_SLOTS) return 0;
if(!VehicleSlots[slotid][vsUsed]) return 0;
new model = VehicleSlots[slotid][vsModelID];
if(model == -1)
{
model = 0; // standard group
VehicleSlots[slotid][vsModelID] = 0;
}
if(model >= 0 && model < 21) // Random car out of a Group!
{
model = VGroups[model][random(VGroupCount[model])];
}
if(model < 400 || model > 611) return printf("Vehicle Slot %d invalid. model: %d vsModelID: %d", slotid, model, VehicleSlots[slotid][vsModelID]);
if(VehicleSlots[slotid][vsVehicleID] > 0) // On a respawn, this is VERY important!!!
{
DestroyVehicle(VehicleSlots[slotid][vsVehicleID]);
VIDs[VehicleSlots[slotid][vsVehicleID]-1] = -1;
}
new Float:oX, Float:oY, Float:oZ;
GetVehicleModelInfo(model, VEHICLE_MODEL_INFO_WHEELSFRONT, oX, oY, oZ); // This one will fix some vehicles to be in the ground (Busses, trucks etc)
VehicleSlots[slotid][vsVehicleID] = CreateVehicle(model, VehicleSlots[slotid][vsX], VehicleSlots[slotid][vsY], VehicleSlots[slotid][vsZ] - oZ, VehicleSlots[slotid][vsA], -1, -1, 1000000);
if(VehicleSlots[slotid][vsVehicleID] <= 0) return printf("Vehicle Slot %d could not spawn. No free vehicle slots.", slotid);
VIDs[VehicleSlots[slotid][vsVehicleID]-1] = slotid;
VehicleSlots[slotid][vsLastUpdate] = GetTickCount();
VehicleSlots[slotid][vsLastDriver] = -1;
VehicleSlots[slotid][vsAnyUpdate] = false;
#if DEFAULT_TUNING == true
if(VehicleComponentsArray[model-400][0] > 0)
{
for(new i = 0; i < random(TUNE_CHANCE*2); i ++) AddVehicleComponent(VehicleSlots[slotid][vsVehicleID], VehicleComponentsArray[model-400][random(VehicleComponentsArray[model-400][0])+1]);
if(Chance(TUNE_CHANCE)) AddVehicleComponent(VehicleSlots[slotid][vsVehicleID], WheelsArray[random(sizeof(WheelsArray))]); // Any Wheel
if(Chance(TUNE_CHANCE)) AddVehicleComponent(VehicleSlots[slotid][vsVehicleID], 1010); // Nitro x10
if(Chance(TUNE_CHANCE)) AddVehicleComponent(VehicleSlots[slotid][vsVehicleID], 1087); // Hydraulics
}
#endif
return VehicleSlots[slotid][vsVehicleID];
}
Re: Interior Vehicle Color Changing -
Dayrion - 26.09.2016
As I said, you have to change the -1 to get a fix color;
PHP код:
VehicleSlots[slotid][vsVehicleID] = CreateVehicle(model, VehicleSlots[slotid][vsX], VehicleSlots[slotid][vsY], VehicleSlots[slotid][vsZ] - oZ, VehicleSlots[slotid][vsA], random(255), random(255), -1); // still randoms colors and -1 avoid respawning the vehicle.