/admins 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 problem (
/showthread.php?tid=444010)
/admins problem -
nor15 - 14.06.2013
I use this command but when is there are 2 or more admins online it only write 1 player
PHP код:
dcmd_admins(playerid,params[])
{
#pragma unused params
new count = 0;
new string[128],name[50];
new name1[MAX_PLAYER_NAME];
for(new i = 0; i < MAX_PLAYERS; i++)
{
if (IsPlayerConnected(i))
{
GetPlayerName(i,name1,MAX_PLAYER_NAME);
if(AdminLevel[i] > 0)
{
if(AdminLevel[i] == 1)
{name = "{FFFF00}Server Moderator {FFFFFF}(Level 1)";}
if(AdminLevel[i] ==2)
{name = "{0000BB}Global Moderator {FFFFFF}(Level 2)";}
if(AdminLevel[i] ==3)
{name = "{ADFF2F}Administrator {FFFFFF}(Level 3)";}
if(AdminLevel[i] ==4)
{name = "{ADFF2F}Lead Adminstrator {FFFFFF}(Level 4)";}
if(AdminLevel[i] ==5)
{name = "{FF0000}Owner {FFFFFF}(Level 5)";}
format(string, 128, "\"%s\" {%s}", name1,name);
ShowPlayerDialog(playerid,DIALOG_ADMINS,DIALOG_STYLE_MSGBOX,"ADMINS ONLINE",string,"Ok","");
count++;
}
}
}
if (count == 0)
SendClientMessage(playerid,COLOR_ADMIN,"There are no admins Online at the moment");
return 1;
}
Re: /admins problem -
IstuntmanI - 14.06.2013
You have to use the previous "string" (I improved it a little):
pawn Код:
dcmd_admins( playerid, params[ ] )
{
#pragma unused params
new count = 0, string[ 1024 ], name[ 50 ], name1[ MAX_PLAYER_NAME ];
for( new i = 0; i < MAX_PLAYERS; i ++ )
{
if( IsPlayerConnected( i ) )
{
GetPlayerName( i, name1, MAX_PLAYER_NAME );
if( AdminLevel[ i ] > 0 )
{
switch( AdminLevel[ i ] )
{
case 1: name = "{FFFF00}Server Moderator {FFFFFF}(Level 1)";
case 2: name = "{0000BB}Global Moderator {FFFFFF}(Level 2)";
case 3: name = "{ADFF2F}Administrator {FFFFFF}(Level 3)";
case 4: name = "{ADFF2F}Lead Adminstrator {FFFFFF}(Level 4)";
case 5: name = "{FF0000}Owner {FFFFFF}(Level 5)";
}
format( string, 1024, "%s\"%s\" {%s}\n", string, name1, name );
ShowPlayerDialog( playerid, DIALOG_ADMINS, DIALOG_STYLE_MSGBOX, "ADMINS ONLINE", string, "Ok", "" );
count ++;
}
}
}
if( count == 0 )
SendClientMessage( playerid, COLOR_ADMIN,"There are no admins Online at the moment" );
return 1;
}
Also, use foreach in your loops, it's faster.