27.06.2012, 21:12
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
2. Variable
3. CallBack (OnDialogResponse)
4. Commands
How create command to job?
Command mechanic:
Hope this helps.
[]'s
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>
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
};
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;
}
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;
}
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;
}
[]'s