Teleport with trailer, BUG?
#1

i have this code:
Код:
stock TeleportWithVehicleTrailer(playerid, Float:Vx, Float:Vy, Float:Vz, Float:Va, Float:Px, Float:Py, Float:Pz, Float:Pa)
{
	if(IsPlayerInAnyVehicle(playerid))
  {
     if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER)
       return SendClientMessage(playerid, 0xFFFFFFFF, "SERVER: Unknown command.");
     SetVehiclePos(GetPlayerVehicleID(playerid), Float:Vx, Float:Vy, Float:Vz);
     SetVehicleZAngle(GetPlayerVehicleID(playerid),Float:Va);
     SetCameraBehindPlayer(playerid);
     
     if(IsTrailerAttachedToVehicle(GetPlayerVehicleID(playerid)))
     {
			 AttachTrailerToVehicle(GetVehicleTrailer(GetPlayerVehicleID(playerid)),GetPlayerVehicleID(playerid));
		 }
  }
  else
  {
    SetPlayerPos(playerid, Float:Px, Float:Py, Float:Pz);
    SetPlayerFacingAngle(playerid, Float:Pa);
    SetCameraBehindPlayer(playerid);
  }
  return 1;
}
i 0.2X Teleport with trailer works good. In 0.3 wont teleport with trailer :S
Reply
#2

Quote:

- Fix for Attach/DetachTrailerFromVehicle (can be applied to streamed in vehicles only).

Not a bug. Set the trailer position too.
Reply
#3

I dont know how to do that. How to set the trailer position
Reply
#4

SetVehiclePos lol ...

Just get Angle between vehpos and trailerpos then calculate trailer pos for new vehpos.
Reply
#5

I made this now:

Код:
stock TeleportWithVehicleTrailer(playerid, Float:Vx, Float:Vy, Float:Vz, Float:Va, Float:Px, Float:Py, Float:Pz, Float:Pa)
{
	if(IsPlayerInAnyVehicle(playerid))
  {
  	if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER)
  		  return SendClientMessage(playerid, 0xFFFFFFFF, "SERVER: Unknown command.");
    SetVehiclePos(GetPlayerVehicleID(playerid), Float:Vx, Float:Vy, Float:Vz);
    SetVehicleZAngle(GetPlayerVehicleID(playerid),Float:Va);
    SetCameraBehindPlayer(playerid);
     
	  AttachTrailerToVehicle(GetVehicleTrailer(GetPlayerVehicleID(playerid)),GetPlayerVehicleID(playerid));
	  SetVehiclePos(GetVehicleTrailer(GetPlayerVehicleID(playerid)), Float:Vx, Float:Vy, Float:Vz);
    SetVehicleZAngle(GetVehicleTrailer(GetPlayerVehicleID(playerid)), Float:Va);
  }
  else
  {
    SetPlayerPos(playerid, Float:Px, Float:Py, Float:Pz);
    SetPlayerFacingAngle(playerid, Float:Pa);
    SetCameraBehindPlayer(playerid);
  }
  return 1;
}
And it works. When i teleport its attached but only 1ms later it detaches :S Than i must attach it with my hands. And when i teleport on the same place again, and again and i repeating teleporting than it still attached! Whats the problem?

I mean the first teleport on one place causes a detach.
Reply
#6

All you have to do is set the trailer position near to the vehicle and then attach it again. You can't attach a trailer to a vehicle if they aren't both streamed in.
Reply
#7

It Works now but there still a problem.

Watch this video carefully:
[url=http://[url]http://www.xfire.com/video/157151/]
Reply
#8

Are you setting both the vehicles positions before trying to attach them?
Reply
#9

I think yes, look at the last script i posted.
Reply
#10

Quote:
Originally Posted by yugokoral
I think yes, look at the last script i posted.
No you're not. You are trying to attach them before they are both streamed in. Set both of the vehicles positions before attaching them.
Reply
#11

! How to do that? I tried the most different things :S

You maybe mean this?:
pawn Code:
stock TeleportWithVehicleTrailer(playerid, Float:Vx, Float:Vy, Float:Vz, Float:Va, Float:Px, Float:Py, Float:Pz, Float:Pa)
{
    if(IsPlayerInAnyVehicle(playerid))
  {
    if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER)
          return SendClientMessage(playerid, 0xFFFFFFFF, "SERVER: Unknown command.");
    SetVehiclePos(GetPlayerVehicleID(playerid), Float:Vx, Float:Vy, Float:Vz);
    SetVehicleZAngle(GetPlayerVehicleID(playerid),Float:Va);
    SetCameraBehindPlayer(playerid);
     

    SetVehiclePos(GetVehicleTrailer(GetPlayerVehicleID(playerid)), Float:Vx, Float:Vy, Float:Vz);
    SetVehicleZAngle(GetVehicleTrailer(GetPlayerVehicleID(playerid)), Float:Va);

    AttachTrailerToVehicle(GetVehicleTrailer(GetPlayerVehicleID(playerid)),GetPlayerVehicleID(playerid)); // this is on the last line
  }
  else
  {
    SetPlayerPos(playerid, Float:Px, Float:Py, Float:Pz);
    SetPlayerFacingAngle(playerid, Float:Pa);
    SetCameraBehindPlayer(playerid);
  }
  return 1;
}

If you mean this, its the same problem.
Reply
#12

SetVehiclePos(GetVehicleTrailer(GetPlayerVehicleID (playerid)), Float:Vx, Float:Vy, Float:Vz);

This is where your problem is, before you do that, you have make sure the trailer is streamed in
Reply
#13

It wont work. I tried everything:

I tried this too:
pawn Code:
stock TeleportWithVehicleTrailer(playerid, Float:Vx, Float:Vy, Float:Vz, Float:Va, Float:Px, Float:Py, Float:Pz, Float:Pa)
{
    if(IsPlayerInAnyVehicle(playerid))
  {
    if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER)
          return SendClientMessage(playerid, 0xFFFFFFFF, "SERVER: Unknown command.");
    SetVehiclePos(GetPlayerVehicleID(playerid), Float:Vx, Float:Vy, Float:Vz);
    SetVehicleZAngle(GetPlayerVehicleID(playerid),Float:Va);
    SetCameraBehindPlayer(playerid);



    if(IsVehicleStreamedIn(GetVehicleTrailer(GetPlayerVehicleID(playerid)), playerid))
    {
          SetVehiclePos(GetVehicleTrailer(GetPlayerVehicleID(playerid)), Float:Vx, Float:Vy, Float:Vz);
          SetVehicleZAngle(GetVehicleTrailer(GetPlayerVehicleID(playerid)), Float:Va);
    }
    AttachTrailerToVehicle(GetVehicleTrailer(GetPlayerVehicleID(playerid)),GetPlayerVehicleID(playerid));
   
  }
  else
  {
    SetPlayerPos(playerid, Float:Px, Float:Py, Float:Pz);
    SetPlayerFacingAngle(playerid, Float:Pa);
    SetCameraBehindPlayer(playerid);
  }

  return 1;
}
Reply
#14

SORY FOR DOUBLE POST

I need to move my post a little higher, that maybe somewho answer me.
Reply
#15

I tried now this:

pawn Code:
stock TeleportWithVehicleTrailer(playerid, Float:Vx, Float:Vy, Float:Vz, Float:Va, Float:Px, Float:Py, Float:Pz, Float:Pa)
{
    if(IsPlayerInAnyVehicle(playerid))
  {
    if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER)
      return SendClientMessage(playerid, 0xFFFFFFFF, "SERVER: Unknown command.");
    SetVehiclePos(GetPlayerVehicleID(playerid), Float:Vx, Float:Vy, Float:Vz);
    SetVehicleZAngle(GetPlayerVehicleID(playerid),Float:Va);
    SetCameraBehindPlayer(playerid);

    SetVehiclePos(GetVehicleTrailer(GetPlayerVehicleID(playerid)), Float:Vx, Float:Vy, Float:Vz);
    SetVehicleZAngle(GetVehicleTrailer(GetPlayerVehicleID(playerid)), Float:Va);

   
  }
  else
  {
    SetPlayerPos(playerid, Float:Px, Float:Py, Float:Pz);
    SetPlayerFacingAngle(playerid, Float:Pa);
    SetCameraBehindPlayer(playerid);
  }
  return 1;
}


public OnVehicleStreamIn(vehicleid, forplayerid)
{
    AttachTrailerToVehicle(GetVehicleTrailer(GetPlayerVehicleID(forplayerid)),GetPlayerVehicleID(forplayerid));
}
IT WORKS, but why it do this: http://www.xfire.com/video/15a12b/
It reattaching the trailer!!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)