08.05.2012, 15:46
(
Last edited by $$inSane; 15/02/2015 at 03:59 AM.
)
CLASS SYSTEM TUTORIAL
Hi guys!
I am getting lots of queries from users and my friend, how to make a class system, how to make its commands for different classes and they get lots of problems with them. So i m making a tutorial for all those who wants a class system for their server. Lets get started:
First of all, lets me tell you what includes i gonna use, Just add these in the top most section of your pawn or gamemode or filterscript:
Now lets define some classes, your wish if you want more classes, i have added 6 classes, add this after includes:Note: If you want to add new class then define it with a value(e.g. #define Your class Value/Number)
Now when you have added these, now you have to add the variables which defines several functions:
These variables are usefull for class functioning.
Now define the colors, there are 5-6 colors offered by me, add these after the below part:
Colours are used to define the class colours, dilogs, lot more. Add more if you want.
Now this is the main function, the dialog part for selecting classes. You can put this dialog in many public functions, like: public OnPlayerRequestSpawn(playerid), public OnPlayerRequestClass(playerid, Classid) or
public OnPlayerConnect(playerid). I had put it in OnPlayerRequestClass(playerid).
Note: This is for Team Death Match Severs. If you have added new class with define then you have to add the class section here also(Put \nYour class name).
Now this is OnPlayerSpawn(playerid) section. Its used here to save your selected class(like if you have selected class soldier and spawned in OnPlayerRequestSpawn, then OnPlayerSpawn it will give you the same weapons and class bonouses that you get OnPlayerRequestSpawn. ).
Note: If you defined and added a new class then add it here also.
Now we can define the classes commands here, There is a command for 2 classes here:
JETTOOPER: theres a command for it i.e. /jetpack through which we can spawn a jet pack if we are jet trooper class.
SPY: theres 4 commands for spy i.e. /dis: used to see the disguize feature kit, /team<1-3> : this is used to disguize to a specific team by which or skin and colour gets changed but we remains the same team.
Now this step is optional, If you want Score requirement to drive such vehicles then add this:
Its used for vechile entrace, it defines that if you are a specific class then you can drive that vechile which you have mentioned for that class. I mean to say that pilot can drive vehicles like hunter, hydra etc but if you are a soldier then you will be removed from the hunter, hydra, etc.
Now the main feature, about the dialog response, the class system dialog functions, add the in public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{ , heres the code:
Note: if you have defined new class and added to the dialog for class selection, then you have to make it responce, you have to put the functioning of it in a listitem.
You are done now with your class system and congrats, you have a new class system added in your server or gamemode or filterscript.
DOWNLOADS:
Team death match class system: Coming soon (by $$insane)
Roleplay Class System: Coming soon (by $$insane)
Death Match class system: Download Here (by naruto)
Hi guys!
I am getting lots of queries from users and my friend, how to make a class system, how to make its commands for different classes and they get lots of problems with them. So i m making a tutorial for all those who wants a class system for their server. Lets get started:
First of all, lets me tell you what includes i gonna use, Just add these in the top most section of your pawn or gamemode or filterscript:
pawn Code:
#include < a_samp >
pawn Code:
#define SOLDIER 1
#define SNIPER 2
#define ENGINEER 3
#define JETTROOPER 4
#define PILOT 5
#define SPY 6
These variables are usefull for class functioning.
pawn Code:
new gPlayerClass[MAX_PLAYERS];// for defining classes
new PickedClass[MAX_PLAYERS];// this variable can be used in many functions
Colours are used to define the class colours, dilogs, lot more. Add more if you want.
pawn Code:
#define COLOR_WHITE 0xFFFFFFFF
#define COL_GREEN "{6EF83C}"
#define COL_WHITE "{FFFFFF}"
#define COLOR_RED 0xAA3333AA
#define COLOR_GREEN 0x33AA33AA
public OnPlayerConnect(playerid). I had put it in OnPlayerRequestClass(playerid).
Note: This is for Team Death Match Severs. If you have added new class with define then you have to add the class section here also(Put \nYour class name).
pawn Code:
public OnPlayerRequestSpawn(playerid)
{
ShowPlayerDialog(playerid, 999, DIALOG_STYLE_LIST, "{6EF83C}Choose A Class:", "Soldier Class\nSniper Class\nEngineer Class\nJet-Trooper Class\nPilot Class\nSpy Class", "Choose","");//this is the class dialog, you can change it if you want but dont forget to define the class also
return 1;
}
Note: If you defined and added a new class then add it here also.
pawn Code:
public OnPlayerSpawn(playerid)
{
if(gPlayerClass[playerid] == SOLDIER)//This is for the First soldier class.
{
TogglePlayerControllable(playerid, 1);
ResetPlayerWeapons(playerid);
GivePlayerWeapon(playerid, 31, 200);//m4
GivePlayerWeapon(playerid, 25, 100);//mp5
GivePlayerWeapon(playerid, 24, 70);//deagle
}
else if(gPlayerClass[playerid] == SNIPER)//This is for the Second Sniper class.
{
TogglePlayerControllable(playerid, 1);
ResetPlayerWeapons(playerid);
GivePlayerWeapon(playerid, 34, 250);//sniper
GivePlayerWeapon(playerid, 29, 250);//mp5
GivePlayerWeapon(playerid, 4, 1);//knife
}
else if(gPlayerClass[playerid] == ENGINEER)//This is for the Second Engineer class.
{
TogglePlayerControllable(playerid, 1);
ResetPlayerWeapons(playerid);
GivePlayerWeapon(playerid, 27, 200);//spas12
GivePlayerWeapon(playerid, 23, 200);//silent pistol
GivePlayerWeapon(playerid, 35, 2);//rpg
GivePlayerWeapon(playerid, 16, 2);//grenade
}
else if(gPlayerClass[playerid] == JETROOPER)//This is for the Second Jetrooper class.
{
TogglePlayerControllable(playerid, 1);
ResetPlayerWeapons(playerid);
GivePlayerWeapon(playerid, 32, 500);//tec-9
GivePlayerWeapon(playerid, 22, 500);//colt
GivePlayerWeapon(playerid, 4, 1);//knife
}
else if(gPlayerClass[playerid] == PILOT)//This is for the Second Pilot class.
{
TogglePlayerControllable(playerid, 1);
ResetPlayerWeapons(playerid);
GivePlayerWeapon(playerid, 24, 200);//deagle
GivePlayerWeapon(playerid, 17, 4);//moltove
GivePlayerWeapon(playerid, 25, 100);//shotgun
}
else if(gPlayerClass[playerid] == SPY)//This is for the Second Spy class.
{
TogglePlayerControllable(playerid, 1);
ResetPlayerWeapons(playerid);
GivePlayerWeapon(playerid, 29, 200);//mp5
GivePlayerWeapon(playerid, 23, 200);//silent pistol
GivePlayerWeapon(playerid, 4, 1);//knife
GivePlayerWeapon(playerid, 18, 2);//moltove
}
return 1;
}
JETTOOPER: theres a command for it i.e. /jetpack through which we can spawn a jet pack if we are jet trooper class.
SPY: theres 4 commands for spy i.e. /dis: used to see the disguize feature kit, /team<1-3> : this is used to disguize to a specific team by which or skin and colour gets changed but we remains the same team.
pawn Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp(cmdtext, "/jetpack", true))//jetpack spawn command
{
if(gPlayerClass[playerid] == JETTROOPER)//if the player is jettrooper
{
SetPlayerSpecialAction(playerid,2);//This is command for the jet trooper, he can spawn jetpack by /jp command
return 1;
}
}
if(!strcmp(cmdtext, "/dis", true))//dialog which tells u about the spy class disguises
{
if(gPlayerClass[playerid] == SPY)
{
ShowPlayerDialog(playerid, 88, DIALOG_STYLE_MSGBOX, "{6EF83C}Spy Disguise Kit:", "/team1\n/team2\n/team3", "Disguise ","Exit");//Replace the team1,2,3 to your game teams name and colors, by /team1 or /team2 or / team3 the player gets disguise to enemy soldier but don't changes its team
return 1;
}
}
if(!strcmp(cmdtext, "/team1", true))//This is for disguise to team 1
{
if(gPlayerClass[playerid] == SPY)//if player class spy
{
ShowPlayerDialog(playerid, 11, DIALOG_STYLE_MSGBOX, "{6EF83C}Disguised to Team1:", "Team: Team1\nColor: Red\nSkin: 285\nDisguised Class: Soldier", "Ok ","");
SetPlayerSkin(playerid,285);//skin set to S.W.A.T, can change to ur team skin
SetPlayerColor(playerid,COLOR_RED)//Color Red
return 1;
}
}
if(!strcmp(cmdtext, "/team2", true))//This is for disguise to team 2
{
if(gPlayerClass[playerid] == SPY)//if player class spy
{
ShowPlayerDialog(playerid, 22, DIALOG_STYLE_MSGBOX, "{6EF83C}Disguised to Team2:", "Team: Team2\nColor: White\nSkin: 287\nDisguised Class: Soldier", "Ok ","");
SetPlayerSkin(playerid,287);//skin set to Military, can change to ur team skin
SetPlayerColor(playerid,COL_WHITE)//Color white
return 1;
}
}
if(!strcmp(cmdtext, "/team3", true))//This is for disguise to team 1
{
if(gPlayerClass[playerid] == SPY)//if player class spy
{
ShowPlayerDialog(playerid, 33, DIALOG_STYLE_MSGBOX, "{6EF83C}Disguised to Team3:", "Team: Team3\nColor: Green\nSkin: 181\nDisguised Class: Soldier", "Ok ","");
SetPlayerSkin(playerid,181);//skin set to Rockstar, can change to ur team skin
SetPlayerColor(playerid,COLOR_GREEN)//Color green
return 1;
}
}
return 0;
}
Now this step is optional, If you want Score requirement to drive such vehicles then add this:
Its used for vechile entrace, it defines that if you are a specific class then you can drive that vechile which you have mentioned for that class. I mean to say that pilot can drive vehicles like hunter, hydra etc but if you are a soldier then you will be removed from the hunter, hydra, etc.
pawn Code:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
new vehicleid = GetPlayerVehicleID(playerid);//variable to get vehicle ids
if(GetVehicleModel(vehicleid) == 425 && gPlayerClass[playerid] == SOLDIER && gPlayerClass[playerid] == SNIPER && gPlayerClass[playerid] == ENGINEER && gPlayerClass[playerid] == JETTROOPER && gPlayerClass[playerid] == SPY)//if player is pilot then he can drive
{
SendClientMessage(playerid, COLOR_RED, "You Need to be a Pilot to fly Hunter");//messages goes to the player that he can't drive the hunter
RemovePlayerFromVehicle(playerid);//get u off from the hunter
}
if(GetVehicleModel(vehicleid) == 425 && gPlayerClass[playerid] == SOLDIER && gPlayerClass[playerid] == SNIPER && gPlayerClass[playerid] == ENGINEER && gPlayerClass[playerid] == JETTROOPER && gPlayerClass[playerid] == SPY)//if player is pilot then he can drive
{
SendClientMessage(playerid, COLOR_RED, "You Need to be a Pilot to fly Hydra");//messages goes to the player that he can't drive the hydra
RemovePlayerFromVehicle(playerid);//get u off from the hydra
}
if(GetVehicleModel(vehicleid) == 425 && gPlayerClass[playerid] == PILOT && gPlayerClass[playerid] == SNIPER && gPlayerClass[playerid] == ENGINEER && gPlayerClass[playerid] == JETTROOPER && gPlayerClass[playerid] == SPY)//if player is Soldier then he can drive
{
SendClientMessage(playerid, COLOR_RED, "You Need to be a Soldier to drive Tank");//messages goes to the player that he can't drive the tank or rhino
RemovePlayerFromVehicle(playerid);//get u off from the tank or rhino
}
if(GetVehicleModel(vehicleid) == 425 && gPlayerClass[playerid] == SOLDIER && gPlayerClass[playerid] == SNIPER && gPlayerClass[playerid] == ENGINEER && gPlayerClass[playerid] == JETTROOPER && gPlayerClass[playerid] == SPY)//if player is pilot then he can drive
{
SendClientMessage(playerid, COLOR_RED, "You Need to be a Pilot to fly Sea Sparrow");/messages goes to the player that he can't drive the tank or sea sparrow
RemovePlayerFromVehicle(playerid);//get u off from the sea sparrow
}
}
{ , heres the code:
Note: if you have defined new class and added to the dialog for class selection, then you have to make it responce, you have to put the functioning of it in a listitem.
pawn Code:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == 999)//dialog id response
{
if(response)
{
if(listitem == 0)//the listitem0, defines the number one option of the dialog
{
if(GetPlayerScore(playerid) >= 0)//if player have 0 score then he can choose this class
{
SendClientMessage(playerid, COLOR_WHITE, "You chose the Soldier as your class.");
ShowPlayerDialog(playerid, 11, DIALOG_STYLE_MSGBOX, "{6EF83C}Soldier Class:", "{F81414}Abilities:\n{FFFFFF}A Solo class, good in infantry attacks.\n\n{F81414}Weapons:\n\n{FFFFFF}M4\n{FFFFFF}Shotgun\n{FFFFFF}Deagle", "Play","");
gPlayerClass[playerid] = SOLDIER;//setting the class to soldier
PickedClass[playerid] = 1;
SetPlayerVirtualWorld(playerid, 0);
TogglePlayerControllable(playerid, 1);
ResetPlayerWeapons(playerid);
GivePlayerWeapon(playerid, 31, 200);//m4
GivePlayerWeapon(playerid, 25, 100);//mp5
GivePlayerWeapon(playerid, 24, 70);//deagle
}
}
if(listitem == 1)//the listitem1, defines the number one option of the dialog
{
if(GetPlayerScore(playerid) >= 0)//if player have 0 score then he can choose this class
{
SendClientMessage(playerid, COLOR_WHITE, "You chose the Sniper as your class.");
ShowPlayerDialog(playerid, 11, DIALOG_STYLE_MSGBOX, "{6EF83C}Sniper Class:", "{F81414}Abilities:\n{FFFFFF}A Locater class, Always invisible on map.\n\n{F81414}Weapons:\n\n{FFFFFF}Sniper Rifle\n{FFFFFF}Mp5\n{FFFFFF}Knife", "Play","");
gPlayerClass[playerid] = SNIPER;//setting the class to Sniper
PickedClass[playerid] = 1;
RemovePlayerMapIcon(playerid, 0);
SetPlayerVirtualWorld(playerid, 0);
TogglePlayerControllable(playerid, 1);
ResetPlayerWeapons(playerid);
GivePlayerWeapon(playerid, 34, 250);//sniper
GivePlayerWeapon(playerid, 29, 250);//mp5
GivePlayerWeapon(playerid, 4, 1);//knife
}
}
if(listitem == 2)//the listitem2, defines the number one option of the dialog
{
if(GetPlayerScore(playerid) >= 0)//if player have 0 score then he can choose this class
{
SendClientMessage(playerid, COLOR_WHITE, "You chose the Engineer as your class.");
ShowPlayerDialog(playerid, 11, DIALOG_STYLE_MSGBOX, "{6EF83C}Engineer Class:", "{F81414}Abilities:\n{FFFFFF}A Strong class, Good in both land and air\nCan drive tanks.\n\n{F81414}Weapons:\n\n{FFFFFF}Spas12\n{FFFFFF}Silent Pistol\n{FFFFFF}RPG\n{FFFFFF}Grenade", "Play","");
gPlayerClass[playerid] = ENGINEER;//setting the class to engineer
PickedClass[playerid] = 1;
SetPlayerVirtualWorld(playerid, 0);
TogglePlayerControllable(playerid, 1);
ResetPlayerWeapons(playerid);
GivePlayerWeapon(playerid, 27, 200);//spas12
GivePlayerWeapon(playerid, 23, 200);//silent pistol
GivePlayerWeapon(playerid, 35, 2);//rpg
GivePlayerWeapon(playerid, 16, 2);//grenade
}
}
if(listitem == 3)//the listitem3, defines the number one option of the dialog
{
if(GetPlayerScore(playerid) >= 0)//if player have 0 score then he can choose this class
{
SendClientMessage(playerid, COLOR_WHITE, "You chose the Jetrooper as your class.");
ShowPlayerDialog(playerid, 11, DIALOG_STYLE_MSGBOX, "{6EF83C}Jetrooper Class:", "{F81414}Abilities:\n{FFFFFF}A Solo class, cna spawn jetpack by /jetpack.\n\n{F81414}Weapons:\n\n{FFFFFF}Tec-9\n{FFFFFF}Colt\n{FFFFFF}Knife", "Play","");
gPlayerClass[playerid] = JETTROOPER;//setting the class to jettrooper
PickedClass[playerid] = 1;
SetPlayerVirtualWorld(playerid, 0);
TogglePlayerControllable(playerid, 1);
ResetPlayerWeapons(playerid);
GivePlayerWeapon(playerid, 32, 500);//tec-9
GivePlayerWeapon(playerid, 22, 500);//colt
GivePlayerWeapon(playerid, 4, 1);//knife
}
}
if(listitem == 4)//the listitem4, defines the number one option of the dialog
{
if(GetPlayerScore(playerid) >= 0)//if player have 0 score then he can choose this class
{
SendClientMessage(playerid, COLOR_WHITE, "You chose the Pilot as your class.");
ShowPlayerDialog(playerid, 11, DIALOG_STYLE_MSGBOX, "{6EF83C}Pilot Class:", "{F81414}Abilities:\n{FFFFFF}A Airforce class, Can drive hunter, hydra & sea sparrow.\n\n{F81414}Weapons:\n\n{FFFFFF}Deagle\n{FFFFFF}Tear Gas\n{FFFFFF}Shotgun", "Play","");
gPlayerClass[playerid] = PILOT;//setting the class to pilot
PickedClass[playerid] = 1;
SetPlayerVirtualWorld(playerid, 0);
TogglePlayerControllable(playerid, 1);
ResetPlayerWeapons(playerid);
GivePlayerWeapon(playerid, 24, 200);//deagle
GivePlayerWeapon(playerid, 17, 4);//moltove
GivePlayerWeapon(playerid, 25, 100);//shotgun
}
}
if(listitem == 5)//the listitem5, defines the number one option of the dialog
{
if(GetPlayerScore(playerid) >= 0)//if player have 0 score then he can choose this class
{
SendClientMessage(playerid, COLOR_WHITE, "You chose the Spy as your class.");
ShowPlayerDialog(playerid, 11, DIALOG_STYLE_MSGBOX, "{6EF83C}Spy Class:", "{F81414}Abilities:\n{FFFFFF}A Victim class, Can Disguise to enemy assaults by /dis\n\n{F81414}Weapons:\n\n{FFFFFF}Mp5\n{FFFFFF}Silent Pistol\n{FFFFFF}Knife\n{FFFFFF}Moltove", "Play","");
gPlayerClass[playerid] = SPY;//setting the class to Spy
PickedClass[playerid] = 1;
SetPlayerVirtualWorld(playerid, 0);
TogglePlayerControllable(playerid, 1);
ResetPlayerWeapons(playerid);
GivePlayerWeapon(playerid, 29, 200);//mp5
GivePlayerWeapon(playerid, 23, 200);//silent pistol
GivePlayerWeapon(playerid, 4, 1);//knife
GivePlayerWeapon(playerid, 18, 2);//moltove
}
}
return 1;
}
return 1;
}
return true;
}
DOWNLOADS:
Team death match class system: Coming soon (by $$insane)
Roleplay Class System: Coming soon (by $$insane)
Death Match class system: Download Here (by naruto)