Check car Health not working :( - 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: Check car Health not working :( (
/showthread.php?tid=516018)
Check car Health not working :( -
Mey6155 - 29.05.2014
Last checkpoint he enters for the drivers license test.
pawn Код:
if(Ccp[playerid] == 17)
{
new Float:health; //Car Health
new vehicleid = GetPlayerVehicleID(playerid); //Vehicle Id
GetVehicleHealth(IsVehicleForDrivingTest(vehicleid), health); // Is a drivers license car, health
if(health < 800) // Health is lower then 800 on the last checkpoint
{ // Do this
DisablePlayerCheckpoint(playerid); // Disable
Ccp[playerid] = 0; // Ccp 0
AllowTakeLCar[playerid] = 0; // DOn't allowed to take car.
SCM(playerid, COLOR_RED, "Sorry, you damaged your car. You failed.");
SCM(playerid, COLOR_PURPLE, "Go back to the icon and re-do it.");
RemovePlayerFromVehicle(playerid); // Remove him.
TextDrawHideForPlayer(playerid, Underline); // Remove the textdraws
TextDrawHideForPlayer(playerid, Title);
TextDrawHideForPlayer(playerid, KMH);
for(new i = 0; i < GetMaxPlayers(); i++)
{
TextDrawHideForPlayer(playerid, VehicleName[i]);
TextDrawHideForPlayer(playerid, VehicleHealth[i]);
TextDrawHideForPlayer(playerid, VehicleSpeed[i]);
}
}
else if(health > 800) // If the health is higher then 800 give the license else not.
{
DisablePlayerCheckpoint(playerid);
Ccp[playerid] = 0;
SCM(playerid, -1, "Here your drivers license.");
PlayerInfo[playerid][pCarLicense] = 1;
AllowTakeLCar[playerid] = 0;
RemovePlayerFromVehicle(playerid);
TextDrawHideForPlayer(playerid, Underline);
TextDrawHideForPlayer(playerid, Title);
TextDrawHideForPlayer(playerid, KMH);
for(new i = 0; i < GetMaxPlayers(); i++)
{
TextDrawHideForPlayer(playerid, VehicleName[i]);
TextDrawHideForPlayer(playerid, VehicleHealth[i]);
TextDrawHideForPlayer(playerid, VehicleSpeed[i]);
}
}
Well my problem is if I get health 800 < something like 600 and enter the last checkpoint I get a license, Idk why here is my isADriversLicenseCar:
pawn Код:
IsVehicleForDrivingTest(vehicleid)
{
for (new i; i != sizeof (DriversTest); ++i)
{
if (vehicleid == DriversTest[i]) return 1;
}
return 0;
}
And creating the vehicles and the new var.
pawn Код:
new DriversTest[4];
new Ccp[MAX_PLAYERS];
new AllowTakeLCar[MAX_PLAYERS];
DriversTest[0] = AddStaticVehicleEx(426,1641.2000000,1293.3000000,10.6000000,270.0000000,254,254,5); //Premier
DriversTest[1] = AddStaticVehicleEx(426,1641.2000000,1296.4000000,10.6000000,270.0000000,254,254,5); //Premier
DriversTest[2] = AddStaticVehicleEx(426,1641.2000000,1299.5000000,10.6000000,270.0000000,254,254,5); //Premier
DriversTest[3] = AddStaticVehicleEx(426,1641.1000000,1302.3000000,10.6000000,270.0000000,254,254,5); //Premier
Re: Check car Health not working :( -
Mey6155 - 29.05.2014
*Sneeze*
Re: Check car Health not working :( -
Konstantinos - 29.05.2014
pawn Код:
GetVehicleHealth(IsVehicleForDrivingTest(vehicleid), health);
IsVehicleForDrivingTest will return 0 or 1 whether the vehicle is for the driving tests. It's not a vehicleid.
pawn Код:
new Float:health; //Car Health
new vehicleid = GetPlayerVehicleID(playerid); //Vehicle Id
if (IsVehicleForDrivingTest(vehicleid)) // it is a vehicle for the driving tests
{
GetVehicleHealth(vehicleid, health); // Is a drivers license car, health
if (health < 800)
{
// code..
}
}