Loop trough missions
#1

Hello, i've been searching alot for a script that loops trough the missions and selects the nearest mission.

This is one of our enums:
pawn Код:
new ALocations[][TLocation] =
{
new MissionID;
        new Float:pPos[3], Float:LowestDistance = 50000000.0000, Float:thisDistance;
        for(new i; i < sizeof(ALocations); i++)
        {
            GetPlayerPos(playerid, pPos[0], pPos[1], pPos[2]);
            thisDistance = GetDistanceBetweenPoints(ALocations[i][LocX],ALocations[i][LocY],ALocations[i][LocZ], pPos[0], pPos[1], pPos[2]);
            if(thisDistance < LowestDistance)
            {
                LowestDistance = thisDistance;
                MissionID = i;
            }
        }
    // LocationName, LocationX, LocationY, LocationZ
    {"LSA Gate A", 1738.3202,-2425.8325,14.4741}, // Location 1
    {"LSA Gate B", 1641.5100,-2423.1333,14.4730},
    {"LSA Gate C", 1562.1697,-2428.0403,14.4765},
    {"LVA Gate A", 1561.0095,1397.6116,11.7708},
    {"LVA Gate B", 1574.6689,1539.6458,11.7481},
    {"SFA Gate B", -1382.1825,-225.9442,15.0717},
    {"SFA Gate C", -1323.3275,-255.5832,15.0703},
    {"Stoneland Int. Gate C", 2717.9512,681.2523,11.2553},
    {"Stoneland Int. Gate D", 2742.9993,679.6970,11.2612}
};
And here is our work command:

pawn Код:
if(strcmp(cmd, "/work", true) == 0 || strcmp(cmd, "/w", true) == 0)
    {
        if(StartedMission[playerid] == 1)
        {
            SendClientMessage(playerid, COLOR_ERROR, "You are already on a mission! (/cancel to quit the mission)");
            return 1;
        }
        if(IsTracingHouse[playerid] == 1)
        {
            SendClientMessage(playerid, COLOR_ERROR, "You are currently locating a house. Please complete it first.");
            return 1;
        }
        if(IsLocatingVehicle[playerid] == 1)
        {
            SendClientMessage(playerid, COLOR_ERROR, "You are currently locating a vehicle. Please complete it first.");
            return 1;
        }
        new vehid = GetPlayerVehicleID(playerid);
        if(GetPlayerVehicleSeat(playerid) != 0)
        {
            SendClientMessage(playerid, COLOR_ERROR, "You must be the main driver of a vehicle to start working!");
            return 1;
        }
        if(IsAirVehicle(vehid))
        {
            if(PInfo[playerid][TotalScore] == 0)
            {
                new msg[200];
                format(msg,sizeof(msg),"Hey! It looks like you have not completed a flight yet! This is just to help you out:");
                SendClientMessage(playerid, COLOR_GREEN, msg);
                format(msg,sizeof(msg),"-When you do missions (/work), it will ask you to fly to a destination. Fly there and land, and it will give another checkpoint.");
                SendClientMessage(playerid, COLOR_GREEN, msg);
                format(msg,sizeof(msg),"-When you complete the mission, you gain money, in which you can purchase vehicle's, houses or even your own airline!");
                SendClientMessage(playerid, COLOR_GREEN, msg);
                format(msg,sizeof(msg),"-All of that information is just to help you understand the main features of the PoT, but there is ALOT more to come! - Have fun!");
                SendClientMessage(playerid, COLOR_GREEN, msg);
            }
            new modelid = GetVehicleModel(vehid);
            if(modelid == 592) //andromada
            {
                TypeFlight[playerid] = 1;
                MissionVehicle[playerid] = vehid;
                StartMission(playerid);
                return 1;
            }
            else if(modelid == 577) // at-400
            {
                TypeFlight[playerid] = 2;
                MissionVehicle[playerid] = vehid;
                StartMission(playerid);
                return 1;
            }
            else if(modelid == 519) // shamal
            {
                TypeFlight[playerid] = 3;
                MissionVehicle[playerid] = vehid;
                StartMission(playerid);
                return 1;
            }
            else if(modelid == 593) // dodo
            {
                TypeFlight[playerid] = 4;
                MissionVehicle[playerid] = vehid;
                StartMission(playerid);
                return 1;
            }
            else if(modelid == 553) // nevada
            {
                TypeFlight[playerid] = 5;
                MissionVehicle[playerid] = vehid;
                StartMission(playerid);
                return 1;
            }
            else if(modelid == 487) // Maverick
            {
                TypeFlight[playerid] = 6;
                MissionVehicle[playerid] = vehid;
                StartMission(playerid);
                return 1;
            }
            else if(modelid == 488) // News Maverick
            {
                TypeFlight[playerid] = 7;
                MissionVehicle[playerid] = vehid;
                StartMission(playerid);
                return 1;
            }
            else if(modelid == 497) // Police Maverick
            {
                TypeFlight[playerid] = 8;
                MissionVehicle[playerid] = vehid;
                StartMission(playerid);
                return 1;
            }
            else if(modelid == 417) // Leviathan
            {
                TypeFlight[playerid] = 9;
                MissionVehicle[playerid] = vehid;
                StartMission(playerid);
                return 1;
            }
            else if(modelid == 447) // Seasparrow
            {
                TypeFlight[playerid] = 10;
                MissionVehicle[playerid] = vehid;
                StartMission(playerid);
                return 1;
            }
            else if(modelid == 469) // Sparrow
            {
                TypeFlight[playerid] = 11;
                MissionVehicle[playerid] = vehid;
                StartMission(playerid);
                return 1;
            }
            else if(modelid == 548) // Cargobob
            {
                TypeFlight[playerid] = 12;
                MissionVehicle[playerid] = vehid;
                StartMission(playerid);
                return 1;
            }
            else if(modelid == 563) //Raindance
            {
                TypeFlight[playerid] = 13;
                MissionVehicle[playerid] = vehid;
                StartMission(playerid);
                return 1;
            }
            else if(modelid == 425) //Hunter
            {
                TypeFlight[playerid] = 14;
                MissionVehicle[playerid] = vehid;
                StartMission(playerid);
                return 1;
            }
            else if(modelid == 460) //Skimmer
            {
                TypeFlight[playerid] = 15;
                MissionVehicle[playerid] = vehid;
                StartMission(playerid);
                return 1;
            }
            else if(modelid == 512) //Cropduster
            {
                TypeFlight[playerid] = 16;
                MissionVehicle[playerid] = vehid;
                StartMission(playerid);
                return 1;
            }
            else if(modelid == 511) //Beagle
            {
                TypeFlight[playerid] = 17;
                MissionVehicle[playerid] = vehid;
                StartMission(playerid);
                return 1;
            }
            else if(modelid == 520) //Hydra
            {
                TypeFlight[playerid] = 18;
                MissionVehicle[playerid] = vehid;
                StartMission(playerid);
                return 1;
            }
        }
        else
        {
            SendClientMessage(playerid, COLOR_ERROR, "You must be in an plane/helicopter to start working !");
            return 1;
        }
    }
I hope someone can help me and my friend so we can finish our mission system.
Reply
#2

bump
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)