20.05.2015, 18:15
@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):
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.).
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; 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; i != sizeof (Vehicles); ++i)
{
if (vehicleid == Vehicles[i][VehicleID])
{
Vehicles[i][Paintjob] = paintjobid;
}
}
// OnVehicleRespray
for (new i; 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
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.).