AddVehicleComponent
#1

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
Reply
#2

Hello there,

You should always check documentation before posting in this section.

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

You cannot use the first option.
Reply
#3

I checked documentation and thank you for direct answer
Reply
#4

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);
Reply
#5

Okay thanks That helped me a lot
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)