/staff command repeats itself.
#1

Hi

I have madfe a /staff command and for some reason it only shows your name (on everything that is) and repeats itself over and over. This is teh code:

PHP код:
command(staffplayeridparams[])
{
    
#pragma unused params
    
new string[128];
    for(new 
0MAX_PLAYERSi++)
    {
        if(
IsPlayerConnected(playerid))
        {
            
SendClientMessage(playeridCOLOR_ORANGE". : : Administrators : : .");
            if(
PlayerInfo[playerid][pAdmin] >= 1)
            {
                
format(stringsizeof(string), "Name: %s{A9C4E4}: (Level %d) {%s}"RPName(playerid), PlayerInfo[playerid][pAdmin], GetAwayStatus(playerid));
                
SendClientMessage(playeridGREYstring);
            }
            
SendClientMessage(playeridCOLOR_ORANGE". : : Moderators : : .");
            if(
PlayerInfo[playerid][pModerator] >= 1)
            {
                
format(stringsizeof(string), "Name: %s{A9C4E4} {%s}"RPName(playerid), GetAwayStatus(i));
                
SendClientMessage(playeridGREYstring);
            }
            
SendClientMessage(playeridCOLOR_ORANGE". : : Helpers : : .");
            if(
PlayerInfo[playerid][pHelper] >= 1)
            {
                
format(stringsizeof(string), "Name: %s{A9C4E4} {%s}"RPName(playerid), GetAwayStatus(playerid));
                
SendClientMessage(playeridGREYstring);
            }
        }
    }

Reply
#2

You do not need that code "#pragma unused params".
Also you are using loops but you never used the loop, you instead used playerid (I replaced them with i).

Another note, The message you put inside the loop excluding the part of listing the admins, will spam the screen. (": : Admins : :, etc..")

PHP код:
command(staffplayeridparams[])
{
    new 
string[128];

    for(new 
0MAX_PLAYERSi++)
    {
        if(
IsPlayerConnected(i))
        {
            
SendClientMessage(playeridCOLOR_ORANGE". : : Administrators : : .");
            if(
PlayerInfo[i][pAdmin] >= 1)
            {
                
format(stringsizeof(string), "Name: %s{A9C4E4}: (Level %d) {%s}"RPName(i), PlayerInfo[i][pAdmin], GetAwayStatus(i));
                
SendClientMessage(playeridGREYstring);
            }
            
SendClientMessage(playeridCOLOR_ORANGE". : : Moderators : : .");
            if(
PlayerInfo[i][pModerator] >= 1)
            {
                
format(stringsizeof(string), "Name: %s{A9C4E4} {%s}"RPName(i), GetAwayStatus(i));
                
SendClientMessage(iGREYstring);
            }
            
SendClientMessage(playeridCOLOR_ORANGE". : : Helpers : : .");
            if(
PlayerInfo[i][pHelper] >= 1)
            {
                
format(stringsizeof(string), "Name: %s{A9C4E4} {%s}"RPName(i), GetAwayStatus(i));
                
SendClientMessage(playeridGREYstring);
            }
        }
    }

Reply
#3

try this: i have made the format of strings at the loop but sending the message out from the loop ,

also you define the loop with i [ check all players stats ] and on player check admin,moderator,and helper you used [playerid] here is the wrong, you have to use it as [i]

PHP код:
command(staffplayeridparams[])
{
    new 
string[128],string2[128],string3[128];
    for(new 
0MAX_PLAYERSi++)
    {
        if(
IsPlayerConnected(i))
        {
            if(
PlayerInfo[i][pAdmin] >= 1)
            {
                
format(stringsizeof(string), "Name: %s{A9C4E4}: (Level %d) {%s}"RPName(i), PlayerInfo[i][pAdmin], GetAwayStatus(i));
            }
            if(
PlayerInfo[i][pModerator] >= 1)
            {
                
format(string2sizeof(string2), "Name: %s{A9C4E4} {%s}"RPName(i), GetAwayStatus(i));
                
            }
            if(
PlayerInfo[i][pHelper] >= 1)
            {
                
format(string3sizeof(string3), "Name: %s{A9C4E4} {%s}"RPName(i), GetAwayStatus(i));
            }
        }
    }
    
SendClientMessage(playeridCOLOR_ORANGE". : : Administrators : : .");
    
SendClientMessage(playeridGREYstring);
    
SendClientMessage(playeridCOLOR_ORANGE". : : Moderators : : .");
    
SendClientMessage(playeridGREYstring2);
    
SendClientMessage(playeridCOLOR_ORANGE". : : Helpers : : .");
    
SendClientMessage(playeridGREYstring3);

Reply
#4

Thanks guys, rep+'d u both.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)