AttachTrailerToVehicle - how to ?
#1

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

It's like this:
PHP код:
GetPlayerVehicleID(playerid); 
The function return the Vehicle ID of the playerid.That's the right way to use it.
Reply
#3

I know how to get the car's ID but I want the trailer's ID, sorry if it was not clear
Reply
#4

It's simple then:
PHP код:
                new Float:xFloat:yFloat:zGetPlayerPos(playerid,x,y,z);
        
newTrailer[playerid] = CreateVehicle(611,x+4,y,z+1,270.0,-1,-1,15);
          
AttachTrailerToVehicle(newTrailer[playerid], vehicleid); 
Reply
#5

The trailer is created but it is not attached to the vehicle .. I think it's because newTrailer = CreateVehicle and not a "GetVehicleID", no ?
Reply
#6

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:xFloat:yFloat:zGetPlayerPos(playerid,x,y,z);
newTrailer[playerid] = CreateVehicle(611,x+4,y,z+1,270.0,-1,-1,15);
SetTimerEx("AttachTrailer"1000false"ii"playeridvehicleid); //It will attach the trailer after 1 sec. 
And now we're creating the "AttachTrailer" function:
PHP код:
forward AttachTrailer(playeridvehicleid);
public 
AttachTrailer(playeridvehicleid)
{
       
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.
Reply
#7

Thank you it's perfect !!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)