CMD:admins(playerid,params[])
{
if(IsPlayerConnected(playerid))
{
new string[10000];
new j;
j = GetPlayerPoolSize();
for(new id=0;id<=j;id++)
{
if(IsPlayerConnected(id))
{
new sendername[MAX_PLAYER_NAME];
GetPlayerName(id, sendername, sizeof(sendername));
format(iname,sizeof(iname),"%s.ini",sendername);
if(dini_Int(iname,"Admin")!=0)
{
new admin[100];
if(dini_Int(iname,"Admin")== 1) { admin = "Админ ниво [ 1 ]"; }
else if(dini_Int(iname,"Admin")== 2) { admin = "Админ ниво [ 2 ]"; }
else if(dini_Int(iname,"Admin")== 3) { admin = "Админ ниво [ 3 ]"; }
else if(dini_Int(iname,"Admin")== 4) { admin = "Админ ниво [ 4 ]"; }
else if(dini_Int(iname,"Admin")== 5) { admin = "[ Гл.Администратор ]"; }
else if(dini_Int(iname,"Admin")== 6) { admin = "[ Заместник-началник ]"; }
else if(dini_Int(iname,"Admin")== 7) { admin = "[ Собственик ]"; }
new strpart[256];
format(strpart, 256, "{FFFFFF}%s {FF0000}%s (ID: %d)\n", admin, sendername, id);
strins(string,strpart,strlen(string));
}
}
}
ShowPlayerDialog(playerid, 21323123, DIALOG_STYLE_MSGBOX, "Онлайн Администратори", string,
"ОК","");
}
return 1;
}
UserName(p){
new s[24];
GetPlayerName(pid,s,24);
return s;
}
UserFile(p){
new s[90];
format(s,90,"users/%s.ini",UserName(p));
return s;
}
new AdminRank[][]={"","Админ ниво [ 1 ]","Админ ниво [ 2 ]","Админ ниво [ 3 ]","Админ ниво [ 4 ]","[ Гл.Администратор ]","[ Заместник-началник ]",
"[ Собственик ]"};
enum {
dialog_admins
};
CMD:admins(pid) {
new bs[1024],
adminlvl;
foreach(new i : Player){
adminlvl=dini_Int(UserFile(i),"Admin");
if(!adminlvl)continue;
format(bs,1024,"%s%s / %s / %d\n",bs,AdminRank[adminlvl],UserName(i),i);
}
ShowPlayerDialog(pid, dialog_admins, DIALOG_STYLE_MSGBOX, "Онлайн Администратори", bs, "ОК","");
return 1;
}
PHP код:
when you use admin ranks, its samrter to create array of rank names when character connects with server, load their admin ranks and other things into array you dont need to check on cmd is player connected use ysi foreach for looping throw players, because its the fastest and smartest way to do it. and use this include https://sampforum.blast.hk/showthread.php?tid=481257 what can save memory |
CMD:admins(playerid,params[]) { new estr[200], levelname[24], pname[24], posfile[50], jval, adminids=0; for(new i=0, q=GetPlayerPoolSize( ); i<=q; i++) { if(!IsPlayerConnected(i)) continue; GetPlayerName(i, pname, sizeof(pname)); format(posfile, sizeof(posfile),"%s.ini",pname); jval=dini_Int(iname,"Admin"); switch(jval) { case 1:levelname = "Админ ниво [ 1 ]"; case 2:levelname = "Админ ниво [ 2 ]"; case 3:levelname = "Админ ниво [ 3 ]"; case 4:levelname = "Админ ниво [ 4 ]"; case 5:levelname = "[ Гл.Администратор ]"; case 6:levelname = "[ Заместник-началник ]"; case 7:levelname = "[ Собственик ]"; default: continue; } adminids++; new strpart[69]; format(strpart, 69, "{FFFFFF}%s {FF0000}%s (ID: %d)\n\r", levelname, pname, i); strcat(estr, strpart, sizeof estr); } if(adminids) { ShowPlayerDialog(playerid, 21323123, DIALOG_STYLE_MSGBOX, "Онлайн Администратори", estr,"ОК",#); } else { //admins not found } return 1; }