Weird compiling error
#1

pawn Код:
dcmd_ac(playerid,params[])
{
    #pragma unused params
    new pname[MAX_PLAYER_NAME];
    new string[128];
    if(!strlen(params))
    {
        SendClientMessage(playerid,COLOR_ERROR,"Usage: /ac (Message)");
        return 1;
    }
    /*format(string,sizeof(string),"4[ADMIN CHAT] %s(%d): %s",PlayerName(playerid),playerid,params);
    IRC_GroupSay(gGroupAdminID,IRC_ADMINCHANNEL,string);*/

    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);
            SendClientMessage(i,COLOR_PINK,string);
        }
    }
    return 1;
}
Error
Код:
D:\SAMP\Server\SACCNR [0.3e R2]\gamemodes\SACCNR.pwn(996) : error 012: invalid function call, not a valid address
D:\SAMP\Server\SACCNR [0.3e R2]\gamemodes\SACCNR.pwn(996) : warning 215: expression has no effect
D:\SAMP\Server\SACCNR [0.3e R2]\gamemodes\SACCNR.pwn(996) : error 001: expected token: ";", but found ")"
D:\SAMP\Server\SACCNR [0.3e R2]\gamemodes\SACCNR.pwn(996) : error 029: invalid expression, assumed zero
D:\SAMP\Server\SACCNR [0.3e R2]\gamemodes\SACCNR.pwn(996) : 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

pawn Код:
if(!strlen(params))
    {
        SendClientMessage(playerid,COLOR_ERROR,"Usage: /ac (Message)");
        return 1;
    }
That's a wrong usage, probably that line causes this. You gotta use sscanf for a command like this and it should be like:

pawn Код:
new text[128];
if(sscanf(params, "s[128]", text)) return SendClientMessage(playerid, -1, "USAGE: /ac [Message]");
Reply
#3

Same errors.
Reply
#4

Have you changed the "params" thing for this line too? If you keep "params", it'll keep making error. Whole code should be like this:

pawn Код:
dcmd_ac(playerid,params[])
{
    new pname[MAX_PLAYER_NAME];
    new string[128], text[128];
    if(sscanf(params, "s[128]", text)) return SendClientMessage(playerid, -1, "USAGE: /ac [Message]");
    GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        if(AdminLevel[i] == 1)
        {
            format(string,sizeof string, "[ADMIN CHAT] %s(%d): %s", pname, playerid, text);
            SendClientMessage(i,COLOR_PINK,string);
        }
    }
    return 1;
}
Edited, use this last one.
Reply
#5

pawn Код:
if(!strlen(params)) return
SendClientMessage(playerid, COLOR_ERROR, "Usage: /ac (message)") &&
SendClientMessage(playerid, COLOR_ERROR, "Function: Will use Admin Chat");
Reply
#6

removed
Reply
#7

I edited my previous post and it should work. Try it.
Reply
#8

It's not sending anything..
What should I do to sendmessage to all admins?
Reply
#9

Give a try.
pawn Код:
dcmd_ac(playerid,params[])
{
    if(!strlen(params)) return SendClientMessage(playerid,COLOR_ERROR,"Usage: /ac (Message)");
    //format(string,sizeof(string),"4[ADMIN CHAT] %s(%d): %s",PlayerName(playerid),playerid,params);
    //IRC_GroupSay(gGroupAdminID,IRC_ADMINCHANNEL,string);
    new string[128],i;
    for(; i < MAX_PLAYERS; ++i)
    {
        if(!IsPlayerConnected(i)) continue; // added.
        if(AdminLevel[i] > 0)
        {
            format(string,sizeof(string),"[ADMIN CHAT] %s(%d): %s",pname(playerid),playerid,params);
            SendClientMessage(i,COLOR_PINK,string);
        }
    }
    return 1;
}
Reply
#10

Quote:
Originally Posted by leonardo1434
Посмотреть сообщение
Give a try.
pawn Код:
dcmd_ac(playerid,params[])
{
    if(!strlen(params)) return SendClientMessage(playerid,COLOR_ERROR,"Usage: /ac (Message)");
    //format(string,sizeof(string),"4[ADMIN CHAT] %s(%d): %s",PlayerName(playerid),playerid,params);
    //IRC_GroupSay(gGroupAdminID,IRC_ADMINCHANNEL,string);
    new string[128],i;
    for(; i < MAX_PLAYERS; ++i)
    {
        if(AdminLevel[i] > 0)
        {
            format(string,sizeof(string),"[ADMIN CHAT] %s(%d): %s",pname(playerid),playerid,params);
            SendClientMessage(i,COLOR_PINK,string);
        }
    }
    return 1;
}
This would be a better alternative:
pawn Код:
dcmd_ac(playerid,params[])
{
    if(!strlen(params)) return SendClientMessage(playerid,COLOR_ERROR,"Usage: /ac (Message)"); //!strlen(params) is a valid function.
    //format(string,sizeof(string),"4[ADMIN CHAT] %s(%d): %s",PlayerName(playerid),playerid,params);
    //IRC_GroupSay(gGroupAdminID,IRC_ADMINCHANNEL,string);
    new string[128];
    format(string,sizeof(string), "[ADMIN CHAT] %s(%d): %s",pname(playerid), playerid, params);
    /*for(new i = 0; i < MAX_PLAYERS; i++) //Your symbols on this line were incredibly wrong.
    {
        if(AdminLevel[i] > 0)
        {
            format(string,sizeof(string),"[ADMIN CHAT] %s(%d): %s",pname(playerid),playerid,params);
            SendClientMessage(i,COLOR_PINK,string);
        }
    }*/

    SendAdminMessage(COLOR_PINK, string);
    return 1;
}

stock SendAdminMessage(color, const string[])
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(AdminLevel[i] > 0)
            {
                SendClientMessage(i, color, string);
            }
        }
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)