[Help Please] Unknown Command?
#1

Hello everybody. I was working on a admin script for my current work San Fierro Harbor. Well, I tested it with my brother and I have an awful error.. Every command with extra parameters like /slap [ID] or /makeadmin [ID] are returning Invalid Command error.

Examples:
pawn Код:
if(strcmp(cmdtext, "/slap", true)==0)
    {
        new tmp[256];
        tmp = strtok( cmdtext, idx );
        if (!strlen(tmp))
        {
            return SendClientMessage(playerid,COLOR_GRAY,"[SERVER]: /slap");
        }
        if(PlayerInfo[playerid][pAdminLevel] > 0)
        {
            new string[50], string2[50], adminname[MAX_PLAYER_NAME], slapname[MAX_PLAYER_NAME];
            GetPlayerName(playerid, adminname, sizeof(adminname));
            GetPlayerName(playerid, slapname, sizeof(slapname));
            format(string, sizeof(string), " Administrator %s has slapped you", adminname);
            format(string2, sizeof(string2), " Player %s has been slapped by administrator %s", slapname, adminname);
            new Float:X, Float:Y, Float:Z;
            GetPlayerPos(strval(tmp), X,Y,Z);
            SetPlayerPos(strval(tmp),X,Y,Z+10);
            SendClientMessage(playerid,COLOR_LIGHTBLUE,string);
            SendClientMessageToAll(COLOR_LIGHTBLUE,string2);
            return 1;
        }
        else SendClientMessage(playerid,COLOR_GRAY,"[SERVER]: You are not an admin !");
        if(strval(tmp) == playerid) SendClientMessage(playerid,COLOR_RED,"[ERROR] You cannot do this on yourself!");
        if(strval(tmp) == INVALID_PLAYER_ID) return SendClientMessage(playerid,COLOR_RED,"[ERROR]: Invalid ID.");
        return 1;
    }
pawn Код:
if(strcmp(cmdtext, "/makegolden", true)==0)
    {
        new tmp[256];
        tmp = strtok( cmdtext, idx );
        if (!strlen(tmp))
        {
            return SendClientMessage(playerid,COLOR_GRAY,"[SERVER]: /makegolden");
        }
        if(PlayerInfo[playerid][pAdminLevel] == 2)
        {
            new string[50], string2[50], adminname[MAX_PLAYER_NAME], givename[MAX_PLAYER_NAME];
            GetPlayerName(playerid, adminname, sizeof(adminname));
            GetPlayerName(playerid, givename, sizeof(givename));
            format(string, sizeof(string), " Administrator %s has made you a Golden User. Thanks for donating!", adminname);
            format(string2, sizeof(string2), " You have made %s a Golden User. He was kicked so he can relog and changes will take effect.", givename);
            SendClientMessage(playerid,COLOR_YELLOW,string2);
            SendClientMessage(strval(tmp),COLOR_YELLOW,string);
            SendClientMessage(strval(tmp),COLOR_YELLOW,"Please relog for the changes to take effect.");
            PlayerInfo[strval(tmp)][pIsGolden] = 1;
                        Kick(strval(tmp));
            return 1;
        }
        else SendClientMessage(playerid,COLOR_GRAY,"[SERVER]: You are not an admin !");
        if(strval(tmp) == playerid) SendClientMessage(playerid,COLOR_RED,"[ERROR] You cannot do this on yourself!");
        if(strval(tmp) == INVALID_PLAYER_ID) return SendClientMessage(playerid,COLOR_RED,"[ERROR]: Invalid ID.");
        return 1;
    }
It always returns SERVER: Unknown Command (in this case as I edited it, [ERROR]: Invalid command) if the command has extra parameters. If I type just /slap it will return a Client Message but if I do /slap [any id] it returns Unknown Command.

P.S: I know the tmp strings are 256 cells and its a waste, dont remind it to me.
P.S: Any improvement is really appreciated.
Reply
#2

Yes, improve your script by using zcmd + sscanf2

Here's a quick slap cmd:
pawn Код:
CMD:slap(playerid, params[])
{
    if(isnull(params)) return /* Usage Message */
    new pID = strval(params);
    new Float:Pos[3];
    GetPlayerPos(pID, Pos[0], Pos[1], Pos[2]);
    SetPlayerPos(pID, Pos[0], Pos[1], Pos[2] + 1000000);
    return 1;
}
Reply
#3

you need
pawn Код:
if(!IsPlayerAdmin)
Reply
#4

Quote:
Originally Posted by fangoth1
Посмотреть сообщение
you need
pawn Код:
if(!IsPlayerAdmin)
if(PlayerInfo[playerid][pAdminLevel] == 2)
else SendClientMessage(playerid,COLOR_GRAY,"[SERVER]: You are not an admin !");

@Lethal: Look.. I would but i have 2 problems: I dont know how to use it, define it .. etc.. I use strcmp since I started scripting, it would be hard to start with a new system. So you could tell me how to define and use DCDM (or zcmd, either which is easier) and convert the /makegolden command posted above? That would be helpful, so I can learn from it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)