20.03.2015, 10:42
(
Last edited by iZN; 20/03/2015 at 12:40 PM.
Reason: https://sampforum.blast.hk/showthread.php?pid=3408363#pid3408363&postcount=11
)
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:
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;
}