AttachTrailerToVehicle - how to ? -
arretdefil - 25.09.2015
Hi !
I'm creating a new filterscript and I need to use the "AttachTrailerToVehicle" after the player get inside a car
So there is my code
Код:
new Float:x, Float:y, Float:z; GetPlayerPos(playerid,x,y,z);
newTrailer[playerid] = CreateVehicle(611,x+4,y,z+1,270.0,-1,-1,15);
new trailerid = GetPlayerVehicleID(newTrailer[playerid]);
AttachTrailerToVehicle(trailerid, vehicleid);
But it doesn't work
I don't really understand how I can have the ID of the
trailer I've just created :/ do someone know ?
Thanks !
Re: AttachTrailerToVehicle - how to ? -
Aly - 25.09.2015
It's like this:
PHP код:
GetPlayerVehicleID(playerid);
The function return the Vehicle ID of the playerid.That's the right way to use it.
Re: AttachTrailerToVehicle - how to ? -
arretdefil - 25.09.2015
I know how to get the car's ID but I want the trailer's ID, sorry if it was not clear
Re: AttachTrailerToVehicle - how to ? -
Aly - 25.09.2015
It's simple then:
PHP код:
new Float:x, Float:y, Float:z; GetPlayerPos(playerid,x,y,z);
newTrailer[playerid] = CreateVehicle(611,x+4,y,z+1,270.0,-1,-1,15);
AttachTrailerToVehicle(newTrailer[playerid], vehicleid);
Re: AttachTrailerToVehicle - how to ? -
arretdefil - 25.09.2015
The trailer is created but it is not attached to the vehicle .. I think it's because newTrailer = CreateVehicle and not a "GetVehicleID", no ?
Re: AttachTrailerToVehicle - how to ? -
Aly - 25.09.2015
Then we'll create a public function and we put a timer on it,I had the same problem.So that code will be like
PHP код:
new Float:x, Float:y, Float:z; GetPlayerPos(playerid,x,y,z);
newTrailer[playerid] = CreateVehicle(611,x+4,y,z+1,270.0,-1,-1,15);
SetTimerEx("AttachTrailer", 1000, false, "ii", playerid, vehicleid); //It will attach the trailer after 1 sec.
And now we're creating the "AttachTrailer" function:
PHP код:
forward AttachTrailer(playerid, vehicleid);
public AttachTrailer(playerid, vehicleid)
{
AttachTrailerToVehicle(newTrailer[playerid], vehicleid);
}
If you don't know were to put this function, do a search into your gm for "public" and put this function there near the others.
Re: AttachTrailerToVehicle - how to ? -
arretdefil - 25.09.2015
Thank you it's perfect !!