CMD:admins(playerid, params[])
{
new id;
new n[MAX_PLAYER_NAME];
new count = 0, string19[256];
GetPlayerName(id,n,sizeof(n));
for(new i = 0; i < MAX_PLAYERS; i ++)
{
if(IsPlayerConnected(i))
{
if(pInfo[id][Adminlevel] == 1)
{
format(string19, sizeof(string19), "Trial Moderator : %s (%i)",n ,playerid);
count++;
}
if(pInfo[id][Adminlevel] == 2)
{
format(string19, sizeof(string19), "Moderator : %s (%i)",n ,playerid);
count++;
}
if(pInfo[id][Adminlevel] == 3)
{
format(string19, sizeof(string19), "Admin : %s (%i)",n ,playerid);
count++;
}
if(pInfo[id][Adminlevel] == 4)
{
format(string19, sizeof(string19), "Server Manager : %s (%i)",n ,playerid);
count++;
}
if(pInfo[id][Adminlevel] == 5)
{
format(string19, sizeof(string19), "Server Owner : %s (%i)",n ,playerid);
count++;
}
}
}
if(count == 0)
{
SendClientMessage(playerid, COLOR_GREEN, "");
SendClientMessage(playerid, COLOR_GREEN, "|======== Online Admins =======|");
SendClientMessage(playerid, COLOR_WHITE, "- No Admins Online at Time!");
SendClientMessage(playerid, COLOR_GREEN, "|==============================|");
SendClientMessage(playerid, COLOR_GREEN, "");
}
else
{
SendClientMessage(playerid, COLOR_GREEN, "");
SendClientMessage(playerid, COLOR_GREEN, "|======== Online Admins =======|");
SendClientMessage(playerid, COLOR_WHITE, string19);
SendClientMessage(playerid, COLOR_GREEN, "|==============================|");
SendClientMessage(playerid, COLOR_GREEN, "");
}
return 1;
}
if(pInfo[id][Adminlevel] == 5)
{
format(string19, sizeof(string19), "Server Owner : %s (%i)",n ,playerid);
SendClientMessage(playerid, COLOR_WHITE, string19);
count++;
}
CMD:admins(playerid, params[])
{
new n[MAX_PLAYER_NAME+1];
new count = 0, string19[128];
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
GetPlayerName(i, n, sizeof(n));
switch(pInfo[i][Adminlevel])
{
case 1:
{
format(string19, sizeof(string19), "Trial Moderator : %s (%i)", n , i);
count++;
}
case 2:
{
format(string19, sizeof(string19), "Moderator : %s (%i)", n , i);
count++;
}
case 3:
{
format(string19, sizeof(string19), "Admin : %s (%i)", n , i);
count++;
}
case 4:
{
format(string19, sizeof(string19), "Server Manager : %s (%i)", n , i);
count++;
}
case 5:
{
format(string19, sizeof(string19), "Server Owner : %s (%i)", n , i);
count++;
}
}
}
}
if(!count)
{
SendClientMessage(playerid, COLOR_GREEN, "");
SendClientMessage(playerid, COLOR_GREEN, "|======== Online Admins =======|");
SendClientMessage(playerid, COLOR_WHITE, "- No Admins Online at Time!");
SendClientMessage(playerid, COLOR_GREEN, "|==============================|");
SendClientMessage(playerid, COLOR_GREEN, "");
}
else
{
SendClientMessage(playerid, COLOR_GREEN, "");
SendClientMessage(playerid, COLOR_GREEN, "|======== Online Admins =======|");
SendClientMessage(playerid, COLOR_WHITE, string19);
SendClientMessage(playerid, COLOR_GREEN, "|==============================|");
SendClientMessage(playerid, COLOR_GREEN, "");
}
return true;
}
CMD:admins(playerid, params[]) { new count = 0, string19[256]; SendClientMessage(playerid, COLOR_GREEN, ""); SendClientMessage(playerid, COLOR_GREEN, "|======== Online Admins =======|"); for(new i = 0; i < MAX_PLAYERS; i ++) { if(IsPlayerConnected(i)) { if(pInfo[i][Adminlevel] == 1) { format(string19, sizeof(string19), "Trial Moderator : %s (%i)",GetName(i), i); SendClientMessage(playerid, COLOR_WHITE, string19); count++; } if(pInfo[i][Adminlevel] == 2) { format(string19, sizeof(string19), "Moderator : %s (%i)",GetName(i), i); SendClientMessage(playerid, COLOR_WHITE, string19); count++; } if(pInfo[i][Adminlevel] == 3) { format(string19, sizeof(string19), "Admin : %s (%i)",GetName(i), i); SendClientMessage(playerid, COLOR_WHITE, string19); count++; } if(pInfo[i][Adminlevel] == 4) { format(string19, sizeof(string19), "Server Manager : %s (%i)",GetName(i), i); SendClientMessage(playerid, COLOR_WHITE, string19); count++; } if(pInfo[i][Adminlevel] == 5) { format(string19, sizeof(string19), "Server Owner : %s (%i)",GetName(i), i); SendClientMessage(playerid, COLOR_WHITE, string19); count++; } } } if(count == 0) SendClientMessage(playerid, COLOR_WHITE, "- No Admins Online at this Time!"); SendClientMessage(playerid, COLOR_GREEN, "|==============================|"); SendClientMessage(playerid, COLOR_GREEN, ""); return 1; } stock GetName(playerid) { new pname[MAX_PLAYER_NAME]; GetPlayerName(playerid, pname, MAX_PLAYER_NAME); return pname; }
// Variables enum pInfo { AdminRank, }; // Stock - Setting out the Administration ranks stock GetAdminRank(playerid) { new adminrank[128]; for(new i = 0; i < MAX_PLAYERS; i++) { switch(pInfo[I][AdminLevel] { case 0: ""; case 1: //designated Admin rank here case 2: //designated Admin rank here case 3: //designated Admin rank here case 4: //designated Admin rank here case 5: // designated Admin rank here } return adminrank; } CMD:admins(playerid, params[]) { format(string, sizeof(string), "[%s] %s [%d]", GetAdminRank(playerid), n, playerid); SendClientMessage(playerid, colour, string); return 1; }
enum pInfo { pPass, pCash, pAdmin, pSkin, pKills, pDeaths } new PlayerInfo[MAX_PLAYERS][pInfo]; CMD:setadmin(playerid, params[]) { new pID, value; if(!IsPlayerAdmin(playerid)) return 0; else if(sscanf(params, "ui", pID, value)) return SendClientMessage(playerid, -1, "Usage: /setadmin (id) (level)"); else if(value < 0 || value > 5) return SendClientMessage(playerid, -1, "Only levels 0-5"); else if(pID == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "Player Is Not Currently Connected"); else { new string[128], string1[128], target[MAX_PLAYER_NAME], pName[MAX_PLAYER_NAME]; GetPlayerName(playerid, pName, sizeof(pName)); GetPlayerName(pID, target, sizeof(target)); format(string, sizeof(string), "You have set %s Admin level to %i", target, value); SendClientMessage(playerid, -1, string); format(string, sizeof(string), "Your Admin level has been set to %i by %s", value, pName); SendClientMessage(pID, -1, string1); PlayerInfo[pID][pAdmin] = value; } return 1; } #define DIALOG_MSG 2 CMD:admins(playerid, params[]) { #pragma unused params //.. new string[41*12], name[24], sformat[41], admins; // string[41*12] = max 12 admins show in dialog. //.. for(new i; i != MAX_PLAYERS; i++) { if(IsPlayerConnected(i)) { if(PlayerInfo[i][pAdmin] >= 1) { GetPlayerName(i, name, sizeof(name)); format(sformat, sizeof(sformat), "* %s Level %d.\n", name, PlayerInfo[i][pAdmin]); strcat(string, sformat); admins = admins+1; } } } if(admins < 1) ShowPlayerDialog(playerid, DIALOG_MSG, DIALOG_STYLE_MSGBOX, "Info admins", "There are no administrators connected.", "Close", ""); else if(admins >= 1) ShowPlayerDialog(playerid, DIALOG_MSG, 0, "Info admins", string, "Close", ""); return true; }
There were mistakes with playerid, the loop's variable 'i' should be the playerid, not variable 'id'. Your variable 'id' would only show player ID 0 since the default variable value is 0. You CAN use playerid parameter. I also did some changes with admin level checks, switch() statement is better than using many if-else statements. String size doesn't needs to be 256, I've lowered it to 128, and I'm sure that's even higher too.
pawn Code:
|
You should format and SendClientMessage for every admin, like:
pawn Code:
|
Thanks For Editing , But Only Show 1 Admin Name Again , And If Player(He Isn't Admin) Type /admins , He Name Will In The Admin List , But He Isn't Admin , Is This A Bug Or? I Want That /admins We Can See More Admins Online , No Only 1. If You Understand Me , Thanks.
Yes , I Tried But No Working , Same Problem Like iZN's Replied. The Problem Is : You're Not Admin But You Name Still In The Admin List. Thanks For You Replied Too. I Just Want That /admins Can Show More Admins Online , And Non-Admin Player's Name No On The Admin List Too. Sorry About My Bad English. |
Code:
..... Also, do you use MySQL or dini for saving? |
You're trying to check if playerid 0 is an admin at all times, since you declared "id" to use, which is set to 0 by default.
Delete "id", and use "i" from the loop instead. |