Car health - 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: Car health (
/showthread.php?tid=254689)
Car health -
Wesley221 - 12.05.2011
Hey guys, i got a little warning, and cant find out what im doing wrong.
pawn Код:
if(newstate == PLAYER_STATE_DRIVER)
{
new vehicleid = GetPlayerVehicleID(playerid);
new chealth = GetVehicleHealth(vehicleid, chealth); //<-- line 845
if(chealth < 350)
{
SetVehicleParamsEx(vehicleid, false, true, true, true, false, false, false);
TogglePlayerControllable(playerid,0);
SendClientMessage(playerid, orange, "Your engine died. Please call a repairsman to repair it");
return 1;
} else if (chealth >350) {
SetVehicleParamsEx(vehicleid, true, false, false, false, false, false, false);
TogglePlayerControllable(playerid, 1);
}
return 1;
}
Код:
C:\Users\wesley.PC_van_Kelsey\Desktop\RolePlay\gamemodes\RolePlay.pwn(845) : warning 213: tag mismatch
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
1 Warning.
Hope you guys can help

~Wesley
Re: Car health -
Haydz - 12.05.2011
EDIT: i was wrong, you forgot to put Float: before the chealth. my bad!
pawn Код:
if(newstate == PLAYER_STATE_DRIVER)
{
new vehicleid = GetPlayerVehicleID(playerid);
new Float:chealth;
GetVehicleHealth(vehicleid, chealth); //<-- line 845
if(chealth < 350)
{
SetVehicleParamsEx(vehicleid, false, true, true, true, false, false, false);
TogglePlayerControllable(playerid,0);
SendClientMessage(playerid, orange, "Your engine died. Please call a repairsman to repair it");
return 1;
} else if (chealth >350) {
SetVehicleParamsEx(vehicleid, true, false, false, false, false, false, false);
TogglePlayerControllable(playerid, 1);
}
return 1;
}
Re: Car health -
Wesley221 - 12.05.2011
Hmm somehow when the cars health is below 350, it wont shut down the engine
Anyone know what to do?
pawn Код:
if(newstate == PLAYER_STATE_DRIVER)
{
new vehicleid = GetPlayerVehicleID(playerid);
new Float:chealth;
GetVehicleHealth(vehicleid, chealth);
if(GetVehicleHealth(vehicleid, chealth) < 350)
{
SetVehicleParamsEx(vehicleid, false, true, true, true, false, false, false);
TogglePlayerControllable(playerid,0);
SendClientMessage(playerid, orange, "Your engine died. Please call a repairsman to repair it");
return 1;
} else if (GetVehicleHealth(vehicleid, chealth) >350) {
SetVehicleParamsEx(vehicleid, true, false, false, false, false, false, false);
TogglePlayerControllable(playerid, 1);
}
return 1;
}
Re: Car health -
Vince - 12.05.2011
GetVehicleHealth does not return a value (well, I think it returns 1/0 on success/failure, but I'm not sure). You already stored the health in the variable
chealth, so use that to check.
if(chealth < 350.0)
Re: Car health -
Wesley221 - 12.05.2011
Okie, changed it now;
When the car health is below 350 & u leave the car & after that get in, it freezes
How to make it if it gets below 350, it shuts the engine down inmediantly?