[Include] || Easy make Jobs! Version 1 ||
#1

Easy Make Jobs

Hello everyone! This is my very first include so I hope you all enjoy it, what this filterscript does is it allows you to create a job per line! That's right! I was making jobs a very inefficient way when I decided to do it like this, and I thought this is the most efficient and easiest way to create jobs. With this include you can create any job you want, eg: Police officer, thief, drug dealer, taxi driver, etc, first off I'm going to show you the functions.
(Note: this include does not create the commands, this simply creates easy functions for you to use)

First:
put underneath #include <a_samp>:
pawn Code:
#include <Jobs>
Underneath OnGameModeInit/OnFilterscriptInit, you will want to create a job
CreateJob(JobID,const name[],Levels,Skin,Weapon,Ammo);
JobID - this is the ID of your job, all jobs must start from 0 and go up
Name - this is the name of your job, just put in Police or whatever you want
Levels - this is the max amount of levels your job will have.
Skin - this is the skin your player will spawn with on this job
Weapon - same as above, the player will spawn with this weapon
Ammo - ammo for the weapon above ^^

(Important note: Make sure that the very first job you create is an Unemployed job!)

If you don't want the player to spawn with any weapon or any preferred skin, put -1 in the Skin or weapon slots, this will make the player spawn with nothing other then the skin they selected at the character selection menu, the player will spawn with any weapons you add to OnPlayerSpawn.



Now we will go through how to set the requirements for the levels, it is really quite simple just add underneath the job

LevelRequirement[JobID][Level] = Requirement
change the JobID to the ID of the job, change the level to 1 if it is your first level and go up from there, now the requirement will be the interval your player has to reach to get a promotion, here is an example of how to do it correctly:
pawn Code:
CreateJob(0,"Unemployed",1,-1,-1,0);// set to -1 so the player doesn't spawn with a specific weapon/skin
    CreateJob(1,"Police",4,280,25,1000);// 4 levels so we add 4 LevelRequirements
    LevelRequirement[1][1] = 1;
    LevelRequirement[1][2] = 5;
    LevelRequirement[1][3] = 10;
    LevelRequirement[1][4] = 15;
the first number in LevelRequirement is the Job ID, since the police job is 1 we make that 1 as well and the next number are the levels going from 1 to 4.

Next put underneath your OnPlayerSpawn:
pawn Code:
J_OnPlayerSpawn(playerid);
Now underneath the OnPlayerConnect callback add this line:
pawn Code:
PInfo[playerid][Job] = 0;
and that's it! here are the functions:
PromotePlayer(playerid) - Promote a player
GetPlayerJobLevel(playerid) - Get the level of a player
GetPlayerJob(playerid) - Returns the ID of the job, will return 0 if unemployed
To Give a player a job, use PInfo[playerid][Job] = JobID and change JobID to the id of your choice

For example, if you want to make it so when the player gets 15 kills he will go to the next level of his job, set the LevelRequirement to 15 along with the level and job IDs, then OnPlayerDeath you would put:
pawn Code:
if(Kills[killerid] == LevelRequirement[GetPlayerJob(playerid)][GetPlayerJobLevel(playerid)+1])
{
    PromotePlayer(playerid);
}
An example command on how to give a player a police job:
pawn Code:
dcmd_cop(playerid,params[])
{
    #pragma unused params
    if(GetPlayerJob(playerid) != 0) return SendClientMessage(playerid,0xFFFFFFAA,"You already have a job!");// if the players job doesnt equal "Unemployed"
    PInfo[playerid][Job] = 1;// give the player a police job
    pLevel[playerid][GetPlayerJob(playerid)] = 1;// we put the GetPlayerJob function in where the JobID is
    SendClientMessage(playerid,WHITE,"You are now a Police Officer!");
    return 1;
}
To check if a player is ready for a promotion. This is what I do:
pawn Code:
new Job = GetPlayerJob(playerid);
new Level = GetPlayerJobLevel(playerid)+1;// the level has to be +1 for the next level
if(Kills[playerid] == LevelRequirement[Job][Level]) return PromotePlayer(playerid);
Download my example filterscript for a full idea on how to use it,it contains 2 jobs, Police and Criminal
its my first release so I'm sure they may be a bug or two so please post what you can find. thanks

Download:
Sendspace
Rapidshare
2Shared

Example FS(Recommended that you download)
2Shared
Reply
#2

nice include good work
Reply
#3

Looks great.
Reply
#4

I will try it as it looks awesome!
Reply
#5

Nice work
Reply
#6

Thanks guys, if you have any suggestions let me know
Reply
#7

nice include good work
Reply
#8

Quite an interesting include. I shall try it later on my test server (After I get to reinstall San Andreas.... I hate you, Windows 7)
Reply
#9

Maybe making some commands for them like the basic start out commands with the include so the people who uses this can know atleast how to start a command for them.
Reply
#10

Yeah, good idea, i added a few in the example filterscript but I still havent explained alot of stuff so ill start editing it now
Reply
#11

Awesome work, good job
Reply
#12

Simple but nice helps alot of new people learn.
Reply
#13

where can i found those jobs what you have in the Example

it look like realy nice no i only need to play it
Reply
#14

delete
Reply
#15

please help me i have created 3 jobs: police, Army and Corleones(gang) i practicly typed over your example script and when i compile it it give no errors but when i am inside the gamemode every command i typed that was upposed to gimme a job returns: Unknown Command

Please help me
Reply
#16

what is the id for a pilot, instead of a policeman? and how do i create ingame commands for this job? thanks
Reply
#17

Not work to download.. Please paste on gihub or pastebin
Reply
#18

....
Reply
#19

Quote:
Originally Posted by SilverGaming
Посмотреть сообщение
Not work to download.. Please paste on gihub or pastebin
Dude, just look at the date of this release...
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)