Making faction system more than 1 faction
#1

MAKELEADER
PHP код:
CMD:makeleader(playeridparams[])
{
    new 
targetidfactionidstring[128], targetname[24], playername[24];
    if(
sscanf(params"ui"targetidfactionid)) return SendClientMessage(playerid, -1"Usage: /makeleader [playerid][factionid]"); //Checks if they typed in anything for the playerid and factionid parameters, and if they don't, return a client message.
    
if(pInfo[playerid][pAdminLevel] < 5) return SendClientMessage(playerid, -1"You are not an admin"); //Checks if they are an admin.  Remember, change this to your admin variable, or use !IsPlayerAdmin to check if they aren't rcon admin.
    
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, -1"Invalid playerid!"); //Sends a message if the player is not connected
    
if(factionid 3//Checks if the factionid is between 0 and 3, and if so, continue.  You can also type this like so: if(factionid >= 1 && factionid <= 2) or if(factionid == 1 || factionid == 2)
    
{
        
GetPlayerName(playeridplayernamesizeof(playername)); //Gets the players name and saves it to the variable playername
        
GetPlayerName(targetidtargetnamesizeof(targetname)); //Gets the targets name and saves it to the variable targetname
        
format(stringsizeof(string), "You made %s leader of faction id %i!"targetnamefactionid); //Formats the string that you will receive
        
SendClientMessage(playerid, -1string); //Sends a message to the person who changes the other persons faction in a random color
        
format(stringsizeof(string), "You were made leader of faction id %i by %s"factionidplayername);//Formats the string that the player will receive
        
SendClientMessage(playerid, -1string); //Sends a message to the person who is made the faction leader
        
pInfo[targetid][pFaction] = factionid;
        
pInfo[targetid][pRank] = 6//Leader, use a switch case or if/else if statement if you want to make it so certain factions have seperate highest ranks
    
}
    else return 
SendClientMessage(playerid, -1"Invalid factionid.  Factionid's: 1-2"); //Sends a message if the faction is NOT between 0 and 3
    
return 1;// Returns 1 to end the command, as we NEED to return a value.

INVITE
PHP код:
CMD:invite(playeridparams[])
//Open bracket
    
new targetidtargetname[24], playername[24], string[128]; //Create the variables
    
if(sscanf(params"u"targetid)) return SendClientMessage(playerid, -1"Usage: /removefromfaction [playerid/partofname]"); //Sends message if they do not type something in for the targetid/name
    
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, -1"Invalid playerid!"); //Sends a message if the player isn't connected
    
if(pInfo[playerid][pRank] != 6) return SendClientMessage(playerid, -1"You are not the leader of a faction!");
    
GetPlayerName(targetidtargetnamesizeof(targetname)); //Stores the targetid's name in the targetname variable
    
GetPlayerName(playeridplayernamesizeof(playername)); //Stores the playerid's name in the playername variable
    
format(stringsizeof(string), "You invited %s to faction!"targetname);//Formats the message that will be sent to you (the player)
    
SendClientMessage(playerid, -1string);//Sends the message that is formatted above to the playerid in a random color
    
format(stringsizeof(string), "You were invited to faction %s by %s!"playername);//Formats the message that will be sent to the targetid
    
SendClientMessage(targetid, -1string);//Sends the message that is formatted above to the targetid in a random color
    
pInfo[targetid][pFaction] = pInfo[playerid][pFaction];
    
pInfo[targetid][pRank] = 1
    return 
1//Returns a value

COmmand /f which you talk
PHP код:
CMD:f(playerid,params[])
{
    new 
factionstring[257];
    if(
pInfo[playerid][pFaction] >= 1)
    {
        if(!
strlen(params))
        {
            
SendClientMessage(playerid, -1""chat" /f [mesaj]");
            return 
1;
        }
        
format(factionstringsizeof(factionstring), ""COL_LIGHTBLUE"(( %s %s: %s",GetRankName(playerid),PlayerName(playerid), params);
        
SendMessageToAllFaction(factionstring, -1);
    }
    else {
        
SendClientMessage(playerid,-1,"*"COL_RED" You are not in any faction!");
    }
    return 
1;

SendMessageToAllFaction Function
PHP код:
stock SendMessageToAllFaction(message[], color)
{
    foreach(
Playeri)
    {
        if(
pInfo[i][pFaction] >= 1)
        {
             
SendClientMessage(icolormessage);
         }
     }
    return 
1;

get rank functio

PHP код:
stock GetRankName(playerid)
{
    new 
rankname[128];
    switch(
pInfo[playerid][pRank])
    {
        case 
0rankname "Police Officer I";
        case 
1rankname "Police Officer II";
        case 
2rankname "Police Officer III";
        case 
3rankname "Police Officer III+1";
        case 
4rankname "Sergeant I";
        case 
5rankname "Sergeant II";
        case 
6rankname "Lieutenant I";
        case 
7rankname "Captain";
    }
    return 
rankname;

My question is, how can i edit that

ID 1 of faction be named Los Santos Police Department
ID 2 of faction be named All Saints General Hospital

ID 1's faction rank's to be named as seen upstair
ID 2's faction rank's to be named as seen upstair (as GetRankName too)


And how to make /f work without faction ID 1 see what faction ID 2 says (And vice versa)


pls help, i give rep
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 3 Guest(s)