public OnDynamicVehDamageStatusUpdate(vehicleid, playerid) {
// comp 1
GetDynamicVehicleHealth(vehicleid, vHPcintoA[vehicleid]);
if(vHPcintoA[vehicleid] < vHPcintoB[vehicleid])
{
// losing life
new Float:danoplayerbatida = (vHPcintoB[vehicleid] - vHPcintoA[vehicleid]) / 100;
vida[playerid] -= danoplayerbatida;
new dmgstring[20];
format(dmgstring, sizeof(dmgstring), "~r~%i.0", danoplayerbatida );
GameTextForPlayer(playerid, dmgstring, 1000, 3);
}
// comp 2
GetDynamicVehicleHealth(vehicleid, vHPcintoB[vehicleid]);
}
|
Float:danoplayerbatida
%i.0 An integer with 0 decimals, but in reality is a float with decimals? Rip errors if format would've returned errors. %f.0 instead of %i.0 |
new Float:danoplayerbatida = (vHPcintoB[vehicleid] - vHPcintoA[vehicleid]) / 100;
//here you have declared it as a float
format(dmgstring, sizeof(dmgstring), "~r~%i.0", danoplayerbatida );
//and here in this line you are formatting as a integer but instead the proper way would be formatting it as a float with 0 decimal places.
format(dmgstring, sizeof(dmgstring), "~r~%.0f", danoplayerbatida );
public OnPlayerUpdate(playerid)
{
if(GetPlayerState(playerid) == 2)
{
new Float:vehHealth;// we create a new var (type Float value 0.0)
new Float:playerArmour;//we create a new var (type floatvalue 0.0)
new curentVeh = GetPlayerVehicleID(playerid);//Get the vehicle (id) of the player (and store it in curentVeh)
GetVehicleHealth(curentVeh, vehHealth);//Get the vehicle health and store it in vehHealth(value returned e.g: 2500.2)
vehHealth = vehHealth/10;// we divide the value of vehHealth per 10
SetPlayerHealth(playerid, vehHealth);//Set the health of the vehicle at the health of the player(value e.g : 250)
if(GetPlayerArmour(playerid,playerArmour) != 0)// if the armour of the playerArmour is not equal at 0 (player have armour)
{
SetPlayerArmour(playerid,0);//Set the armour ofthe player at 0 ("delete his armour")
SetPlayerHealth(playerid, vehHealth);//Set the health of the vehicle at the health of the player
}
}
}