SA-MP Forums Archive
God Damn!, connot attach my trailer to the truck!.. please help! - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: God Damn!, connot attach my trailer to the truck!.. please help! (/showthread.php?tid=140286)



God Damn!, connot attach my trailer to the truck!.. please help! - FujiNNN - 08.04.2010

i just can't attach my trailer to the truck sometime it's just not appear sometime it's not attaching omg please help me!...

i need that if player execute the command lets say.. '/hello' it will CreateVehicle or AddStaticVehicle (GetPlayerVehilcePos) it will spawn that trailer behind my truck and attach automatically the trailer to my truck..

just cannot make that right.., always messed up..

thank you for your help guys.


Re: God Damn!, connot attach my trailer to the truck!.. please help! - Hiddos - 08.04.2010

Already tried AttachTrailerToVehicle?


Re: God Damn!, connot attach my trailer to the truck!.. please help! - DeadalusNetwork - 08.04.2010

try making a command like /tow or /attach...


Re: God Damn!, connot attach my trailer to the truck!.. please help! - Thrarod - 08.04.2010

trailer = CreateVehicl(blahblah)
AttachTrailerToVehicle("trailer" to your vehicle)

:S


Re: God Damn!, connot attach my trailer to the truck!.. please help! - Steven82 - 08.04.2010

Quote:
Originally Posted by Thrarod
trailer = CreateVehicl(blahblah)
AttachTrailerToVehicle("trailer" to your vehicle)

:S
lol


OFFTOPIC:


Yeah i have helped rodney 3 times now he is 22!!!!!


Re: God Damn!, connot attach my trailer to the truck!.. please help! - FujiNNN - 08.04.2010

Quote:
Originally Posted by Steven82
Quote:
Originally Posted by Thrarod
trailer = CreateVehicl(blahblah)
AttachTrailerToVehicle("trailer" to your vehicle)

:S
lol


OFFTOPIC:


Yeah i have helped rodney 3 times now he is 22!!!!!
i've tryed that already but i can't get the vehicle spawned to my truck's ass.. how do i do that?...


Re: God Damn!, connot attach my trailer to the truck!.. please help! - Thrarod - 08.04.2010

Get your position then get your angle then... Spawn trailer behind that point with use (x-4, y-5, z-2 (example not true)) also those may vary with your angle hard huh?


Re: God Damn!, connot attach my trailer to the truck!.. please help! - FujiNNN - 08.04.2010

Quote:
Originally Posted by Thrarod
Get your position then get your angle then... Spawn trailer behind that point with use (x-4, y-5, z-2 (example not true)) also those may vary with your angle hard huh?
if(IsTrailerAttachedToVehicle(GetPlayerVehicleID(p layerid)))
{
new gTrailer = GetVehicleTrailer(GetPlayerVehicleID(playerid));
DetachTrailerFromVehicle(GetPlayerVehicleID(player id));
DestroyVehicle(gTrailer);
}
new FloatX,FloatY,FloatZ;
GetPlayerPos(playerid,pX,pY,pZ);
new FloatA;
GetVehicleZAngle(GetPlayerVehicleID(playerid),pA);
new newtrailer = CreateVehicle(450,pX+7,pY+7,pZ+7,pA,-1,-1,0);
AttachTrailerToVehicle(newtrailer,GetPlayerVehicle ID(playerid));

its not attaching.. simply not attaching... i was searching for xoomer mini mission and i found that he created the vehicle at 0.0,0.0,0.0 and the trailer attached so wth?... how my trailer not attaching to the truck it's just not normal..


Re: God Damn!, connot attach my trailer to the truck!.. please help! - FujiNNN - 09.04.2010

someone please?...


Re: God Damn!, connot attach my trailer to the truck!.. please help! - Grim_ - 09.04.2010

Are you sure there's actually a player in the vehicle when calling that function?

( And use the tags to display code )


Re: God Damn!, connot attach my trailer to the truck!.. please help! - FujiNNN - 09.04.2010

yes. i'm at a truck and when im calling the command the trailer is spawning but not attaching..


Re: God Damn!, connot attach my trailer to the truck!.. please help! - Grim_ - 09.04.2010

Quote:

Important Note: Will only work if both vehicles are streamed in. -> Taken from the SA:MP wiki

Do the above ^.


Re: God Damn!, connot attach my trailer to the truck!.. please help! - FujiNNN - 09.04.2010

what does it mean (need to be streamed?...)


Re: God Damn!, connot attach my trailer to the truck!.. please help! - biltong - 09.04.2010

Both vehicles must be streamed in, IE close to you.

OFFTOPIC:

I helped Rodney to get to level 9, 25 and 26 xD suckit


Re: God Damn!, connot attach my trailer to the truck!.. please help! - FujiNNN - 09.04.2010

Quote:
Originally Posted by biltong
Both vehicles must be streamed in, IE close to you.

OFFTOPIC:

I helped Rodney to get to level 9, 25 and 26 xD suckit
they are closed to me..

pawn Код:
if(strcmp(cmd, "/transport", true) == 0)
    {
      if(IsPlayerConnected(playerid))
        {
            if(PlayerInfo[playerid][pJob] == 23)
            {
              if(tr_check[playerid] >= 1)
              {
                    if(PlayerInfo[playerid][pJobTime] == 0)
                  {
                        new newcar = GetPlayerVehicleID(playerid);
                        if(newcar >= 254 && newcar <= 255)
                        {
                          if(PlayerToPoint(20.0,playerid,1647.3077,-2112.8350,13.5547))
                        { //vlada
                            new Float:pX,Float:pY,Float:pZ;
                                GetPlayerPos(playerid,pX,pY,pZ);
                                /*new Float:pA;
                                GetVehicleZAngle(GetPlayerVehicleID(playerid),pA);*/

                                new Float:vX,Float:vY,Float:vZ;
                                new Found=0;
                                new newtrailer = AddStaticVehicleEx(450,pX,pY,pZ,0.0,-1,-1,0);
                                while((GetPlayerVehicleID(playerid)<MAX_VEHICLES)&&(!Found))
                                {
                                GetVehiclePos(GetPlayerVehicleID(playerid),vX,vY,vZ);
                                if((floatabs(pX-vX)<7.0)&&(floatabs(pY-vY)<7.0)&&(floatabs(pZ-vZ)<7.0))
                                {
                                    Found=1;
                                if(IsTrailerAttachedToVehicle(GetPlayerVehicleID(playerid)))
                                {
                                        new gTrailer = GetVehicleTrailer(GetPlayerVehicleID(playerid));
                                    DetachTrailerFromVehicle(GetPlayerVehicleID(playerid));
                                    DestroyVehicle(gTrailer);
                                }
                                    AttachTrailerToVehicle(newtrailer,GetPlayerVehicleID(playerid));
                                    SetPlayerCheckpoint(playerid,2431.2773,114.5036,26.4689,20.0);
                                    transportcheck[playerid]=1; tr_check[playerid] = 0;
                                    GameTextForPlayer(playerid,"~r~Transport ~w~the container to the selected destination!",8000,3);
                                } }
                            }
                            else
                            {
                              SendClientMessage(playerid, COLOR_GREY,"* You need to be in the working place entrance area to enable the mission.");
                            }
                    }
                        else
                        {
                            SendClientMessage(playerid, COLOR_GREY,"* You cannot transport without a transporter vehicle!");
                        }
                    }
                    else
                    {
                      SendClientMessage(playerid, COLOR_GREY,"* You are already started the your job mission.");
                    }
            }
                else
                {
          format(string, sizeof(string), "* You cannot transport at the moment, please come again in %d minutes.", PlayerInfo[playerid][pJobTime]);
                    SendClientMessage(playerid, COLOR_GREY, string);
                }
            }
            else
            {
                SendClientMessage(playerid, COLOR_GREY,"* You are not a transporter.");
            }
        }
        return 1;
    }



Re: God Damn!, connot attach my trailer to the truck!.. please help! - FujiNNN - 10.04.2010

someone please?...


Re: God Damn!, connot attach my trailer to the truck!.. please help! - FujiNNN - 12.04.2010

not answered yet... please i really need it..


Re: God Damn!, connot attach my trailer to the truck!.. please help! - 0ne - 12.04.2010

Are you sure u did everything good? All i did was go to the position with my character and save it then replaced it with

Код:
new trailer;
Trailer = AddVehicle(blahblah
and then when he pushes a button it goes like:

Код:
if(GetPlayerVehicleID(playerid) == Truck1)
	  {
	    //code
		  AttachTrailerToVehicle(Trailer1,Truck1);
			//code
		}
HOpe i helped?


Re: God Damn!, connot attach my trailer to the truck!.. please help! - =WoR=Varth - 29.06.2011

pawn Код:
new vc = CreateVehicle(trailer,0,0,0,0,0,0,0)
AttachTrailerToVehicle(vc,GetPlayerVehicleID(playerid));



Re: God Damn!, connot attach my trailer to the truck!.. please help! - Resort - 29.06.2011

Compare you code to this.
this code works so just fix what you need

Код:
//Towing Stuff
CMD:tow(playerid, params[]) {
	if(IsPlayerConnected(playerid)) {
		if(IsPlayerInAnyVehicle(playerid)) {
	        new m = GetVehicleModel(GetPlayerVehicleID(playerid));
	    	if (m == 525 || m == 552) {
	   	   	    if(GetPlayerState(playerid)==2) {
					new Float:pX,Float:pY,Float:pZ;
					GetPlayerPos(playerid,pX,pY,pZ);
					new Float:vX,Float:vY,Float:vZ;
					new Found=0;
					new vid=0;
					while((vid<MAX_VEHICLES)&&(!Found)) {
	   					vid++;
	   					GetVehiclePos(vid,vX,vY,vZ);
	   					if ((floatabs(pX-vX)<7.0)&&(floatabs(pY-vY)<7.0)&&(floatabs(pZ-vZ)<7.0)&&(vid!=GetPlayerVehicleID(playerid))) {
	   				    	Found=1;
	   				    	if(IsTrailerAttachedToVehicle(GetPlayerVehicleID(playerid))) {
	   				        	DetachTrailerFromVehicle(GetPlayerVehicleID(playerid));
				           	}
				           	else {
	    						AttachTrailerToVehicle(vid,GetPlayerVehicleID(playerid));
							}
	 					}
	     			}
					if(!Found) {
	   					SendClientMessage(playerid, COLOR_RED, "[ Error ]: There is no car in range.");
	   				}
				}
				else {
					SendClientMessage(playerid, COLOR_RED, "[ Error ]: You need to be the driver!");
					return 1;
				}
			}
			else	{
			SendClientMessage(playerid, COLOR_RED, "[ Error ]: You need to be in a vehicle to do this!");
			return 1;
		}
	}
 	}
	return 1;
}