Quote:
Originally Posted by [MWR]Blood
This is from my script...
pawn Код:
CMD:admins(playerid,params[]) { #pragma unused params new string[150],count = 0,AdminPos[30]; for(new i = 0;i < MAX_PLAYERS; i++) { if(IsPlayerConnected(i)) { if(PInfo[i][Level] >= 1) { if(PInfo[i][Level] == 1) AdminPos=""cwhite"VIP"; else if(PInfo[i][Level] == 2) AdminPos=""cyellow"Moderator"; else if(PInfo[i][Level] == 3) AdminPos=""cyellow"Administrator"; else if(PInfo[i][Level] == 4) AdminPos=""cgreen"Head Administrator"; else if(PInfo[i][Level] == 5) AdminPos=""cred"Owner"; format(string,sizeof(string),"%s"cgreen2"%s(ID:%d) "cyellow2"- "cblue"%s \n",string,GetPName(i),i,AdminPos); ShowPlayerDialog(playerid,Adminsdialog,0,""cwhite"Admins Online",string,"OK",""); count++; } } else if(count == 0) { ShowPlayerDialog(playerid,Adminsdialog,0,"Admins Online",""cred"No Admins Online!","OK",""); } } return 1; }
|
You can better use foreach and delete IsPlayerConnected (you don't need that anymore since 0.3 and foreach is much faster, and loops only through connected players instead of the 500 slots that may not be filled). Also use a switch statement, it's much more clearer (I don't think it would affect the speed though, but its good practice).