False trailer health results when detaching trailer
#1

There seems to be a bug when you detach trailer (other vehicle) from the main vehicle.

Lets say that I damage the trailer vehicle to the 289.5 health. I attach it to the main vehicle and the health result is correct for now.
Код:
debugMsg(1.0): Health: 289.5
debugMsg(1.1): Health: 289.5
The problem appears when I detach the trailer vehicle. The health result of the trailer vehicle is false.
Код:
debugMsg(2.0): Health: 1000.0
debugMsg(2.1): Health: 1000.0
It shows trailer vehicle's health as full, but it's actually 289.5. The problem goes away if someone enters the trailer vehicle but then the problem cycle repeats itself (attaching, detaching).

Testing code:
Код:
new
		gVehicle[2];
Код:
stock Function_Tow(vehicleid, trailerid)
{
	new
			Float:health;

	GetVehicleHealth(trailerid, health);
	printf("debugMsg(1.0): Health: %0.1f", health);

	AttachTrailerToVehicle(trailerid, vehicleid);

	GetVehicleHealth(trailerid, health);
	printf("debugMsg(1.1): Health: %0.1f\n", health);
	return true;
}
Код:
stock Function_Detach(vehicleid)
{
	new
			Float:health, trailerid;

	trailerid = GetVehicleTrailer(vehicleid);

	GetVehicleHealth(trailerid, health);
	printf("debugMsg(2.0): Health: %0.1f", health);

	DetachTrailerFromVehicle(vehicleid);

	GetVehicleHealth(trailerid, health);
	printf("debugMsg(2.1): Health: %0.1f\n", health);
	return true;
}
Код:
public OnGameModeInit()
{
	gVehicle[0] = CreateVehicle(525, 0.0, 0.0, 2.8, 0.0, -1, -1, 3600);
	gVehicle[1] = CreateVehicle(529, 5.0, 5.0, 2.8, 0.0, -1, -1, 3600);
	return true;
}
Код:
command(tow, playerid, params[])
{
	if(!IsPlayerInVehicle(playerid, gVehicle[0]))
		return false;
	if(!IsVehicleStreamedIn(gVehicle[1], playerid))
		return false;
	return Function_Tow(gVehicle[0], gVehicle[1]);
}
Код:
command(detach, playerid, params[])
{
	if(!IsPlayerInVehicle(playerid, gVehicle[0]))
		return false;
	if(!IsTrailerAttachedToVehicle(gVehicle[0]))
		return false;
	return Function_Detach(gVehicle[0]);
}
Reply
#2

Confirmed, I reported this bug as well some time ago: https://sampforum.blast.hk/showthread.php?tid=564138

I really hope it gets fixed ASAP.
Reply
#3

Confirmed this bug myself, but never actually tried some solutions. The only thing that might pass by my mind right now is setting the trailer's health to the old after detaching.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)