[ + rep ] guys i need help with this command
#1

Код:
Problem? : BUG
Description: It wont appear

pawn Код:
CMD:admins(playerid,params[])
{
    new aName[MAX_PLAYER_NAME], amsg[128];
    new count;
    for(new i=0;i<MAX_PLAYERS;i++)
    {
        if(!IsPlayerConnected (i) || pData[i][pAdmin] < MODERATOR) continue;
        count ++;
        GetPlayerName(i,aName,sizeof(aName));
        {
            SendClientMessage(playerid,color_green,"------<< Online Administrators >>------");
            if(IsPlayerAdmin(i))
            {
                format(amsg,sizeof(amsg),"[ %s ] == "#cowner"RCON Administrator",aName);
                SendClientMessage(playerid,color_white,amsg);
            }
            switch(pData[i][pAdmin])
            {
                case MODERATOR:
                {
                    format(amsg,sizeof(amsg),"[ %s ] == "#cmod"MODERATOR",aName);
                    SendClientMessage(playerid,color_white,amsg);
                }
                case ADMINISTRATOR:
                {
                    format(amsg,sizeof(amsg),"[ %s ] == "#cadmin"ADMINISTRATOR",aName);
                    SendClientMessage(playerid,color_white,amsg);
                }
                case OWNER:
                {
                    format(amsg,sizeof(amsg),"[ %s ] == "#cowner"OWNER / DEVELOPER",aName);
                    SendClientMessage(playerid,color_white,amsg);
                }
            }
            if(!count) return SendClientMessage(playerid,color_red,"No Online Server Workers");
        }
    }
    return 1;
}
Reply
#2

You gotta set your count variable to 0, that's at least how I did it!

Then try this:

PHP код:
new count 0
and instead of:

PHP код:
if(!count) return SendClientMessage(playerid,color_red,"No Online Server Workers"); 
try this:

PHP код:
if(count == 0)
    
SendClientMessage(playerid,COLOR_RED,"No Admins online!"); 
Reply
#3

still same wont detect
Reply
#4

*Sigh*
I still don't know why you even did it in such a complicated way? Why the hell you switchin' around? Make it easier, look how mine's done:

PHP код:
COMMAND:admins(playerid,params[])
{
    new 
count 0;
    new 
string[128];
    
SendClientMessage(playerid,COLOR_RED,"");
    
SendClientMessage(playerid,TEAM_GROVE_COLOR,"______________________|ONLINE ADMINS|______________________");
    
SendClientMessage(playerid,COLOR_RED,"");
    for(new 
0MAX_PLAYERSi++)
    {
        if(
IsPlayerConnected(i))
        {
            if(
PlayerInfo[i][pAdmin] > 0)
            {
                if(
PlayerInfo[i][pAdmin] == 1)
                {
                    
AdminRank "Helper";
                }
                else if(
PlayerInfo[i][pAdmin] == 2)
                {
                    
AdminRank "Basic Moderator";
                }
                else if(
PlayerInfo[i][pAdmin] == 3)
                {
                    
AdminRank "Professional Moderator";
                }
                else if(
PlayerInfo[i][pAdmin] == 4)
                {
                    
AdminRank "Master Moderator";
                }
                else if(
PlayerInfo[i][pAdmin] == 5)
                {
                    
AdminRank "Basic Administrator";
                }
                else if(
PlayerInfo[i][pAdmin] == 6)
                {
                    
AdminRank "Advanced Administrator";
                }
                else if(
PlayerInfo[i][pAdmin] == 7)
                {
                    
AdminRank "Professional Administrator";
                }
                else if(
PlayerInfo[i][pAdmin] == 8)
                {
                    
AdminRank "Master Administrator";
                }
                else if(
PlayerInfo[i][pAdmin] == 9)
                {
                    
AdminRank "RCON Helper";
                }
                else if(
PlayerInfo[i][pAdmin] >= 10)
                {
                    
AdminRank "RCON Master Administrator";
                }
                new 
aName[MAX_PLAYER_NAME];
                
GetPlayerName(i,aName,sizeof(aName));
                
format(stringsizeof(string), "Level: %d | Name: %s (ID:%i) | Rank: %s "PlayerInfo[i][pAdmin], aName,i,AdminRank);
                
SendClientMessage(playerid,COLOR_ORANGE,string);
                
count++;
            }
        }
    }
    if(
count == 0)
    
SendClientMessage(playerid,COLOR_RED,"No Admins online!");
    
SendClientMessage(playerid,TEAM_GROVE_COLOR,"____________________________________________________________");
    return 
1;

NO, don't copy-paste everything now, and don't steal! (^^)
What I meant was, why don't you just take the info from the enum? It's easier, and also the "else if"-statement reduces your work!
Reply
#5

pawn Код:
CMD:admins(playerid,params[])
{
    new aName[MAX_PLAYER_NAME], amsg[128];
    new count = 0;
    for(new i=0;i<MAX_PLAYERS;i++)
    {
        if(!IsPlayerConnected (i))
        {
             if(pData[i][pAdmin] != 0)
             {
        GetPlayerName(i,aName,sizeof(aName));
        {
            SendClientMessage(playerid,color_green,"------<< Online Administrators >>------");
            if(IsPlayerAdmin(i))
            {
                format(amsg,sizeof(amsg),"[ %s ] == "#cowner"RCON Administrator",aName);
                SendClientMessage(playerid,color_white,amsg);
            }
            if(pData[i][pAdmin] == 1)
            {
                    format(amsg,sizeof(amsg),"[ %s ] == "#cmod"MODERATOR",aName);
                    SendClientMessage(playerid,color_white,amsg);
                }
            if(pData[i][pAdmin] == 2)
                {
                    format(amsg,sizeof(amsg),"[ %s ] == "#cadmin"ADMINISTRATOR",aName);
                    SendClientMessage(playerid,color_white,amsg);
                }
            if(pData[i][pAdmin] == 3)
                {
                    format(amsg,sizeof(amsg),"[ %s ] == "#cowner"OWNER / DEVELOPER",aName);
                    SendClientMessage(playerid,color_white,amsg);
                }
                count ++;
            }
            if(count == 0) return SendClientMessage(playerid,color_red,"No Online Server Workers");
            }
        }
        }
    }
    return 1;
}
Reply
#6

Tanush did just the same as me, see? He took the infos from the enum where you store the info!

I just didn't want to make you everythin 100% clearly, so you learn from it!
But anyways, it's the same way as I showed!
Reply
#7

umm wait
i use pAdmin on my enum

i always got errors and warnings
Reply
#8

Post your command with the error-lines commented!
Reply
#9

Quote:
Originally Posted by Twisted_Insane
Посмотреть сообщение
Tanush did just the same as me, see? He took the infos from the enum where you store the info!

I just didn't want to make you everythin 100% clearly, so you learn from it!
But anyways, it's the same way as I showed!
I didnt copy you, you just posted your server's /admins or whatever. I edited RicaNiel code...
Quote:
Originally Posted by RicaNiel
Посмотреть сообщение
umm wait
i use pAdmin on my enum

i always got errors and warnings
Try the post i did
Reply
#10

When the hell did I say you copy? I said, that you've done it in the same way/method like my CMD, you've just put Rica's stuff into it instead of mine! Try to read before you comment, dude!

Also, I think that Rica learned from here mistake now, and she knows what do to!^^
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)