[Tutorial] Faction system [Y_INI]
#1

FACTION SYSTEM
FOR BEST RESULTS I SUGGEST USING THIS YINI LOGIN/REGISTER TUTORIAL:CLICK ME





This faction system uses y_ini and includes 1 faction. you can easily add more.
lets start!

First of all you're going to want to get a few includes,

- ZCMD - CLICK
- SSCANF - CLICK
- YSI/Y_ini - CLICK

You can search for these includes and then include them at the top of your script like this:
pawn Code:
#include <a_samp>
#include <zcmd>
#include <YSI\y_ini>
#include <sscanf2>

Now lets establish some colors!
pawn Code:
#define COLOR_RED  0xFF0000AA
#define COLOR_GREEN 0x33AA33AA
#define COLOR_CYAN 0x00FFFFFF
#define COLOR_PDRAD 0x297CCFFF
Assuming you have a normal Y_ini system you are going to want to add to your playerinfo enumerator

pawn Code:
enum pInfo
{
    pFaction, //saves the ID of the faction the player is in, in the players file
    pFacrank,//saves the faction rank of the player, in the players file
    pFacleader// saves weather the player is a leader of the faction and what faction that is
}
new PlayerInfo[MAX_PLAYERS][pInfo];
Next you're going to want to place it where you load the users file:
pawn Code:
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
    INI_Int("Faction",PlayerInfo[playerid][pFaction]);//when the player logs in it will load his faction id
    INI_Int("Facrank",PlayerInfo[playerid][pFacrank]);// when the player logs in it will load his faction rank
    INI_Int("Facleader",PlayerInfo[playerid][pFacleader]);//when the player logs in it will load his leadership status

    return 1;
}
Next up, you're going to want to add a few things for when the player disconnects
pawn Code:
public OnPlayerDisconnect(playerid, reason)
{
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"data");

    INI_WriteInt(File,"Faction",PlayerInfo[playerid][pFaction]);//saves the players faction id on disconnect
    INI_WriteInt(File,"Facrank",PlayerInfo[playerid][pFacrank]);//saves the players faction rank on disconnect
    INI_WriteInt(File,"Facleader",PlayerInfo[playerid][pFacleader]);//saves the players faction leadership status on disconnect
    INI_Close(File);
    return 1;
}
Under the registration dialog you're going to want to add this:
pawn Code:
INI_WriteInt(File,"Faction",0);//sets the players faction to none when they connect for the first time
INI_WriteInt(File,"Facrank",0);sets the players faction rank to none when they connect for the first time
INI_WriteInt(File,"Facleader",0);//sets the players factions leadership status to none when they connect for the first time
Now you've added everything that need to be in the players file, now we need to make some commands to access this faction system!

Here are Admin related commands to set a player as the leader of the faction and kick a player from the faction
pawn Code:
CMD:fackick(playerid,params[])
{
    if(PlayerInfo[playerid][pAdmin] >= 3)//Replace this with your player variable
    {
        new targetid;//establishes a person on the server to use the command on
        if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, COLOR_RED, "/fackick [id]");//tells you how to use the command if you use it incorrectly
        if(targetid != INVALID_PLAYER_ID)//checks if the id you type in is an id that is not connected to the server
        {
            PlayerInfo[targetid][pFaction] = 0; //kicks the player from his faction
            PlayerInfo[targetid][pFacrank] = 0;//sets his rank to 0
            PlayerInfo[targetid][pFacleader] = 0;// revokes his leadership status
            SendClientMessage(targetid,COLOR_CYAN,"You have been kicked from your faction by an admin.");//tells them they have been kicked out of their faction by an admin.
        }
    }
    else//if they arent an admin then it will send them they message below telling them they may not use the command
    {
        SendClientMessage(playerid, COLOR_RED, "Only certain levels of Administration have access to this command.");
    }
    return 1;
}
CMD:makeleader(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >= 4) //Replace this with your player variable
    {
        new targetid, facid;//establishes a player and a faction id, to be typed in
        if(sscanf(params,"ui",targetid, facid)) return SendClientMessage(playerid, COLOR_RED,"/makeleader [id][Faction id]");//if the command is misused it will tell them the correct way to use it
        if(targetid != INVALID_PLAYER_ID)//checks if the id you type in is an id that is not connected to the server
        {
            PlayerInfo[targetid][pFaction] = facid; //sets the players faction to the faction you choose
            PlayerInfo[targetid][pFacrank] = 10;//sets their rank to the highest rank
            PlayerInfo[targetid][pFacleader] = facid;//sets their leadership to the id of the faction
            if(facid == 1)//checks if the factionid typed was 1, and tells them they are the leader of the police below
            {
                SendClientMessage(targetid,COLOR_CYAN,"You have been made the leader of the police department");
            }
        }
    }
    else //if the player is not an admin it will show the below message telling them they are not an admin.
    {
        SendClientMessage(playerid, COLOR_RED, "Only certan levels of Administration have access to this command.");
    }
    return 1;
}

Next we're going to want some commands for the leaders to invite/uninvite and give ranks.


Inviting/accepting invites/uninviting:
pawn Code:
CMD:invite(playerid, params[])
{
    if(PlayerInfo[playerid][pFacleader] > 0 || PlayerInfo[playerid][pFacrank] >= 8)//checks if the player is the leader of a faction or a high rank in it
    {
        new tarid, facid;//establishes a player in the server and a faction id for you to type in
        if(sscanf(params, "u", tarid)) return SendClientMessage(playerid, COLOR_RED, "> USAGE: /invite [playerid]");//if the command is not typed correctly, it will show you the correct way to use the command.
        facid = PlayerInfo[playerid][pFaction];//sets the faction the player is being invited to, as the faction the player that is inviting is in.
        SetPVarInt(tarid, "invitefac", facid);//saves the invite, to /accept it
        SendClientMessage(tarid, COLOR_GREEN, "You have been invited into a faction, use /acceptinvite to join");//tells you that you have been invited to a faction
    }
    else //if you're not the correct rank it will display the message below stating that the player is not the rank to invite
    {
        SendClientMessage(playerid, COLOR_RED, "You do not have the rank to invite");
    }
    return 1;
}
CMD:acceptinvite(playerid, params[])
{

    new facid, string[128];//creates a faction id and some text on the players screen
    facid = GetPVarInt(playerid, "invitefac");//calls the saved invite from the previous command
    PlayerInfo[playerid][pFaction] = facid; //sets the players faction to that of the person inviting.
    PlayerInfo[playerid][pFacrank] = 1;//sets the players faction rank to 1
    format(string, sizeof(string), "> You have accepted the invite to faction %d", facid);//tells the player they have accepted the faction invite
    SendClientMessage(playerid, COLOR_CYAN, string);//shows the above message in the color of CYAN
    DeletePVar(playerid, "invitefac");//deletes the saved invite
    return 1;
}
CMD:uninvite(playerid,params[])
{
    if(PlayerInfo[playerid][pFacleader] > 0 || PlayerInfo[playerid][pFacrank] >= 8)//checks if the player is high enough rank to uninvite
    {
        new targetid;//establishes a person to use the command on in the server
        if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, COLOR_RED, "/copuninvite [id]");//if the command is not typed correctly it will display how to do it the right way.
        if(targetid != INVALID_PLAYER_ID)//checks if the id typed is an actual player on the server
        {
            PlayerInfo[targetid][pFaction] = 0;//uninvites the player from the faction
            PlayerInfo[targetid][pFacrank] = 0;//sets the players rank to 0
            PlayerInfo[targetid][pFacleader] = 0;//revokes leadership status
            SendClientMessage(targetid,COLOR_CYAN,"You have been kicked from your faction.");//states you've been kicked from the faction to the player the command is used on.
        }
    }
    else //if the player is not the sufficient rank to uninvinte it will state that in the chat
    {
        SendClientMessage(playerid, COLOR_RED, "You do not have the rank to uninvite");
    }
    return 1;
}
Giving ranks:
pawn Code:
CMD:giverank(playerid, params[])
{
    if(PlayerInfo[playerid][pFacleader] > 0 || PlayerInfo[playerid][pFacrank] >= 8)//checks if the player is high enough rank
    {
        new targetid, rank, string[128];//establishes a player to use the command on, the rank you want to set, and some words to tell the players the actions used on them.
        if(sscanf(params, "ui", targetid, rank)) return SendClientMessage(playerid, COLOR_RED, "Usage: /coprank [playerid][rank]");//checks if the command was typed correctly
        if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_RED, "That player is not connected!");//if the player id typed is not connected it will state that to you.
        if(PlayerInfo[targetid][pFaction] != PlayerInfo[playerid][pFaction]) return SendClientMessage(playerid, COLOR_RED, "That player is not in your faction!");//if the player is not in the same faction it will not let him set the rank.
        if(rank < 1 || rank > 10) return SendClientMessage(playerid, COLOR_RED,"Rank must be 1-10");//checks if the rank number typed is above or below the correct numbers
        PlayerInfo[targetid][pFacrank] = rank;//sets the players rank to the rank you choose
        format(string, sizeof(string), "Your rank has been changed to rank %d!", rank);
        SendClientMessage(targetid, COLOR_GREEN, string);//states that the players rank was changed
    }
    else //if the player is not the correct rank it will display this message below
    {
        SendClientMessage(playerid, COLOR_RED, "You do not have the rank to set ranks");
    }
    return 1;
}

Now we need to make a way for the faction members to communicate, this can be done with a /radio command:
pawn Code:
CMD:r(playerid, params[]) return cmd_radio(playerid, params);
CMD:radio(playerid, params[])
{
    new string[128], text[128], ctext[60], pname[MAX_PLAYER_NAME+1];//establishes a few things needed to tell the players name, rank, and the text he has written.
    GetPlayerName(playerid, pname, sizeof(pname));//gets the name of the player using /radio
    if(sscanf(params, "s[128]", text)) return SendClientMessage(playerid, 0x46E850FF, "SERVER:{FFFFFF} /r(adio) [text]");//if /r is not used correctly it will tell you the correct way to use it
    if(PlayerInfo[playerid][pFaction] == 1)//checks if the player is in the first faction
    {

        if(PlayerInfo[playerid][pFacrank] == 1){ ctext = "Cadet"; }//all of these check the players rank and
        if(PlayerInfo[playerid][pFacrank] == 2){ ctext = "Officer"; }// sets each rank to a specific name
        if(PlayerInfo[playerid][pFacrank] == 3){ ctext = "Senior Officer"; }
        if(PlayerInfo[playerid][pFacrank] == 4){ ctext = "Corporal"; }
        if(PlayerInfo[playerid][pFacrank] == 5){ ctext = "Sergeant"; }
        if(PlayerInfo[playerid][pFacrank] == 6){ ctext = "Lieutenant"; }
        if(PlayerInfo[playerid][pFacrank] == 7){ ctext = "Captain"; }
        if(PlayerInfo[playerid][pFacrank] == 8){ ctext = "Commander"; }
        if(PlayerInfo[playerid][pFacrank] == 9){ ctext = "Deputy Chief"; }
        if(PlayerInfo[playerid][pFacrank] == 10){ ctext = "Chief"; }
        format(string, sizeof(string), "%s %s: %s", ctext, pname, text);
        if(PlayerInfo[playerid][pFaction] > 0)//if the player is not in a faction it will not send him any messages
        {
            SendCopMessage(COLOR_PDRAD, string);//calls a stock below that checks who the /r should be sent to
        }

    }
    return 1;
}
Now lets create a stock at the bottom to create the cop radio that will only send /r to other faction members
pawn Code:
stock SendCopMessage(col, string[])
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {                
        if(PlayerInfo[i][pFaction] == 1)
            SendClientMessage(i, col, string);         //goes through all the players checking who is and isint in faction 1
    }

    return 1;
}
Now lets make some vehicle models restricted for police use only. We can do this using a stock:
pawn Code:
stock IsACopCar(vehicleid)
{
    switch(GetVehicleModel(vehicleid))
    {
        case 523,427,528,596,598,597,599,601,497,430: return 1; //checks if the vehicle id is a faction restricted vehicle
    }
    return 0;
}
Now find in the script where the player enters a vehicle:
pawn Code:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(IsACopCar(vehicleid) && PlayerInfo[playerid][pFaction] == 0  && !ispassenger) //checks if the car is a faction car,and checks if the player is not in a faction or is not a passenger
    {
        ClearAnimations(playerid);//if they are a civillian and aren't a passenger it will put them out
        SendClientMessage(playerid, COLOR_GREY, "   You are not a Cop !");//will send them a message telling them only police can access this vehicle
    }
    return 1;
}


This is my first tutorial, hope i did a good job explaining everything out


EDIT:

ADDING MORE FACTIONS
Its pretty easy adding a second faction, first of all you're gonna want to go to the makeleader command and edit that a bit, ill do it below with the same code i used in the tutorial:
pawn Code:
CMD:makeleader(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >= 4) //Replace this with your player variable
    {
        new targetid, facid;//establishes a player and a faction id, to be typed in
        if(sscanf(params,"ui",targetid, facid)) return SendClientMessage(playerid, COLOR_RED,"/makeleader [id][Faction id]");//if the command is misused it will tell them the correct way to use it
        if(targetid != INVALID_PLAYER_ID)//checks if the id you type in is an id that is not connected to the server
        {
            PlayerInfo[targetid][pFaction] = facid; //sets the players faction to the faction you choose
            PlayerInfo[targetid][pFacrank] = 10;//sets their rank to the highest rank
            PlayerInfo[targetid][pFacleader] = facid;//sets their leadership to the id of the faction
            if(facid == 1)//checks if the factionid typed was 1, and tells them they are the leader of the police below
            {
                SendClientMessage(targetid,COLOR_CYAN,"You have been made the leader of the police department");
            }
            if(facid == 2)//checks if the factionid typed was 2, and tells them below, they are the leader of the faction
            {
                SendClientMessage(targetid,COLOR_CYAN,"You have been made the leader of blank");//change this to  the faction name you want
            }
        }
    }
    else //if the player is not an admin it will show the below message telling them they are not an admin.
    {
        SendClientMessage(playerid, COLOR_RED, "Only certan levels of Administration have access to this command.");
    }
    return 1;
}
All we're adding here is this
pawn Code:
if(facid == 2)//checks if the factionid typed was 2, and tells them below, they are the leader of the faction
{
        SendClientMessage(targetid,COLOR_CYAN,"You have been made the leader of blank");//change this to  the faction name you want
}
Once you've done that now you want to go to the radio command and add a few things to it:
pawn Code:
CMD:r(playerid, params[]) return cmd_radio(playerid, params);
CMD:radio(playerid, params[])
{
    new string[128], text[128], ctext[60], pname[MAX_PLAYER_NAME+1];//establishes a few things needed to tell the players name, rank, and the text he has written.
    GetPlayerName(playerid, pname, sizeof(pname));//gets the name of the player using /radio
    if(sscanf(params, "s[128]", text)) return SendClientMessage(playerid, 0x46E850FF, "SERVER:{FFFFFF} /r(adio) [text]");//if /r is not used correctly it will tell you the correct way to use it
    if(PlayerInfo[playerid][pFaction] == 1)//checks if the player is in the first faction
    {
        if(PlayerInfo[playerid][pFacrank] == 1){ ctext = "Cadet"; }//all of these check the players rank and
        if(PlayerInfo[playerid][pFacrank] == 2){ ctext = "Officer"; }// sets each rank to a specific name
        if(PlayerInfo[playerid][pFacrank] == 3){ ctext = "Senior Officer"; }
        if(PlayerInfo[playerid][pFacrank] == 4){ ctext = "Corporal"; }
        if(PlayerInfo[playerid][pFacrank] == 5){ ctext = "Sergeant"; }
        if(PlayerInfo[playerid][pFacrank] == 6){ ctext = "Lieutenant"; }
        if(PlayerInfo[playerid][pFacrank] == 7){ ctext = "Captain"; }
        if(PlayerInfo[playerid][pFacrank] == 8){ ctext = "Commander"; }
        if(PlayerInfo[playerid][pFacrank] == 9){ ctext = "Deputy Chief"; }
        if(PlayerInfo[playerid][pFacrank] == 10){ ctext = "Chief"; }
        format(string, sizeof(string), "%s %s: %s", ctext, pname, text);
        if(PlayerInfo[playerid][pFaction] > 0)//if the player is not in a faction it will not send him any messages
        {
            SendCopMessage(COLOR_PDRAD, string);//calls a stock below that checks who the /r should be sent to
        }
    }
    if(PlayerInfo[playerid][pFaction] == 2)//checks if the player is in the second faction
    {
        if(PlayerInfo[playerid][pFacrank] == 1){ ctext = "rank 1 name"; }//all of these check the players rank and
        if(PlayerInfo[playerid][pFacrank] == 2){ ctext = "rank 2 name"; }// sets each rank to a specific name
        if(PlayerInfo[playerid][pFacrank] == 3){ ctext = "rank 3 name"; }
        if(PlayerInfo[playerid][pFacrank] == 4){ ctext = "rank 4 name"; }
        if(PlayerInfo[playerid][pFacrank] == 5){ ctext = "rank 5 name"; }
        if(PlayerInfo[playerid][pFacrank] == 6){ ctext = "rank 6 name"; }
        if(PlayerInfo[playerid][pFacrank] == 7){ ctext = "rank 7 name"; }
        if(PlayerInfo[playerid][pFacrank] == 8){ ctext = "rank 8 name"; }
        if(PlayerInfo[playerid][pFacrank] == 9){ ctext = "rank 9 name"; }
        if(PlayerInfo[playerid][pFacrank] == 10){ ctext = "rank 10 name"; }
        format(string, sizeof(string), "%s %s: %s", ctext, pname, text);
        if(PlayerInfo[playerid][pFaction] > 0)//if the player is not in a faction it will not send him any messages
        {
            SendfacnameMessage(COLOR_PDRAD, string);//calls a stock below that checks who the /r should be sent to
        }
    }
    return 1;
}
For the radio command all you'll be adding is:
pawn Code:
if(PlayerInfo[playerid][pFaction] == 2)//checks if the player is in the second faction
    {
        if(PlayerInfo[playerid][pFacrank] == 1){ ctext = "rank 1 name"; }//all of these check the players rank and
        if(PlayerInfo[playerid][pFacrank] == 2){ ctext = "rank 2 name"; }// sets each rank to a specific name
        if(PlayerInfo[playerid][pFacrank] == 3){ ctext = "rank 3 name"; }
        if(PlayerInfo[playerid][pFacrank] == 4){ ctext = "rank 4 name"; }
        if(PlayerInfo[playerid][pFacrank] == 5){ ctext = "rank 5 name"; }
        if(PlayerInfo[playerid][pFacrank] == 6){ ctext = "rank 6 name"; }
        if(PlayerInfo[playerid][pFacrank] == 7){ ctext = "rank 7 name"; }
        if(PlayerInfo[playerid][pFacrank] == 8){ ctext = "rank 8 name"; }
        if(PlayerInfo[playerid][pFacrank] == 9){ ctext = "rank 9 name"; }
        if(PlayerInfo[playerid][pFacrank] == 10){ ctext = "rank 10 name"; }
        format(string, sizeof(string), "%s %s: %s", ctext, pname, text);
        if(PlayerInfo[playerid][pFaction] > 0)//if the player is not in a faction it will not send him any messages
        {
            SendfacnameMessage(COLOR_PDRAD, string);//calls a stock below that checks who the /r should be sent to
        }
    }
Lastly, you'll want to create another stock to send it to the second faction:
pawn Code:
stock SendfacnameMessage(col, string[])
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(PlayerInfo[i][pFaction] == 2)
            SendClientMessage(i, col, string);         //goes through all the players checking who is and isint in faction 1
    }

    return 1;
}
Reply
#2

Really good
Reply
#3

Quote:
Originally Posted by Sparke
View Post
Really good
Thanks man!
Reply
#4

So how i make second job ?
Reply
#5

This is pretty good and really understable.I'll practice with this.
Thank you sir!.
Reply
#6

Quote:
Originally Posted by Lukasz56
View Post
So how i make second job ?
Added to the thread
Reply
#7

Quote:
Originally Posted by UploaD
View Post
This is pretty good and really understable.I'll practice with this.
Thank you sir!.
No problem at all! if you find any bugs at all let me know, ill look into them
Reply
#8

Nice Tutorial... It Helped me In Creating Gangs/Faction System For my Server. ++Rep'd.
Reply
#9

Really good guide, I've understood everything. Repped.
Reply
#10

When a player uses / acceptinvite command does not work! please fix it = rep +
Reply
#11

Have you changed the command at all? that command that is there should be working. if you've changed it post your new /acceptinvite command here and i will look at it
Reply
#12

my commands..

PHP Code:
CMD:invite(playeridparams[])
{
    if(
PlayerInfo[playerid][pFacleader] > || PlayerInfo[playerid][pFacrank] >= 5)
    {
        new 
taridfacid;//establishes a player in the server and a faction id for you to type in
        
if(sscanf(params"u"tarid)) return SendClientMessage(playeridCOLOR_RED"{0033cc}FACTION:Използвайте: /invite [playerid]");//if the command is not typed correctly, it will show you the correct way to use the command.
        
facid PlayerInfo[playerid][pFaction];//sets the faction the player is being invited to, as the faction the player that is inviting is in.
        
SetPVarInt(tarid"invitefac"facid);//saves the invite, to /accept it
        
SendClientMessage(taridCOLOR_GREEN"{0033cc}FACTION:Вие получихте покана за банда/мафия , използвайте /acceptinvite за да я приемете!");//tells you that you have been invited to a faction
    
}
    else 
//if you're not the correct rank it will display the message below stating that the player is not the rank to invite
    
{
        
SendClientMessage(playeridCOLOR_RED"{0033cc}FACTION:Вие трябва да сте 5 ранг за да може да инвийтвате");
    }
    return 
1;
}
CMD:acceptfaction(playeridparams[])
{
    new 
facidstring[128];//creates a faction id and some text on the players screen
    
facid GetPVarInt(playerid"invitefac");//calls the saved invite from the previous command
    
PlayerInfo[playerid][pFaction] = facid//sets the players faction to that of the person inviting.
    
PlayerInfo[playerid][pFacrank] = 1;//sets the players faction rank to 1
    
format(stringsizeof(string), "FACTION:Вие приехте предложението за влизане в банда %d"facid);//tells the player they have accepted the faction invite
    
SendClientMessage(playeridCOLOR_CYANstring);//shows the above message in the color of CYAN
    
DeletePVar(playerid"invitefac");//deletes the saved invite
    
return 1;

Reply
#13

Quote:
Originally Posted by mrikill
View Post
my commands..

PHP Code:
CMD:invite(playeridparams[])
{
    if(
PlayerInfo[playerid][pFacleader] > || PlayerInfo[playerid][pFacrank] >= 5)
    {
        new 
taridfacid;//establishes a player in the server and a faction id for you to type in
        
if(sscanf(params"u"tarid)) return SendClientMessage(playeridCOLOR_RED"{0033cc}FACTION:Използвайте: /invite [playerid]");//if the command is not typed correctly, it will show you the correct way to use the command.
        
facid PlayerInfo[playerid][pFaction];//sets the faction the player is being invited to, as the faction the player that is inviting is in.
        
SetPVarInt(tarid"invitefac"facid);//saves the invite, to /accept it
        
SendClientMessage(taridCOLOR_GREEN"{0033cc}FACTION:Вие получихте покана за банда/мафия , използвайте /acceptinvite за да я приемете!");//tells you that you have been invited to a faction
    
}
    else 
//if you're not the correct rank it will display the message below stating that the player is not the rank to invite
    
{
        
SendClientMessage(playeridCOLOR_RED"{0033cc}FACTION:Вие трябва да сте 5 ранг за да може да инвийтвате");
    }
    return 
1;
}
CMD:acceptfaction(playeridparams[])
{
    new 
facidstring[128];//creates a faction id and some text on the players screen
    
facid GetPVarInt(playerid"invitefac");//calls the saved invite from the previous command
    
PlayerInfo[playerid][pFaction] = facid//sets the players faction to that of the person inviting.
    
PlayerInfo[playerid][pFacrank] = 1;//sets the players faction rank to 1
    
format(stringsizeof(string), "FACTION:Вие приехте предложението за влизане в банда %d"facid);//tells the player they have accepted the faction invite
    
SendClientMessage(playeridCOLOR_CYANstring);//shows the above message in the color of CYAN
    
DeletePVar(playerid"invitefac");//deletes the saved invite
    
return 1;

This looks like it should work to me.. does it compile alright?
Reply
#14

Its amazing how you made it so... simple!
Pretty sure you can do this in MySQL - but ofc. with some extras ( faction name for an example )
Reply
#15

Really Nice
Reply
#16

Quote:
Originally Posted by Kyance
View Post
Its amazing how you made it so... simple!
Pretty sure you can do this in MySQL - but ofc. with some extras ( faction name for an example )
Simplicity is what I like!


Quote:
Originally Posted by TheRaGeLord
View Post
Really Nice
Thank you sir!
Reply
#17

Simple and good
Reply
#18

Can /createfaction
Reply
#19

Quote:

CMD:acceptinvite(playerid, params[])
{

new facid, string[128];//creates a faction id and some text on the players screen
facid = GetPVarInt(playerid, "invitefac");//calls the saved invite from the previous command
PlayerInfo[playerid][pFaction] = facid; //sets the players faction to that of the person inviting.
PlayerInfo[playerid][pFacrank] = 1;//sets the players faction rank to 1
format(string, sizeof(string), "> You have accepted the invite to faction %d", facid);//tells the player they have accepted the faction invite
SendClientMessage(playerid, COLOR_CYAN, string);//shows the above message in the color of CYAN
DeletePVar(playerid, "invitefac");//deletes the saved invite
return 1;
}

What if the player does not have a faction invite? Add a check, example:

Quote:

//Under the command
if(facid<0) return SendClientMessage(playerid, color,"You have not been invited to any faction.");

Reply
#20

forum.sa-mp.com/showthread.php?t=390214 --- you just use this tutorial and u idn't change any thing u just replace gang to Faction LMFAO
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)