SA-MP Forums Archive
Get Closest Airport doesnt work - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Server (https://sampforum.blast.hk/forumdisplay.php?fid=6)
+--- Forum: Server Support (https://sampforum.blast.hk/forumdisplay.php?fid=19)
+--- Thread: Get Closest Airport doesnt work (/showthread.php?tid=389989)



Get Closest Airport doesnt work - ejul - 04.11.2012

Код:
new Float:Airports[][3] =
{
{1726.0903,-2415.3723,13.5547},
{-1328.1351,-253.0038,14.1484},
{1571.5367,1537.0599,10.8289},
{-1375.4791,-221.9824,14.1484},
{1574.7767,1494.8152,10.8289},
{1645.0848,-2417.2478,13.5547},
{1571.5367,1537.0599,10.8289}

};


Float:GetDisFromPlayerToPoint(playerid,Float:x,Float:y,Float:z)
{
    new Float:xp,Float:yp,Float:zp;
    GetPlayerPos(playerid,xp,yp,zp);
    return floatsqroot(floatpower(floatabs(floatsub(x,xp)),2)+floatpower(floatabs(floatsub(y,yp)),2)+floatpower(floatabs(floatsub(z,zp)),2));

}
GetClosestAirport(playerid)
{
    new Airport = -1;
    new Float:dis = 999999.0;
    for(new x = 0 ; x < sizeof(Airports); x++)
    {
        if(GetDisFromPlayerToPoint(playerid,Airports[x][0],Airports[x][1],Airports[x][2]) < dis)
        {
            dis = GetDisFromPlayerToPoint(playerid,Airports[x][0],Airports[x][1],Airports[x][2]);
            Airport = x;
        }
    }
    return Airport;
}
Код:
        if(strcmp(cmdtext, "/work", true) == 0 || strcmp(cmdtext, "/w", true) == 0)
        {

            if (GetPVarInt(playerid, "Flight") == 1)
            {
                return SendClientMessage(playerid, COLOR_RED, "You are already in a flight!");
                }

                if (GetPVarInt(playerid, "Work") > 0)
                {

					return SendClientMessage(playerid, COLOR_RED, "You are already in a work!");
                }
                new vehicleid = GetPlayerVehicleID(playerid);
                if(GetVehicleModel(vehicleid) == 519)
                {
                
                new IslandName[48], szString[128];
                SetPVarInt(playerid, "Work", 1);
                MissionVehicle[playerid] = GetPlayerVehicleID(playerid);

					 switch(GetClosestAirport(0))
                {

                    case 0: {
                    Island[Las_Venturas][playerid]=SetPlayerFlightCheckpoint(playerid,1571.5367,1537.0599,10.8289, 10.0);
                    IslandName="Las Venturas Gate C"; }
                    


                    case 1: {
                    Island[San_Fierro][playerid] = SetPlayerFlightCheckpoint(playerid, -1328.1351,-253.0038,14.1484, 10.0);
                    IslandName="San Fierro Gate D"; }



                    case 2: {
                    Island[Los_Santos][playerid] = SetPlayerFlightCheckpoint(playerid, 1726.0903,-2415.3723,13.5547, 10.0);
                    IslandName="Los Santos Gate D"; }


		case 3: {
		Island[San_Fierro][playerid] = SetPlayerFlightCheckpoint(playerid, -1375.4791,-221.9824,14.1484, 10.0);
		IslandName="San Fierro Gate E"; }

		case 4: {
              Island[Las_Venturas][playerid] = SetPlayerFlightCheckpoint(playerid, 1574.7767,1494.8152,10.8289, 10.0);
	      IslandName="Las Venturas Gate E"; }

	      case 5: {
	     Island[Los_Santos][playerid] = SetPlayerFlightCheckpoint(playerid, 1645.0848,-2417.2478,13.5547, 10.0);
	    IslandName="Los Santos Gate E"; }


        }

 
                FirstAPName[playerid] = IslandName;
                format(szString, 128, "Go to %s to pick up the passengers!", IslandName);

                WorkTimer[playerid] = SetTimerEx("WorkingMinutes", 60000, true, "i", playerid);
                SendClientMessage(playerid, COLOR_LIGHTGREEN, szString);

Quote:

Get closest airport doesn't work
tell me what is the problem please!!




Re: Get Closest Airport doesnt work - Vince - 04.11.2012

Have a look at this native: https://sampwiki.blast.hk/wiki/GetPlayerDistanceFromPoint


Re: Get Closest Airport doesnt work - Babul - 04.11.2012

...and maybe you will find this line suspicious:
Код:
switch(GetClosestAirport(0))
..iam missing a (playerid) hehe


Re: Get Closest Airport doesnt work - ejul - 04.11.2012

not work!!..