Admin Chat Error
#1

pawn Код:
stock SendAdminMessage(color, const string[])
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(AdminLevel[i] == 100)
            {
                SendClientMessage(i, color, string);
            }
            if(AdminLevel[i] == 1)
            {
                SendClientMessage(i, color, string);
            }
            if(AdminLevel[i] == 2)
            {
                SendClientMessage(i, color, string);
            }
            if(AdminLevel[i] == 3)
            {
                SendClientMessage(i, color, string);
            }
        }
    }
    return 1;
}
//===========================================================================
dcmd_ac(playerid,params[])
{
    if(!strlen(params)) return SendClientMessage(playerid,COLOR_ERROR,"Usage: /ac (Message)");
    new pname[MAX_PLAYER_NAME];
    new string[128];
    format(string,sizeof(string), "[ADMIN CHAT] %s(%d): %s",pname(playerid), playerid, params); // error line
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(AdminLevel[i] == 1)
        {
            format(string,sizeof(string),"[ADMIN CHAT] %s(%d): %s",pname(playerid),playerid,params);
            SendAdminMessage(COLOR_PINK, string);
        }
        if(AdminLevel[i] == 2)
        {
            format(string,sizeof(string),"[ADMIN CHAT] %s(%d): %s",pname(playerid),playerid,params);
            SendAdminMessage(COLOR_PINK, string);
        }
        if(AdminLevel[i] == 3)
        {
            format(string,sizeof(string),"[ADMIN CHAT] %s(%d): %s",pname(playerid),playerid,params);
            SendAdminMessage(COLOR_PINK, string);
        }
        if(AdminLevel[i] == 100)
        {
            format(string,sizeof(string),"[ADMIN CHAT] %s(%d): %s",pname(playerid),playerid,params);
            SendAdminMessage(COLOR_PINK, string);
        }
    }
   
    //format(string,sizeof(string),"4[ADMIN CHAT] %s(%d): %s",PlayerName(playerid),playerid,params);
    //IRC_GroupSay(gGroupAdminID,IRC_ADMINCHANNEL,string);
    return 1;
}
Error:
Код:
D:\SAMP\Server\SACCNR [0.3e R2]\gamemodes\SACCNR.pwn(1074) : error 012: invalid function call, not a valid address
D:\SAMP\Server\SACCNR [0.3e R2]\gamemodes\SACCNR.pwn(1074) : warning 215: expression has no effect
D:\SAMP\Server\SACCNR [0.3e R2]\gamemodes\SACCNR.pwn(1074) : error 001: expected token: ";", but found ")"
D:\SAMP\Server\SACCNR [0.3e R2]\gamemodes\SACCNR.pwn(1074) : error 029: invalid expression, assumed zero
D:\SAMP\Server\SACCNR [0.3e R2]\gamemodes\SACCNR.pwn(1074) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Reply
#2

it should be like this:

pawn Код:
stock SendAdminMessage( level, color, string[ ] ) // add level param
{
    for( new f = 0; f < MAX_PLAYERS; f++ )
    {
        if( IsPlayerConnected( f ) )
        {
            if( AdminLevel[ f ] == level )
            {
                SendClientMessage( f, color, string );
            }
        }
    }
}
and then, in command:

pawn Код:
dcmd_ac(playerid,params[])
{
    if( AdminLevel[ playerid ] < 1 ) return 0;
    if(!strlen(params)) return SendClientMessage(playerid,COLOR_ERROR,"Usage: /ac (Message)");
    new pname[MAX_PLAYER_NAME];
    new string[128];
    format(string,sizeof(string), "[ADMIN CHAT] %s(%d): %s",pname(playerid), playerid, params); // error line

    SendAdminMessage( AdminLevel[ playerid ], COLOR_PINK, string ); // AdminLevel[ playerid ] his level and color and then string
    return 1;
}
With this script only the same admin level players can see the admin message, if you are level 10 and i am level 10 too we can see our messages but we can't see other level messages, that's how it is scripted. If you want it to show for all admins you can use a loop;

pawn Код:
for( new f = 1; f < 10; f++ ) // change 10 to the MAX level of admin system you want
{
    SendAdminMessage( f, color, string ); // this will send the admin message to all admin levels from 1 to 10
}
Reply
#3

Didn't understand the Command part.. what do you mean?
Reply
#4

Could you post a full command please?
Reply
#5

Quote:
Originally Posted by _Khaled_
Посмотреть сообщение
Didn't understand the Command part.. what do you mean?
Well, as far as I know you are trying to make separate chats for each admin level so that's how you can do; the script you made has no sense at all (no offence) So, this is how I made:

pawn Код:
dcmd_ac(playerid,params[])
{
    if( AdminLevel[ playerid ] < 1 ) return 0;
    if(!strlen(params)) return SendClientMessage(playerid,COLOR_ERROR,"Usage: /ac (Message)");
    new pname[MAX_PLAYER_NAME];
    new string[128];
    format(string,sizeof(string), "[ADMIN CHAT] %s(%d): %s",pname(playerid), playerid, params); // error line

    SendAdminMessage( AdminLevel[ playerid ], COLOR_PINK, string ); // AdminLevel[ playerid ] his level and color and then string
    return 1;
}
SendAdminMessage sends the message to the SAME level as you put in level parameter, let me explain you;

pawn Код:
SendAdminMessage( 3, COLOR_PINK, string ); // level 3
This will send message to ONLY level 3 admins. Hope this clears it

Edit: It is the complete code lol. If you want to send the admin message to all admins, you can simply use a loop:

pawn Код:
for( new f = 1; f < 10; f++ ) // change 10 to the MAX level of admin system you want
{
    SendAdminMessage( f, color, string ); // this will send the admin message to all admin levels from 1 to 10
}
Reply
#6

pawn Код:
dcmd_ac(playerid,params[])
{
    if( AdminLevel[ playerid ] =< 1 ) return 0;
    if(!strlen(params)) return SendClientMessage(playerid,COLOR_ERROR,"Usage: /ac (Message)");
    new pname[MAX_PLAYER_NAME];
    new string[128];
    format(string,sizeof(string), "[ADMIN CHAT] %s(%d): %s",pname(playerid), playerid, params); // error line

    SendAdminMessage( AdminLevel[ playerid ], COLOR_PINK, string ); // AdminLevel[ playerid ] his level and color and then string
    //format(string,sizeof(string),"4[ADMIN CHAT] %s(%d): %s",PlayerName(playerid),playerid,params);
    //IRC_GroupSay(gGroupAdminID,IRC_ADMINCHANNEL,string);
    return 1;
}
Код:
D:\SAMP\Server\SACCNR [0.3e R2]\gamemodes\SACCNR.pwn(105) : warning 203: symbol is never used: "level"
D:\SAMP\Server\SACCNR [0.3e R2]\gamemodes\SACCNR.pwn(1070) : warning 211: possibly unintended assignment
D:\SAMP\Server\SACCNR [0.3e R2]\gamemodes\SACCNR.pwn(1070) : error 029: invalid expression, assumed zero
D:\SAMP\Server\SACCNR [0.3e R2]\gamemodes\SACCNR.pwn(1070) : warning 215: expression has no effect
D:\SAMP\Server\SACCNR [0.3e R2]\gamemodes\SACCNR.pwn(1070) : error 001: expected token: ";", but found ")"
D:\SAMP\Server\SACCNR [0.3e R2]\gamemodes\SACCNR.pwn(1070) : error 029: invalid expression, assumed zero
D:\SAMP\Server\SACCNR [0.3e R2]\gamemodes\SACCNR.pwn(1070) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Reply
#7

Did you implement this?

pawn Код:
stock SendAdminMessage( level, color, string[ ] ) // add level param
{
    for( new f = 0; f < MAX_PLAYERS; f++ )
    {
        if( IsPlayerConnected( f ) )
        {
            if( AdminLevel[ f ] == level )
            {
                SendClientMessage( f, color, string );
            }
        }
    }
}
EDIT:

pawn Код:
dcmd_ac(playerid,params[])
{
    if( AdminLevel[ playerid ] < 1 ) return 0;
   
    if(!strlen(params)) return SendClientMessage(playerid,COLOR_ERROR,"Usage: /ac (Message)");
   
    new pname[MAX_PLAYER_NAME], string[128];
   
    GetPlayerName( playerid, pname, sizeof( pname ) );

    format(string,sizeof(string), "[ADMIN CHAT] %s(%d): %s", pname, playerid, params);

    SendAdminMessage( AdminLevel[ playerid ], COLOR_PINK, string ); // AdminLevel[ playerid ] his level and color and then string
    return 1;
}
Reply
#8

pawn Код:
stock SendAdminMessage( level, color, string[ ] )
{
    for( new f = 0; f < MAX_PLAYERS; f++ )
    {
        if( IsPlayerConnected( f ) )
        {
            if( AdminLevel[ f ] =< 1 )
            {
                SendClientMessage( f, color, string );
                return 1;
            }
        }
    }
}
Reply
#9

JUST USE THE WAY I SAID OMG. OR JUST EXPLAIN WHAT THE HECK YOU NEED?

pawn Код:
stock SendAdminMessage( level, color, string[ ] ) // add level param
{
    for( new f = 0; f < MAX_PLAYERS; f++ )
    {
        if( IsPlayerConnected( f ) )
        {
            if( AdminLevel[ f ] == level )
            {
                SendClientMessage( f, color, string );
            }
        }
    }
}
with:

pawn Код:
dcmd_ac(playerid,params[])
{
    if( AdminLevel[ playerid ] < 1 ) return 0;

    if(!strlen(params)) return SendClientMessage(playerid,COLOR_ERROR,"Usage: /ac (Message)");

    new pname[MAX_PLAYER_NAME], string[128];

    GetPlayerName( playerid, pname, sizeof( pname ) );

    format(string,sizeof(string), "[ADMIN CHAT] %s(%d): %s", pname, playerid, params);
   
    switch( AdminLevel[ playerid ] )
    {
        case 1, 2, 3:
        {
            SendAdminMessage( AdminLevel[ playerid ], COLOR_PINK, string );
        }
        case 100:
        {
            SendAdminMessage( AdminLevel[ playerid ], COLOR_PINK, string );
        }
    }

    //SendAdminMessage( AdminLevel[ playerid ], COLOR_PINK, string ); // AdminLevel[ playerid ] his level and color and then string
    return 1;
}
Reply
#10

I HAVEN'T SLEPT FROM TWO DAYS NOW, CHILL!
Let me try.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)