Need help with /tow command.
#6

The problem with your code and detaching your trailer is that you detach and then reattach it.

If you had a vehicle with lowerid within range, it would detach your trailer and attach that one.

pawn Код:
if(IsTrailerAttachedToVehicle(vehicle))
{
    DetachTrailerFromVehicle(vehicle);
}
else AttachTrailerToVehicle(vid,vehicle);

But it would be better to avoid the search entirely when detaching your trailer.

pawn Код:
if(IsTrailerAttachedToVehicle(vehicle))
        {
            DetachTrailerFromVehicle(vehicle);
        }else{
           while((vid < MAX_VEHICLES) && (!Found))
           {
             vid++;
             GetVehiclePos(vid,vX,vY,vZ);
             if((floatabs(pXa-vX) < 7.0) && (floatabs(pYa-vY) < 7.0) && (floatabs(pZa-vZ) < 7.0) && (vid != vehicle))
             {
               Found = 1;
               AttachTrailerToVehicle(vid,vehicle);
             }
           }
        }
Reply


Messages In This Thread
Need help with /tow command. - by Zeromanster - 14.02.2010, 00:32
Re: Need help with /tow command. - by RoneyRemington - 14.02.2010, 00:39
Re: Need help with /tow command. - by RoneyRemington - 14.02.2010, 00:40
Re: Need help with /tow command. - by Zeromanster - 14.02.2010, 00:45
Re: Need help with /tow command. - by RoneyRemington - 14.02.2010, 01:04
Re: Need help with /tow command. - by mansonh - 14.02.2010, 07:06
Re: Need help with /tow command. - by Zeromanster - 14.02.2010, 12:59

Forum Jump:


Users browsing this thread: 1 Guest(s)