floatstr, don't work?
#1

Код:
if(IsPlayerInAnyVehicle(infop)){
new vehid;
vehid = GetPlayerVehicleID(infop);
GetVehicleHealth(vehid, vh);
} else {
vh = floatstr("No");
}
format(string, sizeof(string), "Info -> Vehicle Health: %.0f", vh);
SendClientMessage(playerid, COLOR_GREEN, string);
Its don't show "No" When is no in vehicle. why? Sorrry for my bad english
Reply
#2

somebody can help? please
Reply
#3

That's because vh = floatstr("No"); won't do anything!

You can't convert a non-numerical string into numbers now can you?


pawn Код:
if(IsPlayerInAnyVehicle(infop))
    {
    new vehid;
    vehid = GetPlayerVehicleID(infop);
    GetVehicleHealth(vehid, vh);
    format(string, sizeof(string), "Info -> Vehicle Health: %.0f", vh);
    }
else
    {
    format(string, sizeof(string), "Player Not in a Vehicle!");
    }
SendClientMessage(playerid, COLOR_GREEN, string);
Reply
#4

NVM post
Reply
#5

pawn Код:
if(IsPlayerInAnyVehicle(infop)){
new vehid;
vehid = GetPlayerVehicleID(infop);
GetVehicleHealth(vehid, vh);
} else {
vh = floatstr("No");
}
format(string, sizeof(string), "Info -> Vehicle Health: %.0f", vh);
SendClientMessage(playerid, COLOR_GREEN, string);
Okay so lets see whats wrong here... First of all, the indentation is non existant. Please learn to indent to make things easier to read.

pawn Код:
if(IsPlayerInAnyVehicle(infop))
{
  new vehid;
  vehid = GetPlayerVehicleID(infop);
  GetVehicleHealth(vehid, vh);
}
else
{
  vh = floatstr("No");
}
format(string, sizeof(string), "Info -> Vehicle Health: %.0f", vh);
SendClientMessage(playerid, COLOR_GREEN, string);
MUCH better... Alright, secondly you do not use a float to send the info that is contained in a string... If you wanted it to say " Info -> Vehicle Health: no" then you should have done this.

pawn Код:
if(IsPlayerInAnyVehicle(infop))
{
  new vehid;
  vehid = GetPlayerVehicleID(infop);
  GetVehicleHealth(vehid, vh);
  format(string, sizeof(string), "Info -> Vehicle Health: %.0f", vh);
  SendClientMessage(playerid, COLOR_GREEN, string); // <- I dont suggest using SendClientMessage to tell a vehicles health. Try GameTextForPlayer instead, it will get rid of the chat spam.
}
else
{
  SendClientMessage(playerid, COLOR_GREEN, "Info -> Vehicle Health: No");
}
EDIT: I see someone posted prettymuch exactly what I just said, but ill keep what I got up here anyways as mine is slightly different.
Reply
#6

Okay okay i understand thanks
Reply
#7

Technically the use of format is inefficient but I wanted it to look slightly more like what he started with =/
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)