SA-MP Forums Archive
AddVehicleComponent - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: AddVehicleComponent (/showthread.php?tid=606562)



AddVehicleComponent - Micko123 - 06.05.2016

can i do something like this when adding component
Код:
AddVehicleComponent(GetPlayerVehicleID(playerid), 1010, 500, 608); //imagine those random numbers are components
Or for every new component i need now line??
Код:
AddVehicleComponent(GetPlayerVehicleID(playerid), 1010);
AddVehicleComponent(GetPlayerVehicleID(playerid), 500);
AddVehicleComponent(GetPlayerVehicleID(playerid), 608);
Thx for help


Re: AddVehicleComponent - KevinReinke - 06.05.2016

Hello there,

You should always check documentation before posting in this section.

https://sampwiki.blast.hk/wiki/AddVehicleComponent

You cannot use the first option.


Re: AddVehicleComponent - Micko123 - 06.05.2016

I checked documentation and thank you for direct answer


Re: AddVehicleComponent - Lordzy - 06.05.2016

You can create an array listing the vehicle components that have to be added. Then use a loop to access the array and call AddVehicleComponent.

pawn Код:
new g_VehicleComponents[] = {

    1010,
    500,
    608
};

new vehicleid = GetPlayerVehicleID(playerid);
for(new i = 0; i< sizeof(g_VehicleComponents); i++)
     AddVehicleComponent(vehicleid, g_VehicleComponents[i]);
Or you can simply use this custom function I made.
pawn Код:
stock AddVehicleComponentEx(vehicleid, ...) {

    for(new i = 1, j = numargs(); i< j; i++)
        AddVehicleComponent(vehicleid, getarg(i));
       
    return 1;
}

//can be used like how you mentioned at first
AddVehicleComponentEx(GetPlayerVehicleID(playerid), 1010, 500, 608);



Re: AddVehicleComponent - Micko123 - 06.05.2016

Okay thanks That helped me a lot