Well, you have 3 options.
Create a loop.
Create a loop after all vehicles have been created, and link the vehicles in the array 'Event' to a certain interior.
PHP код:
Event[0] = AddStaticVehicleEx(...
Event[1] = AddStaticVehicleEx(...
// ...
Event[29] = AddStaticVehicleEx(...
for(new i = 0; i != sizeof(Event); i++)
{
if(Event[i] != 0) // if the vehicle was created and has a value
{
LinkVehicleToInterior(Event[i], 5); // This will link the vehicle to interior 5.
}
}
Assign the vehicle IDs to a variable as you go.
This involves creating a new variable before you create the vehicle, and it assigns the vehicle IDs to the variable as you go.
PHP код:
new vehicle_id = 0;
Event[0] = vehicle_id = AddStaticVehicleEx(...
LinkVehicleToInterior(vehicle_id, 5); // This will link the vehicle to interior 5.
Event[1] = vehicle_id = AddStaticVehicleEx(...
LinkVehicleToInterior(vehicle_id, 5);
// ...
Event[29] = vehicle_id = AddStaticVehicleEx(...
LinkVehicleToInterior(vehicle_id, 5);
Note that you don't NEED to create a new variable for this. You can always replace 'vehicle_id' with Event[0], Event[1] etc., but from this post, I gather this is exactly what you're trying to avoid.
Combine the second method by using 1 line.
This basically combines the second method into one line without the use of a variable. As AddStaticVehicleEx returns the created vehicle ID, there's no real need for a variable, you can simply plug and play with a function such as LinkVehicleToInterior.
PHP код:
LinkVehicleToInterior((Event[0] = AddStaticVehicleEx(...)), 5); // This will link the vehicle to interior 5.
LinkVehicleToInterior((Event[1] = AddStaticVehicleEx(...)), 5);
// ...
LinkVehicleToInterior((Event[20] = AddStaticVehicleEx(...)), 5);
The easiest method to understand would be the second method. The first method is the most preferred and widely used version, and saves a lot of time in scripting but isn't necessarily the most efficient. I would personally use the third method, as it saves having to use unnecessary variables and lines. (Though there's nothing wrong with having more lines to achieve a neat code, it's merely personal preference)