SA-MP Forums Archive
[Include] TruckingMissions.inc - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+---- Forum: Includes (https://sampforum.blast.hk/forumdisplay.php?fid=83)
+---- Thread: [Include] TruckingMissions.inc (/showthread.php?tid=182789)

Pages: 1 2


TruckingMissions.inc V2.0 Released! - BLAbla93 - 12.10.2010

TruckingMissions.inc

Current Version: 2.0

Created by: Bill A.K.A Blabla93


CHANGELOG:
pawn Код:
/* CHANGE LOG
*** VERSION 2.0
** You can now cancel a players mission but using CancelPlayersCurrentMission(playerid);
** You can now add custom stuff to when the player finishs the mission using public OnPlayerFinishMission(playerid)
** If you un comment "#define USE_RACE_CHECKPOINT" the Include will use race checkpoints instead of regulare checkpoints!
** You can adjust the amount a player looses when they loose there trailer for 30 seconds if TrailerCheck is enabled using "#define COST_OF_LOST_GOODS"
** You can change the size of the checkpoints using "#define CHECKPOINT_SIZE"
*/
What does it do?:
This include will allow you to create a trucking mission with "CreatePlayerMission".

Configuration?:
pawn Код:
#define COST_OF_LOST_GOODS 1000
#define CHECKPOINT_SIZE 7
//#define USE_RACE_CHECKPOINT   // Un comment this line to enable Race Checkoints!

/* Only change this if USE_RACE_CHECKPOINT is enabled! */
#define RACE_CHECKPOINT_TYPE 0
/* KEY
** 0-Normal
** 1-Finish
** 2-Nothing(Only the checkpoint without anything on it)
** 3-Air normal
** 4-Air finish
*/
Natives?:
pawn Код:
CreatePlayerMission(playerid, bool:TrailerCheck, MissionPay, Float:Startx, Float:Starty, Float:Startz, Float:Endx, Float:Endy, Float:Endz);
CancelPlayersCurrentMission(playerid);

Callbacks?
public OnPlayerFinishMission(playerid)
pawn Код:
public OnPlayerFinishMission(playerid)
{
    return 1;
}

[size=10pt]How to set it up?:[/size]
Under "public OnPlayerConnect(playerid)" add
pawn Код:
M_OnPlayerConnect(playerid);
Under "public OnPlayerDisconnect(playerid, reason)" add
pawn Код:
M_OnPlayerDisconnect(playerid);
Under "public OnPlayerEnterCheckpoint(playerid)" add
pawn Код:
M_OnPlayerEnterCheckpoint(playerid);
Under "public OnPlayerEnterRaceCheckpoint(playerid)" add
pawn Код:
M_OnPlayerEnterRaceCheckpoint(playerid);
You "MUST" add public OnPlayerFinishMission(playerid)
pawn Код:
public OnPlayerFinishMission(playerid)
{
    return 1;
}


Random Missions Example: (Updated for with V2.0 callbacks and natives & mission fail on player death)
pawn Код:
#include <a_samp>
#include <TruckingMissions>

enum TruckingMissionInfo
{
    MissionName[200],
    bool:UseTrailerCheck,
    MissionPay,
    Float:loadx,
    Float:loady,
    Float:loadz,
    Float:unloadx,
    Float:unloady,
    Float:unloadz
}
new TruckingMissionRandom[][TruckingMissionInfo] =
{
    // {"Mission Text", UseTrailerCheck, MissionPay, loadx, loady, loadz, unloadx, unloady, unloadz}

    /* KEY:
    ** "Mission Text" = The text the player will see when he/she is doing the mission!
    ** UseTrailerCheck = Weather or not the mission requires you use a vehile that has a trailer. Ex: Roadtrain with an Artict1 trailer!
    ** MissionPay = The amount the player will recive for doing there mission!
    ** loadx, loady, and loadz = The loading coordinates of the loading checkpoint!
    ** unloadx, unloadx, unloadx = The un-loading coordinates of the unloading checkpoint!
    */

   
    {"Deliver Holy Water from LVA Freight Depot to LVA Church", true, 10000, 1701.9475,940.5465,10.8203, 1496.2524,772.1427,10.8203},
    {"Deliver Junk Car Parts from LVA Freight Depot to Shody Ottos", true, 10000, 1701.9475,940.5465,10.8203, 1727.6351,1812.1750,10.8203}
};

new IsPlayerInMission[MAX_PLAYERS] = 0; // We are going to use this to detect when a player is in a mission!

main()
{
    print("\n----------------------------------");
    print(" [TGG] Trucking Mission Example Script!");
    print("----------------------------------\n");
}

public OnGameModeInit()
{
    // Don't use these lines if it's a filterscript
    SetGameModeText("Blank Script");
    AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
    return 1;
}

public OnGameModeExit()
{
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
    return 1;
}

public OnPlayerConnect(playerid)
{
    M_OnPlayerConnect(playerid);
    IsPlayerInMission[playerid] = 0;// reset
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    M_OnPlayerDisconnect(playerid);
    return 1;
}


public OnPlayerCommandText(playerid, cmdtext[])
{
    if(!strcmp("/work", cmdtext, true))
    {
        new pvehiclemodel = GetVehicleModel(GetPlayerVehicleID(playerid));
        if (pvehiclemodel == 403 || pvehiclemodel == 514 || pvehiclemodel == 515)
        {
            if (IsPlayerInMission[playerid] == 1) return SendClientMessage(playerid, 0xFF0000AA, ">> You are currently in a mission use \"/cancelmission\" to cancel your current mission!"); // prevents them from starting another mission
            new string[200];
            new rand = random(sizeof(TruckingMissionRandom));
            IsPlayerInMission[playerid] = 1; // asign it to 1 becuase there in a mission
            CreatePlayerMission(playerid, TruckingMissionRandom[rand][UseTrailerCheck], TruckingMissionRandom[rand][MissionPay], TruckingMissionRandom[rand][loadx],TruckingMissionRandom[rand][loady], TruckingMissionRandom[rand][loadz], TruckingMissionRandom[rand][unloadx],TruckingMissionRandom[rand][unloady], TruckingMissionRandom[rand][unloadz]);
            format(string, sizeof(string), "You are doing mission: %s", TruckingMissionRandom[rand][MissionName]);
            SendClientMessage(playerid, 0x00FF00FF, string);
        }
        else
        {
            SendClientMessage(playerid, 0xFF0000AA, "Im sorry but this mission requires that you use a vehicle that can pull a semi trailer Ex: Roadtrain with an Artict1!");
        }
        return 1;
    }
    if(!strcmp("/cancelmission", cmdtext, true))
    {
        if (IsPlayerInMission[playerid] == 0) return SendClientMessage(playerid, 0xFF0000AA, "you are not in a mission use \"/work\" to start one!"); // prevents them if there currently not in a mission
        IsPlayerInMission[playerid] = 0; // resets it so they can start another mission
        CancelPlayersCurrentMission(playerid);
        return 1;
    }
    return 0;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    if (IsPlayerInMission[playerid] == 1)// checks to see if a player was in a mission on player death
    {
        CancelPlayersCurrentMission(playerid);// cancels player mission
        IsPlayerInMission[playerid] = 0; // resets the variable so they can start a new mission!
    }
    return 1;
}


public OnPlayerEnterCheckpoint(playerid)
{
    M_OnPlayerEnterCheckpoint(playerid);
    return 1;
}

public OnPlayerEnterRaceCheckpoint(playerid)
{
    M_OnPlayerEnterRaceCheckpoint(playerid);
    return 1;
}

public OnPlayerFinishMission(playerid)
{
    SendClientMessage(playerid, 0x00FF00FF, "You have completed your mission!");
    return 1;
}
!!Conditions!!:
DO NOT RE RELEASE THIS CODE WITHOUT MY PERMISSION
DO NOT CLAIM IT AS YOUR OWN
DO NOT REMOVE THE CREDITS FROM THE INCLUDE!!!!!!!!!!!!

Downloads?:

Version 1.0 (OLD NOT RECOMMENDED!):
include: http://www.mediafire.com/download.php?4p3vnp5j8auzd62
random missions example gm: http://www.mediafire.com/download.php?iceccasfddpdfud
include & random missions example gm (.rar): http://www.mediafire.com/download.php?k80gaiwn4crzfjj

Version 2.0:

include: http://www.mediafire.com/?bz2ea2e4z53nke1
random missions example gm: http://www.mediafire.com/?pp72vk4mwpghz8p
include & random missions example gm (.rar) (Does not have mission fail on player death but has 2.0 natives and callbacks): http://www.mediafire.com/?e3kn02cr5gx9dti

Mirrors:
-None-
your welcome to post mirrors of this!


CREDITS:
Код:
/* CREDITS:
** Blabla93 A.K.A [TGG]Bill | Coding the include
** [HiC]TheKiller, Kwarde & RealCop228 for the suggestion of adding a race checkpoints
** Mauzen for having the idea to add OnPlayerMission(playerid) call back!
*/
Please post suggestions comments


Re: TruckingMissions.inc - Georgelopez1 - 12.10.2010

Very nice FS and Include. Good job!


Re: TruckingMissions.inc - [HiC]TheKiller - 12.10.2010

May I recommend using race checkpoints instead of actual checkpoints?


Re: TruckingMissions.inc - BLAbla93 - 12.10.2010

May I ask why TheKiller?

I prefer regular checkpoints but maybe i could add a boolean that switches between race and standerd check points?


Re: TruckingMissions.inc - vyper - 12.10.2010

nice include


Re: TruckingMissions.inc - BLAbla93 - 12.10.2010

thanks vyper hope you like it


Re: TruckingMissions.inc - Kwarde - 12.10.2010

Nice release.
I think I'm gonna test it tomorrow. Then I can say if it's a good script or not

Quote:

I prefer regular checkpoints but maybe i could add a boolean that switches between race and standerd check points?

Hmm. Maybe you can better use defines then

pawn Код:
#define USE_RACE_CP //Comment if you wanna use normal CP's
And then:
pawn Код:
#if defined USE_RACE_CP
    //Race CP code
#else
    //Normal CP code
#endif
Kind Regards,
Kwarde


Re: TruckingMissions.inc - BLAbla93 - 12.10.2010

I guess I could use that. Kind of want the user to be able to define weather or not they want to use it depending on the mission.


Re: TruckingMissions.inc - [L3th4l] - 12.10.2010

BLAbla93, really nice include! Thanks for sharing.


Re: TruckingMissions.inc - Scenario - 13.10.2010

Hey, this is pretty cool. I like how you've set it up, but I would agree with [HiC]TheKiller - race checkpoints. It just adds to the server. It's how I would run mine.


Re: TruckingMissions.inc - BLAbla93 - 13.10.2010

Ok in the next version I will add a switch between race checkpoints and non race checkpoints


Re: TruckingMissions.inc - HyperZ - 13.10.2010

Great job really nice INC


Re: TruckingMissions.inc - Mauzen - 13.10.2010

Nice work, saves you some time, and seems to be quite efficient.

Small suggestion: Add an OnTruckMissionFinished callback. Should be not more than one line and allows more possibilities.


Re: TruckingMissions.inc - BLAbla93 - 13.10.2010

ok I will look into adding that into the next version I also was going to add a StopPlayersCurrentMission(playerid) callback to it also.


Re: TruckingMissions.inc - Janek17 - 13.10.2010

I tested it good


Re: TruckingMissions.inc - BLAbla93 - 13.10.2010

version 2.0

Код:
/* CHANGE LOG
*** VERSION 2.0
** You can now cancel a players mission but using CancelPlayersCurrentMission(playerid);
** You can now add custom stuff to when the player finishs the mission using public OnPlayerFinishMission(playerid)
** If you un comment "#define USE_RACE_CHECKPOINT" the Include will use race checkpoints instead of regulare checkpoints!
** You can adjust the amount a player looses when they loose there trailer for 30 seconds if TrailerCheck is enabled using "#define COST_OF_LOST_GOODS"
** You can change the size of the checkpoints using "#define CHECKPOINT_SIZE"
*/
btw you wont haft to change your script with the new update you will just haft to add a callback and forward M_OnPlayerEnterRaceCheckpoint(playerid); to OnPlayerEnterRaceCheckpoint(playerid)


Re: TruckingMissions.inc - Typhome - 14.10.2010

But how i do make, if you are at LS, then loading is at LS, and unloading is at random place. Same with other places.


Re: TruckingMissions.inc - BLAbla93 - 14.10.2010

you can make a random for each city so if your in LS call the LS random to load in LS then the random in another city to unload to.


Re: TruckingMissions.inc - Gh0sT_ - 16.10.2010

'ey, if i using a house system with streamer cp's, and will use u with default cps, it will conflict?


Re: TruckingMissions.inc - BLAbla93 - 16.10.2010

if your streamer uses default checkpoints and you have the
Код:
//#define USE_RACE_CHECKPOINT   // Un comment this line to enable Race Checkoints!
Commented you will have problems.

but if you un comment it to use race checkpoints like this
Код:
#define USE_RACE_CHECKPOINT   // Un comment this line to enable Race Checkoints!
it will use race checkpoints and it should not have conflicts!