[Tutorial] How to create job system.
#1

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
Reply


Messages In This Thread
How to create job system. - by WagnerPM - 27.06.2012, 21:12
Re: How to create job system. - by Ukko - 27.06.2012, 21:15
Re: How to create job system. - by Jonny5 - 27.06.2012, 22:47
Re: How to create job system. - by WagnerPM - 28.06.2012, 01:36
Re: How to create job system. - by Lordzy - 28.06.2012, 01:51
Re: How to create job system. - by Kuakie - 28.06.2012, 14:30
Re: How to create job system. - by WagnerPM - 28.06.2012, 19:35
Re: How to create job system. - by Strummer - 21.07.2014, 00:27
Re: How to create job system. - by Strummer - 21.07.2014, 01:21

Forum Jump:


Users browsing this thread: 2 Guest(s)