Show admins online problem -
KillerStrike23 - 21.12.2016
Hello guys its been a long time since i used the forum today i faced a problem "which is the cmd only shows one admin not more"
pawn Код:
CMD:admins(playerid,params[])
{
#pragma unused params
new count = 0;
new string[5521];
new ChangeColor[100];
new AdmRank[128];
new playername[MAX_PLAYER_NAME];
for(new i = 0; i < MAX_PLAYERS; i++)
{
if (IsPlayerConnected(i))
{
if(PlayerInfo[i][Level] >= 1 && PlayerInfo[i][Hide] == 0)
{
if(IsPlayerAdmin(i))
{
AdmRank = "RCON Administrator";
ChangeColor = "{FF0000}";
}
else
{
switch(PlayerInfo[i][Level])
{
case 1:
{
AdmRank = "Trial Moderator";
ChangeColor = "{20B2AA}";
}
case 2:
{
AdmRank = "Moderator";
ChangeColor = "{33AA33}";
}
case 3:
{
AdmRank = "Trial Administrator";
ChangeColor = "{FFFF00}";
}
case 4:
{
AdmRank = "Administrator";
ChangeColor = "{FF9900}";
}
case 5:
{
AdmRank = "Senior Administrator";
ChangeColor = "{00D5FF}";
}
case 6:
{
AdmRank = "Professional Administrator";
ChangeColor = "{808080}";
}
}
}
GetPlayerName(i, playername, MAX_PLAYER_NAME);
format(string, sizeof(string), "%sLevel: %d - %s (Id:%i) | %s |",ChangeColor, PlayerInfo[i][Level], playername, i, AdmRank);
ShowPlayerDialog(playerid, 32112, DIALOG_STYLE_MSGBOX, "{FF0000}SFTDM - Online Admins", string, "OK", "");
count++;
}
}
}
if(count == 0) ShowPlayerDialog(playerid, 3212, DIALOG_STYLE_MSGBOX, "{FF0000}SFTDM - Online Admins", "{FFFFFF}There are currently no Admins online" , "OK", "");
return 1;
}
thanks in advance
Re: Show admins online problem -
SyS - 21.12.2016
The dialog should be shown outside the loop.In an else condition of if(count==0)
Re: Show admins online problem -
BroZeus - 21.12.2016
That is because you have placed ShowPlayerDialog inside the loop! so as soon as it finds one admin it shows it directly without adding other online admins info in the string
Use this script it has some more corrections other than ShowPlayerDialog thing :
PHP код:
CMD:admins(playerid,params[])
{
#pragma unused params
new count = 0;
new string[5521];
new ChangeColor[100];
new AdmRank[128];
new playername[MAX_PLAYER_NAME];
for(new i = 0; i < MAX_PLAYERS; i++)
{
if (IsPlayerConnected(i))
{
if(PlayerInfo[i][Level] >= 1 && PlayerInfo[i][Hide] == 0)
{
if(IsPlayerAdmin(i))
{
AdmRank = "RCON Administrator";
ChangeColor = "{FF0000}";
}
else
{
switch(PlayerInfo[i][Level])
{
case 1:
{
AdmRank = "Trial Moderator";
ChangeColor = "{20B2AA}";
}
case 2:
{
AdmRank = "Moderator";
ChangeColor = "{33AA33}";
}
case 3:
{
AdmRank = "Trial Administrator";
ChangeColor = "{FFFF00}";
}
case 4:
{
AdmRank = "Administrator";
ChangeColor = "{FF9900}";
}
case 5:
{
AdmRank = "Senior Administrator";
ChangeColor = "{00D5FF}";
}
case 6:
{
AdmRank = "Professional Administrator";
ChangeColor = "{808080}";
}
}
}
GetPlayerName(i, playername, MAX_PLAYER_NAME);
format(string, sizeof(string), "%s%sLevel: %d - %s (Id:%i) | %s | \n",string,ChangeColor, PlayerInfo[i][Level], playername, i, AdmRank);
count++;
}
}
}
if(count == 0) ShowPlayerDialog(playerid, 3212, DIALOG_STYLE_MSGBOX, "{FF0000}SFTDM - Online Admins", "{FFFFFF}There are currently no Admins online" , "OK", "");
else ShowPlayerDialog(playerid, 32112, DIALOG_STYLE_MSGBOX, "{FF0000}SFTDM - Online Admins", string, "OK", "");
return 1;
}
Re: Show admins online problem -
KillerStrike23 - 21.12.2016
ah okey thanks for explaining the idea i will test the code right now +rep
Re: Show admins online problem -
KillerStrike23 - 21.12.2016
i have another problem i don't want to make another thread
pawn Код:
CMD:level2(playerid,params[]) {
#pragma unused params
new string[1900];
if(PlayerInfo[playerid][Level] >= 2) {
CMDMessageToAdmins(playerid,"LEVEL2");
strcat(string, "{FFFFFF}/mute /unmute /muted /screen /laston /lspec /lspecvehicle /lspecoff", 1900);
strcat(string, "{FFFFFF}/jetpack /flip /vgoto /lgoto /fu /warn /aslap /jailed /frozen", 1900);
strcat(string, "{FFFFFF}/giveweapon /setcolor /lockcar /unlockcar /burn /spawn /olaston", 1900);
ShowPlayerDialog(playerid, 903021, DIALOG_STYLE_MSGBOX, "{FF0000}SFTDM - LEVEL (2)", string,"OK","");
} else return ShowPlayerDialog(playerid, 90321, DIALOG_STYLE_MSGBOX, "{FF0000}SFTDM - ERROR MSG", HighLevel,"OK","");
return 1;
}
no dialog is shown why?
Re: Show admins online problem -
oMa37 - 21.12.2016
Change the dialog ID, Max dialog ID is 32767.