SA-MP Forums Archive
SendToAdmins Stock has a parameter problem - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: SendToAdmins Stock has a parameter problem (/showthread.php?tid=525413)



SendToAdmins Stock has a parameter problem - Cole_William - 11.07.2014

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"


Re: SendToAdmins Stock has a parameter problem - SHE790 - 11.07.2014

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;
}



Re: SendToAdmins Stock has a parameter problem - Cole_William - 11.07.2014

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.


Re : SendToAdmins Stock has a parameter problem - Clad - 11.07.2014

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;
}



Re: Re : SendToAdmins Stock has a parameter problem - SHE790 - 11.07.2014

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;
}



Re: SendToAdmins Stock has a parameter problem - kizla - 11.07.2014

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


Re: SendToAdmins Stock has a parameter problem - Cole_William - 11.07.2014

It's all working now, thanks everyone.