Command returns SERVER: Unknown command
#1

Hello. This is my 3rd thread regarding this error. Well, I have made a basic admin script for my current work [San Fierro Harbor]. So all the admin commands are 'built' but I need help here because if I do the command with no id / partofname like just /makegolden it returns the right value but if i type /makegolden it returns SERVER: Unknown command with no effect.

P.S: This isn't the only failing commands. other commands with extra parameters faill too.
P.S: The tmp string is 256 cells, I KNOW, DONT SAY IT.
P.S: I get no errors or warnings at all.

So this is the code.

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.", givename);
            SendClientMessage(playerid,COLOR_YELLOW,string2);
            SendClientMessage(strval(tmp),COLOR_YELLOW,string);
       
            PlayerInfo[strval(tmp)][pIsGolden] = 1;
            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;
    }
Thanks for helps !
Reply
#2

Bump. I'm desperate trying to fix this since a week.
Reply
#3

Not really
09/12/2010, 05:47 AM you posted this
09/12/2010, 06:26 AM you replyed?

dunno try this?

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.", givename);
            SendClientMessage(playerid,COLOR_YELLOW,string2);
            SendClientMessage(strval(tmp),COLOR_YELLOW,string);
       
            PlayerInfo[strval(tmp)][pIsGolden] = 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;
    }
Reply
#4

Quote:
Originally Posted by Kitten
Посмотреть сообщение
Not really
09/12/2010, 05:47 AM you posted this
09/12/2010, 06:26 AM you replyed?

dunno try this?

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.", givename);
            SendClientMessage(playerid,COLOR_YELLOW,string2);
            SendClientMessage(strval(tmp),COLOR_YELLOW,string);
       
            PlayerInfo[strval(tmp)][pIsGolden] = 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;
    }
Actually , yes , I have. I have opened 2 similar threads and before opening the threads i already was dealing with this. But I dont want to go offtopic
Can you tell me the difference of your code and my code?
Reply
#5

Tested, and not working. Any heaps?
Reply
#6

Maybe this is your problem...
pawn Код:
if(strcmp(cmdtext, "/makegolden", true)==0)
Change it to:
pawn Код:
if(strcmp(cmd, "/makegolden", true) == 0)
I hope that was your problem..
Reply
#7

Quote:
Originally Posted by EliranPesahov
Посмотреть сообщение
Maybe this is your problem...
pawn Код:
if(strcmp(cmdtext, "/makegolden", true)==0)
Change it to:
pawn Код:
if(strcmp(cmd, "/makegolden", true) == 0)
I hope that was your problem..
not workings ..
please somebody.
Reply
#8

Test this cose, It should work for 100%!
I made it for you :]
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    new cmd[256];
    new tmp[256];
    new string[256];
    new idx;
    cmd = strtok(cmdtext, idx);
    new giveplayerid;
    new giveplayer[MAX_PLAYER_NAME];
    new sendername[MAX_PLAYER_NAME];
    if(strcmp(cmd, "/makegolden", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(gPlayerLogged[playerid] == 0) { return SendClientMessage(playerid,COLOR_RED,"You are not logged in!"); }
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp)) { return SendClientMessage(playerid,COLOR_GRAY,"[SERVER]: /makegolden"); }
            if(PlayerInfo[playerid][pAdminLevel] == 2)
            {
                giveplayerid = ReturnUser(tmp);
                if(IsPlayerConnected(giveplayerid))
                {
                    GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
                    GetPlayerName(playerid, sendername, sizeof(sendername));
                    format(string, sizeof(string),"Administrator %s has made you a Golden User. Thanks for donating!",sendername);
                    SendClientMessage(giveplayerid,COLOR_YELLOW,string);
                    format(string, sizeof(string), " You have made %s a Golden User.",giveplayer);
                    SendClientMessage(playerid,COLOR_YELLOW,string);
                    PlayerInfo[giveplayerid][pIsGolden] = 1;
                } else { return SendClientMessage(playerid,COLOR_RED, "[ERROR]: Invalid ID."); }
            } else { return SendClientMessage(playerid,COLOR_GRAY,"[SERVER]: You are not an admin!"); }
        }
        return 1;
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)