SA-MP Forums Archive
Interior Vehicle Color Changing - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Interior Vehicle Color Changing (/showthread.php?tid=617771)



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 || 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 >= && 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"slotidmodelVehicleSlots[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:oXFloat:oYFloat:oZ;
    
GetVehicleModelInfo(modelVEHICLE_MODEL_INFO_WHEELSFRONToXoYoZ); // This one will fix some vehicles to be in the ground (Busses, trucks etc)

    
VehicleSlots[slotid][vsVehicleID] = CreateVehicle(modelVehicleSlots[slotid][vsX], VehicleSlots[slotid][vsY], VehicleSlots[slotid][vsZ] - oZVehicleSlots[slotid][vsA], -1, -11000000);

    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 
0random(TUNE_CHANCE*2); ++) 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(modelVehicleSlots[slotid][vsX], VehicleSlots[slotid][vsY], VehicleSlots[slotid][vsZ] - oZVehicleSlots[slotid][vsA], random(255), random(255), -1); // still randoms colors and -1 avoid respawning the vehicle.