Help with 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)
+--- Thread: Help with GetVehicleHealth (
/showthread.php?tid=573548)
Help with GetVehicleHealth -
giorgosdim12 - 08.05.2015
i have problem if player finish on driveschool and if vehicle < 880 hp losse driveschool.
code:
Код:
function Finish(p) {
new veh,Float:HPV;
veh = GetPlayerVehicleID(p);
if(WarnCH[p] > 13 || GetVehicleHealth(veh,HPV) < 880)return LosseRace(p);// here my problem GetVehicleHealth(veh,HPV) < 880
DestroyVehicle(CarDriveSchool[p]);
SCM(p,-1,"You have succses finish drive school! now can you drive any car.");
DataAccount[p][DriveS] = 1;
DataAccount[p][XPs] += 25;
KillTimer(Timerr[p]);
DataAccount[p][Money] += 100;
CheckMoney(p);
SpawnPlayer(p);
DisableDrift[p] = 0;
return 1;
}
Re: Help with GetVehicleHealth -
Konstantinos - 08.05.2015
https://sampwiki.blast.hk/wiki/GetVehicleHealth
You check if the function was successful or not. You need to get the vehicle's health and check if the health (stored to a variable) is less than 880.
Re: Help with GetVehicleHealth -
giorgosdim12 - 08.05.2015
if player finish race can check it if vehicle hp < 880?
or i create new variable?
Re: Help with GetVehicleHealth -
giorgosdim12 - 08.05.2015
my problem is if vehicle hp > or < 880 get losse driveschool
any help guys??
Re: Help with GetVehicleHealth -
MP2 - 08.05.2015
You have to use the referenced variable.
pawn Код:
new Float:vehicleHealth;
GetVehicleHealth(vehicleid, vehicleHealth);
if(vHealth < 880)
{
// Fail
}
Re: Help with GetVehicleHealth -
giorgosdim12 - 08.05.2015
hm... again losse driveschool if vehhp > or < 880 -_-...
code now:
Код:
function Finish(p) {
new veh;
new Float:vHealth;
GetVehicleHealth(veh, vHealth);
veh = GetPlayerVehicleID(p);
if(WarnCH[p] > 13 || vHealth < 880)return LosseRace(p);
DestroyVehicle(CarDriveSchool[p]);
SCM(p,-1,"You have succses finish drive school! now can you drive any car.");
DataAccount[p][DriveS] = 1;
DataAccount[p][XPs] += 25;
KillTimer(Timerr[p]);
DataAccount[p][Money] += 100;
CheckMoney(p);
SpawnPlayer(p);
DisableDrift[p] = 0;
return 1;
}
Re: Help with GetVehicleHealth -
MP2 - 08.05.2015
You need to use GetPlayerVehicleID BEFORE GetVehicleHealth..
Re: Help with GetVehicleHealth -
giorgosdim12 - 08.05.2015
ohh yea xD -_- lol i fix it now thx