Vehicle health saving wrong -
thefatshizms - 30.07.2013
Okay I have this code in a timer:
pawn Код:
new Float:VHealth;
GetVehicleHealth(GetPlayerVehicleID(playerid), VHealth);
VehicleInfo[i][VehicleHealth] = VHealth;
I smash up my car a bit till its in black ish smoke.. I then update the database on its health and I look into the database and see that the health is 1135.0 ... 1000.0 is full health.. yet this car was in black smoke?
Re: Vehicle health saving wrong -
Scottas - 30.07.2013
Have you tried to print value passed from 'GetVehicleHealth' before updating it?
Re: Vehicle health saving wrong -
DaRk_RaiN - 30.07.2013
And in the VehicleInfo enum you defined it as this?
pawn Код:
...,
Float:VehicleHealth,
...,
..
Or if you want to store it as an integer you should do this
pawn Код:
VehicleInfo[i][VehicleHealth] = floatround(VHealth);
Re: Vehicle health saving wrong -
thefatshizms - 30.07.2013
VHealth prints out the correct amount of health.. Yes in my enum it's like that.
Re: Vehicle health saving wrong -
Scottas - 30.07.2013
Try to print out your update query, see what happens.
Re: Vehicle health saving wrong -
thefatshizms - 30.07.2013
Код:
UPDATE `vehicle` SET `x_pos`=-2027.304443, `y_pos`=125.211776, `z_pos`=28.788368, `rotation`=173.007995, `pannel_damage`=35717120, `door_damage`=514, `light_damage`=0, `tire_damage`=0, `vehicle_health`=1145441983, `color1`=128, `color2`=128 WHERE `id`=3)
Re: Vehicle health saving wrong -
Scottas - 30.07.2013
you are storing vehicles health as integer? Format it as floating value. Use '%f' instead of '%d' or '%i'
Re: Vehicle health saving wrong -
thefatshizms - 30.07.2013
I'm not storing it as an integar.. I'm storing it as a float.. as I said before.
EDIT: Managed to fix it.
Re: Vehicle health saving wrong -
Scottas - 30.07.2013
can you show more code? Show block from 'new Float:VHealth;' to 'mysql_query'
Re: Vehicle health saving wrong -
Pottus - 30.07.2013
Lets see your format line
pawn Код:
UPDATE `vehicle` SET `x_pos`=-2027.304443, `y_pos`=125.211776, `z_pos`=28.788368, `rotation`=173.007995, `pannel_damage`=35717120, `door_damage`=514, `light_damage`=0, `tire_damage`=0, `vehicle_health`=1145441983, `color1`=128, `color2`=128 WHERE `id`=3)
Looks like you have the wrong specifier for the health