SA-MP Forums Archive
[Tutorial] How to create job system. - 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: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Tutorials (https://sampforum.blast.hk/forumdisplay.php?fid=70)
+---- Thread: [Tutorial] How to create job system. (/showthread.php?tid=354763)



How to create job system. - WagnerPM - 27.06.2012

Hi guys,
I'm Wagner and this will be a tutorial regarding create a job system. This is my first tutorial here forum.



Requirements

zcmd - https://sampforum.blast.hk/showthread.php?tid=91354

Commands

/getjob (In dialog)
/quitjob
/helpjob

Tutorial

1. Include
pawn Код:
#include <zcmd>
2. Variable
pawn Код:
new wJob[MAX_PLAYERS]; //Define the work of each player
pawn Код:
#define MAX_JOBS            3 //"3" Number of jobs

#define JOBLESS             0 //1
#define MECHANIC            1 //2
#define TAXI                2 //(3)

new CommandJobs[ MAX_JOBS ][ 126 ] = //Define jobs commands
{
    {"Jobless"},                    //1 Jobless not have commands.
    {"MECHANIC /its commands"},     //2 MECHANIC Commands
    {"TAXI /its commands"}          //3 TAXI Commands
};

new NamesJobs[ MAX_JOBS ][ 30 ] = //Define jobs name
{
    {"Jobless"},
    {"Mechanic"},
    {"Taxi Driver"}
};

new SalaryJobs[ MAX_JOBS ] = //Define jobs salary
{
    0,      //Salary Jobless
    500,    //Salary Mechanic
    700     //Salary Taxi Driver
};
3. CallBack (OnDialogResponse)

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(response)
    {
        switch(dialogid)
        {
            case 2424:// Our dialog!
            {
                switch(listitem)// Checking which listitem was selected
                {
                    case 0: // The first item listed
                    {
                        SendClientMessage(playerid,0x33CCFFAA,"Congratulations with your new job, type /helpjob to see your new command.");
                        wJob[playerid] = 1;  //Changes your job to 1 (Mechanic)
                    }
                    case 1: // The second item listed
                    {
                        SendClientMessage(playerid,0x33CCFFAA,"Congratulations with your new job, type /helpjob to see your new command.");
                        wJob[playerid] = 2;  //Changes your job to 2 (Taxi)
                    }
                }
            }
        }
    }
    return 1;
}
4. Commands

pawn Код:
CMD:helpjob(playerid, params[])
{
    new wstg[ 126 ];
    format(wstg, sizeof(wstg), "|__| %s |___________________________________|", NamesJobs[wJob[playerid]]);
    SendClientMessage(playerid, 0xFFFF00FF, wstg);
    format(wstg, sizeof(wstg), "{FFFFFF}* Commands: %s", CommandJobs[wJob[playerid]]);
    SendClientMessage(playerid, 0xAFAFAFAA, wstg);
    format(wstg, sizeof(wstg), "{FFFFFF} Salary: %d", SalaryJobs[wJob[playerid]]);
    SendClientMessage(playerid, 0xAFAFAFAA, wstg);
    return 1;
}

CMD:getjob(playerid, params[])
{
    if(wJob[playerid] > 0)
        return SendClientMessage(playerid, 0xAFAFAFAA,"You already have a job, type /quitjob to have quit job.");
       
    ShowPlayerDialog(playerid, 2424, DIALOG_STYLE_LIST, ":: {FFFFFF}Choose a job", ":: {FFFFB7}Mechanic\n:: {FFFFB7}Taxi driver", "Confirm", "Cancel");
    return 1;
}

CMD:quitjob(playerid, params[])
{
    wJob[playerid] = 0; //Changes your job to 0 (Jobless)
    SendClientMessage(playerid,0xAFAFAFAA,"Now you're unemployed");
    return 1;
}
How create command to job?

Command mechanic:
pawn Код:
CMD:command(playerid, params[])
{
    if(wJob[playerid] != 1) //Number "1" is mechanic.
        return SendClientMessage(playerid, 0xAFAFAFAA, "You not are Mechanic");
       
    SendClientMessage(playerid,-1,"Command mechanic :)");
    return 1;
}
Hope this helps.
[]'s


Re: How to create job system. - Ukko - 27.06.2012

Maybe explain more but for me it's fine, was right about to start creating jobs =)
Thank you!


Re: How to create job system. - Jonny5 - 27.06.2012

this is not really a job system as their is no work todo.
you have a Salary but never give users money.

this is just 3 commands to set a few vars
making a job system would require ALLOT more than this 2 secs of coding.


Re: How to create job system. - WagnerPM - 28.06.2012

@Ukko
thanks for the comment

@Jonny5
It's just people adapt in your GM to pay the wages of jobs.
I did it especially for people who are starting now, anyway thanks for the comment.


Re: How to create job system. - Lordzy - 28.06.2012

This is a very good tutorial,just what i needed.


Re: How to create job system. - Kuakie - 28.06.2012

where i put in step 4?


Re: How to create job system. - WagnerPM - 28.06.2012

@Kuakie

The commands at the end


Re: How to create job system. - Strummer - 21.07.2014

Sorry for bumping such a nold topic, but how does the job save? Because I don't see it getting saved anywhere actually. Thanks.


Re: How to create job system. - Strummer - 21.07.2014

Sorry for bumping and double posting. I managed to solve the issue myself.