Not showing the leader names
#1

Hi.

I've made a command /factions, which looks like this.

Код:
CMD:factions(playerid,params[])
{
	if(IsPlayerConnected(playerid))
	{
	    new string[185], stats[1024];
	    format(string,sizeof(string),"*Las Venturas Police Department[ID1] || Leader: %s \n*The Santino Family[ID2] || Leader: %s \n*The Manusco Crew[ID3] || Leader: %s \n*Back Alley Crips[ID4]  Leader: %s",PlayerInfo[playerid][pFacleader] == 1 ,PlayerInfo[playerid][pFacleader] == 2 ,PlayerInfo[playerid][pFacleader] == 3 ,PlayerInfo[playerid][pFacleader] ==4);
	    format(stats, sizeof stats, "%s", string);
	    ShowPlayerDialog(playerid,FACTIONS,DIALOG_STYLE_MSGBOX,"Server Factions:",stats,"Ok","");
	}
	return 1;
}
It works as charm, but it doesen't show the Leaders, am i doing something wrong?
Reply
#2

Код:
CMD:factions(playerid,params[])
{
	if(IsPlayerConnected(playerid))
	{
	    new string[185], stats[1024];
	    format(string,sizeof(string),"*Las Venturas Police Department[ID1] || Leader: %s \n*The Santino Family[ID2] || Leader: %s \n*The Manusco Crew[ID3] || Leader: %s \n*Back Alley Crips[ID4]  Leader: %s",PlayerInfo[playerid][pFacleader] == 1 ,PlayerInfo[playerid][pFacleader] == 2 ,PlayerInfo[playerid][pFacleader] == 3 ,PlayerInfo[playerid][pFacleader] ==4);
	    format(stats, sizeof stats, "%s", string);
	    ShowPlayerDialog(playerid,FACTIONS,DIALOG_STYLE_MSGBOX," Factions:",stats,"Ok","");
	}
	return 1;
}
remove ==
just pFacleader

Код:
CMD:factions(playerid,params[])
{
	if(IsPlayerConnected(playerid))
	{
	    new string[185], stats[1024];
	    format(string,sizeof(string),"*Las Venturas Police Department[ID1] || Leader: %s \n*The Santino Family[ID2] || Leader: %s \n*The Manusco Crew[ID3] || Leader: %s \n*Back Alley Crips[ID4]  Leader: %s",PlayerInfo[playerid][pFacleader] ,PlayerInfo[playerid][pFacleader] ,PlayerInfo[playerid][pFacleader] ,PlayerInfo[playerid][pFacleader]);
	    format(stats, sizeof stats, "%s", string);
	    ShowPlayerDialog(playerid,FACTIONS,DIALOG_STYLE_MSGBOX," Factions:",stats,"Ok","");
	}
	return 1;
}
Maybe this is wrong so theres another way to do it
using
pFacleader1, pFacleader2, pFacleader3, pFacleader4, if you do them in this type they'll be helpful in commands also, to set commands per each faction
Send me /makeleader and i'll make it for you.
Reply
#3

Here is the /setleader cmd

Код:
CMD:setleader(playerid, params[])
{
	if(PlayerInfo[playerid][pAdmin] >= 4)
	{
	    new targetid, facid;
	    if(sscanf(params,"ui",targetid, facid)) return SendClientMessage(playerid, COLOR_RED,"/setleader [id][Faction id]");
	    if(targetid != INVALID_PLAYER_ID)
	    {
	        PlayerInfo[targetid][pFaction] = facid; 
	        PlayerInfo[targetid][pFacrank] = 10;
	        PlayerInfo[targetid][pFacleader] = facid;
	        if(facid == 1)
	        {
				SendClientMessage(targetid,COLOR_CYAN,"You have been made the leader of the Las Venturas PD");
			}
			if(facid == 2)
			{
			    SendClientMessage(targetid,COLOR_CYAN,"You have been made the leader of The Santino Family");
			}
			if(facid == 3)
			{
			    SendClientMessage(targetid,COLOR_CYAN,"You've been made the leader of The Manusco Crew");
			}
			if(facid == 4)
			{
			    SendClientMessage(targetid,COLOR_CYAN,"You've been made the leader of Back Alley Crips");
			}
	    }
	}
	else
	{
	    SendClientMessage(playerid, COLOR_WHITE, "SERVER: Unknown command.");
	}
	return 1;
}
Reply
#4

Код:
//at playerinfo enum add
pFacleader1[MAX_PLAYER_NAME],
pFacleader2[MAX_PLAYER_NAME],
pFacleader3[MAX_PLAYER_NAME],
pFacleader4[MAX_PLAYER_NAME],



CMD:setleader(playerid, params[])
{
	if(PlayerInfo[playerid][pAdmin] >= 4)
	{
	    new targetid, facid;
	    if(sscanf(params,"ui",targetid, facid)) return SendClientMessage(playerid, COLOR_RED,"/setleader [id][Faction id]");
	    if(targetid != INVALID_PLAYER_ID)
	    {
	        PlayerInfo[targetid][pFaction] = facid; 
	        PlayerInfo[targetid][pFacrank] = 10;
	        if(facid == 1)
	        {
				SendClientMessage(targetid,COLOR_CYAN,"You have been made the leader of the Las Venturas PD");
				PlayerInfo[playerid][pFacleader1] = 1;

			}
			if(facid == 2)
			{
			    SendClientMessage(targetid,COLOR_CYAN,"You have been made the leader of The Santino Family");
			    PlayerInfo[playerid][pFacleader2] = 1;
			}
			if(facid == 3)
			{
			    SendClientMessage(targetid,COLOR_CYAN,"You've been made the leader of The Manusco Crew");
			    PlayerInfo[playerid][pFacleader3] = 1;
			}
			if(facid == 4)
			{
			    SendClientMessage(targetid,COLOR_CYAN,"You've been made the leader of Back Alley Crips");
			    PlayerInfo[playerid][pFacleader4] = 1;
			}
	    }
	}
	else
	{
	    SendClientMessage(playerid, COLOR_WHITE, "SERVER: Unknown command.");
	}
	return 1;
}

CMD:factions(playerid,params[])
{
	if(IsPlayerConnected(playerid))
	{
	    new string[185], stats[1024];
	    format(string,sizeof(string),"*Las Venturas Police Department[ID1] || Leader: %s \n*The Santino Family[ID2] || Leader: %s \n*The Manusco Crew[ID3] || Leader: %s \n*Back Alley Crips[ID4]  Leader: %s",PlayerInfo[playerid][pFacleader1] ,PlayerInfo[playerid][pFacleader2] ,PlayerInfo[playerid][pFacleader3] ,PlayerInfo[playerid][pFacleader4]);
	    format(stats, sizeof stats, "%s", string);
	    ShowPlayerDialog(playerid,FACTIONS,DIALOG_STYLE_MSGBOX," Factions:",stats,"Ok","");
	}
	return 1;
}
Reply
#5

Quote:
Originally Posted by AlexMSK
Посмотреть сообщение
Код:
//at playerinfo enum add
pFacleader1[MAX_PLAYER_NAME],
pFacleader2[MAX_PLAYER_NAME],
pFacleader3[MAX_PLAYER_NAME],
pFacleader4[MAX_PLAYER_NAME],



CMD:setleader(playerid, params[])
{
	if(PlayerInfo[playerid][pAdmin] >= 4)
	{
	    new targetid, facid;
	    if(sscanf(params,"ui",targetid, facid)) return SendClientMessage(playerid, COLOR_RED,"/setleader [id][Faction id]");
	    if(targetid != INVALID_PLAYER_ID)
	    {
	        PlayerInfo[targetid][pFaction] = facid; 
	        PlayerInfo[targetid][pFacrank] = 10;
	        if(facid == 1)
	        {
				SendClientMessage(targetid,COLOR_CYAN,"You have been made the leader of the Las Venturas PD");
				PlayerInfo[playerid][pFacleader1] = 1;

			}
			if(facid == 2)
			{
			    SendClientMessage(targetid,COLOR_CYAN,"You have been made the leader of The Santino Family");
			    PlayerInfo[playerid][pFacleader2] = 1;
			}
			if(facid == 3)
			{
			    SendClientMessage(targetid,COLOR_CYAN,"You've been made the leader of The Manusco Crew");
			    PlayerInfo[playerid][pFacleader3] = 1;
			}
			if(facid == 4)
			{
			    SendClientMessage(targetid,COLOR_CYAN,"You've been made the leader of Back Alley Crips");
			    PlayerInfo[playerid][pFacleader4] = 1;
			}
	    }
	}
	else
	{
	    SendClientMessage(playerid, COLOR_WHITE, "SERVER: Unknown command.");
	}
	return 1;
}

CMD:factions(playerid,params[])
{
	if(IsPlayerConnected(playerid))
	{
	    new string[185], stats[1024];
	    format(string,sizeof(string),"*Las Venturas Police Department[ID1] || Leader: %s \n*The Santino Family[ID2] || Leader: %s \n*The Manusco Crew[ID3] || Leader: %s \n*Back Alley Crips[ID4]  Leader: %s",PlayerInfo[playerid][pFacleader1] ,PlayerInfo[playerid][pFacleader2] ,PlayerInfo[playerid][pFacleader3] ,PlayerInfo[playerid][pFacleader4]);
	    format(stats, sizeof stats, "%s", string);
	    ShowPlayerDialog(playerid,FACTIONS,DIALOG_STYLE_MSGBOX," Factions:",stats,"Ok","");
	}
	return 1;
}
Will this code actually save the leader?
Reply
#6

That's what you want to do, it's not done that way. I recommend reading tutorial and learning more. I'll help you just to see how it has to be done.

PHP код:
#define MAX_FACC  (4) // Number of factions
enum ENUM_FACTION_DATA
{
    
fLeader[MAX_PLAYER_NAME+1]
};
new 
Faction[MAX_FACC][ENUM_FACTION_DATA];
CMD:setleader(playeridparams[])
{
    if(
PlayerInfo[playerid][pAdmin] >= 4)
    {
        new 
targetidfacid;
        if(
sscanf(params,"ui",targetidfacid)) return SendClientMessage(playeridCOLOR_RED,"/setleader [id][Faction id]");
        if(
targetid != INVALID_PLAYER_ID)
        {
            
PlayerInfo[targetid][pFaction] = facid
            
PlayerInfo[targetid][pFacrank] = 10;
            
PlayerInfo[targetid][pFacleader] = facid;
            if(
facid == 1)
            {
                
SendClientMessage(targetid,COLOR_CYAN,"You have been made the leader of the Las Venturas PD");
                                
GetPlayerName(targetidFaction[0][fLeader], 25);
            }
            if(
facid == 2)
            {
                
SendClientMessage(targetid,COLOR_CYAN,"You have been made the leader of The Santino Family");
                            
GetPlayerName(targetidFaction[1][fLeader], 25);
            }
            if(
facid == 3)
            {
                
SendClientMessage(targetid,COLOR_CYAN,"You've been made the leader of The Manusco Crew");
                            
GetPlayerName(targetidFaction[2][fLeader], 25);
            }
            if(
facid == 4)
            {
                
SendClientMessage(targetid,COLOR_CYAN,"You've been made the leader of Back Alley Crips");
                            
GetPlayerName(targetidFaction[3][fLeader], 25);
            }
        }
    }
    else
    {
        
SendClientMessage(playeridCOLOR_WHITE"SERVER: Unknown command.");
    }
    return 
1;
}
CMD:factions(playerid,params[])
{
    if(
IsPlayerConnected(playerid))
    {
        new 
string[1024];
        
format(string,sizeof(string),"*Las Venturas Police Department[ID1] || Leader: %s \n*The Santino Family[ID2] || Leader: %s \n*The Manusco Crew[ID3] || Leader: %s \n*Back Alley Crips[ID4]  Leader: %s",Faction[0][fLeader],Faction[1][fLeader] , Faction[2][fLeader], Faction[3][fLeader]);
        
ShowPlayerDialog(playerid,FACTIONS,DIALOG_STYLE_MSGBOX,"Server Factions:",string,"Ok","");
    }
    return 
1;

PS: This is a sample of how you have to do it, you would also have to save it for when the server is closed, the name of the leader is saved, and I have not compiled it if it gives you errors let me know.
Reply
#7

Quote:
Originally Posted by Escobabe
Посмотреть сообщение
Will this code actually save the leader?
Hmm no i guess.
Show me how does it save the "pFacleader".
Reply
#8

Quote:
Originally Posted by AlexMSK
Посмотреть сообщение
Hmm no i guess.
Show me how does it save the "pFacleader".
Thanks for the help everyone [rep], i've figured another way of how to show leaders. I've made the command /facinfo and a DynamicCP. So depending on which CP the players enter, it will show the factions info [members] and the leader. This might actually be a better way.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)