Vehicle color and paintjob!
#9

@kyriakos587: I wouldn't suggest using dini as it's really old and slow. There are better ways to go with: SQL (MySQL or SQLite) or y_ini.

As there are 5 only vehicles, no need to use an array with size of MAX_VEHICLES (totally pointless):
PHP код:
enum e_Vehicles
{
    
VehicleID,
    
Color1,
    
Color2,
    
Paintjob
};
new 
Vehicles[5][e_Vehicles];
// 5 vehicles: bounds 0-4
// OnGameModeInit/OnFilterScriptInit:
for (new i!= sizeof (Vehicles); ++i)
{
    
Vehicles[i][VehicleID] = INVALID_VEHICLE_ID;
    
Vehicles[i][Color1] = Vehicles[i][Color1] = -1;
    
Vehicles[i][Paintjob] = 3;
}
// OnVehiclePaintjob
for (new i!= sizeof (Vehicles); ++i)
{
    if (
vehicleid == Vehicles[i][VehicleID])
    {
        
Vehicles[i][Paintjob] = paintjobid;
    }
}
// OnVehicleRespray
for (new i!= sizeof (Vehicles); ++i)
{
    if (
vehicleid == Vehicles[i][VehicleID])
    {
        
Vehicles[i][Color1] = color1;
        
Vehicles[i][Color2] = color2;
    }
}
// When creating a vehicle check if the vehicle ID is not INVALID_VEHICLE_ID and:
Vehicles[index_here][VehicleID] = CreateVehicle(...);
// when destroying a vehicle (same as above):
DestroyVehicle(Vehicles[index_here][VehicleID]);
Vehicles[index_here][VehicleID] = INVALID_VEHICLE_ID;
// don't forget to reset it 
And for Pay n' Sprays: http://pastebin.com/zX96D4dA
but instead of "-1" as colors, use "random(256)" so it'll be synced with all the players (otherwise use MP2's include for that, it also saves paintjob etc.).
Reply


Messages In This Thread
Vehicle color and paintjob! - by kalanerik99 - 20.05.2015, 17:46
Re: Vehicle color and paintjob! - by kyriakos587 - 20.05.2015, 17:53
Re: Vehicle color and paintjob! - by Luis- - 20.05.2015, 17:56
Re: Vehicle color and paintjob! - by Konstantinos - 20.05.2015, 17:58
Re: Vehicle color and paintjob! - by kalanerik99 - 20.05.2015, 17:59
Re: Vehicle color and paintjob! - by kalanerik99 - 20.05.2015, 18:01
Re: Vehicle color and paintjob! - by kyriakos587 - 20.05.2015, 18:05
Re: Vehicle color and paintjob! - by kalanerik99 - 20.05.2015, 18:06
Re: Vehicle color and paintjob! - by Konstantinos - 20.05.2015, 18:15
Re: Vehicle color and paintjob! - by kalanerik99 - 20.05.2015, 18:55

Forum Jump:


Users browsing this thread: 2 Guest(s)