CMD:admins(){ new string[256]; new fstring[64]; for(new i=0; i<MAX_PLAYERS; i++) { if(Admin[playerid]>= 0) { GetPlayerName(i,adminname, sizeof(adminname)); format(fstring, sizeof(fstring),"%s (%i) - {FF0000}Level: %i{FFFFFF}\n", adminname, i,Admin[playerid]); strcat(string, fstring, sizeof(string)); } } ShowPlayerDialog(playerid,1,DIALOG_STYLE_MSGBOX,"Online Admins",string,"OK",""); return 1; }
Hi I'm making a command to see the online admins on the server , this is the code
Код:
CMD:admins(playerid){ new string[256]; new fstring[64]; for(new i=0; i<MAX_PLAYERS; i++) { if(Admin[playerid]>= 0) { GetPlayerName(i,adminname, sizeof(adminname)); format(fstring, sizeof(fstring),"%s (%i) - {FF0000}Level: %i{FFFFFF}\n", adminname, i,Admin[playerid]); strcat(string, fstring, sizeof(string)); } } ShowPlayerDialog(playerid,1,DIALOG_STYLE_MSGBOX,"Online Admins",string,"OK",""); return 1; } |
CMD:admins(playerid){
new string[300];
new fstring[64];
for(new i=0; i<MAX_PLAYERS; i++)
{
if(Admin[i] > 0 && IsPlayerConnected(i))
{
GetPlayerName(i,adminname, sizeof(adminname));
format(fstring, sizeof(fstring),"%s (%i) - {FF0000}Level: %i{FFFFFF}\n", adminname, i,Admin[i]);
strcat(string, fstring, sizeof(string));
}
}
ShowPlayerDialog(playerid,1,DIALOG_STYLE_MSGBOX,"Online Admins",string,"OK","");
return 1;
}
You are checking Admin[playerid], and you must check if the player connected also
also, you do (Admin[i] >= 0), also non admins will be formatted here is the right code increase string size a little bit more PHP код:
|
CMD:admins(){
new string[300], fstring[64], adminname[25];
for(new i=0; i<MAX_PLAYERS; i++)
{
if(Admin[i] > 0 && IsPlayerConnected(i))
{
GetPlayerName(i,adminname, sizeof(adminname));
format(fstring, sizeof(fstring),"%s (%i) - {FF0000}Level: %i{FFFFFF}\n", adminname, i,Admin[i]);
strcat(string, fstring, sizeof(string));
}
}
ShowPlayerDialog(playerid,1,DIALOG_STYLE_MSGBOX,"Online Admins",string,"OK","");
return 1;
}
CMD:admins(playerid, params[])
{
new string[500], t = 0, aname[MAX_PLAYER_NAME];
for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++)
{
if(!IsPlayerConnected(i)) continue;
if(!Admin[i]) continue;
GetPlayerName(i, aname, sizeof(aname));
format(string, sizeof(string), "%s%s (%d) - {FF0000}Level: %d{FFFFFF}\n", string, aname, i, Admin[i]);
t++;
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_MSGBOX, "Online admins", string, "Close", "");
}
if(!t) return SendClientMessage(playerid, -1, "There are no admins.");
return 1;
}
Strange.. Try this
PHP код:
|
CMD:admins(){