/staff command fails to have more than one staff member on it.
#1

My staff script only shows you if you are an admin. It doesn't show any other administrator.

Код:
command(staff, playerid, params[])
{
	#pragma unused params
	new string[128];

	SendClientMessage(playerid, COLOR_ORANGE, ". : : Administrators : : .");
	for(new i = 0; i < MAX_PLAYERS; i++)
	{
		if(IsPlayerConnected(playerid))
		{
			if(PlayerInfo[playerid][pAdmin] >= 1)
			{
				format(string, sizeof(string), "Name: %s{A9C4E4}: (Level %d) {%s}", RPName(playerid), PlayerInfo[playerid][pAdmin], GetAwayStatus(playerid));
				SendClientMessage(playerid, GREY, string);
				return 1;
			}
		}
	}
	SendClientMessage(playerid, COLOR_ORANGE, ". : : Moderators : : .");
	for(new i = 0; i < MAX_PLAYERS; i++)
	{
		if(IsPlayerConnected(i))
		{
			if(PlayerInfo[playerid][pModerator] >= 1)
			{
				format(string, sizeof(string), "Name: %s{A9C4E4} {%s}", RPName(playerid), GetAwayStatus(i));
				SendClientMessage(playerid, GREY, string);
				return 1;
			}
		}
	}
	SendClientMessage(playerid, COLOR_ORANGE, ". : : Helpers : : .");
	for(new i = 0; i < MAX_PLAYERS; i++)
	{
		if(IsPlayerConnected(i))
		{
			if(PlayerInfo[playerid][pHelper] >= 1)
			{
				format(string, sizeof(string), "Name: %s{A9C4E4} {%s}", RPName(playerid), GetAwayStatus(playerid));
				SendClientMessage(playerid, GREY, string);
				return 1;
			}
		}
	}
	return 1;
}
Please fix.
Reply
#2

You're returning when a staff member is found, so it isn't going to continue. Using multiple loops is useless and inefficient, you should also consider using foreach.

Код:
command(staff, playerid, params[])
{
    #pragma unused params
    new string[128];
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(playerid))
        {
            SendClientMessage(playerid, COLOR_ORANGE, ". : : Administrators : : .");
            if(PlayerInfo[playerid][pAdmin] >= 1)
            {
                format(string, sizeof(string), "Name: %s{A9C4E4}: (Level %d) {%s}", RPName(playerid), PlayerInfo[playerid][pAdmin], GetAwayStatus(playerid));
                SendClientMessage(playerid, GREY, string);
            }
            SendClientMessage(playerid, COLOR_ORANGE, ". : : Moderators : : .");
            if(PlayerInfo[playerid][pModerator] >= 1)
            {
                format(string, sizeof(string), "Name: %s{A9C4E4} {%s}", RPName(playerid), GetAwayStatus(i));
                SendClientMessage(playerid, GREY, string);
            }
            SendClientMessage(playerid, COLOR_ORANGE, ". : : Helpers : : .");
            if(PlayerInfo[playerid][pHelper] >= 1)
            {
                format(string, sizeof(string), "Name: %s{A9C4E4} {%s}", RPName(playerid), GetAwayStatus(playerid));
                SendClientMessage(playerid, GREY, string);
            }
        }
    }
    return 1;
}
Reply
#3

Код:
command(staff, playerid, params[])
{
	#pragma unused params
	new string[128];

	SendClientMessage(playerid, COLOR_ORANGE, ". : : Administrators : : .");
	for(new i = 0; i < MAX_PLAYERS; i++)
	{
		if(IsPlayerConnected(playerid))
		{
			if(PlayerInfo[playerid][pAdmin] >= 1)
			{
				format(string, sizeof(string), "Name: %s{A9C4E4}: (Level %d) {%s}", RPName(playerid), PlayerInfo[playerid][pAdmin], GetAwayStatus(playerid));
				SendClientMessage(playerid, GREY, string);
			}
		}
	}
	SendClientMessage(playerid, COLOR_ORANGE, ". : : Moderators : : .");
	for(new i = 0; i < MAX_PLAYERS; i++)
	{
		if(IsPlayerConnected(i))
		{
			if(PlayerInfo[playerid][pModerator] >= 1)
			{
				format(string, sizeof(string), "Name: %s{A9C4E4} {%s}", RPName(playerid), GetAwayStatus(i));
				SendClientMessage(playerid, GREY, string);
			}
		}
	}
	SendClientMessage(playerid, COLOR_ORANGE, ". : : Helpers : : .");
	for(new i = 0; i < MAX_PLAYERS; i++)
	{
		if(IsPlayerConnected(i))
		{
			if(PlayerInfo[playerid][pHelper] >= 1)
			{
				format(string, sizeof(string), "Name: %s{A9C4E4} {%s}", RPName(playerid), GetAwayStatus(playerid));
				SendClientMessage(playerid, GREY, string);
			}
		}
	}
	return 1;
}
You returned right after sending a message about an admin/mod/helper, that's why the function stopped executing after one staff member.
Reply
#4

This:
Код:
command(staff, playerid, params[])
{
	#pragma unused params
	new string[128],text[1000]

	SendClientMessage(playerid, COLOR_ORANGE, ". : : Administrators : : .");
	for(new i = 0; i < MAX_PLAYERS; i++)
	{
		if(IsPlayerConnected(playerid))
		{
			if(PlayerInfo[playerid][pAdmin] >= 1)
			{
				format(string, sizeof(string), "Name: %s{A9C4E4}: (Level %d) {%s}", RPName(playerid), PlayerInfo[playerid][pAdmin], GetAwayStatus(playerid));
				SendClientMessage(playerid, GREY, string);
				return 1;
			}
		}
	}
	SendClientMessage(playerid, COLOR_ORANGE, ". : : Moderators : : .");
	for(new i = 0; i < MAX_PLAYERS; i++)
	{
		if(IsPlayerConnected(i))
		{
			if(PlayerInfo[playerid][pModerator] >= 1)
			{
				format(string, sizeof(string), "Name: %s{A9C4E4} {%s}", RPName(playerid), GetAwayStatus(i));
				SendClientMessage(playerid, GREY, string);
				return 1;
			}
		}
	}
	SendClientMessage(playerid, COLOR_ORANGE, ". : : Helpers : : .");
	for(new i = 0; i < MAX_PLAYERS; i++)
	{
		if(IsPlayerConnected(i))
		{
			if(PlayerInfo[playerid][pHelper] >= 1)
			{
				format(string, sizeof(string), "Name: %s{A9C4E4} {%s}", RPName(playerid), GetAwayStatus(playerid));
				SendClientMessage(playerid, GREY, string);
				return 1;
			}
		}
	}
         strcat(string,"\n");
         strcat(text,string);
         SendClientMessage(playerid,GREY,text);
	return 1;
}
This will show all in one soo remove all SendClientMessage
Reply
#5

thanks.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)