/admins - 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 (
/showthread.php?tid=565926)
/admins -
TuNiSiAnO1 - 02.03.2015
hello i've this command to see the online admins but the problem its only show me one admin even if is there two or more admins online any way to fix that?
PHP код:
CMD:admins(playerid,params[])
{
new name[24], str[100];
new count = 0;
for(new i = 0; i <MAX_PLAYERS; i++)
{
if(!IsPlayerConnected(i)) continue;
if(pdata[i][Adminstator])
{
GetPlayerName(i,name,sizeof(name));
format(str,sizeof(str),"%s (%d): %s",name,i,AdminLevel(i));
ShowPlayerDialog(playerid,20,DIALOG_STYLE_LIST,"Online admins",str,"Close","");
count++;
}
if(count == 0) return ShowPlayerDialog(playerid,22,DIALOG_STYLE_MSGBOX,"Online admins","No players found","Close","");
}
return 1;
}
Re: /admins -
CalvinC - 02.03.2015
You should use
strcat for each admin online, instead of
format, and
then show a dialog.
Right now you're formatting a string and showing a new dialog for each admin online.
Respuesta: /admins -
JuanStone - 02.03.2015
pawn Код:
CMD:admins(playerid, params[])
{
new name[24], string[60], stringend[60*10+1], count; // max 10 admins in dialog.
//..
for(new i; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(pdata[i][Administrador] >= 1)
{
GetPlayerName(i, name, sizeof(name));
format(string, sizeof(string), "%s (%d): %s\n", name, i, AdminLevel(i));
strcat(stringend, string);
count++;
}
}
}
if(count < 1)
ShowPlayerDialog(playerid, 22, DIALOG_STYLE_MSGBOX, "Online admins", "No players found", "Close","");
else if(count >= 1)
ShowPlayerDialog(playerid, 20, DIALOG_STYLE_LIST, "Online admins", stringend, "Close","");
//..
return true;
}