no admins dialog problem -
MrakBuster - 02.02.2018
Hello everybody, I am having here a little problem with my /admins command, first of all, I will throw my code:
Код:
CMD:admins(playerid, params[])
{
new online;
for(new i = 0; i < MAX_PLAYERS; i++)
{
online ++;
new level[512], string[256], lel[23];
if(IsPlayerConnected(i) && PlayerInfo[i][pAdmin] > 0)
{
if(online == 0) return ShowPlayerDialog(playerid, DIALOG_NOADMINS, DIALOG_STYLE_MSGBOX, "Online administrбtoři", "Momentбlně na serveru nenн přнtomen ћбdnэ administrбtor", "Ok", "");
format(lel, sizeof(lel), "%d", online);
SendClientMessageToAll(ADMIN, lel);
switch(PlayerInfo[i][pAdmin])
{
case 1: level = "Administrбtor-kandidбt";
case 2: level = "Administrбtor";
case 3: level = "Vedoucн Administrбtor";
case 4: level = "Hlavnн Administrбtor";
case 5: level = "Sprбvce serveru";
}
format(string, sizeof(string), "%s %s {FFCC00}/pm %d <sem vpiљte vбљ dotaz>\n", GetName(i), level, i);
ShowPlayerDialog(playerid, DIALOG_ADMINS, DIALOG_STYLE_MSGBOX, "Online administrбtoři", string, "Ok", "");
}
}
return 1;
}
So, and the thing is. I want, so when there is no player with pAdmin higher than 0 online, it will simply just show dialog, that there is no admin online.
What i did, i created a variable storing value in it, which the value increased by script finding out, that there is admin available.
I am not sure if what i am saying actually makes sense, or the script is total bullshit, however if any of you guys understand what I mean and could throw some solution on me, i would appreciate it more than anything. If best with explanation.
Re: no admins dialog problem -
DelK - 02.02.2018
try.
PHP код:
CMD:admins(playerid, params[])
{
new online = 0;
for(new i = 0; i < MAX_PLAYERS; i++)
{
online ++;
new level[512], string[256], lel[23];
if(IsPlayerConnected(i) && PlayerInfo[i][pAdmin] > 0)
{
format(lel, sizeof(lel), "%d", online);
SendClientMessageToAll(ADMIN, lel);
switch(PlayerInfo[i][pAdmin])
{
case 1: level = "Administrбtor-kandidбt";
case 2: level = "Administrбtor";
case 3: level = "Vedoucн Administrбtor";
case 4: level = "Hlavnн Administrбtor";
case 5: level = "Sprбvce serveru";
}
format(string, sizeof(string), "%s %s {FFCC00}/pm %d <sem vpiљte vбљ dotaz>\n", GetName(i), level, i);
ShowPlayerDialog(playerid, DIALOG_ADMINS, DIALOG_STYLE_MSGBOX, "Online administrбtoři", string, "Ok", "");
online++;
}
}
if(online == 0) return ShowPlayerDialog(playerid, DIALOG_NOADMINS, DIALOG_STYLE_MSGBOX, "Online administrбtoři", "Momentбlně na serveru nenн přнtomen ћбdnэ administrбtor", "Ok", "");
return 1;
}
Re: no admins dialog problem -
MrakBuster - 02.02.2018
Thank you for trying, however your solution did not help. Still no showing dialog.
Re: no admins dialog problem -
Mugala - 02.02.2018
Delk's code is not correct, online++ must be placed after this
PHP код:
if(IsPlayerConnected(i) && PlayerInfo[i][pAdmin] > 0)
so here is a fixed code.
PHP код:
CMD:admins(playerid, params[])
{
new online;
for(new i = 0; i < MAX_PLAYERS; i++)
{
new level[512], string[256], lel[23];
if(IsPlayerConnected(i) && PlayerInfo[i][pAdmin] > 0)
{
online ++;
format(lel, sizeof(lel), "%d", online);
SendClientMessageToAll(ADMIN, lel);
switch(PlayerInfo[i][pAdmin])
{
case 1: level = "Administrбtor-kandidбt";
case 2: level = "Administrбtor";
case 3: level = "Vedoucн Administrбtor";
case 4: level = "Hlavnн Administrбtor";
case 5: level = "Sprбvce serveru";
}
format(string, sizeof(string), "%s %s {FFCC00}/pm %d <sem vpiљte vбљ dotaz>\n", GetName(i), level, i);
}
if(online > 0) ShowPlayerDialog(playerid, DIALOG_ADMINS, DIALOG_STYLE_MSGBOX, "Online administrбtoři", string, "Ok", "");
else ShowPlayerDialog(playerid, DIALOG_NOADMINS, DIALOG_STYLE_MSGBOX, "Online administrбtoři", "Momentбlně na serveru nenн přнtomen ћбdnэ administrбtor", "Ok", "");
}
return 1;
}
Re: no admins dialog problem -
jasperschellekens - 02.02.2018
This will work:
PHP код:
CMD:admins(playerid, params[])
{
new online;
for(new i = 0; i < MAX_PLAYERS; i++)
{
new level[512], string[256], lel[23];
if(IsPlayerConnected(i) && PlayerInfo[i][pAdmin] > 0)
{
format(lel, sizeof(lel), "%d", online);
SendClientMessageToAll(ADMIN, lel);
switch(PlayerInfo[i][pAdmin])
{
case 1: level = "Administrбtor-kandidбt";
case 2: level = "Administrбtor";
case 3: level = "Vedoucн Administrбtor";
case 4: level = "Hlavnн Administrбtor";
case 5: level = "Sprбvce serveru";
}
format(string, sizeof(string), "%s %s {FFCC00}/pm %d <sem vpiљte vбљ dotaz>\n", GetName(i), level, i);
ShowPlayerDialog(playerid, DIALOG_ADMINS, DIALOG_STYLE_MSGBOX, "Online administrбtori", string, "Ok", "");
online ++;
}
}
if(online==0) return ShowPlayerDialog(playerid, DIALOG_ADMINS, DIALOG_STYLE_MSGBOX, "Online administrбtori", "No online administrбtori", "Ok", "");
return 1;
}
Re: no admins dialog problem -
Mugala - 02.02.2018
Quote:
Originally Posted by jasperschellekens
This will work:
|
how it's going to work when u already broke code here?
PHP код:
if(IsPlayerConnected(i) && PlayerInfo[i][pAdmin] > 0)
{
if(online == 0) return ShowPlayerDialog(playerid, DIALOG_NOADMINS, DIALOG_STYLE_MSGBOX, "Online administrбtori", "Momentбlne na serveru nenн prнtomen ћбdnэ administrбtor", "Ok", "");
}
Re: no admins dialog problem -
DarkBr - 02.02.2018
be careful when checking values in a loop and returning soon, if you need to break in, you can break it.
Код:
COMMAND:admins(playerid, params [] )
{
new
online=0,
level[30],
string[256],
lel[23]
;
for(new J = GetMaxPlayers(), i; i < J; i++ )
{
if(IsPlayerConnected(i) && PlayerInfo[i][pAdmin])
{
online ++;
/*
format(lel, sizeof(lel), "%d", online);
SendClientMessageToAll(ADMIN, lel);
*/
switch(PlayerInfo [ i ][ pAdmin ] ) {
case 1: level = "Administrбtor-kandidбt";
case 2: level = "Administrбtor";
case 3: level = "Vedoucн Administrбtor";
case 4: level = "Hlavnн Administrбtor";
case 5: level = "Sprбvce serveru";
}
format(string, sizeof(string), "%s %s {FFCC00}/pm %d <sem vpiљte vбљ dotaz>\n\r", GetName(i), level, i);
}
}
if(!online)
{
//not found admins..
ShowPlayerDialog(playerid, DIALOG_NOADMINS, DIALOG_STYLE_MSGBOX, "Online administrбtori", "Momentбlne na serveru nenн prнtomen ћбdnэ administrбtor", "Ok", "");
}
else
{
ShowPlayerDialog(playerid, DIALOG_ADMINS, DIALOG_STYLE_MSGBOX, "Online administrбtoři", string, "Ok", "");
}
return 1;
}