Little Help -
Hunud - 16.06.2017
Hi,
I have attach police siren to infernus car, now how i can attach all this sirens for other 5 infernus cars ? Instead of repeating code! +REP
Re: Little Help -
Abagail - 16.06.2017
I'm not sure what you mean by "repeating" code, show what you currently have or be more specific with what you're trying to do.
Re: Little Help -
JasonRiggs - 16.06.2017
If you are using AddStaticVehicleEx then you can't do it for more other 5 infernus cars without repeating..
Re: Little Help -
Hunud - 16.06.2017
I have variable InfernusCars[5], and i want to attach sirens to all these infernus cars without repeating code like this.
Code:
new Siren= CreateObject(1541, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
AttachObjectToVehicle(InfernusCar[0], 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
Code:
new Siren= CreateObject(1541, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
AttachObjectToVehicle(InfernusCar[1], 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
Code:
new Siren= CreateObject(1541, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
AttachObjectToVehicle(InfernusCar[2], 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
I creating vehicles like this: InfernusCars[0] = CreateVehicle(411, bla bla bla, bla bla bla);
.............
.............
Re: Little Help -
Abagail - 16.06.2017
You could loop through them, which also allows you to dynamically make more later on. Is there also a purpose to storing the object ID? (i.e: destroying them later on).
Re: Little Help -
Hunud - 16.06.2017
I have no idea how to loop trought these :/ . No there is no purpose of storing object
Re: Little Help -
Abagail - 16.06.2017
You could do something such as this:
pawn Code:
for(new i; i < sizeof InfernusCar; i++)
{
if(!GetVehicleModel(InfernusCar[i])) continue;
AttachObjectToVehicle(CreateObject(1541, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0), InfernusCar[0], 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
}
Re: Little Help -
Hunud - 17.06.2017
Now, the siren is only attached to InfernusCar[0]
What to do ?
Re: Little Help -
Bolex_ - 17.06.2017
Quote:
Originally Posted by Hunud
Now, the siren is only attached to InfernusCar[0] What to do ?
|
Code:
for(new i; i < sizeof InfernusCars; i++)
{
if(!GetVehicleModel(InfernusCars[i])) continue;
AttachObjectToVehicle(CreateObject(1541, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0), InfernusCars[i], 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
}
Re: Little Help -
Hunud - 17.06.2017
thanks that work :d