GetPlayerHealth ( Pilot )
#1

Hey guys, I'm on a pilot script and I'd like the script to check the player's health while he is flying the plane. I want it to abort the flight if he dies ( or the plane crash i guess it's harshly the same ^^' )

So here is the /startflight

Код:
CMD:startflight(playerid, params[])
{
		new string[128];
	    if(PlayerInfo[playerid][pJob] != JOB_PILOT && PlayerInfo[playerid][pVIPJob] != JOB_PILOT) return SendClientMessage(playerid, COLOR_GREY, "You are not a pilot.");
	    {
	        if (IsPlayerInRangeOfPoint(playerid, 3.0, 1891.9252, -2328.7129, 13.5469))
	        {
	            if(PackTime[playerid] > 0)
	            {
	                format(string, sizeof(string), "You need to wait %d more seconds before starting a new flight.", PackTime[playerid]);
	             	SendClientMessage(playerid, COLOR_GREY, string);
	            	return 1;
	            }
	            PackTime[playerid] = 180;
	            SetTimerEx("PackTimer", 1000, false, "i", playerid);
	    		if (FlightStarted[playerid] == 0)
 				{
                    if (FlightCooldown[playerid] > 0) return format(string, sizeof(string), "You still have %d seconds left before you can do another flight.", FlightCooldown[playerid]), SendClientMessage(playerid, COLOR_GREY, string);
					CP[playerid] = 2424;
					SetPlayerCheckpoint(playerid, 1891.8619, -2288.7434, 16.7813, 5.0);
					SendClientMessage(playerid, COLOR_YELLOW, "You're about to start a flight, enter a plane.");
					format(string, sizeof(string), "Don't forget to /use abortflight in case the flight goes wrong", PackTime[playerid]);
					return 1;
				}
				else return SendClientMessage(playerid, COLOR_GREY, "    You already started a flight.");
			}
			else return SendClientMessage(playerid, COLOR_GREY, "    You are not at the flight center.");
		}
}
Here is the /abortflight ( which i'd like to execute automatically if the player or the plane crashes

Код:
CMD:abortflight(playerid, params[])
{
	    if (FlightStarted[playerid] == 1)
		{
		    if (GetVehicleModel(GetPlayerVehicleID(playerid)) == 592) DestroyVehicle(GetPlayerVehicleID(playerid));
			CP[playerid] = 0;
			DisablePlayerCheckpoint(playerid);
			FlightStarted[playerid] = 0;
			SetPlayerPos(playerid, 1891.9252, -2328.7129, 13.5469);
			SendClientMessage(playerid, COLOR_YELLOW, "Flight aborted.");
			return 1;
		}
		else SendClientMessage(playerid, COLOR_GREY, "    You didn't start a flight yet.");
		return 1;
}
And here is the CP[playerid] 2424, 2425 and 2426 callback

Код:
if(CP[playerid] == 2424)
	{
		new
			airport = random(2),
			destination[24],
			string[128],
			Float:x, Float:y, Float:z;

		GetPlayerPos(playerid, x, y, z);
        FlightPosition[playerid][0] = x;
		FlightPosition[playerid][1] = y;
		FlightPosition[playerid][2] = z;
		
		FlightStarted[playerid] = 1;
		switch (airport)
		{
			case 0:
			{
			    //SetPlayerCheckpoint(playerid, -1462.8226, 30.5481, 14.1484, 15.0);
			    destination = "San Fierro Airport";
			}
			case 1:
			{
			    //SetPlayerCheckpoint(playerid, 1477.2936, 1664.1234, 10.8125, 15.0);
			    destination = "Las Venturas Airport";
			}
		}
		CP[playerid] = 2425;
  		//format(string, sizeof(string), "* %s enters the plane and starts it up.", RPN(playerid));
		//SendClientMessage(playerid, COLOR_PURPLE, string);
		//SendClientMessage(playerid, COLOR_PURPLE, "* 20 minutes later, the passengers board the plane.");
		format(string, sizeof(string), "Your destination is %s. Land the plane into the checkpoint on the runway.", destination);
		SendClientMessage(playerid, COLOR_YELLOW, string);
		return 1;
	}
	else if(CP[playerid] == 2425)
	{
		new string[128];
		if (GetVehicleModel(GetPlayerVehicleID(playerid)) != 592) return SendClientMessage(playerid, COLOR_GREY, "Hold on there! Where's your plane?");
	    CP[playerid] = 0;
	    DisablePlayerCheckpoint(playerid);
	    format(string, sizeof(string), "* %s switches the landing gear off, announcing that the flight has arrived to it's destination.", RPN(playerid));
	    SendClientMessage(playerid, COLOR_PURPLE, string);
        SendClientMessage(playerid, COLOR_YELLOW, "Please wait while the passengers get off the plane.");
	    SetTimerEx("GetOff", 30000, false, "d", playerid);
	    TogglePlayerControllable(playerid, 0);
	    new Float:x, Float:y, Float:z;
	    GetVehiclePos(GetPlayerVehicleID(playerid), x, y, z);
	    SetVehiclePos(GetPlayerVehicleID(playerid), x, y, z);
	    return 1;
	}
	else if(CP[playerid] == 2426)
	{
	    if (GetVehicleModel(GetPlayerVehicleID(playerid)) != 592) return SendClientMessage(playerid, COLOR_GREY, "Hold on there! Where's your plane?");
	    GiveDodMoney(playerid, 12800);
	    FlightCooldown[playerid] = 1200;
	    SendClientMessage(playerid, COLOR_YELLOW, "You've received $12,800 for the mission. Good job.");
		CP[playerid] = 0;
		DisablePlayerCheckpoint(playerid);
		FlightStarted[playerid] = 0;
		return 1;
	}
Thanks for your replies they're all highly apreciated
Reply
#2

Just put this:
PHP код:
if (FlightStarted[playerid] == 1)
{
    if (
GetVehicleModel(GetPlayerVehicleID(playerid)) == 592DestroyVehicle(GetPlayerVehicleID(playerid));
    
CP[playerid] = 0;
    
DisablePlayerCheckpoint(playerid);
    
FlightStarted[playerid] = 0;
    
SetPlayerPos(playerid1891.9252, -2328.712913.5469);
    
SendClientMessage(playeridCOLOR_YELLOW"Flight aborted.");
    return 
1;
}
else 
SendClientMessage(playeridCOLOR_GREY"    You didn't start a flight yet.");
return 
1
inside OnPlayerDeath callback.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)