AttachObjectToVehicle -
Matyaas - 01.02.2018
Hello everyone, along with say hello, I clarify that my English is not very good and I use the translator on this occasion.
I wanted to know what is the function to add objects to vehicles with AttachObjectToVehicle and how to destroy them when the vehicle explodes, thanks.


Re: AttachObjectToVehicle -
Mugala - 01.02.2018
u can create at anywhere where u want (for examples at CMD)
define object at top of the script
new VehObject[MAX_VEHICLES];
put this script at command
vehid = GetPlayerVehicleID(playerid);
VehObject[vehid] = CreateObject(objectid,0,0,0,0,0,0,0);
AttachObjectToVehicle(VehObject[vehid],vehid,0,0,0,0,0,0);
and put this at OnVehicleDestroy
DestroyObject(VehObject[vehicleid]);
u can also check these functions at wiki to get full information how to use it.
https://sampwiki.blast.hk/wiki/AttachObjectToVehicle
Re: AttachObjectToVehicle -
Matyaas - 02.02.2018
Код:
new ORancher[2];
new vehicleid=GetPlayerVehicleID(playerid);
ORancher[0] = CreateObject(19601,0,0,-1000,0,0,0,100);
ORancher[1] = CreateObject(19601,0,0,-1000,0,0,0,100);
AttachObjectToVehicle(ORancher[0], vehicleid, 0.000000, 3.025021, -0.629999, 177.885086, 0.000000, 0.000000); //Object Model: 19601 | objeto
AttachObjectToVehicle(ORancher[1], vehicleid, 0.000000, 3.025021, 0.234999, 154.769973, 0.000000, 0.000000); //Object Model: 19601 | objeto
in this way it can also or should be necessary to define it as:
Код:
new ORancher [MAX_VEHICLES]; ????
Re: AttachObjectToVehicle -
Mugala - 02.02.2018
yeah it's necessary to be called later in another scripts (such as delete or attachments)