[Tutorial] Making A Class System(Very Simple+Easy+Dialogs+Texts)
#1

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:
pawn Code:
#include < a_samp >
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)
pawn Code:
#define SOLDIER 1
#define SNIPER 2
#define ENGINEER 3
#define JETTROOPER 4
#define PILOT 5
#define SPY 6
Now when you have added these, now you have to add the variables which defines several functions:
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
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.

pawn Code:
#define COLOR_WHITE 0xFFFFFFFF
#define COL_GREEN          "{6EF83C}"
#define COL_WHITE          "{FFFFFF}"
#define COLOR_RED          0xAA3333AA
#define COLOR_GREEN        0x33AA33AA
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).

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;
}
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.


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;
}
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.

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
    }
}
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.

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;
}
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)
Reply
#2

Hows the tutorial guys
Reply
#3

In$$ane there is something is not valid...
pawn Code:
new vehicleid = GetPlayerVehicleID(playerid);//variable to get vehicle ids
    if(GetVehicleModel(vehicleid) == 425 && gPlayerClass[playerid] == PILOT)//if player is pilot
    {
        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
    }
This will remover pilot from hunter not other classes.
This should be this:

pawn Code:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    new Float:PosX,Float:PosY,Float:PosZ,model = GetVehicleModel(vehicleid);
if(model == 425)//Hunter
    {
        if(GetVehicleModel(vehicleid) == 425 && gPlayerClass[playerid] == ASSAULT)
        {//then
            GetPlayerPos(playerid,PosX,PosY,PosZ);//getting player pos
            SetPlayerPos(playerid,PosX,PosY,PosZ);//setting player to same pos to avoid entering vehicle
            SendClientMessage(playerid, 0xAA3333AA, "ERROR: You Need to be Pilot to Fly Hunter!");
        }
    }
    if(model == 425)//Hunter
    {
        if(GetVehicleModel(vehicleid) == 425 && gPlayerClass[playerid] == SNIPER)
        {//then
            GetPlayerPos(playerid,PosX,PosY,PosZ);//getting player pos
            SetPlayerPos(playerid,PosX,PosY,PosZ);//setting player to same pos to avoid entering vehicle
            SendClientMessage(playerid, 0xAA3333AA, "ERROR: You Need to be Pilot to Fly Hunter!");
        }
    }
    if(model == 425)//Hunter
    {
        if(GetVehicleModel(vehicleid) == 425 && gPlayerClass[playerid] == ENGINEER)
        {//then
            GetPlayerPos(playerid,PosX,PosY,PosZ);//getting player pos
            SetPlayerPos(playerid,PosX,PosY,PosZ);//setting player to same pos to avoid entering vehicle
            SendClientMessage(playerid, 0xAA3333AA, "ERROR: You Need to be Pilot to Fly Hunter!");
        }
    }
    if(model == 425)//Hunter
    {
        if(GetVehicleModel(vehicleid) == 425 && gPlayerClass[playerid] == JETTROOPER)
        {//then
            GetPlayerPos(playerid,PosX,PosY,PosZ);//getting player pos
            SetPlayerPos(playerid,PosX,PosY,PosZ);//setting player to same pos to avoid entering vehicle
            SendClientMessage(playerid, 0xAA3333AA, "ERROR: You Need to be Pilot to Fly Hunter!");
        }
    }

    return 1;
}
This will remove all except pilot class member...

==> And one more thing i am not understanding your spy system..... Can u tell it clearly?
Reply
#4

this spy class can disguise to enemy soldier by /yourteam1name and then u will become the specific team spy
e.g. /usa with this u can disguise to usa team
Reply
#5

Why all user always ask Reputation?
it just bunch of numbers.

On Topic:

Hmm good but explain more

6/10
Reply
#6

Quote:
Originally Posted by iOmar
View Post
In$$ane there is something is not valid...
pawn Code:
new vehicleid = GetPlayerVehicleID(playerid);//variable to get vehicle ids
    if(GetVehicleModel(vehicleid) == 425 && gPlayerClass[playerid] == PILOT)//if player is pilot
    {
        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
    }
This will remover pilot from hunter not other classes.
This should be this:

pawn Code:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    new Float:PosX,Float:PosY,Float:PosZ,model = GetVehicleModel(vehicleid);
if(model == 425)//Hunter
    {
        if(GetVehicleModel(vehicleid) == 425 && gPlayerClass[playerid] == ASSAULT)
        {//then
            GetPlayerPos(playerid,PosX,PosY,PosZ);//getting player pos
            SetPlayerPos(playerid,PosX,PosY,PosZ);//setting player to same pos to avoid entering vehicle
            SendClientMessage(playerid, 0xAA3333AA, "ERROR: You Need to be Pilot to Fly Hunter!");
        }
    }
    if(model == 425)//Hunter
    {
        if(GetVehicleModel(vehicleid) == 425 && gPlayerClass[playerid] == SNIPER)
        {//then
            GetPlayerPos(playerid,PosX,PosY,PosZ);//getting player pos
            SetPlayerPos(playerid,PosX,PosY,PosZ);//setting player to same pos to avoid entering vehicle
            SendClientMessage(playerid, 0xAA3333AA, "ERROR: You Need to be Pilot to Fly Hunter!");
        }
    }
    if(model == 425)//Hunter
    {
        if(GetVehicleModel(vehicleid) == 425 && gPlayerClass[playerid] == ENGINEER)
        {//then
            GetPlayerPos(playerid,PosX,PosY,PosZ);//getting player pos
            SetPlayerPos(playerid,PosX,PosY,PosZ);//setting player to same pos to avoid entering vehicle
            SendClientMessage(playerid, 0xAA3333AA, "ERROR: You Need to be Pilot to Fly Hunter!");
        }
    }
    if(model == 425)//Hunter
    {
        if(GetVehicleModel(vehicleid) == 425 && gPlayerClass[playerid] == JETTROOPER)
        {//then
            GetPlayerPos(playerid,PosX,PosY,PosZ);//getting player pos
            SetPlayerPos(playerid,PosX,PosY,PosZ);//setting player to same pos to avoid entering vehicle
            SendClientMessage(playerid, 0xAA3333AA, "ERROR: You Need to be Pilot to Fly Hunter!");
        }
    }

    return 1;
}
This will remove all except pilot class member...

==> And one more thing i am not understanding your spy system..... Can u tell it clearly?
Topic updated, i made that system, but ur one is too long, and mine is very short,, ..
btw thnx
Reply
#7

Why do you include zcmd and sscanf2 into your "tutorial script" even if you don't use its features?
/facepalm

And please people stop asking for reputations otherwise you'll get bad ones.
Reply
#8

Not understanding "SPY" Class. I did 100 times. But i can't
One more thing: Sniper class is visible not invisible i tried this one..
Reply
#9

you need to explain a little bit more
Reply
#10

Quote:
Originally Posted by Rudy_
View Post
you need to explain a little bit more
what i should explain more??
Reply
#11

Spy system
Reply
#12

ok i ll do that
Reply
#13

pawn Code:
enum { Soldier, Sniper, Engineer, JetTrooper, Pilot, Spy };
enum PlayerInfo { Team };
new Info[MAX_PLAYERS][PlayerInfo];

//So instead of #define a hundred times, a simple enum..and an info array instead of a gPlayerClass array.
//This way they can put Kills etc into that single array instead of making a new one.

if(!strcmp(cmdtext, "/jetpack", true))
{
    if(Info[playerid][Team] != JetTrooper) return SendClientMessage(playerid, 0xCC0000AA, "You aren't a Jet Trooper!");
    SetPlayerSpecialAction(playerid,2);
    return 1;
}

//or

CMD:jetpack(playerid, params[])
{
    if(Info[playerid][Team] != JetTrooper) return SendClientMessage(playerid, 0xCC0000AA, "You aren't a Jet Trooper!");
    SetPlayerSpecialAction(playerid,2);
    return 1;
}

//That's an example on what I mean by a different array
Also, you have NO need to do that many things in your team vehicles (it's not score required I don't know why you'd call it that)...

pawn Code:
if(GetVehicleModel(vehicleid) == 425 && gPlayerClass[playerid] == SOLDIER && gPlayerClass[playerid] == SNIPER && gPlayerClass[playerid] == ENGINEER && gPlayerClass[playerid] == JETROOPER && 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
}

//can be

if(Info[playerid][Team] != Pilot && GetVehicleModel(vehicleid) == 425)
{
    SendClientMessage(playerid, COLOR_RED, "You Need to  be a Pilot to fly Hunter");
    RemovePlayerFromVehicle(playerid);
}
I'd also like to note, using an else if is a much better thing to do in this situation. The code is still going to run through the checks even if you've found the proper vehicle model.

pawn Code:
if(something) //if this isn't found THEN
else if(somethingelse) //we check this, if it isn't found
else if(somethingelseagain) //we check this
else //if nothing is found above, we do this
is a better method

pawn Code:
if(something) //ok we found this
if(somethingelse) //we found this too, so we run it
if(blahblah) //we found this so we're still gonna do it
This is what you're doing

https://sampwiki.blast.hk/ look around there...
Reply
#14

Quote:
Originally Posted by iOmar
View Post
In$$ane there is something is not valid...
pawn Code:
new vehicleid = GetPlayerVehicleID(playerid);//variable to get vehicle ids
    if(GetVehicleModel(vehicleid) == 425 && gPlayerClass[playerid] == PILOT)//if player is pilot
    {
        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
    }
This will remover pilot from hunter not other classes.
This should be this:

pawn Code:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    new Float:PosX,Float:PosY,Float:PosZ,model = GetVehicleModel(vehicleid);
if(model == 425)//Hunter
    {
        if(GetVehicleModel(vehicleid) == 425 && gPlayerClass[playerid] == ASSAULT)
        {//then
            GetPlayerPos(playerid,PosX,PosY,PosZ);//getting player pos
            SetPlayerPos(playerid,PosX,PosY,PosZ);//setting player to same pos to avoid entering vehicle
            SendClientMessage(playerid, 0xAA3333AA, "ERROR: You Need to be Pilot to Fly Hunter!");
        }
    }
    if(model == 425)//Hunter
    {
        if(GetVehicleModel(vehicleid) == 425 && gPlayerClass[playerid] == SNIPER)
        {//then
            GetPlayerPos(playerid,PosX,PosY,PosZ);//getting player pos
            SetPlayerPos(playerid,PosX,PosY,PosZ);//setting player to same pos to avoid entering vehicle
            SendClientMessage(playerid, 0xAA3333AA, "ERROR: You Need to be Pilot to Fly Hunter!");
        }
    }
    if(model == 425)//Hunter
    {
        if(GetVehicleModel(vehicleid) == 425 && gPlayerClass[playerid] == ENGINEER)
        {//then
            GetPlayerPos(playerid,PosX,PosY,PosZ);//getting player pos
            SetPlayerPos(playerid,PosX,PosY,PosZ);//setting player to same pos to avoid entering vehicle
            SendClientMessage(playerid, 0xAA3333AA, "ERROR: You Need to be Pilot to Fly Hunter!");
        }
    }
    if(model == 425)//Hunter
    {
        if(GetVehicleModel(vehicleid) == 425 && gPlayerClass[playerid] == JETTROOPER)
        {//then
            GetPlayerPos(playerid,PosX,PosY,PosZ);//getting player pos
            SetPlayerPos(playerid,PosX,PosY,PosZ);//setting player to same pos to avoid entering vehicle
            SendClientMessage(playerid, 0xAA3333AA, "ERROR: You Need to be Pilot to Fly Hunter!");
        }
    }

    return 1;
}
This will remove all except pilot class member...

==> And one more thing i am not understanding your spy system..... Can u tell it clearly?
You do realize that we can easily replace:
pawn Code:
GetPlayerPos(playerid,PosX,PosY,PosZ);
SetPlayerPos(playerid,PosX,PosY,PosZ);
with:
pawn Code:
ClearAnimations(playerid);
Reply
#15

Ok. i was only telling him....
Reply
#16

lol...
Reply
#17

i m making a fs on class sys now
Reply
#18

Instead of creating those many lines for checking each class you could have just done this:


pawn Code:
if(gPlayerClass[playerid] == WHATEVER_CLASS_OTHER_THAN_PILOT return SendClientMessage(playerid, RED, "You need to be a pilot to enter this vehicle! ");
instead of checking all classes, 1 line per class instead of 3-5 :/

+ You haven't really explained the system. Tutorials are for newbies and this is NOT a newbie-friendly tutorial.
Reply
#19

oh yeah
Reply
#20

Realy nice tutorial
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)