Vehicle health saving wrong
#1

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?
Reply
#2

Have you tried to print value passed from 'GetVehicleHealth' before updating it?
Reply
#3

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);
Reply
#4

VHealth prints out the correct amount of health.. Yes in my enum it's like that.
Reply
#5

Try to print out your update query, see what happens.
Reply
#6

Код:
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)
Reply
#7

you are storing vehicles health as integer? Format it as floating value. Use '%f' instead of '%d' or '%i'
Reply
#8

I'm not storing it as an integar.. I'm storing it as a float.. as I said before.

EDIT: Managed to fix it.
Reply
#9

can you show more code? Show block from 'new Float:VHealth;' to 'mysql_query'
Reply
#10

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)