SA-MP Forums

Go Back   SA-MP Forums > SA-MP > Bug Reports

Reply
 
Thread Tools Display Modes
Old 12/02/2016, 07:08 PM   #1
Correlli
Godfather
 
Correlli's Avatar
 
Join Date: May 2009
Location: Slovenia
Posts: 7,161
Reputation: 361
Default False trailer health results when detaching trailer

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.
Code:
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.
Code:
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:
Code:
new
		gVehicle[2];
Code:
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;
}
Code:
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;
}
Code:
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;
}
Code:
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]);
}
Code:
command(detach, playerid, params[])
{
	if(!IsPlayerInVehicle(playerid, gVehicle[0]))
		return false;
	if(!IsTrailerAttachedToVehicle(gVehicle[0]))
		return false;
	return Function_Detach(gVehicle[0]);
}
Correlli is offline   Reply With Quote
Old 13/02/2016, 09:01 AM   #2
HazardouS
Huge Clucker
 
HazardouS's Avatar
 
Join Date: Aug 2014
Posts: 256
Reputation: 26
Default Re: False trailer health results when detaching trailer

Confirmed, I reported this bug as well some time ago: http://forum.sa-mp.com/showthread.php?t=564138

I really hope it gets fixed ASAP.
HazardouS is offline   Reply With Quote
Old 13/02/2016, 12:07 PM   #3
Private200
High-roller
 
Private200's Avatar
 
Join Date: May 2012
Posts: 1,229
Reputation: 206
Default Re: False trailer health results when detaching trailer

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.
__________________
just a signature
Private200 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Trailer health mamorunl Scripting Help 2 08/09/2014 10:25 AM
After detaching trailer from vehicle sometimes other users see trailer attached to vehicle diclofoss Bug Reports 0 26/03/2014 03:35 PM


All times are GMT. The time now is 11:46 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.