SendToAdmins Stock has a parameter problem
#1

So i been trying all day to make a /a command but it returns
Код:
sscanf warning: Format specifier does not match parameter count.
So here's the two codes.

Command:

Код:
CMD:a(playerid,params[]){
    new string[128];
    if(PlayerInfo[playerid][pAdminLevel] <= 1) return SendClientMessage(playerid,COLOR_GREY,"You're not authorized to use this command!");
    if(sscanf(params, "us")) return SendClientMessage(playerid,COLOR_GREY,"SYNTAX: /a(dmin) [message]");
    else
    {
    format(string,sizeof(string),"%s: %d",GetName(playerid), params);
    SendToAdmins(COLOR_RED, string);
    }
    return 1;
}
Stock

Код:
stock SendToAdmins(COLOR,message[])//here we set params for this stock, [] means string/message
{
    for( new i = 0; i < MAX_PLAYERS; i++ )
    if( PlayerInfo[i][pAdminLevel] <= 1 )
    {
        SendClientMessage( i,COLOR,message );
    }
    return 0; //for everyone else return 0;
}
Now i have tried changing the "us" to "u"
Reply
#2

pawn Код:
CMD:a(playerid, params[])
{
        if(PlayerInfo[playerid][pAdminLevel]< 1) return SCM(playerid, Red, "You're not authorized to use this command");
        new
            text[128];
        if(sscanf(params, "s[128]",text)) return SCM(playerid, -1, "USAGE: /a [Text]");
        format(text,sizeof(text),"Admin %s| Message: %s",GN(playerid),params[0]);
        foreach(Player, i) {
        if(pInfo[i][Adminlevel] > 0){
        SCM(i,Purple,text);}}
        return 1;
}
Reply
#3

Quote:
Originally Posted by SHE790
Посмотреть сообщение
pawn Код:
CMD:a(playerid, params[])
{
        if(PlayerInfo[playerid][pAdminLevel]< 1) return SCM(playerid, Red, "You're not authorized to use this command");
        new
            text[128];
        if(sscanf(params, "s[128]",text)) return SCM(playerid, -1, "USAGE: /a [Text]");
        format(text,sizeof(text),"Admin %s| Message: %s",GN(playerid),params[0]);
        foreach(Player, i) {
        if(pInfo[i][Adminlevel] > 0){
        SCM(i,Purple,text);}}
        return 1;
}
I didn't have most of what you used defined so i am trying to fix it.
Reply
#4

He did copy from his own script that command that's why you had that error.
pawn Код:
CMD:a(playerid,params[]){
    new string[128];
    if(PlayerInfo[playerid][pAdminLevel] <= 1) return SendClientMessage(playerid,COLOR_GREY,"You're not authorized to use this command!");
    if(sscanf(params, "us",string)) return SendClientMessage(playerid,COLOR_GREY,"SYNTAX: /a(dmin) [message]");
    else
    {
    format(string,sizeof(string),"%s: %d",GetName(playerid), params);
    SendToAdmins(COLOR_RED, string);
    }
    return 1;
}
Reply
#5

Quote:
Originally Posted by Clad
Посмотреть сообщение
He did copy from his own script that command that's why you had that error.
pawn Код:
CMD:a(playerid,params[]){
    new string[128];
    if(PlayerInfo[playerid][pAdminLevel] <= 1) return SendClientMessage(playerid,COLOR_GREY,"You're not authorized to use this command!");
    if(sscanf(params, "us",string)) return SendClientMessage(playerid,COLOR_GREY,"SYNTAX: /a(dmin) [message]");
    else
    {
    format(string,sizeof(string),"%s: %d",GetName(playerid), params);
    SendToAdmins(COLOR_RED, string);
    }
    return 1;
}
i didnt copy from my own this is my own
pawn Код:
CMD:a(playerid, params[])
{
        if(pInfo[playerid][Adminlevel]< 1) return SCM(playerid, Red, "You are not admin");
        new
            text[128];
        if(sscanf(params, "s[128]",text)) return SCM(playerid, -1, "USAGE: /a [Message]");
        format(text,sizeof(text),"%s Message: %s",GN(playerid),params[0]);
        foreach(Player, i) {
        if(pInfo[i][Adminlevel] > 0){
        SCM(i,Pink,text);}}
        return 1;
}
Reply
#6

pawn Код:
CMD:a(playerid,params[])
{
    new string[128], chat[128];
    if(PlayerInfo[playerid][pAdminLevel] <= 1) return SendClientMessage(playerid,COLOR_GREY,"You're not authorized to use this command!");
    if(sscanf(params, "s[128]", chat)) return SendClientMessage(playerid,COLOR_GREY,"SYNTAX: /a(dmin) [message]");
    format(string,sizeof(string),"%s: %d",GetName(playerid), chat);
    SendToAdmins(COLOR_RED, string);
    return 1;
}
pawn Код:
stock SendToAdmins(COLOR,message[])//here we set params for this stock, [] means string/message
{
    for( new i = 0; i < MAX_PLAYERS; i++ )
    {
        if( PlayerInfo[i][pAdminLevel] >= 1 )
        {
            SendClientMessage( i,COLOR,message );
        }
    }
    return 1; //for everyone else return 0;
}
This should works
Reply
#7

It's all working now, thanks everyone.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)