16.09.2010, 17:05
(
Last edited by PinkFloydLover; 17/09/2010 at 08:57 AM.
)
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>
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;
Next put underneath your OnPlayerSpawn:
pawn Code:
J_OnPlayerSpawn(playerid);
pawn Code:
PInfo[playerid][Job] = 0;
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);
}
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;
}
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);
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