/admins dialog problem
#1

The dialog will only show one person at any given time and shows people whose stats aren't even admin.
Can someone fix both of these issues?

pawn Код:
CMD:admins(playerid, params[]){
    for(new i = 0;i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(pStats[i][Admin] >= 0)
            {
                new str[128],duty[32];
                switch(Duty[i]){
                    case 0: format(duty,sizeof(duty),"(Off duty)");
                    case 1: format(duty,sizeof(duty),"{FF6347}(On duty)");
                }
                format(str,sizeof(str),"%s %s %s\n",GetAdmin(i),GetName(i),duty);
                ShowPlayerDialog(playerid,10,0,"Administration",str,"Close","");
            }
            else{
                ShowPlayerDialog(playerid,11,0,"Administration","There's no administrators online.","Close","");
            }
        }
    }
    return 1;
}
Reply
#2

Код:
CMD:admins(playerid, params[]){
	new admins=0;
    for(new i = 0;i < MAX_PLAYERS; i++){
        if(IsPlayerConnected(i))
        {
            if(pStats[i][Admin] > 0)
            {
                new str[256],duty[32];
                switch(Duty[i]){
                    case 0: format(duty,sizeof(duty),"(Off duty)");
                    case 1: format(duty,sizeof(duty),"{FF6347}(On duty)");
                }
                format(str,sizeof(str),"%s\n%s %s %s",str,GetAdmin(i),GetName(i),duty);
				admins+=1;
            }
        }
    }
	if(admins==0) ShowPlayerDialog(playerid,11,0,"Administration","There's no administrators online.","Close","");
	else ShowPlayerDialog(playerid,10,0,"Administration",str,"Close","");
	return 1;
}
I didn't test it, but this should put you in the write way
Reply
#3

Does anyone else have a possible solution?
Reply
#4

Did you even try my solution?
Reply
#5

Try this:
pawn Код:
CMD:admins(playerid, params[]) {
    new bool:iCount,
        str[516];
       
    for(new i = 0; i < MAX_PLAYERS; i++) {
        if(IsPlayerConnected(i)) {
            if(pStats[i][Admin] > 0) {
                iCount = true;
                format(str,sizeof(str),"%s%s %s %s\n", str, GetAdmin(i), GetName(i), ((Duty[i]) ? ("{FF6347}on duty") : ("off duty")));
            }
        }
    }
    if(iCount == true)
        ShowPlayerDialog(playerid,10,0,"Administration",str,"Close","");
    else
        ShowPlayerDialog(playerid,11,0,"Administration","There's no administrators online.","Close","");
    return 1;
}
For the admin part you used a greater than and equal statement (">=") which means it will find people who are not admin, also you weren't formatting the string correctly to display all the admins in one dialog and the string was too small.
Reply
#6

You are all doing this wrong.. Try using a smaller string to format, then strcat'ing it to the bigger string inside of the loop.

example:
pawn Код:
CMD:admins(playerid, params[]) {
    new iCount,
        str[1024],
        str2[128];
       
    for(new i = 0; i < MAX_PLAYERS; i++) {
        if(IsPlayerConnected(i)) {
            if(pStats[i][Admin] > 0) {
                iCount++;
                format(str2,sizeof(str2),"%s%s %s %s\n", str, GetAdmin(i), GetName(i), ((Duty[i]) ? ("{FF6347}on duty") : ("off duty")));
                strcat(str, str2);
            }
        }
    }
    if(iCount > 0)
        ShowPlayerDialog(playerid,10,0,"Administration",str,"Close","");
    else
        ShowPlayerDialog(playerid,11,0,"Administration","There's no administrators online.","Close","");
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)