SA-MP Forums Archive
/admins dialog problem - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: /admins dialog problem (/showthread.php?tid=420194)



/admins dialog problem - Noles2197 - 03.03.2013

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;
}



Re: /admins dialog problem - mati233 - 03.03.2013

Код:
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


Re: /admins dialog problem - Noles2197 - 03.03.2013

Does anyone else have a possible solution?


Re: /admins dialog problem - mati233 - 03.03.2013

Did you even try my solution?


Re: /admins dialog problem - ryansheilds - 03.03.2013

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.


Re: /admins dialog problem - Dubya - 03.03.2013

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;
}