Modifying the Trucking Mission
#1

I just followed this tutorial

http://forum.sa-mp.com/showthread.ph...hlight=Mission

it work fine

however it is classic.

i want to modify it to more interesting.

Like, if you leave the truck during the work, you have 30 seconds to go back and get it.
or if you lose the trailer you have 30 seconds to get it back.

and how can i make the Truckers_Job available to other trucks like PPC_Trucking
cause i use the ppc_trucking's vehicle spawning.

code

pawn Код:
CMD:work(playerid, params[])
{
    if(gTeam[playerid] == TEAM_TRUCKERS) return Truckers_Job(playerid);
    return 1;
}

CMD:cancelwork(playerid, params[])
{
    if(gTeam[playerid] == TEAM_TRUCKERS) return StopWork(playerid);
    return 1;
}

public OnPlayerLoadGoods(playerid)
{
    KillTimer(LoadGoodsT[playerid]);
    SendClientMessage(playerid, COLOR_YELLOW, "Goods Loaded!, Head to the next checkpoint!");
    GameTextForPlayer(playerid, "~w~Loading the ~g~Goods...~n~~w~Please wait...", 4500, 3);
    MissionStatus[playerid] = 2;
    CheckpointEntered(playerid);
    return 1;
}

public OnPlayerLoadGoodsEx(playerid)
{
    new str[128];
    KillTimer(LoadGoodsT[playerid]);
    SendClientMessage(playerid, COLOR_YELLOW, "You finished delivering the goods, You receive $1000!");
    format(str, sizeof(str), "%s has completed mission delivering %s", GetName(playerid), iMissionText[playerid]);
    SendClientMessageToAll(COLOR_YELLOW, str);
    SetPlayerScore(playerid, GetPlayerScore(playerid) + 2);
    MissionStatus[playerid] = 0;
    return 1;
}

stock Truckers_Job(playerid)
{
    new vID = GetPlayerVehicleID(playerid); //gets called on the next line
    if(GetVehicleModel(vID)== 403 || GetVehicleModel(vID)== 515 || GetVehicleModel(vID) == 514)
    {
        if(IsTrailerAttachedToVehicle(vID))
        {
            MissionStatus[playerid] = 1;
            new MisRand = random(sizeof(MisLocations));
            new LoadText[128], Float:x, Float:y, Float:z;
            x = MisLocations[MisRand][LoadX];
            y = MisLocations[MisRand][LoadY];
            z = MisLocations[MisRand][LoadZ];
            unx[playerid] = MisLocations[MisRand][UnloadX];
            uny[playerid] = MisLocations[MisRand][UnloadY];
            unz[playerid] = MisLocations[MisRand][UnloadZ];
            iPay[playerid] = MisLocations[MisRand][Pay];
            SetPlayerCheckpoint(playerid, x, y, z, 7);
            format(LoadText, 128, "%s", MisLocations[MisRand][LoadName]);
            SendClientMessage(playerid, COLOR_LIME, "Mission:");
            SendClientMessage(playerid, -1, "_____________________");
            SendClientMessage(playerid, -1, " ");
            SendClientMessage(playerid, COLOR_YELLOW, LoadText);
            SendClientMessage(playerid, -1, "_____________________");
        }
        else
        {
            SendClientMessage(playerid, COLOR_RED, "You need a trailer first before working!");
        }
    }
    else
    {
        SendClientMessage(playerid, COLOR_RED, "You must be in a Truck to perform this!");
    }
    return 1;
}

stock StopWork(playerid)
{
    if(MissionStatus[playerid] == 0) return SendClientMessage(playerid, COLOR_RED, "You are not working!");
    DisablePlayerCheckpoint(playerid);
    SendClientMessage(playerid, COLOR_RED, "You got fined $1000, As the payment for the lose of the goods!");
    GameTextForPlayer(playerid, "~w~You got fined ~r~$1000~n~~w~As the payment for the lose of the goods", 5300, 3);
    GivePlayerMoney(playerid, -1000);
    MissionStatus[playerid] = 0;
    return 1;
}

stock CheckpointEntered(playerid)
{
    new vID = GetPlayerVehicleID(playerid);
    if(!IsTrailerAttachedToVehicle(vID)) return SendClientMessage(playerid, COLOR_RED, "You need a trailer to unload the goods!");
    if(MissionStatus[playerid] == 1)
    {
        DisablePlayerCheckpoint(playerid);
        SetPlayerCheckpoint(playerid, unx[playerid], uny[playerid], unz[playerid], 7);
        SendClientMessage(playerid, COLOR_ORANGE, "Loading the goods..");
        GameTextForPlayer(playerid, "~w~Loading the ~g~Goods...~n~~w~Please wait...", 3500, 3);
        LoadGoodsT[playerid] = SetTimerEx("OnPlayerLoadGoods", 3500, false, "d", playerid);
    }
    else if(MissionStatus[playerid] == 2)
    {
        DisablePlayerCheckpoint(playerid);
        GameTextForPlayer(playerid, "~w~Unloading the ~r~Goods...~n~~w~Please wait...", 3500, 3);
        LoadGoodsT[playerid] = SetTimerEx("OnPlayerLoadGoodsEx", 3500, false, "d", playerid);
    }
    return 1;
}
Reply
#2

Use a timer to OnPlayerExitVehicle when he is in mission..
I wanted to do something like this to my gm..
Reply
#3

After you exit your vehicle set player a timer which counts to 0 and display a message how much the player have time to get back to work. If timer hit to 0 set player variable to 0/false in public function. If he want to work more kill the timer in OnPlayerStateChange.
Reply
#4

How about how to check if player's trailer lose?

Ex.

I'm driving, accidentally, the trailer split up.

How can i check if the trailer split up.
Reply
#5

This one should work.
https://sampwiki.blast.hk/wiki/IsTrailerAttachedToVehicle
Reply
#6

use this:
pawn Код:
if(IsTrailerAttachedToVehicle(GetPlayerVehicleID(playerid))) return SendClientMessage(playerid,-1,"You Need Trailer!");
Reply
#7

I have problem.

How can i fix it.
It keep spamming

pawn Код:
public OnPlayerLoadGoods(playerid)
{
    KillTimer(LoadGoodsT[playerid]);
    SendClientMessage(playerid, COLOR_YELLOW, "Goods Loaded!, Head to the next checkpoint!");
    TogglePlayerControllable(playerid, 1);
    MissionStatus[playerid] = 2;
    return 1;
}

public OnPlayerLoadGoodsEx(playerid)
{
    new str[128];
    KillTimer(LoadGoodsT[playerid]);
    TogglePlayerControllable(playerid, 1);
    SendClientMessage(playerid, COLOR_YELLOW, "You finished delivering the goods, You receive $1000!");
    format(str, sizeof(str), "%s has completed mission delivering %s", GetName(playerid), iMissionText[playerid]);
    SendClientMessageToAll(COLOR_YELLOW, str);
    SetPlayerScore(playerid, GetPlayerScore(playerid) + 2);
    GivePlayerMoney(playerid, 1000);
    MissionStatus[playerid] = 0;
    return 1;
}

public CheckTrailerEx(playerid)
{
    if (GetPlayerVehicleSeat(playerid) == 0)
    {
        switch (GetVehicleModel(GetPlayerVehicleID(playerid)))
        {
            case VehicleFlatbed, VehicleDFT30, VehicleCementTruck:
                if(!IsTrailerAttachedToVehicle(GetPlayerVehicleID(playerid))) return 1;
            case VehicleLineRunner, VehicleTanker, VehicleRoadTrain:
            {
                if(IsTrailerAttachedToVehicle(GetPlayerVehicleID(playerid)))
                {
                    if(MissionStatus[playerid] == -1)
                    {
                        SendClientMessage(playerid, COLOR_YELLOW, "You bring the trailer back!");
                        SendClientMessage(playerid, COLOR_ORANGE, "Now back to work!");
                        GameTextForPlayer(playerid, "~w~Trailer ~g~Back!!", 3500, 3);
                        MissionStatus[playerid] = 1;
                        SetPlayerCheckpoint(playerid, ucx[playerid], ucy[playerid], ucz[playerid], 7);
                    }
                }
                else if(!IsTrailerAttachedToVehicle(GetPlayerVehicleID(playerid)))
                {
                    DisablePlayerCheckpoint(playerid);
                    MissionStatus[playerid] = -1;
                    GameTextForPlayer(playerid, "~w~Trailer ~r~Lost!!", 3500, 3);
                    SendClientMessage(playerid, COLOR_YELLOW, "Your trailer split up, Pick it up!");
                    SendClientMessage(playerid, COLOR_ORANGE, "You have 30 seconds to pick it up!");
                    HaveItElse[playerid] = SetTimerEx("FailTrailerEx", 30000, false, "d", playerid);
                }
            }
        }
    }
    return 1;
}

public FailTrailerEx(playerid)
{
    SendClientMessage(playerid, COLOR_ORANGE, "You lost the trailer!");
    SendClientMessage(playerid, COLOR_RED, "Mission failed!");
    Truckers_StopWork(playerid);
    return 1;
}
Reply
#8

It fix now
the problem is how to check if player attach the trailer (which was lost)
i'm storing the trailer id in the Trailer[playerid].

How to check if the attached trailer is the Trailer[playerid]
Reply
#9

Which message is spamming?

@XtreameR, your code is not properly. You need an exclamation mark before a function to work it like you said.

edit://
Okey its fixed i see.
Reply
#10

Bump,
How can i check it?

Again:

how to check if player attach the trailer (which was lost)
i'm storing the trailer id in the Trailer[playerid].

How to check if the attached trailer is the Trailer[playerid]
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)