SetPlayerColorClass Normal :S
#1

Been Trying to do this for ages How do i make that if the player gets in to a taxi or if a taxi driver is next to them it removes them from being red marked (TaxiNeeded)

And also how can i make it that if a player gets in to a seat That isnt the driver it charges them For The journey , Like $10 for every minute there in the vehicle. And when they get out it pays the driver.

Thanks in advance

pawn Код:
forward Taxi_LoadUnload(playerid);
forward Taxi_CheckPlayers(playerid);
forward Taxi_CheckPlayers(playerid);
public Taxi_CheckPlayers(playerid)
{
    // Scan through all players
    for (new PlayerToCheck; PlayerToCheck < MAX_PLAYERS; PlayerToCheck++)
    {
        // check if this player is connected
        if (IsPlayerConnected(PlayerToCheck))
        {
            //Check if that player needs assistance
            if (APlayerData[PlayerToCheck][TaxiNeeded] == true)
                SetPlayerMarkerForPlayer(playerid, PlayerToCheck, 0xFF0000FF); // Make that player red to the assistance-player
            else
            {
                // Reset the playercolor based on the player's class
                switch (APlayerData[PlayerToCheck][PlayerClass])
                {
                    case ClassTruckDriver: SetPlayerMarkerForPlayer(playerid, PlayerToCheck, ColorClassTruckDriver);
                    case ClassBusDriver: SetPlayerMarkerForPlayer(playerid, PlayerToCheck, ColorClassBusDriver);
                    case ClassPilot: SetPlayerMarkerForPlayer(playerid, PlayerToCheck, ColorClassPilot);
                    case ClassPolice: SetPlayerMarkerForPlayer(playerid, PlayerToCheck, ColorClassPolice);
                    case ClassMafia: SetPlayerMarkerForPlayer(playerid, PlayerToCheck, ColorClassMafia);
                    case ClassCourier: SetPlayerMarkerForPlayer(playerid, PlayerToCheck, ColorClassCourier);
                    case ClassAssistance: SetPlayerMarkerForPlayer(playerid, PlayerToCheck, ColorClassAssistance);
                    case ClassFarmer: SetPlayerMarkerForPlayer(playerid, PlayerToCheck, ColorClassFarmer);
                    case ClassSailor: SetPlayerMarkerForPlayer(playerid, PlayerToCheck, ColorClassSailor);
                    case ClassParamedic: SetPlayerMarkerForPlayer(playerid, PlayerToCheck, ColorClassParamedic);
                    case ClassTrain: SetPlayerMarkerForPlayer(playerid, PlayerToCheck, ColorClassTrain);
                    case ClassPizza: SetPlayerMarkerForPlayer(playerid, PlayerToCheck, ColorClassPizza);

                }
            }
        }
    }
}
Taxi_HealPlayer(playerid)
{
    // Setup local variables
    new Float:x, Float:y, Float:z, TaxiName[24], Msg[128];


    // Get the assistance player's name
    GetPlayerName(playerid, TaxiName, sizeof(TaxiName));

    // Loop through all players
    for (new OtherPlayer; OtherPlayer < MAX_PLAYERS; OtherPlayer++)
    {
        // Check if this player is online
        if (IsPlayerConnected(OtherPlayer))
        {
            // Check if this player isn't the assistance player
            if (OtherPlayer != playerid)
            {
                // Check if this player needs assistance
                if (APlayerData[OtherPlayer][TaxiNeeded] == true)
                {


                        // Get the location of the player
                        GetPlayerPos(OtherPlayer, x, y, z);
                        // Check if this player is closeby the assistance player
                        if (IsPlayerInRangeOfPoint(playerid, 5.0, x, y, z))
                        {
                            // Clear the other player's need for assistance
                            APlayerData[OtherPlayer][TaxiNeeded] = false;
                            // Get the name of the other player
                           
                            SendClientMessage(playerid, 0xFFFFFFFF, Msg);

                            // Increase the stats
                            APlayerData[playerid][StatsTaxiJobs]++;
                            // Save the player's account
                            PlayerFile_Save(playerid);
                        }
                }
            }
        }
    }

    return 1;
}
// 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, "Paasenger Getting In", 5000, 4);
                // JobStep is 2 (truckdriver is unloading his goods at the checkpoint) or 3 (unloading for convoys)
                case 2, 3: GameTextForPlayer(playerid, "Passenger Getting Out", 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_Taxi3, 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;
}
// This function gets called when the assistance player dies (or changes class)





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], "~y~No Job At The Moment Use ~g~/Work ~y~ To Earn ~g~Score ~y~& ~g~Money");
        // 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


Forum Jump:


Users browsing this thread: 1 Guest(s)