SA-MP Forums Archive
[Include] || Easy make Jobs! Version 1 || - 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] || Easy make Jobs! Version 1 || (/showthread.php?tid=177151)



|| Easy make Jobs! Version 1 || - PinkFloydLover - 16.09.2010

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


Re: || Easy make Jobs! Version 1 || - vyper - 16.09.2010

nice include good work


Re: || Easy make Jobs! Version 1 || - willsuckformoney - 16.09.2010

Looks great.


Re: || Easy make Jobs! Version 1 || - Luis- - 16.09.2010

I will try it as it looks awesome!


Re: || Easy make Jobs! Version 1 || - ♣RОЗK♣ - 16.09.2010

Nice work


Re: || Easy make Jobs! Version 1 || - PinkFloydLover - 17.09.2010

Thanks guys, if you have any suggestions let me know


Re: || Easy make Jobs! Version 1 || - royal_king - 17.09.2010

nice include good work


Re: || Easy make Jobs! Version 1 || - Tails - 17.09.2010

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)


Re: || Easy make Jobs! Version 1 || - willsuckformoney - 17.09.2010

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.


Re: || Easy make Jobs! Version 1 || - PinkFloydLover - 17.09.2010

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


Re: || Easy make Jobs! Version 1 || - speedruntrainer - 17.09.2010

Awesome work, good job


Re: || Easy make Jobs! Version 1 || - [4k]Wang - 28.09.2010

Simple but nice helps alot of new people learn.


Re: || Easy make Jobs! Version 1 || - biglittle - 02.01.2011

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

it look like realy nice no i only need to play it


Re: || Easy make Jobs! Version 1 || - justsomeguy - 17.02.2011

delete


Re: || Easy make Jobs! Version 1 || - entireworld - 01.09.2011

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


Re: || Easy make Jobs! Version 1 || - TequL - 07.06.2013

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


Re: || Easy make Jobs! Version 1 || - SilverGaming - 21.11.2016

Not work to download.. Please paste on gihub or pastebin


Re: || Easy make Jobs! Version 1 || - SilverGaming - 22.11.2016

....


Re: || Easy make Jobs! Version 1 || - Jelly23 - 22.11.2016

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