GetVehicleHealth - 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: GetVehicleHealth (
/showthread.php?tid=254596)
GetVehicleHealth -
[MWR]Blood - 11.05.2011
I have this code, i think its correct, but even the vehicle being wih full health, why does it still send a message saying
"It's to wrecked... use (/phone)"
Everything works exept that bit of the health, if it's full it still sends a message saying it's to wrecked
pawn Код:
public Start(playerid)
{
new engine,lights,alarm,doors,bonnet,boot,objective,Float:health,rand;
if(GetVehicleHealth(GetPlayerVehicleID(playerid),health) < 500)
{
SendClientMessage(playerid,white,"*"lred"The vehicle is too wrecked, please call assistance! "lyellow2"(/phone)");
starting[playerid] = 0;
}
rand = random(2);
if(rand == 0)
{
SendClientMessage(playerid,white,"*"lred"Unable to start the vehicle"lwhite"*");
starting[playerid] = 0;
}
if(rand == 1 && Started[GetPlayerVehicleID(playerid)] == 0)
{
GetVehicleParamsEx(GetPlayerVehicleID(playerid),engine,lights,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(GetPlayerVehicleID(playerid),1,lights,alarm,doors,bonnet,boot,objective);
Started[GetPlayerVehicleID(playerid)] = 1;
SendClientMessage(playerid,white,"*"lred"Vehicle "lgreen"started"lred"!"lwhite"*");
starting[playerid] = 0;
}
return 1;
}
Re: GetVehicleHealth -
Steve M. - 11.05.2011
Код:
public Start(playerid)
{
new engine,lights,alarm,doors,bonnet,boot,objective,Float:health,rand;
GetVehicleHealth(GetPlayerVehicleID(playerid), health);
if(health < 500)
{
SendClientMessage(playerid,white,"*"lred"The vehicle is too wrecked, please call assistance! "lyellow2"(/phone)");
starting[playerid] = 0;
}
rand = random(2);
if(rand == 0)
{
SendClientMessage(playerid,white,"*"lred"Unable to start the vehicle"lwhite"*");
starting[playerid] = 0;
}
if(rand == 1 && Started[GetPlayerVehicleID(playerid)] == 0)
{
GetVehicleParamsEx(GetPlayerVehicleID(playerid),engine,lights,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(GetPlayerVehicleID(playerid),1,lights,alarm,doors,bonnet,boot,objective);
Started[GetPlayerVehicleID(playerid)] = 1;
SendClientMessage(playerid,white,"*"lred"Vehicle "lgreen"started"lred"!"lwhite"*");
starting[playerid] = 0;
}
return 1;
}
Try that.
You called function to get vehicle's health in a if() statment. That does nothing, it just stores vehicle's health in a variable. Because function returnes 1 or 0 it's smaller that 500 and then the code in if() statment is called.