/admins bug
#1

I have a problem with ym /admins command when i get in the players rank changes to Server Owner but when im out he is back to his normal rank

PHP код:
CMD:admins(playeridparams[])
{
    new 
id;
    new 
n[MAX_PLAYER_NAME];
    new 
count 0string19[256];
    
GetPlayerName(id,n,sizeof(n));
    for(new 
0MAX_PLAYERS++)
    {
    if(
IsPlayerConnected(i))
    {
    if(
GetPVarInt(i"PlayerAdminLevel") < 1)
    {
    
format(string19sizeof(string19), "Trial Moderator : %s (%i)",,playerid);
    
count++;
    }
    if(
GetPVarInt(i"PlayerAdminLevel") < 2)
    {
    
format(string19sizeof(string19), "Moderator : %s (%i)",,playerid);
    
count++;
    }
    if(
GetPVarInt(i"PlayerAdminLevel") < 3)
    {
    
format(string19sizeof(string19), "Administrator : %s (%i)",,playerid);
    
count++;
    }
    if(
GetPVarInt(i"PlayerAdminLevel") < 4)
    {
    
format(string19sizeof(string19), "Chief Administrator : %s (%i)",,playerid);
    
count++;
    }
    if(
GetPVarInt(i"PlayerAdminLevel") < 5)
    {
    
format(string19sizeof(string19), "Server Owner : %s (%i)",,playerid);
    
count++;
    }
    }
    }
    if(
count == 0)
    {
    
SendClientMessage(playeridCOLOR_GREEN"");
    
SendClientMessage(playeridCOLOR_GREEN"|======== Online Admins =======|");
    
SendClientMessage(playeridCOLOR_WHITE"- No Admins Online at Time!");
    
SendClientMessage(playeridCOLOR_GREEN"|==============================|");
    
SendClientMessage(playeridCOLOR_GREEN"");
    }
    else
    {
    
SendClientMessage(playeridCOLOR_GREEN"");
    
SendClientMessage(playeridCOLOR_GREEN"|======== Online Admins =======|");
    
SendClientMessage(playeridCOLOR_WHITEstring19);
    
SendClientMessage(playeridCOLOR_GREEN"|==============================|");
    
SendClientMessage(playeridCOLOR_GREEN"");
    }
    return 
1;

Reply
#2

The problem isn't in the command, its just showing online admins, Please show us the code where you saves the player admin level , or if you didn't than save it, by using Y INI, its much easy/simple.
Reply
#3

Basic logic operators: < means smaller than, > means greater than. Although in this situation it is much better to use a switch instead because there is no fall-through.

PHP код:
new title[24];
        
switch(
GetPVarInt(i"PlayerAdminLevel"))
{
    case 
1title "Trial Moderator";
    case 
2title "Moderator";
    case 
3title "Administrator";
    case 
4title "Chief Administrator";
    case 
5title "Server Owner";
}

format(string19sizeof(string19), "%s : %s (%i)"titlenplayerid);
count++; 
Much shorter, much cleaner, less unnecessary repetition.
Reply
#4

Quote:
Originally Posted by Vince
Посмотреть сообщение
Basic logic operators: < means smaller than, > means greater than. Although in this situation it is much better to use a switch instead because there is no fall-through.

PHP код:
new title[24];
        
switch(
GetPVarInt(i"PlayerAdminLevel"))
{
    case 
1title "Trial Moderator";
    case 
2title "Moderator";
    case 
3title "Administrator";
    case 
4title "Chief Administrator";
    case 
5title "Server Owner";
}
format(string19sizeof(string19), "%s : %s (%i)"titlenplayerid);
count++; 
Much shorter, much cleaner, less unnecessary repetition.
This save much unnecessary code:

Код:
new const AdminLevels[6][] = {
	{"User"},
	{"Trial Moderator"},
	{"Moderator"},
	{"Administrator"},
	{"Chief Administrator"},
	{"Server Owner"},
}
Код:
AdminsLevels[GetPVarInt(i, "PlayerAdminLevel")]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)