/admins confused
#1

pawn Code:
CMD:admins(playerid,params[])
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(Duty[i] == 1)
        {
        new string[124];
        format(string,sizeof(string),"%s",GetName(i));
        SendClientMessage(playerid,-1,string);
        }
        if(Duty[i] == 0)
        {
        SendClientMessage(playerid,-1,"No admins online");
        }
    }
    return 1;
}
I dont know where to send the message. I know not to do it in le' loop but im not sure where else to put it. Any help would be appreciated..

- tyler.
Reply
#2

whats the exact problem?
Reply
#3

Quote:
Originally Posted by CROSS_Hunter
View Post
whats the exact problem?
Its in a loop, it sends the message alot. I just dont know where to put the code.
Reply
#4

You are looping trough all the players and if they arn't admin you will get the message for each player online. you need to check outside the loop if any admin is online and if not, send the message.
Reply
#5

pawn Code:
CMD:admins(playerid,params[])
{
    new count = 0, string[128];
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(Duty[i] == 1)
        {
            new string[124];
            format(string,sizeof(string),"%s",GetName(i));
            SendClientMessage(playerid,-1,string);
            count ++;
        }
    }
    if(count == 0)
    {
        SendClientMessage(playerid,-1,"No admins online");
    }
    return 1;
}
Reply
#6

Try this ...
Code:
acmd:admins(playerid, params[], bool:help)
{
	new string[128], bool:dfound = false, dcount = 0;
	for(new i = 0; i < GetMaxPlayers(); i++) {
		if(Duty[i] != 1) continue;
		
		if(dcount == 0) {
			dfound = true; dcount += 1;
			format(string, sizeof(string), "%s", GetName(i));
		} else {
			dcount += 1;
			format(string, sizeof(string), "%s, %s", string, GetName(i));
		}
		
		if(dcount == 6) {
			dcount = 0;
			SendClientMessage(playerid, -1, string);
		}
	}
	if(dcount != 0) {
		SendClientMessage(playerid, -1, string);
	}
	if(!dfound) {
		SendClientMessage(playerid, -1, "No admins online");
	}
	return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)