26.09.2016, 10:34
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];
}