Player gets in taxi with taxi driver
#1

Then he gets charged if the player is a taxi driver only and when the passenger gets out he gets charged.

the gamemode uses its classes from a include, but i think maybe better putting in gm
ive alreaddy got them to be able to use /work for when no1 needs a taxi
Here is the include of the taxi classFor defining the classes can someone help me please.

pawn Code:
forward Taxi_LoadUnload(playerid);
forward Taxi_CheckPlayers(playerid);


// After a truckdriver entered a checkpoint, a timer is created. This function is called when the timer runs out
public Taxi_LoadUnload(playerid)
{


    // If the player isn't inside a convoy, this part is executed

    // Check the JobStep
    switch (APlayerData[playerid][JobStep])
    {
        case 1: // Player must load his goods
        {
            // Setup local variables
            new StartLoc[50], EndLoc[50], Load[50], RouteText2[255], Float:x, Float:y, Float:z, UnloadMsg[100];
            // Set JobStep to 2 (unloading goods)
            APlayerData[playerid][JobStep] = 2;
            // Delete the loading-checkpoint
            DisablePlayerCheckpoint(playerid);
            // Get the startlocation, endlocation and the load texts
            format(StartLoc, 50, ALocations[APlayerData[playerid][JobLoc1]][LocationName]);
            format(EndLoc, 50, ALocations[APlayerData[playerid][JobLoc2]][LocationName]);
            format(Load, 50, ALoads[APlayerData[playerid][LoadID]][LoadName]);



            // Pre-format the missiontext (there may be some parts appended when overloaded/mafiaload
            format(RouteText2, 255, TXT_Taxi2, Load, StartLoc, EndLoc);
            // Check if the player is overloaded

            // Check if the player is carrying a mafia-load


            // Set the TextDraw so the player can see it
            TextDrawSetString(APlayerData[playerid][MissionText], RouteText2);

            // Grab the x, y, z positions for the second location (to unload the goods)
            x = ALocations[APlayerData[playerid][JobLoc2]][LocX];
            y = ALocations[APlayerData[playerid][JobLoc2]][LocY];
            z = ALocations[APlayerData[playerid][JobLoc2]][LocZ];
            // Create a checkpoint where the player should unload the goods
            SetPlayerCheckpoint(playerid, x, y, z, 7);
            // Inform the player that he must unload his goods
            format(UnloadMsg, 100, TXT_taxiDeliverCargoTo, Load, EndLoc);
            SendClientMessage(playerid, 0xFFFFFFFF, UnloadMsg);
        }
        case 2: // Player is delivering his goods
        {
            // Setup local variables
            new StartLoc[50], EndLoc[50], Load[50], Msg25[128], Name[24];

            // Get the player name
            GetPlayerName(playerid, Name, sizeof(Name));
            // Get the startlocation, endlocation and the load texts
            format(StartLoc, 50, ALocations[APlayerData[playerid][JobLoc1]][LocationName]);
            format(EndLoc, 50, ALocations[APlayerData[playerid][JobLoc2]][LocationName]);
            format(Load, 50, ALoads[APlayerData[playerid][LoadID]][LoadName]);

            // Construct the message sent to all players that this player completed a trucking mission
            format(Msg25, 178, TXT_Taxiend, Name, Load, StartLoc, EndLoc);
            SendClientMessageToAll(0xFFFFFFFF, Msg25);
   



            // Setup local variables
            new Float:x1, Float:y1, Float:x2, Float:y2, Float:Distance, Message[128], Payment, Bonus;
            // Grab the x, y, z positions for the first location (to load the goods)
            x1 = ALocations[APlayerData[playerid][JobLoc1]][LocX];
            y1 = ALocations[APlayerData[playerid][JobLoc1]][LocY];
            // Grab the x, y, z positions for the second location (to unload the goods)
            x2 = ALocations[APlayerData[playerid][JobLoc2]][LocX];
            y2 = ALocations[APlayerData[playerid][JobLoc2]][LocY];
            // Calculate the distance between both points
            Distance = floatsqroot(((x2 - x1) * (x2 - x1)) + ((y2 - y1) * (y2 - y1)));

            // Calculate the payment for the player
            Payment = floatround((Distance * ALoads[APlayerData[playerid][LoadID]][PayPerUnit]), floatround_floor);

            // Pay the player based on the distance between the loading-point and unloading-point
            RewardPlayer(playerid, Payment, 0);
            // Send a message to let the player know he finished his mission and got paid
            format(Message, 128, TXT_RewardJob, Payment);
            SendClientMessage(playerid, 0xFFFFFFFF, Message);




            // Add 10% bonus if the player has delivered the load with his own truck
            if (AVehicleData[APlayerData[playerid][VehicleID]][Owned] == true)
            {
                // Calculate the bonus
                Bonus = (Payment * 10) / 100;
                // Pay the bonus to the player
                RewardPlayer(playerid, Bonus, 0);
                // Send a message to let the player know he was overloaded and got paid
                format(Message, 128, TXT_TruckerBonusOwnVehicle, Bonus);
                SendClientMessage(playerid, 0xFFFFFFFF, Message);
            }

            // Also add score-points to the score of the player based on the distance between the loading and unloading points
            if (Distance > 501961000.0)
                RewardPlayer(playerid, 0, 2); // Distance is larger than 3000 units, so add 2 points
            else
                RewardPlayer(playerid, 0, 1); // Distance is less than 3000 units, so add 1 point

            // Increase the stats for completing a trucking job
            APlayerData[playerid][StatsTaxiJobs]++;
            // Also save the data (in case the server crashes, progress would be lost)
            PlayerFile_Save(playerid);

            // End the current trucker job (clear mission-data)
            Taxi_EndJob(playerid);
        }
    }

    // Enable the player again (he can move again)
    TogglePlayerControllable(playerid, 1);

    return 1;
}
Taxi_OnPlayerCheckpoint(playerid)
{
    // Check if the player is inside his vehicle while entering a checkpoint
    if (GetPlayerVehicleID(playerid) == APlayerData[playerid][VehicleID])
    {
        // Also check if the player still has his trailer attached
        if (APlayerData[playerid][TrailerID] == GetVehicleTrailer(GetPlayerVehicleID(playerid)))
        {
            // Check the jobstep
            switch (APlayerData[playerid][JobStep])
            {
                // JobStep is 1 (truckdriver is loading his goods at the checkpoint)
                case 1: GameTextForPlayer(playerid, "Loading The Goods", 5000, 4);
                // JobStep is 2 (truckdriver is unloading his goods at the checkpoint) or 3 (unloading for convoys)
                case 2, 3: GameTextForPlayer(playerid, "Delivering The Goods", 5000, 4);
            }

            // Disable the player's actions (he cannot move anymore)
            TogglePlayerControllable(playerid, 0);
            // Start a timer (Public function "LoadUnload(playerid)" gets called when the timer runs out)
            APlayerData[playerid][LoadingTimer] = SetTimerEx("Taxi_LoadUnload", 5000, false, "d" , playerid);
        }
        else
            SendClientMessage(playerid, 0xFFFFFFFF, TXT_NeedTrailerToProceed);
    }
    else
        SendClientMessage(playerid, 0xFFFFFFFF, TXT_NeedVehicleToProceed);

    return 1;
}
// This function is called when a truckdriver wants to start a job by entering "/work" and has no truckers license
Taxi_StartRandomJob(playerid)
{
    // Check if a job could be set correctly (player must be driving a valid trucking vehicle)
    if (Taxi_SetRandomJob(playerid) != 0)
    {
        // Setup local variables
        new StartLoc[50], EndLoc[50], Load[50], RouteText[255], Float:x, Float:y, Float:z, LoadMsg[128];

        // Job has started
        APlayerData[playerid][JobStarted] = true;

        // Set jobstep to 1 (going to load the goods)
        APlayerData[playerid][JobStep] = 1;
        // Get the startlocation, endlocation and the load texts
        format(StartLoc, 50, ALocations[APlayerData[playerid][JobLoc1]][LocationName]);
        format(EndLoc, 50, ALocations[APlayerData[playerid][JobLoc2]][LocationName]);
        format(Load, 50, ALoads[APlayerData[playerid][LoadID]][LoadName]);
        // Combine it all into a string for the TextDraw (the player can see this all the time) to describe the mission
        format(RouteText, 255, TXT_Paramedic, Load, StartLoc, EndLoc);
        // Set the TextDraw so the player can see it
        TextDrawSetString(APlayerData[playerid][MissionText], RouteText);
        // Grab the x, y, z positions for the first location
        x = ALocations[APlayerData[playerid][JobLoc1]][LocX];
        y = ALocations[APlayerData[playerid][JobLoc1]][LocY];
        z = ALocations[APlayerData[playerid][JobLoc1]][LocZ];
        // Create a checkpoint where the player should load the goods
        SetPlayerCheckpoint(playerid, x, y, z, 7);
        // Inform the player that he must load his goods
        format(LoadMsg, 128, TXT_taxiPickupCargoAt, Load, StartLoc);
        SendClientMessage(playerid, 0xFFFFFFFF, LoadMsg);
    }

    return 1;
}

// This function sets a random job based on the player's vehicle and returns 1 if a job has been set
Taxi_SetRandomJob(playerid)
{
    // If the player is the driver of the vehicle (GetPlayerVehicleSeat returns -1 if the player is not in a vehicle)
    if (GetPlayerVehicleSeat(playerid) == 0)
    {

        if (GetVehicleModel(GetPlayerVehicleID(playerid)) == VehicleTaxi)
        {
            return Taxi_SetRandomJobData(playerid, PCV_Taxi);
        }
    }

    // If no job could be set correctly, return 0
    return 0;
}

// This function chooses a random product for the trucker with a given vehicle-type and also the start-location and end-location
Taxi_SetRandomJobData(playerid, PCV_Needed)
{
    // Get a random Load from the loads that are defined for truckers with the given vehicle-type
    APlayerData[playerid][LoadID] = Product_GetRandom(PCV_Needed);
    // Get a random start-location and end-location for this load
    APlayerData[playerid][JobLoc1] = Product_GetRandomStartLoc(APlayerData[playerid][LoadID]);
    APlayerData[playerid][JobLoc2] = Product_GetRandomEndLoc(APlayerData[playerid][LoadID]);

    // Store the vehicleID (required to be able to check if the player left his vehicle)
    APlayerData[playerid][VehicleID] = GetPlayerVehicleID(playerid);
    // Store the trailerID (required to be able to check if the player lost his trailer)
   

    // Return 1 to indicate that a job has been set correctly
    return 1;
}



Taxi_EndJob(playerid)
{
    if (APlayerData[playerid][JobStarted] == true)
    {
        // Clear the Mafia-wanted status of the vehicle (or trailer) in the array "AVehicleData"
        if (APlayerData[playerid][TrailerID] == 0)
            AVehicleData[APlayerData[playerid][VehicleID]][MafiaLoad] = false; // The player has no trailer, so clear his main vehicle as wanted by the mafia
        else
            AVehicleData[APlayerData[playerid][TrailerID]][MafiaLoad] = false; // The player has a trailer, so clear his trailer as wanted by the mafia

        // Clear all data about the job from the player, so he can start a new one
        APlayerData[playerid][JobStarted] = false;
        APlayerData[playerid][JobStep] = 0;
        APlayerData[playerid][JobID] = 0;
        APlayerData[playerid][VehicleTimerTime] = 0;
        APlayerData[playerid][VehicleID] = 0;
        APlayerData[playerid][TrailerID] = 0;
        APlayerData[playerid][LoadID] = 0;
        APlayerData[playerid][JobLoc1] = 0;
        APlayerData[playerid][JobLoc2] = 0;
        APlayerData[playerid][MafiaLoad] = false;

        // Delete the checkpoint
        DisablePlayerCheckpoint(playerid);
        // Reset the missiontext
        TextDrawSetString(APlayerData[playerid][MissionText], "No job at this moment type ~r~/work~w~");
        // Kill the LoadingTimer
        KillTimer(APlayerData[playerid][LoadingTimer]);

        // Check if the player has been overloaded
    /*  if (APlayerData[playerid][Overloaded] == true)
        {
            // Clear the overloaded status of the player
            APlayerData[playerid][Overloaded] = false;

            // Check if the player has a wanted level of 2 or higher
            if (GetPlayerWantedLevel(playerid) >= 2)
                SetPlayerWantedLevel(playerid, GetPlayerWantedLevel(playerid) - 2); // Reduce the wanted level by 2
            else
                SetPlayerWantedLevel(playerid, 0); // If the player has a wanted level of less than 2, reset the wanted level to 0
        }*/

    }

    return 1;
}
Reply


Messages In This Thread
Player gets in taxi with taxi driver - by [LHT]Bally - 13.01.2013, 21:22
Re: Player gets in taxi with taxi driver - by [LHT]Bally - 14.01.2013, 13:11

Forum Jump:


Users browsing this thread: 1 Guest(s)