14.02.2010, 07:06
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.
But it would be better to avoid the search entirely when detaching your trailer.
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);
}
}
}