floatstr, don't work? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: floatstr, don't work? (
/showthread.php?tid=68874)
floatstr, don't work? -
DmXPlay - 14.03.2009
Код:
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
Re: floatstr, don't work? -
DmXPlay - 15.03.2009
somebody can help? please
Re: floatstr, don't work? -
Weirdosport - 15.03.2009
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);
Re: floatstr, don't work? -
DmXPlay - 15.03.2009
NVM post
Re: floatstr, don't work? -
Kinetic - 15.03.2009
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.
Re: floatstr, don't work? -
DmXPlay - 15.03.2009
Okay okay i understand thanks
Re: floatstr, don't work? -
Weirdosport - 15.03.2009
Technically the use of format is inefficient but I wanted it to look slightly more like what he started with =/